Ayaka Koshibe
Committed by Gerrit Code Review

in opticalUtils.py:

General logic fixes for emulating multi-domain networks

Change-Id: I58e487e0b663a6b64e99d93d6fa5cea6afe86aac
...@@ -58,7 +58,7 @@ import os ...@@ -58,7 +58,7 @@ import os
58 from time import sleep 58 from time import sleep
59 import urllib2 59 import urllib2
60 60
61 -from mininet.node import Switch, RemoteController 61 +from mininet.node import Switch, OVSSwitch, RemoteController
62 from mininet.topo import Topo 62 from mininet.topo import Topo
63 from mininet.util import quietRun 63 from mininet.util import quietRun
64 from mininet.net import Mininet 64 from mininet.net import Mininet
...@@ -357,7 +357,13 @@ class LINCSwitch(OpticalSwitch): ...@@ -357,7 +357,13 @@ class LINCSwitch(OpticalSwitch):
357 357
358 @staticmethod 358 @staticmethod
359 def bootOE(net): 359 def bootOE(net):
360 - "Start the LINC optical emulator within a mininet instance" 360 + """
361 + Start the LINC optical emulator within a mininet instance
362 +
363 + This involves 1. converting the information stored in Linc* to configs
364 + for both LINC and the network config system, 2. starting Linc, 3. connecting
365 + cross-connects, and finally pushing the network configs to ONOS.
366 + """
361 LINCSwitch.opticalJSON = {} 367 LINCSwitch.opticalJSON = {}
362 linkConfig = [] 368 linkConfig = []
363 devices = [] 369 devices = []
...@@ -367,7 +373,7 @@ class LINCSwitch(OpticalSwitch): ...@@ -367,7 +373,7 @@ class LINCSwitch(OpticalSwitch):
367 for switch in net.switches: 373 for switch in net.switches:
368 if isinstance(switch, OpticalSwitch): 374 if isinstance(switch, OpticalSwitch):
369 devices.append(switch.json()) 375 devices.append(switch.json())
370 - else: 376 + elif isinstance(switch, OVSSwitch):
371 devices.append(LINCSwitch.switchJSON(switch)) 377 devices.append(LINCSwitch.switchJSON(switch))
372 LINCSwitch.opticalJSON[ 'devices' ] = devices 378 LINCSwitch.opticalJSON[ 'devices' ] = devices
373 379
...@@ -450,17 +456,20 @@ class LINCSwitch(OpticalSwitch): ...@@ -450,17 +456,20 @@ class LINCSwitch(OpticalSwitch):
450 opener = urllib2.build_opener(handler) 456 opener = urllib2.build_opener(handler)
451 opener.open(url) 457 opener.open(url)
452 urllib2.install_opener(opener) 458 urllib2.install_opener(opener)
459 + # focus on just checking the state of devices we're interested in
460 + devlist = map( lambda x: x['uri'], devices )
453 while True: 461 while True:
454 response = json.load(urllib2.urlopen(url)) 462 response = json.load(urllib2.urlopen(url))
455 devs = response.get('devices') 463 devs = response.get('devices')
456 464
457 - # Wait for all devices to be registered 465 + # Wait for all devices to be registered. There is a chance that this is only a subgraph.
458 - if (len(devices) != len(devs)): 466 + if (len(devices) > len(devs)):
459 continue 467 continue
460 468
461 # Wait for all devices to available 469 # Wait for all devices to available
462 available = True 470 available = True
463 for d in devs: 471 for d in devs:
472 + if d['id'] in devlist:
464 available &= d['available'] 473 available &= d['available']
465 if available: 474 if available:
466 break 475 break
...@@ -615,9 +624,11 @@ class LINCSwitch(OpticalSwitch): ...@@ -615,9 +624,11 @@ class LINCSwitch(OpticalSwitch):
615 if isinstance(link, LINCLink): 624 if isinstance(link, LINCLink):
616 if link.annotations[ 'optical.type' ] == 'cross-connect': 625 if link.annotations[ 'optical.type' ] == 'cross-connect':
617 tapCount += 1 626 tapCount += 1
618 -
619 while True: 627 while True:
620 - if str(tapCount) == quietRun('ip addr | grep tap | wc -l', shell=True).strip('\n'): 628 + # tapCount can be less than the actual number of taps if the optical network
629 + # is a subgraph of a larger multidomain network.
630 + tapNum = int(quietRun('ip addr | grep tap | wc -l', shell=True).strip('\n'))
631 + if tapCount <= tapNum:
621 return True 632 return True
622 if timeout: 633 if timeout:
623 if time >= TIMEOUT: 634 if time >= TIMEOUT:
......