Merge "Support deletion of all tags" into stable/victoria
This commit is contained in:
commit
0b6734b687
|
@ -106,7 +106,7 @@ class BaseRepository(object):
|
|||
"""
|
||||
with session.begin(subtransactions=True):
|
||||
tags = model_kwargs.pop('tags', None)
|
||||
if tags:
|
||||
if tags is not None:
|
||||
resource = session.query(self.model_class).get(id)
|
||||
resource.tags = tags
|
||||
session.query(self.model_class).filter_by(
|
||||
|
@ -1142,15 +1142,15 @@ class ListenerRepository(BaseRepository):
|
|||
|
||||
def update(self, session, id, **model_kwargs):
|
||||
with session.begin(subtransactions=True):
|
||||
tags = model_kwargs.pop('tags', None)
|
||||
if tags:
|
||||
resource = session.query(self.model_class).get(id)
|
||||
resource.tags = tags
|
||||
listener_db = session.query(self.model_class).filter_by(
|
||||
id=id).first()
|
||||
if not listener_db:
|
||||
raise exceptions.NotFound(
|
||||
resource=data_models.Listener._name(), id=id)
|
||||
tags = model_kwargs.pop('tags', None)
|
||||
if tags is not None:
|
||||
resource = session.query(self.model_class).get(id)
|
||||
resource.tags = tags
|
||||
# Verify any newly specified default_pool_id exists
|
||||
default_pool_id = model_kwargs.get('default_pool_id')
|
||||
if default_pool_id:
|
||||
|
|
|
@ -1842,6 +1842,21 @@ class TestLoadBalancer(base.BaseAPITest):
|
|||
self.assert_correct_lb_status(api_lb.get('id'), constants.ONLINE,
|
||||
constants.PENDING_UPDATE)
|
||||
|
||||
def test_update_delete_tag(self):
|
||||
project_id = uuidutils.generate_uuid()
|
||||
lb = self.create_load_balancer(uuidutils.generate_uuid(),
|
||||
name='lb1',
|
||||
project_id=project_id,
|
||||
admin_state_up=False,
|
||||
tags=['test_tag1'],)
|
||||
lb_dict = lb.get(self.root_tag)
|
||||
lb_json = self._build_body({'tags': []})
|
||||
self.set_lb_status(lb_dict.get('id'))
|
||||
response = self.put(self.LB_PATH.format(lb_id=lb_dict.get('id')),
|
||||
lb_json)
|
||||
api_lb = response.json.get(self.root_tag)
|
||||
self.assertEqual([], api_lb.get('tags'))
|
||||
|
||||
def test_update_with_vip(self):
|
||||
project_id = uuidutils.generate_uuid()
|
||||
lb = self.create_load_balancer(uuidutils.generate_uuid(),
|
||||
|
|
Loading…
Reference in New Issue