Support deletion of all tags
Add support for removal of all tags by PUTing empty tags array. Also moved assignment after initial session query for the object in the listener update path. Conflicts: octavia/db/repositories.py Task: #41009 Story: #2008220 Change-Id: I7488f2fae61917f6d4a56cedd05bace7c5e2bc70 Signed-off-by: Andrew Karpow <andrew.karpow@sap.com> (cherry picked from commit7ad022379f
) (cherry picked from commitadb4e78e44
) (cherry picked from commit95a97cf1eb
)
This commit is contained in:
parent
fd622009e6
commit
a94e5af899
|
@ -106,7 +106,7 @@ class BaseRepository(object):
|
||||||
"""
|
"""
|
||||||
with session.begin(subtransactions=True):
|
with session.begin(subtransactions=True):
|
||||||
tags = model_kwargs.pop('tags', None)
|
tags = model_kwargs.pop('tags', None)
|
||||||
if tags:
|
if tags is not None:
|
||||||
resource = session.query(self.model_class).get(id)
|
resource = session.query(self.model_class).get(id)
|
||||||
resource.tags = tags
|
resource.tags = tags
|
||||||
session.query(self.model_class).filter_by(
|
session.query(self.model_class).filter_by(
|
||||||
|
@ -1061,12 +1061,12 @@ class ListenerRepository(BaseRepository):
|
||||||
|
|
||||||
def update(self, session, id, **model_kwargs):
|
def update(self, session, id, **model_kwargs):
|
||||||
with session.begin(subtransactions=True):
|
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(
|
listener_db = session.query(self.model_class).filter_by(
|
||||||
id=id).first()
|
id=id).first()
|
||||||
|
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
|
# Verify any newly specified default_pool_id exists
|
||||||
default_pool_id = model_kwargs.get('default_pool_id')
|
default_pool_id = model_kwargs.get('default_pool_id')
|
||||||
if default_pool_id:
|
if default_pool_id:
|
||||||
|
|
|
@ -1780,6 +1780,21 @@ class TestLoadBalancer(base.BaseAPITest):
|
||||||
self.assert_correct_lb_status(api_lb.get('id'), constants.ONLINE,
|
self.assert_correct_lb_status(api_lb.get('id'), constants.ONLINE,
|
||||||
constants.PENDING_UPDATE)
|
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):
|
def test_update_with_vip(self):
|
||||||
project_id = uuidutils.generate_uuid()
|
project_id = uuidutils.generate_uuid()
|
||||||
lb = self.create_load_balancer(uuidutils.generate_uuid(),
|
lb = self.create_load_balancer(uuidutils.generate_uuid(),
|
||||||
|
|
Loading…
Reference in New Issue