Example #1
0
    def handle_vrid_for_member_subflow(self):
        handle_vrid_for_member_subflow = linear_flow.Flow(
            a10constants.HANDLE_VRID_MEMBER_SUBFLOW)
        handle_vrid_for_member_subflow.add(
            a10_network_tasks.GetLBResourceSubnet(
                rebind={a10constants.LB_RESOURCE: constants.MEMBER},
                provides=constants.SUBNET))
        handle_vrid_for_member_subflow.add(
            a10_database_tasks.GetChildProjectsOfParentPartition(
                rebind={a10constants.LB_RESOURCE: constants.MEMBER},
                provides=a10constants.PARTITION_PROJECT_LIST))
        handle_vrid_for_member_subflow.add(
            a10_database_tasks.GetVRIDForLoadbalancerResource(
                requires=a10constants.PARTITION_PROJECT_LIST,
                provides=a10constants.VRID_LIST))
        handle_vrid_for_member_subflow.add(
            a10_network_tasks.HandleVRIDFloatingIP(
                requires=[
                    a10constants.VTHUNDER, a10constants.VRID_LIST,
                    constants.SUBNET
                ],
                rebind={a10constants.LB_RESOURCE: constants.MEMBER},
                provides=a10constants.VRID_LIST))
        handle_vrid_for_member_subflow.add(
            a10_database_tasks.UpdateVRIDForLoadbalancerResource(
                requires=a10constants.VRID_LIST,
                rebind={a10constants.LB_RESOURCE: constants.MEMBER}))

        return handle_vrid_for_member_subflow
 def get_delete_member_vrid_subflow(self):
     delete_member_vrid_subflow = linear_flow.Flow(
         a10constants.DELETE_MEMBER_VRID_SUBFLOW)
     delete_member_vrid_subflow.add(
         a10_network_tasks.GetLBResourceSubnet(
             rebind={a10constants.LB_RESOURCE: constants.MEMBER},
             provides=constants.SUBNET))
     delete_member_vrid_subflow.add(
         a10_database_tasks.GetChildProjectsOfParentPartition(
             rebind={a10constants.LB_RESOURCE: constants.MEMBER},
             provides=a10constants.PARTITION_PROJECT_LIST))
     delete_member_vrid_subflow.add(
         a10_database_tasks.CountLoadbalancersInProjectBySubnet(
             requires=[
                 constants.SUBNET, a10constants.PARTITION_PROJECT_LIST,
                 a10constants.USE_DEVICE_FLAVOR
             ],
             provides=a10constants.LB_COUNT_SUBNET))
     delete_member_vrid_subflow.add(
         a10_database_tasks.CountLoadbalancersOnThunderBySubnet(
             requires=[
                 a10constants.VTHUNDER, constants.SUBNET,
                 a10constants.USE_DEVICE_FLAVOR
             ],
             provides=a10constants.LB_COUNT_THUNDER))
     delete_member_vrid_subflow.add(
         a10_database_tasks.CountMembersInProjectBySubnet(
             requires=[
                 constants.SUBNET, a10constants.PARTITION_PROJECT_LIST
             ],
             provides=a10constants.MEMBER_COUNT))
     delete_member_vrid_subflow.add(
         a10_database_tasks.GetVRIDForLoadbalancerResource(
             requires=[
                 a10constants.PARTITION_PROJECT_LIST, a10constants.VTHUNDER,
                 constants.LOADBALANCER
             ],
             provides=a10constants.VRID_LIST))
     delete_member_vrid_subflow.add(
         a10_network_tasks.DeleteVRIDPort(
             requires=[
                 a10constants.VTHUNDER, a10constants.VRID_LIST,
                 constants.SUBNET, a10constants.USE_DEVICE_FLAVOR,
                 a10constants.LB_COUNT_SUBNET, a10constants.MEMBER_COUNT,
                 a10constants.LB_COUNT_THUNDER,
                 a10constants.MEMBER_COUNT_THUNDER
             ],
             rebind={a10constants.LB_RESOURCE: constants.MEMBER},
             provides=(a10constants.VRID, a10constants.DELETE_VRID)))
     delete_member_vrid_subflow.add(
         a10_database_tasks.DeleteVRIDEntry(
             requires=[a10constants.VRID, a10constants.DELETE_VRID]))
     return delete_member_vrid_subflow
Example #3
0
    def _get_vthunder_for_amphora_subflow(self, prefix, role):
        """Subflow to create lb in existing vThunder."""

        sf_name = prefix + '-' + a10constants.LB_TO_VTHUNDER_SUBFLOW
        vthunder_for_amphora_subflow = linear_flow.Flow(sf_name)
        vthunder_for_amphora_subflow.add(
            database_tasks.CreateAmphoraInDB(name=sf_name + '-' +
                                             constants.CREATE_AMPHORA_INDB,
                                             provides=constants.AMPHORA_ID))
        vthunder_for_amphora_subflow.add(
            a10_database_tasks.ValidateComputeForProject(
                name=sf_name + '-' + a10constants.VALIDATE_COMPUTE_FOR_PROJECT,
                requires=constants.LOADBALANCER,
                inject={"role": role},
                provides=constants.COMPUTE_ID))
        vthunder_for_amphora_subflow.add(
            database_tasks.UpdateAmphoraComputeId(
                name=sf_name + '-' + constants.UPDATE_AMPHORA_COMPUTEID,
                requires=(constants.AMPHORA_ID, constants.COMPUTE_ID)))
        vthunder_for_amphora_subflow.add(
            compute_tasks.ComputeActiveWait(
                name=sf_name + '-' + constants.COMPUTE_WAIT,
                requires=(constants.COMPUTE_ID, constants.AMPHORA_ID),
                provides=constants.COMPUTE_OBJ))
        vthunder_for_amphora_subflow.add(
            database_tasks.UpdateAmphoraInfo(
                name=sf_name + '-' + constants.UPDATE_AMPHORA_INFO,
                requires=(constants.AMPHORA_ID, constants.COMPUTE_OBJ),
                provides=constants.AMPHORA))
        # create vThunder entry in custom DB
        vthunder_for_amphora_subflow.add(
            a10_database_tasks.CreateVThunderEntry(
                name=sf_name + '-' + a10constants.CREATE_VTHUNDER_ENTRY,
                requires=(constants.AMPHORA, constants.LOADBALANCER),
                inject={
                    "role": role,
                    "status": constants.PENDING_CREATE
                }))
        # Get VThunder details from database
        vthunder_for_amphora_subflow.add(
            a10_database_tasks.GetVThunderByLoadBalancer(
                name=sf_name + '-' + a10constants.VTHUNDER_BY_LB,
                requires=constants.LOADBALANCER,
                provides=a10constants.VTHUNDER))
        vthunder_for_amphora_subflow.add(
            database_tasks.ReloadLoadBalancer(
                name=sf_name + '-' + constants.RELOADLOAD_BALANCER,
                requires=constants.LOADBALANCER_ID,
                provides=constants.LOADBALANCER))
        vthunder_for_amphora_subflow.add(
            a10_network_tasks.GetLBResourceSubnet(
                name=sf_name + '-' + a10constants.GET_LB_RESOURCE,
                rebind={a10constants.LB_RESOURCE: constants.LOADBALANCER},
                provides=constants.SUBNET))
        vthunder_for_amphora_subflow.add(
            a10_database_tasks.GetChildProjectsOfParentPartition(
                name=sf_name + '-' + a10constants.GET_PROJECT_COUNT,
                requires=[a10constants.VTHUNDER],
                rebind={a10constants.LB_RESOURCE: constants.LOADBALANCER},
                provides=a10constants.PARTITION_PROJECT_LIST))
        vthunder_for_amphora_subflow.add(
            a10_database_tasks.CountLoadbalancersInProjectBySubnet(
                name=sf_name + '-' + a10constants.GET_LB_COUNT_SUBNET,
                requires=[
                    constants.SUBNET, a10constants.PARTITION_PROJECT_LIST
                ],
                provides=a10constants.LB_COUNT_SUBNET))
        vthunder_for_amphora_subflow.add(
            a10_network_tasks.AllocateVIP(
                name=sf_name + '-' + a10constants.ALLOCATE_VIP,
                requires=[
                    constants.LOADBALANCER, a10constants.LB_COUNT_SUBNET
                ],
                provides=constants.VIP))
        vthunder_for_amphora_subflow.add(
            database_tasks.UpdateVIPAfterAllocation(
                name=sf_name + '-' + a10constants.UPDATE_VIP_AFTER_ALLOCATION,
                requires=(constants.LOADBALANCER_ID, constants.VIP),
                provides=constants.LOADBALANCER))
        vthunder_for_amphora_subflow.add(
            database_tasks.MarkAmphoraAllocatedInDB(
                name=sf_name + '-' + constants.MARK_AMPHORA_ALLOCATED_INDB,
                requires=(constants.AMPHORA, constants.LOADBALANCER_ID)))
        vthunder_for_amphora_subflow.add(
            database_tasks.ReloadAmphora(name=sf_name + '-' +
                                         constants.RELOAD_AMPHORA,
                                         requires=constants.AMPHORA_ID,
                                         provides=constants.AMPHORA))
        vthunder_for_amphora_subflow.add(
            vthunder_tasks.AllowL2DSR(
                name=sf_name + '-' + a10constants.ALLOW_L2DSR,
                requires=(constants.SUBNET, constants.AMPHORA)))
        if role == constants.ROLE_MASTER:
            vthunder_for_amphora_subflow.add(
                database_tasks.MarkAmphoraMasterInDB(
                    name=sf_name + '-' + constants.MARK_AMP_MASTER_INDB,
                    requires=constants.AMPHORA))
        elif role == constants.ROLE_BACKUP:
            vthunder_for_amphora_subflow.add(
                database_tasks.MarkAmphoraBackupInDB(
                    name=sf_name + '-' + constants.MARK_AMP_BACKUP_INDB,
                    requires=constants.AMPHORA))
        elif role == constants.ROLE_STANDALONE:
            vthunder_for_amphora_subflow.add(
                database_tasks.MarkAmphoraStandAloneInDB(
                    name=sf_name + '-' + constants.MARK_AMP_STANDALONE_INDB,
                    requires=constants.AMPHORA))
        return vthunder_for_amphora_subflow
Example #4
0
    def _get_create_amp_for_lb_subflow(self, prefix, role):
        """Flow to create a new vThunder for lb."""

        sf_name = prefix + '-' + constants.CREATE_AMP_FOR_LB_SUBFLOW
        create_amp_for_lb_subflow = linear_flow.Flow(sf_name)
        create_amp_for_lb_subflow.add(
            database_tasks.CreateAmphoraInDB(name=sf_name + '-' +
                                             constants.CREATE_AMPHORA_INDB,
                                             provides=constants.AMPHORA_ID))
        # VIP subnet integration at bootup
        create_amp_for_lb_subflow.add(
            database_tasks.ReloadLoadBalancer(
                name=sf_name + '-' + constants.RELOADLOAD_BALANCER,
                requires=constants.LOADBALANCER_ID,
                provides=constants.LOADBALANCER))
        require_server_group_id_condition = (
            role in (constants.ROLE_BACKUP, constants.ROLE_MASTER)
            and CONF.a10_nova.enable_anti_affinity)

        if require_server_group_id_condition:
            create_amp_for_lb_subflow.add(
                compute_tasks.ComputeCreate(
                    name=sf_name + '-' + constants.COMPUTE_CREATE,
                    requires=(constants.AMPHORA_ID,
                              constants.BUILD_TYPE_PRIORITY,
                              constants.SERVER_GROUP_ID,
                              constants.LOADBALANCER),
                    provides=constants.COMPUTE_ID))
        else:
            create_amp_for_lb_subflow.add(
                compute_tasks.ComputeCreate(
                    name=sf_name + '-' + constants.COMPUTE_CREATE,
                    requires=(constants.AMPHORA_ID,
                              constants.BUILD_TYPE_PRIORITY,
                              constants.LOADBALANCER),
                    provides=constants.COMPUTE_ID))

        create_amp_for_lb_subflow.add(
            database_tasks.UpdateAmphoraComputeId(
                name=sf_name + '-' + constants.UPDATE_AMPHORA_COMPUTEID,
                requires=(constants.AMPHORA_ID, constants.COMPUTE_ID)))
        create_amp_for_lb_subflow.add(
            database_tasks.MarkAmphoraBootingInDB(
                name=sf_name + '-' + constants.MARK_AMPHORA_BOOTING_INDB,
                requires=(constants.AMPHORA_ID, constants.COMPUTE_ID)))
        create_amp_for_lb_subflow.add(
            compute_tasks.ComputeActiveWait(
                name=sf_name + '-' + constants.COMPUTE_WAIT,
                requires=(constants.COMPUTE_ID, constants.AMPHORA_ID),
                provides=constants.COMPUTE_OBJ))
        create_amp_for_lb_subflow.add(
            database_tasks.UpdateAmphoraInfo(
                name=sf_name + '-' + constants.UPDATE_AMPHORA_INFO,
                requires=(constants.AMPHORA_ID, constants.COMPUTE_OBJ),
                provides=constants.AMPHORA))
        # create vThunder entry in custom DB
        create_amp_for_lb_subflow.add(
            a10_database_tasks.CreateVThunderEntry(
                name=sf_name + '-' + a10constants.CREATE_VTHUNDER_ENTRY,
                requires=(constants.AMPHORA, constants.LOADBALANCER),
                inject={
                    a10constants.ROLE: role,
                    a10constants.STATUS: constants.PENDING_CREATE
                }))
        # Get VThunder details from database
        create_amp_for_lb_subflow.add(
            a10_database_tasks.GetVThunderByLoadBalancer(
                name=sf_name + '-' + a10constants.VTHUNDER_BY_LB,
                requires=constants.LOADBALANCER,
                provides=a10constants.VTHUNDER))
        create_amp_for_lb_subflow.add(
            vthunder_tasks.VThunderComputeConnectivityWait(
                name=sf_name + '-' +
                a10constants.WAIT_FOR_VTHUNDER_CONNECTIVITY,
                requires=(a10constants.VTHUNDER, constants.AMPHORA)))
        create_amp_for_lb_subflow.add(
            database_tasks.MarkAmphoraAllocatedInDB(
                name=sf_name + '-' + constants.MARK_AMPHORA_ALLOCATED_INDB,
                requires=(constants.AMPHORA, constants.LOADBALANCER_ID)))
        create_amp_for_lb_subflow.add(
            database_tasks.ReloadAmphora(name=sf_name + '-' +
                                         constants.RELOAD_AMPHORA,
                                         requires=constants.AMPHORA_ID,
                                         provides=constants.AMPHORA))
        create_amp_for_lb_subflow.add(
            a10_network_tasks.GetLBResourceSubnet(
                name=sf_name + '-' + a10constants.GET_LB_RESOURCE,
                rebind={a10constants.LB_RESOURCE: constants.LOADBALANCER},
                provides=constants.SUBNET))
        create_amp_for_lb_subflow.add(
            vthunder_tasks.AllowL2DSR(
                name=sf_name + '-' + a10constants.ALLOW_L2DSR,
                requires=(constants.SUBNET, constants.AMPHORA)))
        if role == constants.ROLE_MASTER:
            create_amp_for_lb_subflow.add(
                database_tasks.MarkAmphoraMasterInDB(
                    name=sf_name + '-' + constants.MARK_AMP_MASTER_INDB,
                    requires=constants.AMPHORA))
        elif role == constants.ROLE_BACKUP:
            create_amp_for_lb_subflow.add(
                database_tasks.MarkAmphoraBackupInDB(
                    name=sf_name + '-' + constants.MARK_AMP_BACKUP_INDB,
                    requires=constants.AMPHORA))
        elif role == constants.ROLE_STANDALONE:
            create_amp_for_lb_subflow.add(
                database_tasks.MarkAmphoraStandAloneInDB(
                    name=sf_name + '-' + constants.MARK_AMP_STANDALONE_INDB,
                    requires=constants.AMPHORA))

        return create_amp_for_lb_subflow
Example #5
0
    def _get_vthunder_for_amphora_subflow(self, prefix, role):
        """Subflow to create lb in existing vThunder."""

        sf_name = prefix + '-' + a10constants.LB_TO_VTHUNDER_SUBFLOW
        vthunder_for_amphora_subflow = linear_flow.Flow(sf_name)
        vthunder_for_amphora_subflow.add(
            database_tasks.CreateAmphoraInDB(name=sf_name + '-' +
                                             constants.CREATE_AMPHORA_INDB,
                                             provides=constants.AMPHORA_ID))
        vthunder_for_amphora_subflow.add(
            a10_database_tasks.ValidateComputeForProject(
                name=sf_name + '-' + a10constants.VALIDATE_COMPUTE_FOR_PROJECT,
                requires=constants.LOADBALANCER,
                inject={"role": role},
                provides=constants.COMPUTE_ID))

        # if no compute, use spare vThunder and prepare network for spare vThunder
        vthunder_for_amphora_subflow.add(
            a10_database_tasks.GetSpareComputeForProject(
                name=sf_name + '-' +
                a10constants.GET_SPARE_COMPUTE_FOR_PROJECT,
                requires=constants.COMPUTE_ID,
                provides=(constants.COMPUTE_ID, a10constants.SPARE_VTHUNDER)))
        vthunder_for_amphora_subflow.add(
            a10_network_tasks.PlugVipNetworkOnSpare(
                name=sf_name + '-' + a10constants.PLUG_VIP_NETWORK_ON_SPARE,
                requires=(a10constants.SPARE_VTHUNDER, constants.LOADBALANCER),
                provides=a10constants.ADDED_NETWORK))
        vthunder_for_amphora_subflow.add(
            vthunder_tasks.SparePostNetworkPlug(
                name=sf_name + '-' + a10constants.POST_SPARE_PLUG_NETWORK,
                rebind={a10constants.VTHUNDER: a10constants.SPARE_VTHUNDER},
                requires=(a10constants.ADDED_NETWORK)))
        vthunder_for_amphora_subflow.add(
            a10_database_tasks.GetVThunderAmphora(
                name=sf_name + '-' + a10constants.GET_VTHUNDER_AMPHORA,
                rebind={a10constants.VTHUNDER: a10constants.SPARE_VTHUNDER},
                provides=constants.AMPHORA))
        vthunder_for_amphora_subflow.add(
            vthunder_tasks.VThunderComputeConnectivityWait(
                name=sf_name + '-' + constants.AMP_COMPUTE_CONNECTIVITY_WAIT,
                rebind={a10constants.VTHUNDER: a10constants.SPARE_VTHUNDER},
                requires=(constants.AMPHORA)))
        vthunder_for_amphora_subflow.add(
            vthunder_tasks.EnableInterfaceOnSpare(
                name=sf_name + '-' + a10constants.ENABLE_VTHUNDER_INTERFACE,
                rebind={a10constants.VTHUNDER: a10constants.SPARE_VTHUNDER},
                requires=(a10constants.ADDED_NETWORK)))

        vthunder_for_amphora_subflow.add(
            database_tasks.UpdateAmphoraComputeId(
                name=sf_name + '-' + constants.UPDATE_AMPHORA_COMPUTEID,
                requires=(constants.AMPHORA_ID, constants.COMPUTE_ID)))
        vthunder_for_amphora_subflow.add(
            compute_tasks.ComputeActiveWait(
                name=sf_name + '-' + constants.COMPUTE_WAIT,
                requires=(constants.COMPUTE_ID, constants.AMPHORA_ID),
                provides=constants.COMPUTE_OBJ))
        vthunder_for_amphora_subflow.add(
            database_tasks.UpdateAmphoraInfo(
                name=sf_name + '-' + constants.UPDATE_AMPHORA_INFO,
                requires=(constants.AMPHORA_ID, constants.COMPUTE_OBJ),
                provides=constants.AMPHORA))
        # create vThunder entry in custom DB
        vthunder_for_amphora_subflow.add(
            a10_database_tasks.CreateVThunderEntry(
                name=sf_name + '-' + a10constants.CREATE_VTHUNDER_ENTRY,
                requires=(constants.AMPHORA, constants.LOADBALANCER),
                inject={
                    "role": role,
                    "status": constants.PENDING_CREATE
                }))
        # Get VThunder details from database
        vthunder_for_amphora_subflow.add(
            a10_database_tasks.GetVThunderByLoadBalancer(
                name=sf_name + '-' + a10constants.VTHUNDER_BY_LB,
                requires=constants.LOADBALANCER,
                provides=a10constants.VTHUNDER))
        vthunder_for_amphora_subflow.add(
            database_tasks.ReloadLoadBalancer(
                name=sf_name + '-' + a10constants.RELOADLOAD_BALANCER,
                requires=constants.LOADBALANCER_ID,
                provides=constants.LOADBALANCER))
        vthunder_for_amphora_subflow.add(
            a10_network_tasks.GetLBResourceSubnet(
                name=sf_name + '-' + a10constants.GET_LB_RESOURCE,
                rebind={a10constants.LB_RESOURCE: constants.LOADBALANCER},
                provides=constants.SUBNET))
        vthunder_for_amphora_subflow.add(
            a10_database_tasks.GetChildProjectsOfParentPartition(
                name=sf_name + '-' + a10constants.GET_PROJECT_COUNT,
                requires=[a10constants.VTHUNDER],
                rebind={a10constants.LB_RESOURCE: constants.LOADBALANCER},
                provides=a10constants.PARTITION_PROJECT_LIST))
        vthunder_for_amphora_subflow.add(
            a10_database_tasks.CountLoadbalancersInProjectBySubnet(
                name=sf_name + '-' + a10constants.GET_LB_COUNT_SUBNET,
                requires=[
                    constants.SUBNET, a10constants.PARTITION_PROJECT_LIST
                ],
                provides=a10constants.LB_COUNT_SUBNET))
        vthunder_for_amphora_subflow.add(
            a10_network_tasks.AllocateVIP(
                name=sf_name + '-' + a10constants.ALLOCATE_VIP,
                requires=[
                    constants.LOADBALANCER, a10constants.LB_COUNT_SUBNET
                ],
                provides=constants.VIP))
        vthunder_for_amphora_subflow.add(
            database_tasks.UpdateVIPAfterAllocation(
                name=sf_name + '-' + a10constants.UPDATE_VIP_AFTER_ALLOCATION,
                requires=(constants.LOADBALANCER_ID, constants.VIP),
                provides=constants.LOADBALANCER))
        vthunder_for_amphora_subflow.add(
            database_tasks.MarkAmphoraAllocatedInDB(
                name=sf_name + '-' + constants.MARK_AMPHORA_ALLOCATED_INDB,
                requires=(constants.AMPHORA, constants.LOADBALANCER_ID)))
        vthunder_for_amphora_subflow.add(
            database_tasks.ReloadAmphora(name=sf_name + '-' +
                                         constants.RELOAD_AMPHORA,
                                         requires=constants.AMPHORA_ID,
                                         provides=constants.AMPHORA))
        if role == constants.ROLE_MASTER:
            vthunder_for_amphora_subflow.add(
                database_tasks.MarkAmphoraMasterInDB(
                    name=sf_name + '-' + constants.MARK_AMP_MASTER_INDB,
                    requires=constants.AMPHORA))
            vthunder_for_amphora_subflow.add(
                vthunder_tasks.UpdateAcosVersionInVthunderEntry(
                    name=sf_name + '-' +
                    a10constants.UPDATE_ACOS_VERSION_FOR_BACKUP_VTHUNDER,
                    requires=(a10constants.VTHUNDER)))
        elif role == constants.ROLE_BACKUP:
            vthunder_for_amphora_subflow.add(
                database_tasks.MarkAmphoraBackupInDB(
                    name=sf_name + '-' + constants.MARK_AMP_BACKUP_INDB,
                    requires=constants.AMPHORA))
            vthunder_for_amphora_subflow.add(
                a10_database_tasks.GetBackupVThunderByLoadBalancer(
                    name=sf_name + '-' + a10constants.BACKUP_VTHUNDER,
                    requires=constants.LOADBALANCER,
                    provides=a10constants.BACKUP_VTHUNDER))
            vthunder_for_amphora_subflow.add(
                vthunder_tasks.UpdateAcosVersionInVthunderEntry(
                    name=sf_name + '-' +
                    a10constants.UPDATE_ACOS_VERSION_FOR_BACKUP_VTHUNDER,
                    rebind={
                        a10constants.VTHUNDER: a10constants.BACKUP_VTHUNDER
                    }))
        elif role == constants.ROLE_STANDALONE:
            vthunder_for_amphora_subflow.add(
                database_tasks.MarkAmphoraStandAloneInDB(
                    name=sf_name + '-' + constants.MARK_AMP_STANDALONE_INDB,
                    requires=constants.AMPHORA))
            vthunder_for_amphora_subflow.add(
                vthunder_tasks.UpdateAcosVersionInVthunderEntry(
                    name=sf_name + '-' +
                    a10constants.UPDATE_ACOS_VERSION_FOR_BACKUP_VTHUNDER,
                    requires=(a10constants.VTHUNDER)))

        # If spare vThunder is used, remove spare vThunder the database
        vthunder_for_amphora_subflow.add(
            a10_database_tasks.DeleteStaleSpareVThunder(
                name=sf_name + '-' + a10constants.DELETE_STALE_SPARE_VTHUNDER,
                requires=(a10constants.SPARE_VTHUNDER)))
        return vthunder_for_amphora_subflow
    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