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])) 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_batch_update_members_flow(self, old_members, new_members, updated_members): """Create a flow to batch update members :returns: The flow for batch updating members """ batch_update_members_flow = linear_flow.Flow( constants.BATCH_UPDATE_MEMBERS_FLOW) unordered_members_flow = unordered_flow.Flow( constants.UNORDERED_MEMBER_UPDATES_FLOW) unordered_members_active_flow = unordered_flow.Flow( constants.UNORDERED_MEMBER_ACTIVE_FLOW) # Delete old members unordered_members_flow.add( lifecycle_tasks.MembersToErrorOnRevertTask( inject={constants.MEMBERS: old_members}, name='{flow}-deleted'.format( flow=constants.MEMBER_TO_ERROR_ON_REVERT_FLOW))) for m in old_members: unordered_members_flow.add( model_tasks.DeleteModelObject( inject={constants.OBJECT: m}, name='{flow}-{id}'.format( id=m.id, flow=constants.DELETE_MODEL_OBJECT_FLOW))) unordered_members_flow.add( database_tasks.DeleteMemberInDB( inject={constants.MEMBER: m}, name='{flow}-{id}'.format( id=m.id, flow=constants.DELETE_MEMBER_INDB))) unordered_members_flow.add( database_tasks.DecrementMemberQuota( inject={constants.MEMBER: m}, name='{flow}-{id}'.format( id=m.id, flow=constants.DECREMENT_MEMBER_QUOTA_FLOW))) # Create new members unordered_members_flow.add( lifecycle_tasks.MembersToErrorOnRevertTask( inject={constants.MEMBERS: new_members}, name='{flow}-created'.format( flow=constants.MEMBER_TO_ERROR_ON_REVERT_FLOW))) for m in new_members: unordered_members_active_flow.add( database_tasks.MarkMemberActiveInDB( inject={constants.MEMBER: m}, name='{flow}-{id}'.format( id=m.id, flow=constants.MARK_MEMBER_ACTIVE_INDB))) # Update existing members unordered_members_flow.add( lifecycle_tasks.MembersToErrorOnRevertTask( # updated_members is a list of (obj, dict), only pass `obj` inject={constants.MEMBERS: [m[0] for m in updated_members]}, name='{flow}-updated'.format( flow=constants.MEMBER_TO_ERROR_ON_REVERT_FLOW))) for m, um in updated_members: um.pop('id', None) unordered_members_active_flow.add( database_tasks.MarkMemberActiveInDB( inject={constants.MEMBER: m}, name='{flow}-{id}'.format( id=m.id, flow=constants.MARK_MEMBER_ACTIVE_INDB))) batch_update_members_flow.add(unordered_members_flow) # Done, do real updates batch_update_members_flow.add( network_tasks.CalculateDelta(requires=constants.LOADBALANCER, provides=constants.DELTAS)) batch_update_members_flow.add( network_tasks.HandleNetworkDeltas(requires=constants.DELTAS, provides=constants.ADDED_PORTS)) batch_update_members_flow.add( amphora_driver_tasks.AmphoraePostNetworkPlug( requires=(constants.LOADBALANCER, constants.ADDED_PORTS))) # Update the Listener (this makes the changes active on the Amp) batch_update_members_flow.add( amphora_driver_tasks.ListenersUpdate( requires=(constants.LOADBALANCER, constants.LISTENERS))) # Mark all the members ACTIVE here, then pool then LB/Listeners batch_update_members_flow.add(unordered_members_active_flow) batch_update_members_flow.add( database_tasks.MarkPoolActiveInDB(requires=constants.POOL)) batch_update_members_flow.add( database_tasks.MarkLBAndListenersActiveInDB( requires=(constants.LOADBALANCER, constants.LISTENERS))) return batch_update_members_flow
def get_rack_vthunder_delete_member_flow(self, vthunder_conf, device_dict): """Flow to delete a member in Thunder devices :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( a10_database_tasks.GetVThunderByLoadBalancer( requires=constants.LOADBALANCER, provides=a10constants.VTHUNDER)) delete_member_flow.add( vthunder_tasks.SetupDeviceNetworkMap( requires=a10constants.VTHUNDER, provides=a10constants.VTHUNDER)) delete_member_flow.add( a10_database_tasks.CountMembersWithIP( requires=constants.MEMBER, provides=a10constants.MEMBER_COUNT_IP)) delete_member_flow.add( a10_database_tasks.CountMembersWithIPPortProtocol( requires=(constants.MEMBER, constants.POOL), provides=a10constants.MEMBER_COUNT_IP_PORT_PROTOCOL)) delete_member_flow.add( a10_database_tasks.GetFlavorData( rebind={a10constants.LB_RESOURCE: constants.LOADBALANCER}, provides=constants.FLAVOR)) delete_member_flow.add( vthunder_tasks.GetVthunderConfByFlavor( inject={ a10constants.VTHUNDER_CONFIG: vthunder_conf, a10constants.DEVICE_CONFIG_DICT: device_dict }, 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_member_flow.add( a10_network_tasks.GetLBResourceSubnet( name=a10constants.GET_LB_RESOURCE_SUBNET, rebind={a10constants.LB_RESOURCE: constants.MEMBER}, provides=constants.SUBNET)) delete_member_flow.add( a10_network_tasks.GetMembersOnThunder( requires=[ a10constants.VTHUNDER, a10constants.USE_DEVICE_FLAVOR ], provides=a10constants.MEMBERS)) delete_member_flow.add( a10_database_tasks.CountMembersOnThunderBySubnet( requires=[ constants.SUBNET, a10constants.USE_DEVICE_FLAVOR, a10constants.MEMBERS ], provides=a10constants.MEMBER_COUNT_THUNDER)) delete_member_flow.add( server_tasks.MemberFindNatPool(requires=[ constants.MEMBER, a10constants.VTHUNDER, constants.POOL, constants.FLAVOR ], provides=a10constants.NAT_FLAVOR)) delete_member_flow.add( a10_database_tasks.GetNatPoolEntry( requires=[constants.MEMBER, a10constants.NAT_FLAVOR], provides=a10constants.NAT_POOL)) delete_member_flow.add( a10_network_tasks.ReleaseSubnetAddressForMember(requires=[ constants.MEMBER, a10constants.NAT_FLAVOR, a10constants.NAT_POOL ])) delete_member_flow.add( a10_database_tasks.DeleteNatPoolEntry( requires=a10constants.NAT_POOL)) delete_member_flow.add( server_tasks.MemberDelete( requires=(constants.MEMBER, a10constants.VTHUNDER, constants.POOL, a10constants.MEMBER_COUNT_IP, a10constants.MEMBER_COUNT_IP_PORT_PROTOCOL))) if CONF.a10_global.network_type == 'vlan': delete_member_flow.add( vthunder_tasks.DeleteInterfaceTagIfNotInUseForMember( requires=[constants.MEMBER, a10constants.VTHUNDER])) # Handle VRID setting delete_member_flow.add(self.get_delete_member_vrid_subflow()) delete_member_flow.add( database_tasks.DeleteMemberInDB(requires=constants.MEMBER)) 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])) delete_member_flow.add( vthunder_tasks.WriteMemory(requires=a10constants.VTHUNDER)) delete_member_flow.add( a10_database_tasks.SetThunderUpdatedAt( requires=a10constants.VTHUNDER)) return delete_member_flow
def test_decrement_member_quota(self): task = database_tasks.DecrementMemberQuota() data_model = data_models.Member self._test_decrement_quota(task, data_model)
def get_delete_member_flow(self, topology): """Flow to delete a member on VThunder :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( vthunder_tasks.VthunderInstanceBusy( requires=a10constants.COMPUTE_BUSY)) 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.GetAmphoraeFromLoadbalancer( requires=constants.LOADBALANCER_ID, provides=constants.AMPHORA)) delete_member_flow.add( a10_database_tasks.GetVThunderByLoadBalancer( requires=constants.LOADBALANCER, provides=a10constants.VTHUNDER)) delete_member_flow.add( a10_database_tasks.CountMembersWithIP( requires=constants.MEMBER, provides=a10constants.MEMBER_COUNT_IP)) delete_member_flow.add( a10_database_tasks.CountMembersWithIPPortProtocol( requires=(constants.MEMBER, constants.POOL), provides=a10constants.MEMBER_COUNT_IP_PORT_PROTOCOL)) delete_member_flow.add( a10_database_tasks.GetFlavorData( rebind={a10constants.LB_RESOURCE: constants.LOADBALANCER}, provides=constants.FLAVOR)) delete_member_flow.add( a10_database_tasks.GetLoadBalancerListByProjectID( requires=a10constants.VTHUNDER, provides=a10constants.LOADBALANCERS_LIST)) delete_member_flow.add( a10_database_tasks.GetMemberListByProjectID( requires=a10constants.VTHUNDER, provides=a10constants.MEMBER_LIST)) delete_member_flow.add( a10_network_tasks.CalculateDelta( requires=(constants.LOADBALANCER, a10constants.LOADBALANCERS_LIST, a10constants.MEMBER_LIST), provides=constants.DELTAS)) delete_member_flow.add( a10_network_tasks.HandleNetworkDeltas( requires=constants.DELTAS, provides=constants.ADDED_PORTS)) if topology == constants.TOPOLOGY_ACTIVE_STANDBY: delete_member_flow.add( vthunder_tasks.VCSSyncWait(name=a10constants.VCS_SYNC_WAIT, requires=a10constants.VTHUNDER)) delete_member_flow.add( vthunder_tasks.GetMasterVThunder( name=a10constants.GET_MASTER_VTHUNDER, requires=a10constants.VTHUNDER, provides=a10constants.VTHUNDER)) delete_member_flow.add( vthunder_tasks.AmphoraePostNetworkUnplug( requires=(constants.LOADBALANCER, constants.ADDED_PORTS, a10constants.VTHUNDER))) delete_member_flow.add( vthunder_tasks.VThunderComputeConnectivityWait( name=a10constants.VTHUNDER_CONNECTIVITY_WAIT, requires=(a10constants.VTHUNDER, constants.AMPHORA))) if topology == constants.TOPOLOGY_ACTIVE_STANDBY: delete_member_flow.add( a10_database_tasks.GetBackupVThunderByLoadBalancer( name=a10constants.GET_BACKUP_VTHUNDER_BY_LB, requires=(constants.LOADBALANCER, a10constants.VTHUNDER), provides=a10constants.BACKUP_VTHUNDER)) delete_member_flow.add( vthunder_tasks.VThunderComputeConnectivityWait( name=a10constants.BACKUP_CONNECTIVITY_WAIT + "-before-unplug", requires=constants.AMPHORA, rebind={ a10constants.VTHUNDER: a10constants.BACKUP_VTHUNDER })) delete_member_flow.add( vthunder_tasks.VCSSyncWait(name='member-unplug-' + a10constants.VCS_SYNC_WAIT, requires=a10constants.VTHUNDER)) delete_member_flow.add( vthunder_tasks.GetMasterVThunder( name=a10constants.GET_VTHUNDER_MASTER, requires=a10constants.VTHUNDER, provides=a10constants.VTHUNDER)) delete_member_flow.add( server_tasks.MemberFindNatPool(requires=[ constants.MEMBER, a10constants.VTHUNDER, constants.POOL, constants.FLAVOR ], provides=a10constants.NAT_FLAVOR)) delete_member_flow.add( a10_database_tasks.GetNatPoolEntry( requires=[constants.MEMBER, a10constants.NAT_FLAVOR], provides=a10constants.NAT_POOL)) delete_member_flow.add( a10_network_tasks.ReleaseSubnetAddressForMember(requires=[ constants.MEMBER, a10constants.NAT_FLAVOR, a10constants.NAT_POOL ])) delete_member_flow.add( a10_database_tasks.DeleteNatPoolEntry( requires=a10constants.NAT_POOL)) delete_member_flow.add( server_tasks.MemberDelete( requires=(constants.MEMBER, a10constants.VTHUNDER, constants.POOL, a10constants.MEMBER_COUNT_IP, a10constants.MEMBER_COUNT_IP_PORT_PROTOCOL))) delete_member_flow.add(self.get_delete_member_vrid_subflow()) delete_member_flow.add( database_tasks.DeleteMemberInDB(requires=constants.MEMBER)) 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])) delete_member_flow.add( vthunder_tasks.WriteMemory(requires=a10constants.VTHUNDER)) delete_member_flow.add( a10_database_tasks.SetThunderUpdatedAt( requires=a10constants.VTHUNDER)) return delete_member_flow