Merge "NSX|V3+V: Fix octavia completor func"
This commit is contained in:
commit
2919467331
@ -90,8 +90,8 @@ class NSXOctaviaListenerEndpoint(object):
|
|||||||
def get_completor_func(self, obj_type, obj, delete=False, cascade=False):
|
def get_completor_func(self, obj_type, obj, delete=False, cascade=False):
|
||||||
# return a method that will be called on success/failure completion
|
# return a method that will be called on success/failure completion
|
||||||
def completor_func(success=True):
|
def completor_func(success=True):
|
||||||
LOG.debug("Octavia transaction completed. status %s",
|
LOG.debug("Octavia transaction completed. delete %s, status %s",
|
||||||
'success' if success else 'failure')
|
delete, 'success' if success else 'failure')
|
||||||
|
|
||||||
# calculate the provisioning and operating statuses
|
# calculate the provisioning and operating statuses
|
||||||
main_prov_status = constants.ACTIVE
|
main_prov_status = constants.ACTIVE
|
||||||
@ -141,22 +141,26 @@ class NSXOctaviaListenerEndpoint(object):
|
|||||||
loadbalancer_id = obj['policy']['listener'].get(
|
loadbalancer_id = obj['policy']['listener'].get(
|
||||||
'loadbalancer_id')
|
'loadbalancer_id')
|
||||||
|
|
||||||
if loadbalancer_id:
|
if (loadbalancer_id and
|
||||||
|
not status_dict.get(constants.LOADBALANCERS)):
|
||||||
status_dict[constants.LOADBALANCERS] = [{
|
status_dict[constants.LOADBALANCERS] = [{
|
||||||
'id': loadbalancer_id,
|
'id': loadbalancer_id,
|
||||||
constants.PROVISIONING_STATUS: parent_prov_status,
|
constants.PROVISIONING_STATUS: parent_prov_status,
|
||||||
constants.OPERATING_STATUS: op_status}]
|
constants.OPERATING_STATUS: op_status}]
|
||||||
if listener_id:
|
if (listener_id and
|
||||||
|
not status_dict.get(constants.LISTENERS)):
|
||||||
status_dict[constants.LISTENERS] = [{
|
status_dict[constants.LISTENERS] = [{
|
||||||
'id': listener_id,
|
'id': listener_id,
|
||||||
constants.PROVISIONING_STATUS: parent_prov_status,
|
constants.PROVISIONING_STATUS: parent_prov_status,
|
||||||
constants.OPERATING_STATUS: op_status}]
|
constants.OPERATING_STATUS: op_status}]
|
||||||
if pool_id:
|
if (pool_id and
|
||||||
|
not status_dict.get(constants.POOLS)):
|
||||||
status_dict[constants.POOLS] = [{
|
status_dict[constants.POOLS] = [{
|
||||||
'id': pool_id,
|
'id': pool_id,
|
||||||
constants.PROVISIONING_STATUS: parent_prov_status,
|
constants.PROVISIONING_STATUS: parent_prov_status,
|
||||||
constants.OPERATING_STATUS: op_status}]
|
constants.OPERATING_STATUS: op_status}]
|
||||||
if policy_id:
|
if (policy_id and
|
||||||
|
not status_dict.get(constants.L7POLICIES)):
|
||||||
status_dict[constants.L7POLICIES] = [{
|
status_dict[constants.L7POLICIES] = [{
|
||||||
'id': policy_id,
|
'id': policy_id,
|
||||||
constants.PROVISIONING_STATUS: parent_prov_status,
|
constants.PROVISIONING_STATUS: parent_prov_status,
|
||||||
|
@ -197,14 +197,33 @@ class TestNsxOctaviaListener(testtools.TestCase):
|
|||||||
|
|
||||||
def test_pool_delete(self):
|
def test_pool_delete(self):
|
||||||
self.dummyResource.delete_called = False
|
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.assertTrue(self.dummyResource.delete_called)
|
||||||
self.clientMock.cast.assert_called_once_with(
|
self.clientMock.cast.assert_called_once_with(
|
||||||
{}, 'update_loadbalancer_status',
|
{}, 'update_loadbalancer_status',
|
||||||
status={'pools': [
|
status={'loadbalancers': [{'operating_status': 'ONLINE',
|
||||||
{'operating_status': 'ONLINE',
|
'provisioning_status': 'ACTIVE',
|
||||||
|
'id': lb_id}],
|
||||||
|
'pools': [{'operating_status': 'ONLINE',
|
||||||
'provisioning_status': 'DELETED',
|
'provisioning_status': 'DELETED',
|
||||||
'id': mock.ANY}]})
|
'id': pool_id}],
|
||||||
|
'listeners': [{'operating_status': 'ONLINE',
|
||||||
|
'provisioning_status': 'ACTIVE',
|
||||||
|
'id': listener_id}],
|
||||||
|
})
|
||||||
|
|
||||||
def test_pool_update(self):
|
def test_pool_update(self):
|
||||||
self.dummyResource.update_called = False
|
self.dummyResource.update_called = False
|
||||||
|
Loading…
Reference in New Issue
Block a user