Search for both name and tag if tag is given.

Change-Id: Ib0406832f241ed676c6c5511037ffe0aaed6995d
This commit is contained in:
Kien Nguyen 2017-09-17 16:47:02 +07:00
parent fa290eafcf
commit 0f1943142c
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(