Esempio n. 1
0
    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_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 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