Merge "NSX|V3+V: Fix octavia completor func"

This commit is contained in:
Zuul 2019-03-03 09:15:16 +00:00 committed by Gerrit Code Review
commit 2919467331
2 changed files with 34 additions and 11 deletions

View File

@ -90,8 +90,8 @@ class NSXOctaviaListenerEndpoint(object):
def get_completor_func(self, obj_type, obj, delete=False, cascade=False):
# return a method that will be called on success/failure completion
def completor_func(success=True):
LOG.debug("Octavia transaction completed. status %s",
'success' if success else 'failure')
LOG.debug("Octavia transaction completed. delete %s, status %s",
delete, 'success' if success else 'failure')
# calculate the provisioning and operating statuses
main_prov_status = constants.ACTIVE
@ -141,22 +141,26 @@ class NSXOctaviaListenerEndpoint(object):
loadbalancer_id = obj['policy']['listener'].get(
'loadbalancer_id')
if loadbalancer_id:
if (loadbalancer_id and
not status_dict.get(constants.LOADBALANCERS)):
status_dict[constants.LOADBALANCERS] = [{
'id': loadbalancer_id,
constants.PROVISIONING_STATUS: parent_prov_status,
constants.OPERATING_STATUS: op_status}]
if listener_id:
if (listener_id and
not status_dict.get(constants.LISTENERS)):
status_dict[constants.LISTENERS] = [{
'id': listener_id,
constants.PROVISIONING_STATUS: parent_prov_status,
constants.OPERATING_STATUS: op_status}]
if pool_id:
if (pool_id and
not status_dict.get(constants.POOLS)):
status_dict[constants.POOLS] = [{
'id': pool_id,
constants.PROVISIONING_STATUS: parent_prov_status,
constants.OPERATING_STATUS: op_status}]
if policy_id:
if (policy_id and
not status_dict.get(constants.L7POLICIES)):
status_dict[constants.L7POLICIES] = [{
'id': policy_id,
constants.PROVISIONING_STATUS: parent_prov_status,

View File

@ -197,14 +197,33 @@ class TestNsxOctaviaListener(testtools.TestCase):
def test_pool_delete(self):
self.dummyResource.delete_called = False
self.endpoint.pool_delete(self.ctx, self.dummyObj)
lb_id = uuidutils.generate_uuid()
listener_id = uuidutils.generate_uuid()
pool_id = uuidutils.generate_uuid()
pool_obj = {
'id': pool_id,
'pool_id': pool_id,
'project_id': uuidutils.generate_uuid(),
'listener_id': listener_id,
'loadbalancer_id': lb_id,
'listener': {'protocol': 'HTTP',
'id': listener_id,
'default_pool_id': pool_id,
'loadbalancer': {'id': lb_id}}}
self.endpoint.pool_delete(self.ctx, pool_obj)
self.assertTrue(self.dummyResource.delete_called)
self.clientMock.cast.assert_called_once_with(
{}, 'update_loadbalancer_status',
status={'pools': [
{'operating_status': 'ONLINE',
'provisioning_status': 'DELETED',
'id': mock.ANY}]})
status={'loadbalancers': [{'operating_status': 'ONLINE',
'provisioning_status': 'ACTIVE',
'id': lb_id}],
'pools': [{'operating_status': 'ONLINE',
'provisioning_status': 'DELETED',
'id': pool_id}],
'listeners': [{'operating_status': 'ONLINE',
'provisioning_status': 'ACTIVE',
'id': listener_id}],
})
def test_pool_update(self):
self.dummyResource.update_called = False