Improve error messag if subnet is not found
If a subnet that does not exist the error returned is:
"Error managing network ports 'intenal_api_leaf2'"
This patch improves this by raising a more informative
error message.
Change-Id: Ic52d8c630d809efdabd10ec921deff83bbcd86bf
(cherry picked from commit 5558f97b2c
)
This commit is contained in:
parent
a6813adb56
commit
060c0ce5ce
|
@ -316,7 +316,12 @@ def generate_port_defs(net_maps, instance, inst_ports):
|
||||||
fixed_ips = [{'ip_address': net['fixed_ip']}]
|
fixed_ips = [{'ip_address': net['fixed_ip']}]
|
||||||
else:
|
else:
|
||||||
if net.get('subnet'):
|
if net.get('subnet'):
|
||||||
subnet_id = subnet_name_map[net['subnet']]
|
try:
|
||||||
|
subnet_id = subnet_name_map[net['subnet']]
|
||||||
|
except KeyError:
|
||||||
|
raise Exception(
|
||||||
|
'Subnet {subnet} not found on network {net_name}'
|
||||||
|
.format(subnet=net['subnet'], net_name=net_name))
|
||||||
elif len(net_maps['by_name'][net_name]['subnets']) == 1:
|
elif len(net_maps['by_name'][net_name]['subnets']) == 1:
|
||||||
subnet_id = next(iter(subnet_name_map.values()))
|
subnet_id = next(iter(subnet_name_map.values()))
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue