Skip to content

Commit

Permalink
This will read ipam_ref uuid from fq_name if uuid is not in update
Browse files Browse the repository at this point in the history
message

This will also convert exceptions to str from unicode
In pre_dbe_update, it is not necessary that we will get uuid some time
fq_name is available, in that case we need to use db to retrieve uuid
from the given fq_name
Closes-Bug: #1728028

Change-Id: I5a016bab06a3736e61cf92ed04a4e10525f3cfa6
  • Loading branch information
moghea committed Nov 9, 2017
1 parent 0f2704e commit 8fc404a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/config/api-server/vnc_addr_mgmt.py
Expand Up @@ -72,7 +72,7 @@ def __str__(self):
class AddrMgmtSubnetAbsent(AddrMgmtError):

def __init__(self, vn_fq_name):
self.vn_fq_name = vn_fq_name
self.vn_fq_name = map(str, vn_fq_name)
# end __init__

def __str__(self):
Expand All @@ -84,8 +84,8 @@ def __str__(self):
class AddrMgmtSubnetExhausted(AddrMgmtError):

def __init__(self, vn_fq_name, subnet_val):
self.vn_fq_name = vn_fq_name
self.subnet_val = subnet_val
self.vn_fq_name = map(str, vn_fq_name)
self.subnet_val = map(str, subnet_val)
# end __init__

def __str__(self):
Expand Down Expand Up @@ -567,7 +567,7 @@ def _get_net_subnet_dicts(self, vn_uuid, vn_dict=None):

def _create_subnet_obj_for_ipam_subnet(self, ipam_subnet, fq_name_str, should_persist):
subnet = ipam_subnet['subnet']
subnet_name = subnet['ip_prefix'] + '/' + str(subnet['ip_prefix_len'])
subnet_name = str(subnet['ip_prefix']) + '/' + str(subnet['ip_prefix_len'])
gateway_ip = ipam_subnet.get('default_gateway')
service_address = ipam_subnet.get('dns_server_address')
allocation_pools = ipam_subnet.get('allocation_pools')
Expand Down
9 changes: 8 additions & 1 deletion src/config/api-server/vnc_cfg_types.py
Expand Up @@ -2034,7 +2034,14 @@ def _validate_vrouter_alloc_pools(cls, vrouter_dict, db_conn, ipam_refs):
return True, ''

vrouter_uuid = vrouter_dict['uuid']
ipam_uuid_list = [(ipam_ref['uuid']) for ipam_ref in ipam_refs]
ipam_uuid_list = []
for ipam_ref in ipam_refs:
if 'uuid' in ipam_ref:
ipam_ref_uuid = ipam_ref.get('uuid')
else:
ipam_fq_name = ipam_ref['to']
ipam_ref_uuid = db_conn.fq_name_to_uuid('network_ipam', ipam_fq_name)
ipam_uuid_list.append(ipam_ref_uuid)
(ok, ipam_list, _) = db_conn.dbe_list('network_ipam',
obj_uuids=ipam_uuid_list,
field_names=['ipam_subnet_method',
Expand Down
8 changes: 6 additions & 2 deletions src/config/schema-transformer/test/test_route_target.py
Expand Up @@ -79,14 +79,18 @@ def test_configured_targets(self):
self.check_ri_is_deleted(fq_name=vn1_obj.fq_name+[vn1_obj.name])
# end test_configured_targets

@retries(5)
def wait_for_route_target(self, ri_obj):
return self._vnc_lib.route_target_read(
ri_obj.get_route_target_refs()[0]['to'])

def test_db_manage_zk_route_target_missing(self):
# create vn
vn_name = 'vn_' + self.id()
vn_obj = self.create_virtual_network(vn_name, '10.0.0.0/24')
ri_obj = self._vnc_lib.routing_instance_read(
vn_obj.get_routing_instances()[0]['to'])
rt_obj = self._vnc_lib.route_target_read(
ri_obj.get_route_target_refs()[0]['to'])
rt_obj = self.wait_for_route_target(ri_obj)
rt_id_str = "%(#)010d" % {
'#': int(rt_obj.get_fq_name_str().split(':')[-1])}
db_checker = db_manage.DatabaseChecker(
Expand Down

0 comments on commit 8fc404a

Please sign in to comment.