Skip to content

Commit

Permalink
Merge "Fix subnet_key calculation" into R3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Aug 6, 2016
2 parents 1987ddb + 86865e0 commit 5a9e82f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/config/vnc_openstack/vnc_openstack/__init__.py
Expand Up @@ -879,7 +879,7 @@ def post_virtual_network_create(self, vn_dict):
prefix = subnet_dict['ip_prefix']
prefix_len = subnet_dict['ip_prefix_len']
network = IPNetwork('%s/%s' % (prefix, prefix_len))
subnet_name = vn_dict['uuid'] + ' ' + subnet_dict['ip_prefix'] + '/' + str(
subnet_name = vn_dict['uuid'] + ' ' + str(network.ip) + '/' + str(
subnet_dict['ip_prefix_len'])
subnet_uuid = ipam_subnet['subnet_uuid']
self._vnc_lib.kv_store(subnet_uuid, subnet_name)
Expand Down
21 changes: 5 additions & 16 deletions src/config/vnc_openstack/vnc_openstack/neutron_plugin_db.py
Expand Up @@ -1428,14 +1428,7 @@ def _subnet_vnc_to_neutron(self, subnet_vnc, net_obj, ipam_fq_name):
sn_q_dict['cidr'] = cidr
sn_q_dict['ip_version'] = IPNetwork(cidr).version # 4 or 6

# read from useragent kv only for old subnets created
# before schema had uuid in subnet
sn_id = subnet_vnc.subnet_uuid
if not sn_id:
subnet_key = self._subnet_vnc_get_key(subnet_vnc, net_obj.uuid)
sn_id = self._subnet_vnc_read_mapping(id=subnet_vnc.subnet_uuid,
key=subnet_key)

sn_q_dict['id'] = sn_id

sn_q_dict['gateway_ip'] = subnet_vnc.default_gateway
Expand Down Expand Up @@ -2222,8 +2215,7 @@ def _port_check_and_add_iface_route_table(self, fixed_ips, net_obj,
host_routes = subnet.get_host_routes()
if host_routes is None:
continue
subnet_key = self._subnet_vnc_get_key(subnet, net_obj.uuid)
sn_id = self._subnet_vnc_read_mapping(key=subnet_key)
sn_id = subnet.subnet_uuid
subnet_cidr = '%s/%s' % (subnet.subnet.get_ip_prefix(),
subnet.subnet.get_ip_prefix_len())

Expand Down Expand Up @@ -2623,7 +2615,7 @@ def subnet_create(self, subnet_q):
else: # virtual-network already linked to this ipam
for subnet in net_ipam_ref['attr'].get_ipam_subnets():
if subnet_key == self._subnet_vnc_get_key(subnet, net_id):
existing_sn_id = self._subnet_vnc_read_mapping(key=subnet_key)
existing_sn_id = subnet.subnet_uuid
# duplicate !!
msg = _("Cidr %s overlaps with another subnet of subnet %s"
) % (subnet_q['cidr'], existing_sn_id)
Expand Down Expand Up @@ -2662,8 +2654,7 @@ def subnet_read(self, subnet_id):
for ipam_ref in ipam_refs:
subnet_vncs = ipam_ref['attr'].get_ipam_subnets()
for subnet_vnc in subnet_vncs:
if (self._subnet_vnc_get_key(subnet_vnc, net_id) ==
subnet_key):
if subnet_vnc.subnet_uuid == subnet_id:
ret_subnet_q = self._subnet_vnc_to_neutron(
subnet_vnc, net_obj, ipam_ref['to'])
return ret_subnet_q
Expand Down Expand Up @@ -2698,8 +2689,7 @@ def subnet_update(self, subnet_id, subnet_q):
for ipam_ref in ipam_refs:
subnets = ipam_ref['attr'].get_ipam_subnets()
for subnet_vnc in subnets:
if self._subnet_vnc_get_key(subnet_vnc,
net_id) == subnet_key:
if subnet_vnc.subnet_uuid == subnet_id:
subnet_found = True
break
if subnet_found:
Expand Down Expand Up @@ -2770,8 +2760,7 @@ def subnet_delete(self, subnet_id):
for ipam_ref in ipam_refs:
orig_subnets = ipam_ref['attr'].get_ipam_subnets()
new_subnets = [subnet_vnc for subnet_vnc in orig_subnets
if self._subnet_vnc_get_key(subnet_vnc,
net_id) != subnet_key]
if subnet_vnc.subnet_uuid != subnet_id]
if len(orig_subnets) != len(new_subnets):
# matched subnet to be deleted
ipam_ref['attr'].set_ipam_subnets(new_subnets)
Expand Down

0 comments on commit 5a9e82f

Please sign in to comment.