Avoid hackery in VNI list and support direct type

This commit is contained in:
Joshua Boniface 2021-06-15 00:31:13 -04:00
parent f540dd320b
commit da48304d4a
1 changed files with 2 additions and 8 deletions

View File

@ -1242,13 +1242,7 @@ def format_list(config, vm_list, raw):
# Network list # Network list
net_list = [] net_list = []
for net in domain_information['networks']: for net in domain_information['networks']:
# Split out just the numerical (VNI) part of the brXXXX name net_list.append(net['vni'])
net_vnis = re.findall(r'\d+', net['source'])
if net_vnis:
net_vni = net_vnis[0]
else:
net_vni = re.sub('br', '', net['source'])
net_list.append(net_vni)
return net_list return net_list
# Handle raw mode since it just lists the names # Handle raw mode since it just lists the names
@ -1348,7 +1342,7 @@ def format_list(config, vm_list, raw):
for net_vni in raw_net_list: for net_vni in raw_net_list:
if net_vni not in valid_net_list: if net_vni not in valid_net_list:
response = call_api(config, 'get', '/network/{net}'.format(net=net_vni)) response = call_api(config, 'get', '/network/{net}'.format(net=net_vni))
if response.status_code != 200 and net_vni not in ['cluster', 'storage', 'upstream']: if response.status_code != 200 and net_vni not in ['cluster', 'storage', 'upstream'] and not re.match(r'^e.*', net_vni):
vm_net_colour = ansiprint.red() vm_net_colour = ansiprint.red()
else: else:
valid_net_list.append(net_vni) valid_net_list.append(net_vni)