Update get_physical_network with the latest change to topology
The keys to the json output of 'show network physical-topology hosts' command changed from hostname to chassis ID. This patch makes the code to work with older and latest version of the command's output. Change-Id: Ibfe35e7da4555ea9a5f77645eaca0a498b83cb87
This commit is contained in:
parent
4cff9a370a
commit
fa68051ccf
|
@ -1986,7 +1986,6 @@ class AristaRPCWrapperEapi(AristaRPCWrapperBase):
|
|||
for a given host_id
|
||||
"""
|
||||
fqdns_used = cfg.CONF.ml2_arista['use_fqdn']
|
||||
hostname = None
|
||||
physnet = None
|
||||
switch_id = None
|
||||
mac_to_hostname = {}
|
||||
|
@ -1999,20 +1998,20 @@ class AristaRPCWrapperEapi(AristaRPCWrapperBase):
|
|||
neighbors = response[0]['neighbors']
|
||||
for neighbor in neighbors:
|
||||
if host_id in neighbor:
|
||||
hostname = neighbors[neighbor]['toPort'][0]['hostname']
|
||||
physnet = hostname if fqdns_used else (
|
||||
hostname.split('.')[0])
|
||||
switchname = neighbors[neighbor]['toPort'][0]['hostname']
|
||||
physnet = switchname if fqdns_used else (
|
||||
switchname.split('.')[0])
|
||||
switch_id = neighbors[neighbor]['toPort'][0].get('hostid')
|
||||
if not switch_id:
|
||||
switch_id = response[1]['hosts'][switchname]['name']
|
||||
break
|
||||
# Get response for 'show network physical-topology hosts' command
|
||||
if hostname:
|
||||
switch_id = response[1]['hosts'][hostname]['name']
|
||||
|
||||
# Check if the switch is part of an MLAG pair, and lookup the
|
||||
# pair's physnet name if so
|
||||
physnet = self.mlag_pairs.get(physnet, physnet)
|
||||
|
||||
for k in response[1]['hosts']:
|
||||
mac_to_hostname[response[1]['hosts'][k]['name']] = k
|
||||
for host in response[1]['hosts'].values():
|
||||
mac_to_hostname[host['name']] = host['hostname']
|
||||
|
||||
res = {'physnet': physnet,
|
||||
'switch_id': switch_id,
|
||||
|
|
Loading…
Reference in New Issue