Merge "Search for both name and tag if tag is given."

This commit is contained in:
Jenkins 2017-10-04 16:50:17 +00:00 committed by Gerrit Code Review
commit 0fef11cd5e
2 changed files with 5 additions and 5 deletions

View File

@ -563,10 +563,10 @@ def _create_kuryr_subnet(pool_cidr, subnet_cidr, pool_id, network_id, gateway):
def _create_kuryr_subnetpool(pool_cidr, pool_tag):
pool_name = lib_utils.get_neutron_subnetpool_name(pool_cidr)
kwargs = {'name': pool_name}
if pool_tag:
kwargs = {'tags': [pool_tag]}
else:
kwargs = {'name': pool_name}
kwargs['tags'] = [pool_tag]
pools = _get_subnetpools_by_attrs(**kwargs)
if len(pools):
raise exceptions.KuryrException(

View File

@ -109,7 +109,7 @@ class TestKuryrIpam(base.TestKuryrBase):
self.assertEqual(200, response.status_code)
mock_list_subnetpools.assert_called_with(
tags=[str(neutron_subnet_v4_id)])
name=pool_name, tags=[str(neutron_subnet_v4_id)])
mock_create_subnetpool.assert_called_with(
{'subnetpool': new_subnetpool})
mock_add_tag.assert_called_once_with(
@ -184,7 +184,7 @@ class TestKuryrIpam(base.TestKuryrBase):
self.assertEqual(200, response.status_code)
mock_list_subnets.assert_called_with(name=neutron_subnet_v4_name)
mock_list_subnetpools.assert_called_with(
tags=[str(neutron_subnet_v4_id)])
name=pool_name, tags=[str(neutron_subnet_v4_id)])
mock_create_subnetpool.assert_called_with(
{'subnetpool': new_subnetpool})
mock_add_tag.assert_called_once_with(