+ def __get_peer_MLAG(self, device_id):
+ peer = None
+ url = '/api/v1/rest/{}/Sysdb/mlag/status/'.format(device_id)
+ self.logger.debug('get_MLAG_status: URL {}'.format(url))
+ try:
+ data = self.client.get(url, timeout=self.__API_REQUEST_TOUT)
+ if data['notifications']:
+ found = False
+ for notification in data['notifications']:
+ for update in notification['updates']:
+ if update == 'systemId':
+ mlagSystemId = notification['updates'][update]['value']
+ found = True
+ break
+ if found:
+ break
+ # search the MLAG System Id
+ if found:
+ for s in self.switches:
+ if self.switches[s]['serialNumber'] == device_id:
+ continue
+ url = '/api/v1/rest/{}/Sysdb/mlag/status/'.format(self.switches[s]['serialNumber'])
+ self.logger.debug('Searching for MLAG system id {} in switch {}'.format(mlagSystemId, s))
+ data = self.client.get(url, timeout=self.__API_REQUEST_TOUT)
+ found = False
+ for notification in data['notifications']:
+ for update in notification['updates']:
+ if update == 'systemId':
+ if mlagSystemId == notification['updates'][update]['value']:
+ peer = s
+ found = True
+ break
+ if found:
+ break
+ if found:
+ break
+ if peer == None:
+ self.logger.error('No Peer device found for device {} with MLAG address {}'.format(device_id, mlagSystemId))
+ else:
+ self.logger.debug('Peer MLAG for device {} - value {}'.format(device_id, peer))
+ return peer
+ except Exception:
+ raise SdnConnectorError("Invalid response from url {}: data {}".format(url, data))
+