Parsing subnet-id for ipv4 subnet from neutron

Parsing the subnet-id from neutron which corresponds to the ipv4 address.
Currently, when parsing the neutron subnet ids, we are picking the first
entry from a list. See line 26 of:

https://github.com/stackforge/solum/blob/master/solum/common/heat_utils.py

However, the first entry could be either for ipv4 subnet or ipv6 subnet.
We want to pick the ipv4 subnet id.

Fixes-Bug: #1485749

Change-Id: I6ff79853e9879436dbbb730eda637179be2082e0
This commit is contained in:
Devdatta Kulkarni 2015-08-17 15:12:35 -05:00
parent 139c315344
commit c5d20692d9

View File

@ -23,5 +23,14 @@ def get_network_parameters(osc):
params['public_net'] = tenant_network['id'] params['public_net'] = tenant_network['id']
else: else:
params['private_net'] = tenant_network['id'] params['private_net'] = tenant_network['id']
params['private_subnet'] = tenant_network['subnets'][0] # Note (devkulkarni): Neutron subnet may contain
# ipv6 and ipv4 subnets. We want to pick the ipv4 subnet
params['private_subnet'] = get_ipv4_subnet_id(osc, tenant_network)
return params return params
def get_ipv4_subnet_id(osc, tenant_network):
for tenant_sub_id in tenant_network['subnets']:
subnet_data = osc.neutron().show_subnet(tenant_sub_id)
if subnet_data['subnet']['ip_version'] == 4:
return tenant_sub_id