def get_update_member_flow(self): """Create a flow to update a member :returns: The flow for updating a member """ update_member_flow = linear_flow.Flow(constants.UPDATE_MEMBER_FLOW) update_member_flow.add( lifecycle_tasks.MemberToErrorOnRevertTask(requires=[ constants.MEMBER, constants.LISTENERS, constants.LOADBALANCER, constants.POOL ])) update_member_flow.add( database_tasks.MarkMemberPendingUpdateInDB( requires=constants.MEMBER)) update_member_flow.add( amphora_driver_tasks.ListenersUpdate( requires=constants.LOADBALANCER)) update_member_flow.add( database_tasks.UpdateMemberInDB( requires=[constants.MEMBER, constants.UPDATE_DICT])) update_member_flow.add( database_tasks.MarkMemberActiveInDB(requires=constants.MEMBER)) update_member_flow.add( database_tasks.MarkPoolActiveInDB(requires=constants.POOL)) update_member_flow.add( database_tasks.MarkLBAndListenersActiveInDB( requires=[constants.LOADBALANCER, constants.LISTENERS])) return update_member_flow
def get_delete_member_flow(self): """Create a flow to delete a member :returns: The flow for deleting a member """ delete_member_flow = linear_flow.Flow(constants.DELETE_MEMBER_FLOW) delete_member_flow.add( lifecycle_tasks.MemberToErrorOnRevertTask(requires=[ constants.MEMBER, constants.LISTENERS, constants.LOADBALANCER, constants.POOL ])) delete_member_flow.add( database_tasks.MarkMemberPendingDeleteInDB( requires=constants.MEMBER)) delete_member_flow.add( model_tasks.DeleteModelObject( rebind={constants.OBJECT: constants.MEMBER})) delete_member_flow.add( database_tasks.DeleteMemberInDB(requires=constants.MEMBER)) delete_member_flow.add( amphora_driver_tasks.ListenersUpdate( requires=constants.LOADBALANCER)) delete_member_flow.add( database_tasks.DecrementMemberQuota(requires=constants.MEMBER)) delete_member_flow.add( database_tasks.MarkPoolActiveInDB(requires=constants.POOL)) delete_member_flow.add( database_tasks.MarkLBAndListenersActiveInDB( requires=[constants.LOADBALANCER, constants.LISTENERS])) return delete_member_flow
def get_create_member_flow(self): """Create a flow to create a member :returns: The flow for creating a member """ create_member_flow = linear_flow.Flow(constants.CREATE_MEMBER_FLOW) create_member_flow.add( lifecycle_tasks.MemberToErrorOnRevertTask(requires=[ constants.MEMBER, constants.LISTENERS, constants.LOADBALANCER, constants.POOL ])) create_member_flow.add( database_tasks.MarkMemberPendingCreateInDB( requires=constants.MEMBER)) create_member_flow.add( network_tasks.CalculateDelta(requires=constants.LOADBALANCER, provides=constants.DELTAS)) create_member_flow.add( network_tasks.HandleNetworkDeltas(requires=constants.DELTAS, provides=constants.ADDED_PORTS)) create_member_flow.add( amphora_driver_tasks.AmphoraePostNetworkPlug( requires=(constants.LOADBALANCER, constants.ADDED_PORTS))) create_member_flow.add( amphora_driver_tasks.ListenersUpdate( requires=constants.LOADBALANCER)) create_member_flow.add( database_tasks.MarkMemberActiveInDB(requires=constants.MEMBER)) create_member_flow.add( database_tasks.MarkPoolActiveInDB(requires=constants.POOL)) create_member_flow.add( database_tasks.MarkLBAndListenersActiveInDB( requires=(constants.LOADBALANCER, constants.LISTENERS))) return create_member_flow
def get_create_member_flow(self): """Create a flow to create a member :returns: The flow for creating a member """ create_member_flow = linear_flow.Flow(constants.CREATE_MEMBER_FLOW) create_member_flow.add(lifecycle_tasks.MemberToErrorOnRevertTask( requires=[constants.MEMBER, constants.LISTENERS, constants.LOADBALANCER, constants.POOL])) create_member_flow.add(database_tasks.MarkMemberPendingCreateInDB( requires=constants.MEMBER)) create_member_flow.add(network_tasks.CalculateDelta( requires=constants.LOADBALANCER, provides=constants.DELTAS)) create_member_flow.add(network_tasks.HandleNetworkDeltas( requires=constants.DELTAS, provides=constants.ADDED_PORTS)) # Need to add relaod vThunder logic here #create_member_flow.add(amphora_driver_tasks.AmphoraePostNetworkPlug( # requires=(constants.LOADBALANCER, constants.ADDED_PORTS) #)) #create_member_flow.add(amphora_driver_tasks.ListenersUpdate( # requires=(constants.LOADBALANCER, constants.LISTENERS))) # Get VThunder details from database create_member_flow.add(database_tasks.GetAmphoraeFromLoadbalancer( requires=constants.LOADBALANCER, provides=constants.AMPHORA)) create_member_flow.add(a10_database_tasks.GetVThunderByLoadBalancer( requires=constants.LOADBALANCER, provides=a10constants.VTHUNDER)) # managing interface additions here create_member_flow.add(vthunder_tasks.AmphoraePostMemberNetworkPlug( requires=(constants.LOADBALANCER, constants.ADDED_PORTS, a10constants.VTHUNDER))) create_member_flow.add(vthunder_tasks.VThunderComputeConnectivityWait( requires=(a10constants.VTHUNDER, constants.AMPHORA))) create_member_flow.add(vthunder_tasks.EnableInterfaceForMembers( requires=[constants.ADDED_PORTS, constants.LOADBALANCER, a10constants.VTHUNDER])) create_member_flow.add(handler_server.MemberCreate( requires=(constants.MEMBER, a10constants.VTHUNDER, constants.POOL))) create_member_flow.add(database_tasks.MarkMemberActiveInDB( requires=constants.MEMBER)) create_member_flow.add(database_tasks.MarkPoolActiveInDB( requires=constants.POOL)) create_member_flow.add(database_tasks. MarkLBAndListenersActiveInDB( requires=(constants.LOADBALANCER, constants.LISTENERS))) return create_member_flow
def test_MemberToErrorOnRevertTask(self, mock_pool_prov_status_active, mock_listener_prov_status_active, mock_loadbalancer_prov_status_active, mock_member_prov_status_error): member_to_error_on_revert = lifecycle_tasks.MemberToErrorOnRevertTask() # Execute member_to_error_on_revert.execute(self.MEMBER, self.LISTENERS, self.LOADBALANCER, self.POOL) self.assertFalse(mock_member_prov_status_error.called) # Revert member_to_error_on_revert.revert(self.MEMBER, self.LISTENERS, self.LOADBALANCER, self.POOL) mock_member_prov_status_error.assert_called_once_with(self.MEMBER_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) mock_pool_prov_status_active.assert_called_once_with(self.POOL_ID)
def get_delete_member_flow(self): """Create a flow to delete a member :returns: The flow for deleting a member """ delete_member_flow = linear_flow.Flow(constants.DELETE_MEMBER_FLOW) delete_member_flow.add(lifecycle_tasks.MemberToErrorOnRevertTask( requires=[constants.MEMBER, constants.LISTENERS, constants.LOADBALANCER, constants.POOL])) delete_member_flow.add(database_tasks.MarkMemberPendingDeleteInDB( requires=constants.MEMBER)) delete_member_flow.add(model_tasks. DeleteModelObject(rebind={constants.OBJECT: constants.MEMBER})) delete_member_flow.add(database_tasks.DeleteMemberInDB( requires=constants.MEMBER)) #delete_member_flow.add(amphora_driver_tasks.ListenersUpdate( # requires=[constants.LOADBALANCER, constants.LISTENERS])) # Get VThunder details from database delete_member_flow.add(a10_database_tasks.GetVThunderByLoadBalancer( requires=constants.LOADBALANCER, provides=a10constants.VTHUNDER)) delete_member_flow.add(handler_server.MemberDelete( requires=(constants.MEMBER, a10constants.VTHUNDER, constants.POOL))) delete_member_flow.add(database_tasks.DecrementMemberQuota( requires=constants.MEMBER)) delete_member_flow.add(database_tasks.MarkPoolActiveInDB( requires=constants.POOL)) delete_member_flow.add(database_tasks. MarkLBAndListenersActiveInDB( requires=[constants.LOADBALANCER, constants.LISTENERS])) return delete_member_flow