Marc De Leenheer
Committed by Gerrit Code Review

[Falcon] Cleanup of unused annotations in optical test topos.

First round of cleanups in opticalUtils.py.

Change-Id: I5f627fc471220c3a7194d913764f8c84e6f0fe6e
......@@ -90,7 +90,7 @@ class OpticalDomain(Domain):
oean = { "optical.regens": 0 }
self.addSwitch('OE%s' % i, dpid='0000ffffffffff0%s' % i, annotations=oean, cls=LINCSwitch)
an = { "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }
an = { "durable": "true" }
self.addLink('OE1', 'OE2', port1=50, port2=30, annotations=an, cls=LINCLink)
self.addLink('OE2', 'OE3', port1=50, port2=30, annotations=an, cls=LINCLink)
self.addLink('OE3', 'OE1', port1=50, port2=30, annotations=an, cls=LINCLink)
......@@ -188,7 +188,7 @@ def setup(argv):
# connect COs to core - sort of hard-wired at this moment
for i in range(1,len(domains)):
an = { "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }
an = { "bandwidth": 100000, "durable": "true" }
net.addLink(domains[i].getTether(), d0.getSwitches('OE%s' % i),
port1=OVS_AP, port2=OE_AP, speed=10000, annotations=an, cls=LINCLink)
......
......@@ -38,34 +38,34 @@ class SmallOpticalTopo( Topo ):
JFKR10 = self.addSwitch( 'JFK-R10', dpid='0000ffffffff0005', annotations={ "latitude": 40.8, "longitude": -73.1 } )
ATLR10 = self.addSwitch( 'ATL-R10', dpid='0000ffffffff0006', annotations={ "latitude": 33.8, "longitude": -84.1 } )
self.addLink( O1, O2, port1=50, port2=30, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=LINCLink )
self.addLink( O2, O3, port1=50, port2=30, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=LINCLink )
self.addLink( O3, O4, port1=50, port2=50, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=LINCLink )
self.addLink( O1, O5, port1=20, port2=50, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=LINCLink )
self.addLink( O2, O5, port1=20, port2=20, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=LINCLink )
self.addLink( O3, O6, port1=20, port2=50, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=LINCLink )
self.addLink( O4, O6, port1=20, port2=20, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=LINCLink )
self.addLink( O5, O6, port1=30, port2=40, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=LINCLink )
self.addLink( O5, O7, port1=40, port2=50, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=LINCLink )
self.addLink( O6, O8, port1=30, port2=50, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=LINCLink )
self.addLink( O7, O8, port1=20, port2=30, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=LINCLink )
self.addLink( O7, O9, port1=30, port2=50, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=LINCLink )
self.addLink( O8, O10, port1=20, port2=50, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=LINCLink )
self.addLink( O9, O10, port1=20, port2=20, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=LINCLink )
self.addLink( O1, O2, port1=50, port2=30, annotations={ "durable": "true" }, cls=LINCLink )
self.addLink( O2, O3, port1=50, port2=30, annotations={ "durable": "true" }, cls=LINCLink )
self.addLink( O3, O4, port1=50, port2=50, annotations={ "durable": "true" }, cls=LINCLink )
self.addLink( O1, O5, port1=20, port2=50, annotations={ "durable": "true" }, cls=LINCLink )
self.addLink( O2, O5, port1=20, port2=20, annotations={ "durable": "true" }, cls=LINCLink )
self.addLink( O3, O6, port1=20, port2=50, annotations={ "durable": "true" }, cls=LINCLink )
self.addLink( O4, O6, port1=20, port2=20, annotations={ "durable": "true" }, cls=LINCLink )
self.addLink( O5, O6, port1=30, port2=40, annotations={ "durable": "true" }, cls=LINCLink )
self.addLink( O5, O7, port1=40, port2=50, annotations={ "durable": "true" }, cls=LINCLink )
self.addLink( O6, O8, port1=30, port2=50, annotations={ "durable": "true" }, cls=LINCLink )
self.addLink( O7, O8, port1=20, port2=30, annotations={ "durable": "true" }, cls=LINCLink )
self.addLink( O7, O9, port1=30, port2=50, annotations={ "durable": "true" }, cls=LINCLink )
self.addLink( O8, O10, port1=20, port2=50, annotations={ "durable": "true" }, cls=LINCLink )
self.addLink( O9, O10, port1=20, port2=20, annotations={ "durable": "true" }, cls=LINCLink )
self.addLink( SFOR10, O1, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=LINCLink )
self.addLink( SFOR10, O1, port1=3, port2=11, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=LINCLink )
self.addLink( SFOR10, O1, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "durable": "true" }, cls=LINCLink )
self.addLink( SFOR10, O1, port1=3, port2=11, speed1=10000, annotations={ "bandwidth": 100000, "durable": "true" }, cls=LINCLink )
self.addLink( LAXR10, O3, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=LINCLink )
self.addLink( LAXR10, O3, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "durable": "true" }, cls=LINCLink )
# added second tap
self.addLink( LAXR10, O3, port1=3, port2=11, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=LINCLink )
self.addLink( SDGR10, O4, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=LINCLink )
self.addLink( CHGR10, O7, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=LINCLink )
self.addLink( LAXR10, O3, port1=3, port2=11, speed1=10000, annotations={ "bandwidth": 100000, "durable": "true" }, cls=LINCLink )
self.addLink( SDGR10, O4, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "durable": "true" }, cls=LINCLink )
self.addLink( CHGR10, O7, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "durable": "true" }, cls=LINCLink )
self.addLink( JFKR10, O9, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=LINCLink )
self.addLink( JFKR10, O9, port1=3, port2=11, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=LINCLink )
self.addLink( JFKR10, O9, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "durable": "true" }, cls=LINCLink )
self.addLink( JFKR10, O9, port1=3, port2=11, speed1=10000, annotations={ "bandwidth": 100000, "durable": "true" }, cls=LINCLink )
self.addLink( ATLR10, O10, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=LINCLink )
self.addLink( ATLR10, O10, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "durable": "true" }, cls=LINCLink )
h1 = self.addHost( 'h1' )
h2 = self.addHost( 'h2' )
......
This diff is collapsed. Click to expand it.
......@@ -346,7 +346,7 @@ class LINCSwitch(OpticalSwitch):
portDict[ 'port' ] = port
portType = 'COPPER'
if isinstance(intf.link, LINCLink):
portType = 'OCH' if intf.link.isCrossConnect else 'OMS'
portType = 'OCH' if intf.link.isCrossConnect() else 'OMS'
portDict[ 'type' ] = portType
intfList = [ intf.link.intf1, intf.link.intf2 ]
intfList.remove(intf)
......@@ -396,10 +396,9 @@ class LINCSwitch(OpticalSwitch):
info('*** Converting Topology.json to linc-oe format (TopoConfig.json) file (no oecfg) \n')
topoConfigJson = {}
dpIdToName = {}
topoConfigJson["switchConfig"] = LINCSwitch.getSwitchConfig(dpIdToName)
topoConfigJson["linkConfig"] = LINCSwitch.getLinkConfig(dpIdToName)
topoConfigJson["switchConfig"] = LINCSwitch.getSwitchConfig(net.switches)
topoConfigJson["linkConfig"] = LINCSwitch.getLinkConfig(net.links)
#Writing to TopoConfig.json
with open( 'TopoConfig.json', 'w' ) as outfile:
......@@ -443,8 +442,7 @@ class LINCSwitch(OpticalSwitch):
info('*** Adding cross-connect (tap) interfaces to packet switches...\n')
for link in net.links:
if isinstance(link, LINCLink):
if link.annotations[ 'optical.type' ] == 'cross-connect':
if isinstance(link, LINCLink) and link.isCrossConnect():
for intf in [ link.intf1, link.intf2 ]:
if not isinstance(intf, LINCIntf):
intfList = [ intf.link.intf1, intf.link.intf2 ]
......@@ -502,12 +500,12 @@ class LINCSwitch(OpticalSwitch):
id = id.split("/", 1)[0]
for i in range(3, len(id) - 1, 2):
nodeDpid += (id[i:(i + 2):]) + ":"
return nodeDpid[0:-1];
return nodeDpid[0:-1]
@staticmethod
def makeTopoJSON():
"""
Builds ONOS network conifg system compatible dicts to be written as Topology.json file.
Builds ONOS network config system compatible dicts to be written as Topology.json file.
"""
topology = {}
links = {}
......@@ -549,77 +547,68 @@ class LINCSwitch(OpticalSwitch):
return topology
@staticmethod
def getSwitchConfig (dpIdToName):
switchConfig = [];
#Iterate through all switches and convert the ROADM switches to linc-oe format
for switch in LINCSwitch.opticalJSON["devices"]:
if switch.get("type", "none") == "ROADM":
builtSwitch = {}
#set basic switch params based on annotations
builtSwitch["allowed"] = True;
builtSwitch["latitude"] = switch["annotations"].get("latitude", 0.0);
builtSwitch["longitude"] = switch["annotations"].get("longitude", 0.0);
def getSwitchConfig(switches):
switchConfig = []
#assumed that all switches have this entry
nodeId = switch["uri"]
#convert the nodeId to linc-oe format
nodeDpid = LINCSwitch.dpId(nodeId);
builtSwitch["name"] = switch.get("name", "none");
# Iterate through all switches and convert the ROADM switches to linc-oe format
for switch in switches:
if isinstance(switch, LINCSwitch):
builtSwitch = {}
#keep track of the name corresponding to each switch dpid
dpIdToName[nodeDpid] = builtSwitch["name"];
# Set basic switch params based on annotations
builtSwitch["allowed"] = True
builtSwitch["latitude"] = switch.annotations.get("latitude", 0.0)
builtSwitch["longitude"] = switch.annotations.get("longitude", 0.0)
builtSwitch["nodeDpid"] = nodeDpid
# Convert dpid to linc-oe format
builtSwitch["name"] = switch.name
builtSwitch["nodeDpid"] = LINCSwitch.dpId('of:' + switch.dpid)
#set switch params and type
builtSwitch["params"] = {};
builtSwitch["params"]["numregens"] = switch["annotations"].get("optical.regens", 0);
# Set switch params and type
builtSwitch["params"] = {}
builtSwitch["params"]["numregens"] = switch.annotations.get("optical.regens", 0)
builtSwitch["type"] = "Roadm"
#append to list of switches
switchConfig.append(builtSwitch);
switchConfig.append(builtSwitch)
return switchConfig
@staticmethod
def getLinkConfig (dpIdToName):
newLinkConfig = [];
#Iterate through all optical links and convert them to linc-oe format
for link in LINCSwitch.opticalJSON["links"]:
if link.get("type", "none") == "OPTICAL":
def getLinkConfig(links):
linkConfig = []
# Iterate through all non-edge links and convert them to linc-oe format
for link in links:
if isinstance(link, LINCLink):
builtLink = {}
#set basic link params for src and dst
builtLink["allowed"] = True;
builtLink["nodeDpid1"] = LINCSwitch.dpId(link["src"])
builtLink["nodeDpid2"] = LINCSwitch.dpId(link["dst"])
# Set basic link params for src and dst
builtLink["allowed"] = True
builtLink["nodeDpid1"] = LINCSwitch.dpId('of:' + link.intf1.node.dpid)
builtLink["nodeDpid2"] = LINCSwitch.dpId('of:' + link.intf2.node.dpid)
#set more params such as name/bandwidth/port/waves if they exist
# Set more params such as name/bandwidth/port if they exist
params = {}
params["nodeName1"] = dpIdToName.get(builtLink["nodeDpid1"], "none")
params["nodeName2"] = dpIdToName.get(builtLink["nodeDpid2"], "none")
params["port1"] = int(link["src"].split("/")[1])
params["port2"] = int(link["dst"].split("/")[1])
params["nodeName1"] = link.intf1.node.name
params["nodeName2"] = link.intf2.node.name
if "bandwidth" in link["annotations"]:
params["bandwidth"] = link["annotations"]["bandwidth"]
params["port1"] = link.port1
params["port2"] = link.port2
if "optical.waves" in link["annotations"]:
params["numWaves"] = link["annotations"]["optical.waves"]
if "bandwidth" in link.annotations:
params["bandwidth"] = link.annotations["bandwidth"]
builtLink["params"] = params
#set type of link (WDM or pktOpt)
if link["annotations"].get("optical.type", "cross-connect") == "WDM":
# Set link type to WDM or packet (LINC-config-generator relies on it)
if link.isTransportLayer():
builtLink["type"] = "wdmLink"
else:
builtLink["type"] = "pktOptLink"
newLinkConfig.append(builtLink);
return newLinkConfig
linkConfig.append(builtLink)
return linkConfig
@staticmethod
......@@ -628,9 +617,9 @@ class LINCSwitch(OpticalSwitch):
tapCount = 0
time = 0
for link in net.links:
if isinstance(link, LINCLink):
if link.annotations[ 'optical.type' ] == 'cross-connect':
if isinstance(link, LINCLink) and link.isCrossConnect():
tapCount += 1
while True:
# tapCount can be less than the actual number of taps if the optical network
# is a subgraph of a larger multidomain network.
......@@ -748,14 +737,13 @@ class LINCLink(Link):
self.port2 = port2
params1 = { 'speed': speed1 }
params2 = { 'speed': speed2 }
# self.isCrossConnect = True if self.annotations.get('optical.type') == 'cross-connect' else False
if isinstance(node1, LINCSwitch) and isinstance(node2, LINCSwitch):
self.isCrossConnect = False
self.isXC = False
else:
self.isCrossConnect = True
self.isXC = True
if isinstance(node1, LINCSwitch):
cls1 = LINCIntf
if self.isCrossConnect:
if self.isXC:
node1.crossConnects.append(self)
else:
cls1 = Intf
......@@ -764,7 +752,7 @@ class LINCLink(Link):
intfName1 = 'lo'
if isinstance(node2, LINCSwitch):
cls2 = LINCIntf
if self.isCrossConnect:
if self.isXC:
node2.crossConnects.append(self)
else:
cls2 = Intf
......@@ -788,6 +776,18 @@ class LINCLink(Link):
configData[ 'annotations' ] = self.annotations
return configData
def isCrossConnect(self):
if isinstance(self.intf1.node, LINCSwitch) ^ isinstance(self.intf2.node, LINCSwitch):
return True
return False
def isTransportLayer(self):
if isinstance(self.intf1.node, LINCSwitch) and isinstance(self.intf2.node, LINCSwitch):
return True
return False
class LINCIntf(OpticalIntf):
"""
LINC interface class
......@@ -810,7 +810,7 @@ class LINCIntf(OpticalIntf):
configDict[ 'speed' ] = self.speed
portType = 'COPPER'
if isinstance(self.link, LINCLink):
portType = 'OCH' if self.link.isCrossConnect else 'OMS'
portType = 'OCH' if self.link.isCrossConnect() else 'OMS'
configDict[ 'type' ] = portType
return configDict
......