def get_update_l7policy_flow(self): """Create a flow to update an L7 policy :returns: The flow for updating an L7 policy """ update_l7policy_flow = linear_flow.Flow(constants.UPDATE_L7POLICY_FLOW) update_l7policy_flow.add( lifecycle_tasks.L7PolicyToErrorOnRevertTask(requires=[ constants.L7POLICY, constants.LISTENERS, constants.LOADBALANCER ])) update_l7policy_flow.add( database_tasks.MarkL7PolicyPendingUpdateInDB( requires=constants.L7POLICY)) update_l7policy_flow.add( amphora_driver_tasks.ListenersUpdate( requires=[constants.LOADBALANCER, constants.LISTENERS])) update_l7policy_flow.add( database_tasks.UpdateL7PolicyInDB( requires=[constants.L7POLICY, constants.UPDATE_DICT])) update_l7policy_flow.add( database_tasks.MarkL7PolicyActiveInDB(requires=constants.L7POLICY)) update_l7policy_flow.add( database_tasks.MarkLBAndListenersActiveInDB( requires=[constants.LOADBALANCER, constants.LISTENERS])) return update_l7policy_flow
def get_delete_l7policy_flow(self): """Create a flow to delete an L7 policy :returns: The flow for deleting an L7 policy """ delete_l7policy_flow = linear_flow.Flow(constants.DELETE_L7POLICY_FLOW) delete_l7policy_flow.add( lifecycle_tasks.L7PolicyToErrorOnRevertTask(requires=[ constants.L7POLICY, constants.LISTENERS, constants.LOADBALANCER ])) delete_l7policy_flow.add( database_tasks.MarkL7PolicyPendingDeleteInDB( requires=constants.L7POLICY)) delete_l7policy_flow.add( model_tasks.DeleteModelObject( rebind={constants.OBJECT: constants.L7POLICY})) delete_l7policy_flow.add( amphora_driver_tasks.ListenersUpdate( requires=[constants.LOADBALANCER, constants.LISTENERS])) delete_l7policy_flow.add( database_tasks.DeleteL7PolicyInDB(requires=constants.L7POLICY)) delete_l7policy_flow.add( database_tasks.MarkLBAndListenersActiveInDB( requires=[constants.LOADBALANCER, constants.LISTENERS])) return delete_l7policy_flow
def get_update_l7policy_flow(self, topology): """Create a flow to update an L7 policy :returns: The flow for updating an L7 policy """ update_l7policy_flow = linear_flow.Flow(constants.UPDATE_L7POLICY_FLOW) update_l7policy_flow.add( lifecycle_tasks.L7PolicyToErrorOnRevertTask(requires=[ constants.L7POLICY, constants.LISTENERS, constants.LOADBALANCER ])) update_l7policy_flow.add( vthunder_tasks.VthunderInstanceBusy( requires=a10constants.COMPUTE_BUSY)) update_l7policy_flow.add( database_tasks.MarkL7PolicyPendingUpdateInDB( requires=constants.L7POLICY)) update_l7policy_flow.add( a10_database_tasks.GetVThunderByLoadBalancer( requires=constants.LOADBALANCER, provides=a10constants.VTHUNDER)) if topology == constants.TOPOLOGY_ACTIVE_STANDBY: update_l7policy_flow.add( vthunder_tasks.GetMasterVThunder( name=a10constants.GET_MASTER_VTHUNDER, requires=a10constants.VTHUNDER, provides=a10constants.VTHUNDER)) update_l7policy_flow.add( l7policy_tasks.UpdateL7Policy(requires=[ constants.L7POLICY, constants.LISTENERS, a10constants.VTHUNDER, constants.UPDATE_DICT ])) update_l7policy_flow.add( database_tasks.UpdateL7PolicyInDB( requires=[constants.L7POLICY, constants.UPDATE_DICT])) update_l7policy_flow.add( database_tasks.MarkL7PolicyActiveInDB(requires=constants.L7POLICY)) update_l7policy_flow.add( database_tasks.MarkLBAndListenersActiveInDB( requires=[constants.LOADBALANCER, constants.LISTENERS])) update_l7policy_flow.add( vthunder_tasks.WriteMemory(requires=a10constants.VTHUNDER)) update_l7policy_flow.add( a10_database_tasks.SetThunderUpdatedAt( requires=a10constants.VTHUNDER)) return update_l7policy_flow
def test_L7PolicyToErrorOnRevertTask(self, mock_listener_prov_status_active, mock_loadbalancer_prov_status_active, mock_l7policy_prov_status_error): l7policy_to_error_on_revert = ( lifecycle_tasks.L7PolicyToErrorOnRevertTask()) # Execute l7policy_to_error_on_revert.execute(self.L7POLICY, self.LISTENERS, self.LOADBALANCER) self.assertFalse(mock_l7policy_prov_status_error.called) # Revert l7policy_to_error_on_revert.revert(self.L7POLICY, self.LISTENERS, self.LOADBALANCER) mock_l7policy_prov_status_error.assert_called_once_with( self.L7POLICY_ID) mock_loadbalancer_prov_status_active.assert_called_once_with( self.LOADBALANCER_ID) mock_listener_prov_status_active.assert_called_once_with( self.LISTENER_ID)