Marc De Leenheer
Committed by Gerrit Code Review

Optical link annotations are enabled (only 'durable' for now). Removed dead code.

ONOS-3388

Change-Id: Ibe05e1298aa469ec1cd3b9f3664911323bc59015
...@@ -197,9 +197,6 @@ class LINCSwitch(OpticalSwitch): ...@@ -197,9 +197,6 @@ class LINCSwitch(OpticalSwitch):
197 self.configDict[ 'uri' ] = 'of:' + self.dpid 197 self.configDict[ 'uri' ] = 'of:' + self.dpid
198 self.configDict[ 'annotations' ] = self.annotations 198 self.configDict[ 'annotations' ] = self.annotations
199 self.configDict[ 'annotations' ].setdefault('name', self.name) 199 self.configDict[ 'annotations' ].setdefault('name', self.name)
200 - self.configDict[ 'hw' ] = 'linc-oe'
201 - self.configDict[ 'mfr' ] = 'Linc'
202 - self.configDict[ 'mac' ] = 'ffffffffffff' + self.dpid[-2] + self.dpid[-1]
203 self.configDict[ 'type' ] = self.switchType 200 self.configDict[ 'type' ] = self.switchType
204 self.configDict[ 'ports' ] = [] 201 self.configDict[ 'ports' ] = []
205 for port, intf in self.intfs.items(): 202 for port, intf in self.intfs.items():
...@@ -331,10 +328,7 @@ class LINCSwitch(OpticalSwitch): ...@@ -331,10 +328,7 @@ class LINCSwitch(OpticalSwitch):
331 "Returns the json configuration for a packet switch" 328 "Returns the json configuration for a packet switch"
332 configDict = {} 329 configDict = {}
333 configDict[ 'uri' ] = 'of:' + switch.dpid 330 configDict[ 'uri' ] = 'of:' + switch.dpid
334 - configDict[ 'mac' ] = quietRun('cat /sys/class/net/%s/address' % switch.name).strip('\n').translate(None, ':') 331 + configDict[ 'type' ] = 'SWITCH'
335 - configDict[ 'hw' ] = 'PK' # FIXME what about OVS?
336 - configDict[ 'mfr' ] = 'Linc' # FIXME what about OVS?
337 - configDict[ 'type' ] = 'SWITCH' # FIXME what about OVS?
338 annotations = switch.params.get('annotations', {}) 332 annotations = switch.params.get('annotations', {})
339 annotations.setdefault('name', switch.name) 333 annotations.setdefault('name', switch.name)
340 configDict[ 'annotations' ] = annotations 334 configDict[ 'annotations' ] = annotations
...@@ -513,30 +507,26 @@ class LINCSwitch(OpticalSwitch): ...@@ -513,30 +507,26 @@ class LINCSwitch(OpticalSwitch):
513 ports = {} 507 ports = {}
514 508
515 for switch in LINCSwitch.opticalJSON[ 'devices' ]: 509 for switch in LINCSwitch.opticalJSON[ 'devices' ]:
516 - # build device entries - keyed on uri (DPID) and config key 'basic' 510 + # Build device entries - keyed on uri (DPID) and config key 'basic'
511 + # 'type' is necessary field, else ONOS assumes it's a SWITCH
512 + # Annotations hold switch name and latitude/longitude
517 devDict = {} 513 devDict = {}
518 - devDict[ 'driver' ] = switch[ 'hw' ]
519 - devDict[ 'mfr' ] = switch[ 'mfr' ]
520 - devDict[ 'mac' ] = switch[ 'mac' ]
521 devDict[ 'type' ] = switch[ 'type' ] 514 devDict[ 'type' ] = switch[ 'type' ]
522 devDict.update(switch[ 'annotations' ]) 515 devDict.update(switch[ 'annotations' ])
523 -
524 devSubj = switch[ 'uri' ] 516 devSubj = switch[ 'uri' ]
525 devices[ devSubj ] = { 'basic': devDict } 517 devices[ devSubj ] = { 'basic': devDict }
526 518
527 - # build port entries - keyed on "uri/port" and config key 'optical' 519 + # Build port entries - keyed on "uri/port" and config key 'optical'
528 for port in switch[ 'ports' ]: 520 for port in switch[ 'ports' ]:
529 portSubj = devSubj + '/' + str(port[ 'port' ]) 521 portSubj = devSubj + '/' + str(port[ 'port' ])
530 ports[ portSubj ] = { 'optical': port } 522 ports[ portSubj ] = { 'optical': port }
531 523
532 - # build link entries - keyed on "uri/port-uri/port" and config key 'basic' 524 + # Build link entries - keyed on "uri/port-uri/port" and config key 'basic'
525 + # Annotations hold the 'durable' field, which is necessary as long as we don't discover optical links
533 for link in LINCSwitch.opticalJSON[ 'links' ]: 526 for link in LINCSwitch.opticalJSON[ 'links' ]:
534 linkDict = {} 527 linkDict = {}
535 linkDict[ 'type' ] = link[ 'type' ] 528 linkDict[ 'type' ] = link[ 'type' ]
536 - # FIXME: Clean up unnecessary link/device attributes, then re-enable annotations 529 + linkDict.update(link[ 'annotations' ])
537 - linkDict['durable'] = True
538 - # linkDict.update(link[ 'annotations' ])
539 -
540 linkSubj = link[ 'src' ] + '-' + link[ 'dst' ] 530 linkSubj = link[ 'src' ] + '-' + link[ 'dst' ]
541 links[ linkSubj ] = { 'basic': linkDict } 531 links[ linkSubj ] = { 'basic': linkDict }
542 532
...@@ -652,7 +642,7 @@ class LINCSwitch(OpticalSwitch): ...@@ -652,7 +642,7 @@ class LINCSwitch(OpticalSwitch):
652 @staticmethod 642 @staticmethod
653 def getTaps(path=None): 643 def getTaps(path=None):
654 ''' 644 '''
655 - return list of all the tops in sys.config 645 + return list of all the taps in sys.config
656 ''' 646 '''
657 if path is None: 647 if path is None:
658 path = '%s/rel/linc/releases/1.0/sys.config' % LINCSwitch.lincDir 648 path = '%s/rel/linc/releases/1.0/sys.config' % LINCSwitch.lincDir
...@@ -663,21 +653,6 @@ class LINCSwitch(OpticalSwitch): ...@@ -663,21 +653,6 @@ class LINCSwitch(OpticalSwitch):
663 return taps 653 return taps
664 654
665 @staticmethod 655 @staticmethod
666 - def findUser():
667 - "Try to return logged-in (usually non-root) user"
668 - try:
669 - # If we're running sudo
670 - return os.environ[ 'SUDO_USER' ]
671 - except:
672 - try:
673 - # Logged-in user (if we have a tty)
674 - return quietRun('who am i').split()[ 0 ]
675 - except:
676 - # Give up and return effective user
677 - return quietRun('whoami')
678 -
679 -
680 - @staticmethod
681 def findTap(node, port, path=None): 656 def findTap(node, port, path=None):
682 '''utility function to parse through a sys.config 657 '''utility function to parse through a sys.config
683 file to find tap interfaces for a switch''' 658 file to find tap interfaces for a switch'''
......