def get_delete_pool_flow(self): """Create a flow to delete a pool :returns: The flow for deleting a pool """ delete_pool_flow = linear_flow.Flow(constants.DELETE_POOL_FLOW) delete_pool_flow.add(lifecycle_tasks.PoolToErrorOnRevertTask( requires=[constants.POOL, constants.LISTENERS, constants.LOADBALANCER])) delete_pool_flow.add(database_tasks.MarkPoolPendingDeleteInDB( requires=constants.POOL)) delete_pool_flow.add(database_tasks.CountPoolChildrenForQuota( requires=constants.POOL, provides=constants.POOL_CHILD_COUNT)) delete_pool_flow.add(model_tasks.DeleteModelObject( rebind={constants.OBJECT: constants.POOL})) delete_pool_flow.add(amphora_driver_tasks.ListenersUpdate( requires=[constants.LOADBALANCER, constants.LISTENERS])) delete_pool_flow.add(database_tasks.DeletePoolInDB( requires=constants.POOL)) delete_pool_flow.add(database_tasks.DecrementPoolQuota( requires=[constants.POOL, constants.POOL_CHILD_COUNT])) delete_pool_flow.add(database_tasks.MarkLBAndListenersActiveInDB( requires=[constants.LOADBALANCER, constants.LISTENERS])) return delete_pool_flow
def get_delete_pool_rack_flow(self, members, health_mon, store): """Create a flow to delete a pool rack :returns: The flow for deleting a pool """ delete_pool_flow = linear_flow.Flow(constants.DELETE_POOL_FLOW) delete_pool_flow.add(lifecycle_tasks.PoolToErrorOnRevertTask( requires=[constants.POOL, constants.LISTENERS, constants.LOADBALANCER])) delete_pool_flow.add(database_tasks.MarkPoolPendingDeleteInDB( requires=constants.POOL)) delete_pool_flow.add(database_tasks.CountPoolChildrenForQuota( requires=constants.POOL, provides=constants.POOL_CHILD_COUNT)) delete_pool_flow.add(model_tasks.DeleteModelObject( rebind={constants.OBJECT: constants.POOL})) # Get VThunder details from database delete_pool_flow.add(a10_database_tasks.GetVThunderByLoadBalancer( requires=constants.LOADBALANCER, provides=a10constants.VTHUNDER)) delete_pool_flow.add(virtual_port_tasks.ListenerUpdateForPool( requires=[constants.LOADBALANCER, constants.LISTENER, a10constants.VTHUNDER])) delete_pool_flow.add(persist_tasks.DeleteSessionPersistence( requires=[a10constants.VTHUNDER, constants.POOL])) delete_pool_flow.add(vthunder_tasks.SetupDeviceNetworkMap( requires=a10constants.VTHUNDER, provides=a10constants.VTHUNDER)) # Device Flavor delete_pool_flow.add(a10_database_tasks.GetFlavorData( rebind={a10constants.LB_RESOURCE: constants.LOADBALANCER}, provides=constants.FLAVOR)) delete_pool_flow.add(vthunder_tasks.GetVthunderConfByFlavor( requires=(constants.LOADBALANCER, a10constants.VTHUNDER_CONFIG, a10constants.DEVICE_CONFIG_DICT), rebind={constants.FLAVOR_DATA: constants.FLAVOR}, provides=(a10constants.VTHUNDER_CONFIG, a10constants.USE_DEVICE_FLAVOR))) delete_pool_flow.add(a10_network_tasks.GetPoolsOnThunder( requires=[a10constants.VTHUNDER, a10constants.USE_DEVICE_FLAVOR], provides=a10constants.POOLS)) # Delete pool children delete_pool_flow.add(self._get_delete_health_monitor_vthunder_subflow(health_mon)) delete_pool_flow.add(self._get_delete_member_vthunder_subflow(members, store)) delete_pool_flow.add(service_group_tasks.PoolDelete( requires=[constants.POOL, a10constants.VTHUNDER])) delete_pool_flow.add(database_tasks.DeletePoolInDB( requires=constants.POOL)) delete_pool_flow.add(database_tasks.DecrementPoolQuota( requires=[constants.POOL, constants.POOL_CHILD_COUNT])) delete_pool_flow.add(database_tasks.MarkLBAndListenersActiveInDB( requires=[constants.LOADBALANCER, constants.LISTENERS])) delete_pool_flow.add(vthunder_tasks.WriteMemory( requires=a10constants.VTHUNDER)) delete_pool_flow.add(a10_database_tasks.SetThunderUpdatedAt( requires=a10constants.VTHUNDER)) return delete_pool_flow
def get_update_pool_flow(self, topology): """Create a flow to update a pool :returns: The flow for updating a pool """ update_pool_flow = linear_flow.Flow(constants.UPDATE_POOL_FLOW) update_pool_flow.add( lifecycle_tasks.PoolToErrorOnRevertTask(requires=[ constants.POOL, constants.LISTENERS, constants.LOADBALANCER ])) update_pool_flow.add( vthunder_tasks.VthunderInstanceBusy( requires=a10constants.COMPUTE_BUSY)) update_pool_flow.add( database_tasks.MarkPoolPendingUpdateInDB(requires=constants.POOL)) update_pool_flow.add( a10_database_tasks.GetVThunderByLoadBalancer( requires=constants.LOADBALANCER, provides=a10constants.VTHUNDER)) if topology == constants.TOPOLOGY_ACTIVE_STANDBY: update_pool_flow.add( vthunder_tasks.GetMasterVThunder( name=a10constants.GET_MASTER_VTHUNDER, requires=a10constants.VTHUNDER, provides=a10constants.VTHUNDER)) update_pool_flow.add( a10_database_tasks.GetFlavorData( rebind={a10constants.LB_RESOURCE: constants.POOL}, provides=constants.FLAVOR)) update_pool = service_group_tasks.PoolUpdate(requires=[ constants.POOL, a10constants.VTHUNDER, constants.UPDATE_DICT, constants.FLAVOR ], provides=constants.POOL) update_pool_flow.add(*self._get_sess_pers_subflow(update_pool)) update_pool_flow.add( virtual_port_tasks.ListenerUpdateForPool(requires=[ constants.LOADBALANCER, constants.LISTENER, a10constants.VTHUNDER ])) update_pool_flow.add( database_tasks.UpdatePoolInDB( requires=[constants.POOL, constants.UPDATE_DICT])) update_pool_flow.add( database_tasks.MarkPoolActiveInDB(requires=constants.POOL)) update_pool_flow.add( database_tasks.MarkLBAndListenersActiveInDB( requires=[constants.LOADBALANCER, constants.LISTENERS])) update_pool_flow.add( vthunder_tasks.WriteMemory(requires=a10constants.VTHUNDER)) update_pool_flow.add( a10_database_tasks.SetThunderUpdatedAt( requires=a10constants.VTHUNDER)) return update_pool_flow
def get_create_pool_flow(self): """Create a flow to create a pool :returns: The flow for creating a pool """ create_pool_flow = linear_flow.Flow(constants.CREATE_POOL_FLOW) create_pool_flow.add(lifecycle_tasks.PoolToErrorOnRevertTask( requires=[constants.POOL, constants.LISTENERS, constants.LOADBALANCER])) create_pool_flow.add(database_tasks.MarkPoolPendingCreateInDB( requires=constants.POOL)) create_pool_flow.add(amphora_driver_tasks.ListenersUpdate( requires=[constants.LOADBALANCER, constants.LISTENERS])) create_pool_flow.add(database_tasks.MarkPoolActiveInDB( requires=constants.POOL)) create_pool_flow.add(database_tasks.MarkLBAndListenersActiveInDB( requires=[constants.LOADBALANCER, constants.LISTENERS])) return create_pool_flow
def test_PoolToErrorOnRevertTask(self, mock_listener_prov_status_active, mock_loadbalancer_prov_status_active, mock_pool_prov_status_error): pool_to_error_on_revert = lifecycle_tasks.PoolToErrorOnRevertTask() # Execute pool_to_error_on_revert.execute(self.POOL, self.LISTENERS, self.LOADBALANCER) self.assertFalse(mock_pool_prov_status_error.called) # Revert pool_to_error_on_revert.revert(self.POOL, self.LISTENERS, self.LOADBALANCER) mock_pool_prov_status_error.assert_called_once_with(self.POOL_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)
def get_delete_pool_flow(self, members, health_mon, store, topology): """Create a flow to delete a pool :returns: The flow for deleting a pool """ delete_pool_flow = linear_flow.Flow(constants.DELETE_POOL_FLOW) delete_pool_flow.add( lifecycle_tasks.PoolToErrorOnRevertTask(requires=[ constants.POOL, constants.LISTENERS, constants.LOADBALANCER ])) delete_pool_flow.add( vthunder_tasks.VthunderInstanceBusy( requires=a10constants.COMPUTE_BUSY)) delete_pool_flow.add( database_tasks.MarkPoolPendingDeleteInDB(requires=constants.POOL)) delete_pool_flow.add( database_tasks.CountPoolChildrenForQuota( requires=constants.POOL, provides=constants.POOL_CHILD_COUNT)) delete_pool_flow.add( model_tasks.DeleteModelObject( rebind={constants.OBJECT: constants.POOL})) # Get VThunder details from database delete_pool_flow.add( a10_database_tasks.GetVThunderByLoadBalancer( requires=constants.LOADBALANCER, provides=a10constants.VTHUNDER)) if topology == constants.TOPOLOGY_ACTIVE_STANDBY: delete_pool_flow.add( vthunder_tasks.GetMasterVThunder( name=a10constants.GET_MASTER_VTHUNDER, requires=a10constants.VTHUNDER, provides=a10constants.VTHUNDER)) delete_pool_flow.add( virtual_port_tasks.ListenerUpdateForPool(requires=[ constants.LOADBALANCER, constants.LISTENER, a10constants.VTHUNDER ])) delete_pool_flow.add( persist_tasks.DeleteSessionPersistence( requires=[a10constants.VTHUNDER, constants.POOL])) # Delete pool children delete_pool_flow.add( self._get_delete_health_monitor_vthunder_subflow(health_mon)) delete_pool_flow.add( self._get_delete_member_vthunder_subflow(members, store)) delete_pool_flow.add( service_group_tasks.PoolDelete( requires=[constants.POOL, a10constants.VTHUNDER])) delete_pool_flow.add( database_tasks.DeletePoolInDB(requires=constants.POOL)) # Interface delete. delete_pool_flow.add( a10_database_tasks.GetLoadBalancerListByProjectID( requires=a10constants.VTHUNDER, provides=a10constants.LOADBALANCERS_LIST)) delete_pool_flow.add( a10_database_tasks.GetMemberListByProjectID( requires=a10constants.VTHUNDER, provides=a10constants.MEMBER_LIST)) delete_pool_flow.add( a10_network_tasks.CalculateDelta( requires=(constants.LOADBALANCER, a10constants.LOADBALANCERS_LIST, a10constants.MEMBER_LIST), provides=constants.DELTAS)) delete_pool_flow.add( a10_network_tasks.HandleNetworkDeltas( requires=constants.DELTAS, provides=constants.ADDED_PORTS)) delete_pool_flow.add( vthunder_tasks.AmphoraePostNetworkUnplug( requires=(constants.LOADBALANCER, constants.ADDED_PORTS, a10constants.VTHUNDER))) delete_pool_flow.add( database_tasks.GetAmphoraeFromLoadbalancer( requires=constants.LOADBALANCER_ID, provides=constants.AMPHORA)) delete_pool_flow.add( vthunder_tasks.VThunderComputeConnectivityWait( requires=(a10constants.VTHUNDER, constants.AMPHORA))) delete_pool_flow.add( database_tasks.DecrementPoolQuota( requires=[constants.POOL, constants.POOL_CHILD_COUNT])) delete_pool_flow.add( database_tasks.MarkLBAndListenersActiveInDB( requires=[constants.LOADBALANCER, constants.LISTENERS])) delete_pool_flow.add( vthunder_tasks.WriteMemory(requires=a10constants.VTHUNDER)) delete_pool_flow.add( a10_database_tasks.SetThunderUpdatedAt( requires=a10constants.VTHUNDER)) return delete_pool_flow