From c026ea054e19429fc4843c0bf60e3cec612dc611 Mon Sep 17 00:00:00 2001 From: Sahil Sabharwal Date: Fri, 29 Jul 2016 15:36:28 -0700 Subject: [PATCH] Capturing the correct ip address length (ipv4: 32 & for ipv6: 128) to update the address pair field accordingly that goes from vnc->neutron. Closes-Bug: 1529317 Change-Id: I00c7909c8dae328c3d0389cd22e4ea729a35fb5e --- .../vnc_openstack/vnc_openstack/neutron_plugin_db.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/config/vnc_openstack/vnc_openstack/neutron_plugin_db.py b/src/config/vnc_openstack/vnc_openstack/neutron_plugin_db.py index 41eaf88d290..34e93afbca6 100644 --- a/src/config/vnc_openstack/vnc_openstack/neutron_plugin_db.py +++ b/src/config/vnc_openstack/vnc_openstack/neutron_plugin_db.py @@ -2071,11 +2071,17 @@ def _port_vnc_to_neutron(self, port_obj, port_req_memo=None): for aap in allowed_address_pairs.allowed_address_pair: pair = {} pair["mac_address"] = aap.mac - if aap.ip.get_ip_prefix_len() == 32: + + if IPAddress(aap.ip.get_ip_prefix()).version is 4: + ip_len = 32 + elif IPAddress(aap.ip.get_ip_prefix()).version is 6: + ip_len = 128 + + if aap.ip.get_ip_prefix_len() == ip_len: pair["ip_address"] = '%s' % (aap.ip.get_ip_prefix()) else: pair["ip_address"] = '%s/%s' % (aap.ip.get_ip_prefix(), - aap.ip.get_ip_prefix_len()), + aap.ip.get_ip_prefix_len()) address_pairs.append(pair) port_q_dict['allowed_address_pairs'] = address_pairs