Run stratum-bmv2 in trellis_hybrid_v4 topo
Change-Id: I54502a1e3ad6765a440144d0c7d9c21dd887d46c
diff --git a/.gitignore b/.gitignore
index 6bbaf2c..c3b91d0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,3 +9,6 @@
trellis/.vagrant/
# virtualbox
trellis/*.log
+
+trellis/zebradbgp1.conf
+trellis/zebradbgp2.conf
diff --git a/trellis/trellis_hybrid_v4.json b/trellis/trellis_hybrid_v4.json
index 6cb46ac..1bfbc15 100644
--- a/trellis/trellis_hybrid_v4.json
+++ b/trellis/trellis_hybrid_v4.json
@@ -26,7 +26,7 @@
}
]
},
- "device:bmv2:s204/5" : {
+ "device:s204/5" : {
"interfaces" : [
{
"ips" : [ "10.1.2.254/24"],
@@ -34,7 +34,7 @@
}
]
},
- "device:bmv2:s204/6" : {
+ "device:s204/6" : {
"interfaces" : [
{
"name": "h1-eth0",
@@ -43,7 +43,7 @@
}
]
},
- "device:bmv2:s204/7" : {
+ "device:s204/7" : {
"interfaces" : [
{
"name": "h2-eth0",
@@ -52,7 +52,7 @@
}
]
},
- "device:bmv2:s204/8" : {
+ "device:s204/8" : {
"interfaces" : [
{
"name": "dh1-eth0",
@@ -168,7 +168,7 @@
}
]
},
- "device:bmv2:s208/3" : {
+ "device:s208/3" : {
"interfaces" : [
{
"name": "rpd6-eth0",
@@ -186,7 +186,7 @@
"ipv4Loopback" : "192.168.0.203",
"routerMac" : "00:00:00:00:02:03",
"isEdgeRouter" : true,
- "pairDeviceId" : "device:bmv2:s204",
+ "pairDeviceId" : "device:s204",
"pairLocalPort" : 5,
"adjacencySids" : []
},
@@ -197,7 +197,7 @@
"longitude" : "-111.359"
}
},
- "device:bmv2:s204" : {
+ "device:s204" : {
"segmentrouting" : {
"name" : "s204",
"ipv4NodeSid" : 204,
@@ -251,7 +251,7 @@
"longitude" : "-92.029"
}
},
- "device:bmv2:s226" : {
+ "device:s226" : {
"segmentrouting" : {
"name" : "s226",
"ipv4NodeSid" : 226,
@@ -300,7 +300,7 @@
"longitude" : "-122.359"
}
},
- "device:bmv2:s208" : {
+ "device:s208" : {
"segmentrouting" : {
"name" : "s208",
"ipv4NodeSid" : 208,
@@ -315,7 +315,7 @@
"longitude" : "-116.029"
}
},
- "device:bmv2:s246" : {
+ "device:s246" : {
"segmentrouting" : {
"name" : "s246",
"ipv4NodeSid" : 246,
@@ -330,7 +330,7 @@
"longitude" : "-121.679"
}
},
- "device:bmv2:s247" : {
+ "device:s247" : {
"segmentrouting" : {
"name" : "s247",
"ipv4NodeSid" : 247,
diff --git a/trellis/trellis_hybrid_v4.py b/trellis/trellis_hybrid_v4.py
index 0b0b3bb..c5135ca 100755
--- a/trellis/trellis_hybrid_v4.py
+++ b/trellis/trellis_hybrid_v4.py
@@ -1,38 +1,48 @@
#!/usr/bin/python
-
+import argparse
import sys
sys.path.append('..')
from mininet.topo import Topo
from mininet.cli import CLI
from mininet.log import setLogLevel
-from mininet.node import RemoteController, OVSBridge, Host, OVSSwitch
-from mininet.link import TCLink
+from mininet.node import OVSBridge, OVSSwitch
from mininet.nodelib import NAT
from ipaddress import ip_network
from routinglib import BgpRouter
-from routinglib import RoutedHost, RoutedHost6
-from trellislib import DhcpClient, Dhcp6Client, Dhcp4and6Client, DhcpRelay, DhcpServer, Dhcp6Server
+from routinglib import RoutedHost
+from trellislib import DhcpClient, DhcpServer
from trellislib import DualHomedDhcpClient
from trellislib import DualHomedDhcp4and6Client
-from trellislib import get_mininet, parse_trellis_args, set_up_zebra_config
+from trellislib import get_mininet, set_up_zebra_config
from functools import partial
-from bmv2 import ONOSBmv2Switch
PIPECONF_ID = 'org.onosproject.pipelines.fabric'
-class Trellis( Topo ):
+
+class Trellis(Topo):
"""Trellis HAG topology with both OVS and BMV2 switches"""
- def __init__( self, *args, **kwargs ):
- Topo.__init__( self, *args, **kwargs )
+ p4_cls = None
+
+ def get_p4_switch_args(self, name):
+ assert Trellis.p4_cls is not None
+ return dict(
+ name=name,
+ cls=Trellis.p4_cls,
+ pipeconf=PIPECONF_ID,
+ portcfg=True,
+ onosdevid="device:" + name)
+
+ def __init__(self, *args, **kwargs):
+ Topo.__init__(self, *args, **kwargs)
# Spines
- s226 = self.addSwitch('s226', cls=ONOSBmv2Switch, pipeconf=PIPECONF_ID, portcfg=True)
+ s226 = self.addSwitch(**self.get_p4_switch_args('s226'))
s227 = self.addSwitch('s227', dpid='227')
# Leaves
s203 = self.addSwitch('s203', dpid='203')
- s204 = self.addSwitch('s204', cls=ONOSBmv2Switch, pipeconf=PIPECONF_ID, portcfg=True)
+ s204 = self.addSwitch(**self.get_p4_switch_args('s204'))
s205 = self.addSwitch('s205', dpid='205')
s206 = self.addSwitch('s206', dpid='206')
@@ -190,12 +200,12 @@
# ----- Secondary fabric -----
# Spines(HAG)
- s246 = self.addSwitch('s246', cls=ONOSBmv2Switch, pipeconf=PIPECONF_ID, portcfg=True)
- s247 = self.addSwitch('s247', cls=ONOSBmv2Switch, pipeconf=PIPECONF_ID, portcfg=True)
+ s246 = self.addSwitch(**self.get_p4_switch_args('s246'))
+ s247 = self.addSwitch(**self.get_p4_switch_args('s247'))
# Leaves(DAAS)
s207 = self.addSwitch('s207', dpid='207')
- s208 = self.addSwitch('s208', cls=ONOSBmv2Switch, pipeconf=PIPECONF_ID, portcfg=True)
+ s208 = self.addSwitch(**self.get_p4_switch_args('s208'))
# HAG-DAAS Links
self.addLink(s246, s207)
@@ -221,17 +231,30 @@
-
-
topos = { 'trellis' : Trellis }
if __name__ == "__main__":
setLogLevel('debug')
+ parser = argparse.ArgumentParser(description="Trellis Arguments")
+ parser.add_argument("-c", "--controllers", help = "Comma Separated List of ONOS controllers",
+ required = True, default = "")
+ parser.add_argument("-a", "--p4runtime-agent", help = "P4Runtime agent to use on Bmv2 devices (pi or stratum)",
+ required = False, default = "pi")
+ arguments = parser.parse_args()
+ agent = arguments.p4runtime_agent
+
+ if agent == "stratum":
+ from stratum import ONOSStratumBmv2Switch
+ Trellis.p4_cls = ONOSStratumBmv2Switch
+ else:
+ from bmv2 import ONOSBmv2Switch
+ Trellis.p4_cls = ONOSBmv2Switch
+
+ set_up_zebra_config(arguments.controllers)
+
topo = Trellis()
switch = partial(OVSSwitch, protocols='OpenFlow13')
- arguments = parse_trellis_args()
- set_up_zebra_config(arguments.controllers)
net = get_mininet(arguments, topo, switch)
net.start()