From c5d20692d9c56d4dc5182bb6af8580961822116e Mon Sep 17 00:00:00 2001 From: Devdatta Kulkarni Date: Mon, 17 Aug 2015 15:12:35 -0500 Subject: [PATCH] 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 --- solum/common/heat_utils.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/solum/common/heat_utils.py b/solum/common/heat_utils.py index f16ae766c..e69af69cf 100644 --- a/solum/common/heat_utils.py +++ b/solum/common/heat_utils.py @@ -23,5 +23,14 @@ def get_network_parameters(osc): params['public_net'] = tenant_network['id'] else: 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 + + +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