def get_create_member_snat_pool_subflow(self): create_member_snat_subflow = linear_flow.Flow( a10constants.CREATE_MEMBER_SNAT_POOL_SUBFLOW) create_member_snat_subflow.add( server_tasks.MemberFindNatPool(requires=[ constants.MEMBER, a10constants.VTHUNDER, constants.POOL, constants.FLAVOR ], provides=a10constants.NAT_FLAVOR)) create_member_snat_subflow.add( a10_database_tasks.GetNatPoolEntry( requires=[constants.MEMBER, a10constants.NAT_FLAVOR], provides=a10constants.NAT_POOL)) create_member_snat_subflow.add( a10_network_tasks.ReserveSubnetAddressForMember( requires=[ constants.MEMBER, a10constants.NAT_FLAVOR, a10constants.NAT_POOL ], provides=a10constants.SUBNET_PORT)) create_member_snat_subflow.add( a10_database_tasks.UpdateNatPoolDB(requires=[ constants.MEMBER, a10constants.NAT_FLAVOR, a10constants.NAT_POOL, a10constants.SUBNET_PORT ])) return create_member_snat_subflow
def test_GetNatPoolEntry(self): db_task = task.GetNatPoolEntry() db_task.nat_pool_repo = self.nat_pool_repo flavor = { "pool_name": "p1", "start_address": "1.1.1.1", "end_address": "1.1.1.2" } db_task.execute(MEMBER_1, flavor) self.nat_pool_repo.get(mock.ANY, name="p1", subnet_id=MEMBER_1.subnet_id)
def get_delete_member_vthunder_internal_subflow(self, member_id, pool=constants.POOL): delete_member_thunder_subflow = linear_flow.Flow( a10constants.DELETE_MEMBER_VTHUNDER_INTERNAL_SUBFLOW) delete_member_thunder_subflow.add( vthunder_tasks.SetupDeviceNetworkMap( name='setup_device_network_map_' + member_id, requires=a10constants.VTHUNDER, provides=a10constants.VTHUNDER)) delete_member_thunder_subflow.add( a10_database_tasks.CountMembersWithIPPortProtocol( name='count_members_ip_port_' + member_id, requires=(constants.MEMBER, constants.POOL), provides=a10constants.MEMBER_COUNT_IP_PORT_PROTOCOL, rebind={ constants.MEMBER: member_id, constants.POOL: pool })) delete_member_thunder_subflow.add( a10_database_tasks.PoolCountforIP( name='pool_count_for_ip_' + member_id, requires=constants.MEMBER, provides=a10constants.POOL_COUNT_IP, rebind={constants.MEMBER: member_id})) # NAT pools database and pools clean up for flavor delete_member_thunder_subflow.add( a10_database_tasks.GetFlavorData( name='get_flavor_data_' + member_id, rebind={a10constants.LB_RESOURCE: constants.LOADBALANCER}, provides=constants.FLAVOR)) delete_member_thunder_subflow.add( server_tasks.MemberFindNatPool( name='member_find_nat_pool_' + member_id, requires=[ constants.MEMBER, a10constants.VTHUNDER, constants.POOL, constants.FLAVOR ], provides=a10constants.NAT_FLAVOR, rebind={ constants.MEMBER: member_id, constants.POOL: pool })) delete_member_thunder_subflow.add( a10_database_tasks.GetNatPoolEntry( name='get_nat_pool_db_entry_' + member_id, requires=[constants.MEMBER, a10constants.NAT_FLAVOR], provides=a10constants.NAT_POOL, rebind={constants.MEMBER: member_id})) delete_member_thunder_subflow.add( a10_network_tasks.ReleaseSubnetAddressForMember( name='release_subnet_address_for_member_' + member_id, requires=[ constants.MEMBER, a10constants.NAT_FLAVOR, a10constants.NAT_POOL ], rebind={constants.MEMBER: member_id})) delete_member_thunder_subflow.add( a10_database_tasks.DeleteNatPoolEntry( name='delete_nat_pool_entry_' + member_id, requires=a10constants.NAT_POOL)) delete_member_thunder_subflow.add( server_tasks.MemberDeletePool( name='delete_thunder_member_pool_' + member_id, requires=(constants.MEMBER, a10constants.VTHUNDER, constants.POOL, a10constants.POOL_COUNT_IP, a10constants.MEMBER_COUNT_IP_PORT_PROTOCOL), rebind={ constants.MEMBER: member_id, constants.POOL: pool })) if CONF.a10_global.network_type == 'vlan': delete_member_thunder_subflow.add( vthunder_tasks.DeleteInterfaceTagIfNotInUseForMember( name='delete_unused_interface_tag_in_member_' + member_id, requires=[constants.MEMBER, a10constants.VTHUNDER], rebind={constants.MEMBER: member_id})) return delete_member_thunder_subflow
def get_rack_vthunder_delete_member_flow(self): """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( 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 get_delete_member_flow(self): """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( 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, 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( database_tasks.DeleteMemberInDB(requires=constants.MEMBER)) delete_member_flow.add( a10_database_tasks.GetLoadBalancerListByProjectID( requires=a10constants.VTHUNDER, provides=a10constants.LOADBALANCERS_LIST)) delete_member_flow.add( a10_network_tasks.CalculateDelta( requires=(constants.LOADBALANCER, a10constants.LOADBALANCERS_LIST), provides=constants.DELTAS)) delete_member_flow.add( a10_network_tasks.HandleNetworkDeltas( requires=constants.DELTAS, provides=constants.ADDED_PORTS)) delete_member_flow.add( vthunder_tasks.AmphoraePostNetworkUnplug( requires=(constants.LOADBALANCER, constants.ADDED_PORTS, a10constants.VTHUNDER))) delete_member_flow.add( vthunder_tasks.VThunderComputeConnectivityWait( requires=(a10constants.VTHUNDER, constants.AMPHORA))) 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.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 get_rack_vthunder_create_member_flow(self): """Create a flow to create a rack vthunder member :returns: The flow for creating a rack vthunder 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( a10_database_tasks.GetVThunderByLoadBalancer( requires=constants.LOADBALANCER, provides=a10constants.VTHUNDER)) create_member_flow.add( vthunder_tasks.SetupDeviceNetworkMap( requires=a10constants.VTHUNDER, provides=a10constants.VTHUNDER)) create_member_flow.add(self.handle_vrid_for_member_subflow()) if CONF.a10_global.network_type == 'vlan': create_member_flow.add( vthunder_tasks.TagInterfaceForMember( requires=[constants.MEMBER, a10constants.VTHUNDER])) create_member_flow.add( a10_database_tasks.CountMembersWithIP( requires=constants.MEMBER, provides=a10constants.MEMBER_COUNT_IP)) create_member_flow.add( a10_database_tasks.GetFlavorData( rebind={a10constants.LB_RESOURCE: constants.LOADBALANCER}, provides=constants.FLAVOR)) create_member_flow.add( server_tasks.MemberFindNatPool(requires=[ constants.MEMBER, a10constants.VTHUNDER, constants.POOL, constants.FLAVOR ], provides=a10constants.NAT_FLAVOR)) create_member_flow.add( a10_database_tasks.GetNatPoolEntry( requires=[constants.MEMBER, a10constants.NAT_FLAVOR], provides=a10constants.NAT_POOL)) create_member_flow.add( a10_network_tasks.ReserveSubnetAddressForMember( requires=[ constants.MEMBER, a10constants.NAT_FLAVOR, a10constants.NAT_POOL ], provides=a10constants.SUBNET_PORT)) create_member_flow.add( a10_database_tasks.UpdateNatPoolDB(requires=[ constants.MEMBER, a10constants.NAT_FLAVOR, a10constants.NAT_POOL, a10constants.SUBNET_PORT ])) create_member_flow.add( server_tasks.MemberCreate(requires=(constants.MEMBER, a10constants.VTHUNDER, constants.POOL, a10constants.MEMBER_COUNT_IP, constants.FLAVOR))) 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))) create_member_flow.add( vthunder_tasks.WriteMemory(requires=a10constants.VTHUNDER)) create_member_flow.add( a10_database_tasks.SetThunderUpdatedAt( requires=a10constants.VTHUNDER)) return create_member_flow
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, 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_network_tasks.CalculateDelta( requires=(constants.LOADBALANCER, a10constants.LOADBALANCERS_LIST), provides=constants.DELTAS)) delete_member_flow.add(a10_network_tasks.HandleNetworkDeltas( requires=constants.DELTAS, provides=constants.ADDED_PORTS)) 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.AmphoraePostNetworkUnplug( name=a10constants.AMPHORA_POST_NETWORK_UNPLUG_FOR_BACKUP_VTHUNDER, requires=(constants.LOADBALANCER, constants.ADDED_PORTS), rebind={a10constants.VTHUNDER: a10constants.BACKUP_VTHUNDER})) delete_member_flow.add( vthunder_tasks.VThunderComputeConnectivityWait( name=a10constants.BACKUP_CONNECTIVITY_WAIT, 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