Exclude gateway_ip of subnet in get_unused_ip_addresses
When running test_create_list_show_delete_interfaces, if subnet
used by the testcase has gateway_ip set, a BadRequest exception
will occur with error message something like "Fixed IP 172.168.200.1
is already in use."
This is to exclude gateway_ip of subnet in get_unused_ip_addresses
besides pruning out addresses already allocated to existing ports.
Change-Id: I036d2940ff39450ca30d19be1cd9ae581ffb1b4f
Closes-Bug: 1616714
diff --git a/tempest/common/utils/net_utils.py b/tempest/common/utils/net_utils.py
index fd0391d..f0d3da3 100644
--- a/tempest/common/utils/net_utils.py
+++ b/tempest/common/utils/net_utils.py
@@ -37,6 +37,11 @@
for fixed_ip in port.get('fixed_ips'):
alloc_set.add(fixed_ip['ip_address'])
+ # exclude gateway_ip of subnet
+ gateway_ip = subnet['subnet']['gateway_ip']
+ if gateway_ip:
+ alloc_set.add(gateway_ip)
+
av_set = subnet_set - alloc_set
addrs = []
for cidr in reversed(av_set.iter_cidrs()):