Committed by
Gerrit Code Review
[Falcon] Cleanup of unused annotations in optical test topos.
First round of cleanups in opticalUtils.py. Change-Id: I5f627fc471220c3a7194d913764f8c84e6f0fe6e
Showing
4 changed files
with
97 additions
and
97 deletions
... | @@ -90,7 +90,7 @@ class OpticalDomain(Domain): | ... | @@ -90,7 +90,7 @@ class OpticalDomain(Domain): |
90 | oean = { "optical.regens": 0 } | 90 | oean = { "optical.regens": 0 } |
91 | self.addSwitch('OE%s' % i, dpid='0000ffffffffff0%s' % i, annotations=oean, cls=LINCSwitch) | 91 | self.addSwitch('OE%s' % i, dpid='0000ffffffffff0%s' % i, annotations=oean, cls=LINCSwitch) |
92 | 92 | ||
93 | - an = { "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" } | 93 | + an = { "durable": "true" } |
94 | self.addLink('OE1', 'OE2', port1=50, port2=30, annotations=an, cls=LINCLink) | 94 | self.addLink('OE1', 'OE2', port1=50, port2=30, annotations=an, cls=LINCLink) |
95 | self.addLink('OE2', 'OE3', port1=50, port2=30, annotations=an, cls=LINCLink) | 95 | self.addLink('OE2', 'OE3', port1=50, port2=30, annotations=an, cls=LINCLink) |
96 | self.addLink('OE3', 'OE1', port1=50, port2=30, annotations=an, cls=LINCLink) | 96 | self.addLink('OE3', 'OE1', port1=50, port2=30, annotations=an, cls=LINCLink) |
... | @@ -188,7 +188,7 @@ def setup(argv): | ... | @@ -188,7 +188,7 @@ def setup(argv): |
188 | 188 | ||
189 | # connect COs to core - sort of hard-wired at this moment | 189 | # connect COs to core - sort of hard-wired at this moment |
190 | for i in range(1,len(domains)): | 190 | for i in range(1,len(domains)): |
191 | - an = { "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" } | 191 | + an = { "bandwidth": 100000, "durable": "true" } |
192 | net.addLink(domains[i].getTether(), d0.getSwitches('OE%s' % i), | 192 | net.addLink(domains[i].getTether(), d0.getSwitches('OE%s' % i), |
193 | port1=OVS_AP, port2=OE_AP, speed=10000, annotations=an, cls=LINCLink) | 193 | port1=OVS_AP, port2=OE_AP, speed=10000, annotations=an, cls=LINCLink) |
194 | 194 | ... | ... |
... | @@ -38,34 +38,34 @@ class SmallOpticalTopo( Topo ): | ... | @@ -38,34 +38,34 @@ class SmallOpticalTopo( Topo ): |
38 | JFKR10 = self.addSwitch( 'JFK-R10', dpid='0000ffffffff0005', annotations={ "latitude": 40.8, "longitude": -73.1 } ) | 38 | JFKR10 = self.addSwitch( 'JFK-R10', dpid='0000ffffffff0005', annotations={ "latitude": 40.8, "longitude": -73.1 } ) |
39 | ATLR10 = self.addSwitch( 'ATL-R10', dpid='0000ffffffff0006', annotations={ "latitude": 33.8, "longitude": -84.1 } ) | 39 | ATLR10 = self.addSwitch( 'ATL-R10', dpid='0000ffffffff0006', annotations={ "latitude": 33.8, "longitude": -84.1 } ) |
40 | 40 | ||
41 | - self.addLink( O1, O2, port1=50, port2=30, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=LINCLink ) | 41 | + self.addLink( O1, O2, port1=50, port2=30, annotations={ "durable": "true" }, cls=LINCLink ) |
42 | - self.addLink( O2, O3, port1=50, port2=30, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=LINCLink ) | 42 | + self.addLink( O2, O3, port1=50, port2=30, annotations={ "durable": "true" }, cls=LINCLink ) |
43 | - self.addLink( O3, O4, port1=50, port2=50, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=LINCLink ) | 43 | + self.addLink( O3, O4, port1=50, port2=50, annotations={ "durable": "true" }, cls=LINCLink ) |
44 | - self.addLink( O1, O5, port1=20, port2=50, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=LINCLink ) | 44 | + self.addLink( O1, O5, port1=20, port2=50, annotations={ "durable": "true" }, cls=LINCLink ) |
45 | - self.addLink( O2, O5, port1=20, port2=20, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=LINCLink ) | 45 | + self.addLink( O2, O5, port1=20, port2=20, annotations={ "durable": "true" }, cls=LINCLink ) |
46 | - self.addLink( O3, O6, port1=20, port2=50, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=LINCLink ) | 46 | + self.addLink( O3, O6, port1=20, port2=50, annotations={ "durable": "true" }, cls=LINCLink ) |
47 | - self.addLink( O4, O6, port1=20, port2=20, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=LINCLink ) | 47 | + self.addLink( O4, O6, port1=20, port2=20, annotations={ "durable": "true" }, cls=LINCLink ) |
48 | - self.addLink( O5, O6, port1=30, port2=40, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=LINCLink ) | 48 | + self.addLink( O5, O6, port1=30, port2=40, annotations={ "durable": "true" }, cls=LINCLink ) |
49 | - self.addLink( O5, O7, port1=40, port2=50, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=LINCLink ) | 49 | + self.addLink( O5, O7, port1=40, port2=50, annotations={ "durable": "true" }, cls=LINCLink ) |
50 | - self.addLink( O6, O8, port1=30, port2=50, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=LINCLink ) | 50 | + self.addLink( O6, O8, port1=30, port2=50, annotations={ "durable": "true" }, cls=LINCLink ) |
51 | - self.addLink( O7, O8, port1=20, port2=30, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=LINCLink ) | 51 | + self.addLink( O7, O8, port1=20, port2=30, annotations={ "durable": "true" }, cls=LINCLink ) |
52 | - self.addLink( O7, O9, port1=30, port2=50, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=LINCLink ) | 52 | + self.addLink( O7, O9, port1=30, port2=50, annotations={ "durable": "true" }, cls=LINCLink ) |
53 | - self.addLink( O8, O10, port1=20, port2=50, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=LINCLink ) | 53 | + self.addLink( O8, O10, port1=20, port2=50, annotations={ "durable": "true" }, cls=LINCLink ) |
54 | - self.addLink( O9, O10, port1=20, port2=20, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=LINCLink ) | 54 | + self.addLink( O9, O10, port1=20, port2=20, annotations={ "durable": "true" }, cls=LINCLink ) |
55 | 55 | ||
56 | - self.addLink( SFOR10, O1, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=LINCLink ) | 56 | + self.addLink( SFOR10, O1, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "durable": "true" }, cls=LINCLink ) |
57 | - self.addLink( SFOR10, O1, port1=3, port2=11, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=LINCLink ) | 57 | + self.addLink( SFOR10, O1, port1=3, port2=11, speed1=10000, annotations={ "bandwidth": 100000, "durable": "true" }, cls=LINCLink ) |
58 | 58 | ||
59 | - self.addLink( LAXR10, O3, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=LINCLink ) | 59 | + self.addLink( LAXR10, O3, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "durable": "true" }, cls=LINCLink ) |
60 | # added second tap | 60 | # added second tap |
61 | - self.addLink( LAXR10, O3, port1=3, port2=11, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=LINCLink ) | 61 | + self.addLink( LAXR10, O3, port1=3, port2=11, speed1=10000, annotations={ "bandwidth": 100000, "durable": "true" }, cls=LINCLink ) |
62 | - self.addLink( SDGR10, O4, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=LINCLink ) | 62 | + self.addLink( SDGR10, O4, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "durable": "true" }, cls=LINCLink ) |
63 | - self.addLink( CHGR10, O7, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=LINCLink ) | 63 | + self.addLink( CHGR10, O7, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "durable": "true" }, cls=LINCLink ) |
64 | 64 | ||
65 | - self.addLink( JFKR10, O9, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=LINCLink ) | 65 | + self.addLink( JFKR10, O9, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "durable": "true" }, cls=LINCLink ) |
66 | - self.addLink( JFKR10, O9, port1=3, port2=11, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=LINCLink ) | 66 | + self.addLink( JFKR10, O9, port1=3, port2=11, speed1=10000, annotations={ "bandwidth": 100000, "durable": "true" }, cls=LINCLink ) |
67 | 67 | ||
68 | - self.addLink( ATLR10, O10, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=LINCLink ) | 68 | + self.addLink( ATLR10, O10, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "durable": "true" }, cls=LINCLink ) |
69 | 69 | ||
70 | h1 = self.addHost( 'h1' ) | 70 | h1 = self.addHost( 'h1' ) |
71 | h2 = self.addHost( 'h2' ) | 71 | h2 = self.addHost( 'h2' ) | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -346,7 +346,7 @@ class LINCSwitch(OpticalSwitch): | ... | @@ -346,7 +346,7 @@ class LINCSwitch(OpticalSwitch): |
346 | portDict[ 'port' ] = port | 346 | portDict[ 'port' ] = port |
347 | portType = 'COPPER' | 347 | portType = 'COPPER' |
348 | if isinstance(intf.link, LINCLink): | 348 | if isinstance(intf.link, LINCLink): |
349 | - portType = 'OCH' if intf.link.isCrossConnect else 'OMS' | 349 | + portType = 'OCH' if intf.link.isCrossConnect() else 'OMS' |
350 | portDict[ 'type' ] = portType | 350 | portDict[ 'type' ] = portType |
351 | intfList = [ intf.link.intf1, intf.link.intf2 ] | 351 | intfList = [ intf.link.intf1, intf.link.intf2 ] |
352 | intfList.remove(intf) | 352 | intfList.remove(intf) |
... | @@ -396,10 +396,9 @@ class LINCSwitch(OpticalSwitch): | ... | @@ -396,10 +396,9 @@ class LINCSwitch(OpticalSwitch): |
396 | info('*** Converting Topology.json to linc-oe format (TopoConfig.json) file (no oecfg) \n') | 396 | info('*** Converting Topology.json to linc-oe format (TopoConfig.json) file (no oecfg) \n') |
397 | 397 | ||
398 | topoConfigJson = {} | 398 | topoConfigJson = {} |
399 | - dpIdToName = {} | ||
400 | 399 | ||
401 | - topoConfigJson["switchConfig"] = LINCSwitch.getSwitchConfig(dpIdToName) | 400 | + topoConfigJson["switchConfig"] = LINCSwitch.getSwitchConfig(net.switches) |
402 | - topoConfigJson["linkConfig"] = LINCSwitch.getLinkConfig(dpIdToName) | 401 | + topoConfigJson["linkConfig"] = LINCSwitch.getLinkConfig(net.links) |
403 | 402 | ||
404 | #Writing to TopoConfig.json | 403 | #Writing to TopoConfig.json |
405 | with open( 'TopoConfig.json', 'w' ) as outfile: | 404 | with open( 'TopoConfig.json', 'w' ) as outfile: |
... | @@ -443,14 +442,13 @@ class LINCSwitch(OpticalSwitch): | ... | @@ -443,14 +442,13 @@ class LINCSwitch(OpticalSwitch): |
443 | 442 | ||
444 | info('*** Adding cross-connect (tap) interfaces to packet switches...\n') | 443 | info('*** Adding cross-connect (tap) interfaces to packet switches...\n') |
445 | for link in net.links: | 444 | for link in net.links: |
446 | - if isinstance(link, LINCLink): | 445 | + if isinstance(link, LINCLink) and link.isCrossConnect(): |
447 | - if link.annotations[ 'optical.type' ] == 'cross-connect': | 446 | + for intf in [ link.intf1, link.intf2 ]: |
448 | - for intf in [ link.intf1, link.intf2 ]: | 447 | + if not isinstance(intf, LINCIntf): |
449 | - if not isinstance(intf, LINCIntf): | 448 | + intfList = [ intf.link.intf1, intf.link.intf2 ] |
450 | - intfList = [ intf.link.intf1, intf.link.intf2 ] | 449 | + intfList.remove(intf) |
451 | - intfList.remove(intf) | 450 | + intf2 = intfList[ 0 ] |
452 | - intf2 = intfList[ 0 ] | 451 | + intf.node.attach(LINCSwitch.findTap(intf2.node, intf2.node.ports[ intf2 ])) |
453 | - intf.node.attach(LINCSwitch.findTap(intf2.node, intf2.node.ports[ intf2 ])) | ||
454 | 452 | ||
455 | info('*** Waiting for all devices to be available in ONOS...\n') | 453 | info('*** Waiting for all devices to be available in ONOS...\n') |
456 | url = 'http://%s:8181/onos/v1/devices' % LINCSwitch.controllers[0].ip | 454 | url = 'http://%s:8181/onos/v1/devices' % LINCSwitch.controllers[0].ip |
... | @@ -502,12 +500,12 @@ class LINCSwitch(OpticalSwitch): | ... | @@ -502,12 +500,12 @@ class LINCSwitch(OpticalSwitch): |
502 | id = id.split("/", 1)[0] | 500 | id = id.split("/", 1)[0] |
503 | for i in range(3, len(id) - 1, 2): | 501 | for i in range(3, len(id) - 1, 2): |
504 | nodeDpid += (id[i:(i + 2):]) + ":" | 502 | nodeDpid += (id[i:(i + 2):]) + ":" |
505 | - return nodeDpid[0:-1]; | 503 | + return nodeDpid[0:-1] |
506 | 504 | ||
507 | @staticmethod | 505 | @staticmethod |
508 | def makeTopoJSON(): | 506 | def makeTopoJSON(): |
509 | """ | 507 | """ |
510 | - Builds ONOS network conifg system compatible dicts to be written as Topology.json file. | 508 | + Builds ONOS network config system compatible dicts to be written as Topology.json file. |
511 | """ | 509 | """ |
512 | topology = {} | 510 | topology = {} |
513 | links = {} | 511 | links = {} |
... | @@ -549,77 +547,68 @@ class LINCSwitch(OpticalSwitch): | ... | @@ -549,77 +547,68 @@ class LINCSwitch(OpticalSwitch): |
549 | return topology | 547 | return topology |
550 | 548 | ||
551 | @staticmethod | 549 | @staticmethod |
552 | - def getSwitchConfig (dpIdToName): | 550 | + def getSwitchConfig(switches): |
553 | - switchConfig = []; | 551 | + switchConfig = [] |
554 | - #Iterate through all switches and convert the ROADM switches to linc-oe format | 552 | + |
555 | - for switch in LINCSwitch.opticalJSON["devices"]: | 553 | + # Iterate through all switches and convert the ROADM switches to linc-oe format |
556 | - if switch.get("type", "none") == "ROADM": | 554 | + for switch in switches: |
555 | + if isinstance(switch, LINCSwitch): | ||
557 | builtSwitch = {} | 556 | builtSwitch = {} |
558 | 557 | ||
559 | - #set basic switch params based on annotations | 558 | + # Set basic switch params based on annotations |
560 | - builtSwitch["allowed"] = True; | 559 | + builtSwitch["allowed"] = True |
561 | - builtSwitch["latitude"] = switch["annotations"].get("latitude", 0.0); | 560 | + builtSwitch["latitude"] = switch.annotations.get("latitude", 0.0) |
562 | - builtSwitch["longitude"] = switch["annotations"].get("longitude", 0.0); | 561 | + builtSwitch["longitude"] = switch.annotations.get("longitude", 0.0) |
563 | - | ||
564 | - #assumed that all switches have this entry | ||
565 | - nodeId = switch["uri"] | ||
566 | - | ||
567 | - #convert the nodeId to linc-oe format | ||
568 | - nodeDpid = LINCSwitch.dpId(nodeId); | ||
569 | - | ||
570 | - builtSwitch["name"] = switch.get("name", "none"); | ||
571 | 562 | ||
572 | - #keep track of the name corresponding to each switch dpid | 563 | + # Convert dpid to linc-oe format |
573 | - dpIdToName[nodeDpid] = builtSwitch["name"]; | 564 | + builtSwitch["name"] = switch.name |
565 | + builtSwitch["nodeDpid"] = LINCSwitch.dpId('of:' + switch.dpid) | ||
574 | 566 | ||
575 | - builtSwitch["nodeDpid"] = nodeDpid | 567 | + # Set switch params and type |
576 | - | 568 | + builtSwitch["params"] = {} |
577 | - #set switch params and type | 569 | + builtSwitch["params"]["numregens"] = switch.annotations.get("optical.regens", 0) |
578 | - builtSwitch["params"] = {}; | ||
579 | - builtSwitch["params"]["numregens"] = switch["annotations"].get("optical.regens", 0); | ||
580 | builtSwitch["type"] = "Roadm" | 570 | builtSwitch["type"] = "Roadm" |
581 | 571 | ||
582 | - #append to list of switches | 572 | + switchConfig.append(builtSwitch) |
583 | - switchConfig.append(builtSwitch); | 573 | + |
584 | return switchConfig | 574 | return switchConfig |
585 | 575 | ||
586 | @staticmethod | 576 | @staticmethod |
587 | - def getLinkConfig (dpIdToName): | 577 | + def getLinkConfig(links): |
588 | - newLinkConfig = []; | 578 | + linkConfig = [] |
589 | - #Iterate through all optical links and convert them to linc-oe format | 579 | + |
590 | - for link in LINCSwitch.opticalJSON["links"]: | 580 | + # Iterate through all non-edge links and convert them to linc-oe format |
591 | - if link.get("type", "none") == "OPTICAL": | 581 | + for link in links: |
582 | + if isinstance(link, LINCLink): | ||
592 | builtLink = {} | 583 | builtLink = {} |
593 | 584 | ||
594 | - #set basic link params for src and dst | 585 | + # Set basic link params for src and dst |
595 | - builtLink["allowed"] = True; | 586 | + builtLink["allowed"] = True |
596 | - builtLink["nodeDpid1"] = LINCSwitch.dpId(link["src"]) | 587 | + builtLink["nodeDpid1"] = LINCSwitch.dpId('of:' + link.intf1.node.dpid) |
597 | - builtLink["nodeDpid2"] = LINCSwitch.dpId(link["dst"]) | 588 | + builtLink["nodeDpid2"] = LINCSwitch.dpId('of:' + link.intf2.node.dpid) |
598 | 589 | ||
599 | - #set more params such as name/bandwidth/port/waves if they exist | 590 | + # Set more params such as name/bandwidth/port if they exist |
600 | params = {} | 591 | params = {} |
601 | - params["nodeName1"] = dpIdToName.get(builtLink["nodeDpid1"], "none") | 592 | + params["nodeName1"] = link.intf1.node.name |
602 | - params["nodeName2"] = dpIdToName.get(builtLink["nodeDpid2"], "none") | 593 | + params["nodeName2"] = link.intf2.node.name |
603 | 594 | ||
604 | - params["port1"] = int(link["src"].split("/")[1]) | 595 | + params["port1"] = link.port1 |
605 | - params["port2"] = int(link["dst"].split("/")[1]) | 596 | + params["port2"] = link.port2 |
606 | 597 | ||
607 | - if "bandwidth" in link["annotations"]: | 598 | + if "bandwidth" in link.annotations: |
608 | - params["bandwidth"] = link["annotations"]["bandwidth"] | 599 | + params["bandwidth"] = link.annotations["bandwidth"] |
609 | 600 | ||
610 | - if "optical.waves" in link["annotations"]: | ||
611 | - params["numWaves"] = link["annotations"]["optical.waves"] | ||
612 | - | ||
613 | builtLink["params"] = params | 601 | builtLink["params"] = params |
614 | 602 | ||
615 | - #set type of link (WDM or pktOpt) | 603 | + # Set link type to WDM or packet (LINC-config-generator relies on it) |
616 | - if link["annotations"].get("optical.type", "cross-connect") == "WDM": | 604 | + if link.isTransportLayer(): |
617 | builtLink["type"] = "wdmLink" | 605 | builtLink["type"] = "wdmLink" |
618 | else: | 606 | else: |
619 | builtLink["type"] = "pktOptLink" | 607 | builtLink["type"] = "pktOptLink" |
620 | 608 | ||
621 | - newLinkConfig.append(builtLink); | 609 | + linkConfig.append(builtLink) |
622 | - return newLinkConfig | 610 | + |
611 | + return linkConfig | ||
623 | 612 | ||
624 | 613 | ||
625 | @staticmethod | 614 | @staticmethod |
... | @@ -628,9 +617,9 @@ class LINCSwitch(OpticalSwitch): | ... | @@ -628,9 +617,9 @@ class LINCSwitch(OpticalSwitch): |
628 | tapCount = 0 | 617 | tapCount = 0 |
629 | time = 0 | 618 | time = 0 |
630 | for link in net.links: | 619 | for link in net.links: |
631 | - if isinstance(link, LINCLink): | 620 | + if isinstance(link, LINCLink) and link.isCrossConnect(): |
632 | - if link.annotations[ 'optical.type' ] == 'cross-connect': | 621 | + tapCount += 1 |
633 | - tapCount += 1 | 622 | + |
634 | while True: | 623 | while True: |
635 | # tapCount can be less than the actual number of taps if the optical network | 624 | # tapCount can be less than the actual number of taps if the optical network |
636 | # is a subgraph of a larger multidomain network. | 625 | # is a subgraph of a larger multidomain network. |
... | @@ -748,14 +737,13 @@ class LINCLink(Link): | ... | @@ -748,14 +737,13 @@ class LINCLink(Link): |
748 | self.port2 = port2 | 737 | self.port2 = port2 |
749 | params1 = { 'speed': speed1 } | 738 | params1 = { 'speed': speed1 } |
750 | params2 = { 'speed': speed2 } | 739 | params2 = { 'speed': speed2 } |
751 | - # self.isCrossConnect = True if self.annotations.get('optical.type') == 'cross-connect' else False | ||
752 | if isinstance(node1, LINCSwitch) and isinstance(node2, LINCSwitch): | 740 | if isinstance(node1, LINCSwitch) and isinstance(node2, LINCSwitch): |
753 | - self.isCrossConnect = False | 741 | + self.isXC = False |
754 | else: | 742 | else: |
755 | - self.isCrossConnect = True | 743 | + self.isXC = True |
756 | if isinstance(node1, LINCSwitch): | 744 | if isinstance(node1, LINCSwitch): |
757 | cls1 = LINCIntf | 745 | cls1 = LINCIntf |
758 | - if self.isCrossConnect: | 746 | + if self.isXC: |
759 | node1.crossConnects.append(self) | 747 | node1.crossConnects.append(self) |
760 | else: | 748 | else: |
761 | cls1 = Intf | 749 | cls1 = Intf |
... | @@ -764,7 +752,7 @@ class LINCLink(Link): | ... | @@ -764,7 +752,7 @@ class LINCLink(Link): |
764 | intfName1 = 'lo' | 752 | intfName1 = 'lo' |
765 | if isinstance(node2, LINCSwitch): | 753 | if isinstance(node2, LINCSwitch): |
766 | cls2 = LINCIntf | 754 | cls2 = LINCIntf |
767 | - if self.isCrossConnect: | 755 | + if self.isXC: |
768 | node2.crossConnects.append(self) | 756 | node2.crossConnects.append(self) |
769 | else: | 757 | else: |
770 | cls2 = Intf | 758 | cls2 = Intf |
... | @@ -788,6 +776,18 @@ class LINCLink(Link): | ... | @@ -788,6 +776,18 @@ class LINCLink(Link): |
788 | configData[ 'annotations' ] = self.annotations | 776 | configData[ 'annotations' ] = self.annotations |
789 | return configData | 777 | return configData |
790 | 778 | ||
779 | + def isCrossConnect(self): | ||
780 | + if isinstance(self.intf1.node, LINCSwitch) ^ isinstance(self.intf2.node, LINCSwitch): | ||
781 | + return True | ||
782 | + | ||
783 | + return False | ||
784 | + | ||
785 | + def isTransportLayer(self): | ||
786 | + if isinstance(self.intf1.node, LINCSwitch) and isinstance(self.intf2.node, LINCSwitch): | ||
787 | + return True | ||
788 | + | ||
789 | + return False | ||
790 | + | ||
791 | class LINCIntf(OpticalIntf): | 791 | class LINCIntf(OpticalIntf): |
792 | """ | 792 | """ |
793 | LINC interface class | 793 | LINC interface class |
... | @@ -810,7 +810,7 @@ class LINCIntf(OpticalIntf): | ... | @@ -810,7 +810,7 @@ class LINCIntf(OpticalIntf): |
810 | configDict[ 'speed' ] = self.speed | 810 | configDict[ 'speed' ] = self.speed |
811 | portType = 'COPPER' | 811 | portType = 'COPPER' |
812 | if isinstance(self.link, LINCLink): | 812 | if isinstance(self.link, LINCLink): |
813 | - portType = 'OCH' if self.link.isCrossConnect else 'OMS' | 813 | + portType = 'OCH' if self.link.isCrossConnect() else 'OMS' |
814 | configDict[ 'type' ] = portType | 814 | configDict[ 'type' ] = portType |
815 | return configDict | 815 | return configDict |
816 | 816 | ... | ... |
-
Please register or login to post a comment