示例#1
0
    def get_cascade_delete_load_balancer_flow(self, lb):
        """Creates a flow to delete a load balancer.

        :returns: The flow for deleting a load balancer
        """

        (listeners_delete, store) = self._get_delete_listeners_flow(lb)
        (pools_delete, pool_store) = self._get_delete_pools_flow(lb)
        store.update(pool_store)

        delete_LB_flow = linear_flow.Flow(constants.DELETE_LOADBALANCER_FLOW)
        delete_LB_flow.add(lifecycle_tasks.LoadBalancerToErrorOnRevertTask(
            requires=constants.LOADBALANCER))
        delete_LB_flow.add(compute_tasks.NovaServerGroupDelete(
            requires=constants.SERVER_GROUP_ID))
        delete_LB_flow.add(database_tasks.MarkLBAmphoraeHealthBusy(
            requires=constants.LOADBALANCER))
        delete_LB_flow.add(pools_delete)
        delete_LB_flow.add(listeners_delete)
        delete_LB_flow.add(network_tasks.UnplugVIP(
            requires=constants.LOADBALANCER))
        delete_LB_flow.add(network_tasks.DeallocateVIP(
            requires=constants.LOADBALANCER))
        delete_LB_flow.add(compute_tasks.DeleteAmphoraeOnLoadBalancer(
            requires=constants.LOADBALANCER))
        delete_LB_flow.add(database_tasks.MarkLBAmphoraeDeletedInDB(
            requires=constants.LOADBALANCER))
        delete_LB_flow.add(database_tasks.DisableLBAmphoraeHealthMonitoring(
            requires=constants.LOADBALANCER))
        delete_LB_flow.add(database_tasks.MarkLBDeletedInDB(
            requires=constants.LOADBALANCER))
        delete_LB_flow.add(database_tasks.DecrementLoadBalancerQuota(
            requires=constants.LOADBALANCER))

        return (delete_LB_flow, store)
    def get_delete_load_balancer_flow(self, lb, deleteCompute):
        """Creates a flow to delete a load balancer.

        :returns: The flow for deleting a load balancer
        """
        store = {}
        delete_LB_flow = linear_flow.Flow(constants.DELETE_LOADBALANCER_FLOW)
        delete_LB_flow.add(
            lifecycle_tasks.LoadBalancerToErrorOnRevertTask(
                requires=constants.LOADBALANCER))
        delete_LB_flow.add(
            a10_database_tasks.GetVThunderByLoadBalancer(
                requires=constants.LOADBALANCER,
                provides=a10constants.VTHUNDER))
        delete_LB_flow.add(
            a10_database_tasks.MarkVThunderStatusInDB(
                name="set load balancer status PENDING_DELETE",
                requires=a10constants.VTHUNDER,
                inject={"status": constants.PENDING_DELETE}))
        delete_LB_flow.add(
            compute_tasks.NovaServerGroupDelete(
                requires=constants.SERVER_GROUP_ID))
        delete_LB_flow.add(
            database_tasks.MarkLBAmphoraeHealthBusy(
                requires=constants.LOADBALANCER))
        delete_LB_flow.add(
            virtual_server_tasks.DeleteVirtualServerTask(
                requires=(constants.LOADBALANCER, a10constants.VTHUNDER)))

        # delete_LB_flow.add(listeners_delete)
        # delete_LB_flow.add(network_tasks.UnplugVIP(
        #    requires=constants.LOADBALANCER))
        # delete_LB_flow.add(network_tasks.DeallocateVIP(
        #    requires=constants.LOADBALANCER))
        if deleteCompute:
            delete_LB_flow.add(
                compute_tasks.DeleteAmphoraeOnLoadBalancer(
                    requires=constants.LOADBALANCER))
        delete_LB_flow.add(
            a10_database_tasks.MarkVThunderStatusInDB(
                name="DELETED",
                requires=a10constants.VTHUNDER,
                inject={"status": constants.DELETED}))
        delete_LB_flow.add(
            database_tasks.MarkLBAmphoraeDeletedInDB(
                requires=constants.LOADBALANCER))
        delete_LB_flow.add(
            database_tasks.DisableLBAmphoraeHealthMonitoring(
                requires=constants.LOADBALANCER))
        delete_LB_flow.add(
            database_tasks.MarkLBDeletedInDB(requires=constants.LOADBALANCER))
        delete_LB_flow.add(
            database_tasks.DecrementLoadBalancerQuota(
                requires=constants.LOADBALANCER))

        return (delete_LB_flow, store)
示例#3
0
 def test_decrement_loadbalancer_quota(self):
     task = database_tasks.DecrementLoadBalancerQuota()
     data_model = data_models.LoadBalancer
     self._test_decrement_quota(task, data_model)
    def get_delete_load_balancer_flow(self, lb, deleteCompute):
        """Flow to delete load balancer"""

        store = {}
        delete_LB_flow = linear_flow.Flow(constants.DELETE_LOADBALANCER_FLOW)
        delete_LB_flow.add(
            lifecycle_tasks.LoadBalancerToErrorOnRevertTask(
                requires=constants.LOADBALANCER))
        delete_LB_flow.add(
            a10_database_tasks.GetVThunderByLoadBalancer(
                requires=constants.LOADBALANCER,
                provides=a10constants.VTHUNDER))
        delete_LB_flow.add(
            a10_database_tasks.MarkVThunderStatusInDB(
                requires=a10constants.VTHUNDER,
                inject={"status": constants.PENDING_DELETE}))
        delete_LB_flow.add(
            vthunder_tasks.SetupDeviceNetworkMap(
                requires=a10constants.VTHUNDER,
                provides=a10constants.VTHUNDER))
        delete_LB_flow.add(
            compute_tasks.NovaServerGroupDelete(
                requires=constants.SERVER_GROUP_ID))
        delete_LB_flow.add(
            database_tasks.MarkLBAmphoraeHealthBusy(
                requires=constants.LOADBALANCER))
        delete_LB_flow.add(
            virtual_server_tasks.DeleteVirtualServerTask(
                requires=(constants.LOADBALANCER, a10constants.VTHUNDER)))
        delete_LB_flow.add(self.get_delete_lb_vrid_subflow())
        if CONF.a10_global.network_type == 'vlan':
            delete_LB_flow.add(
                vthunder_tasks.DeleteInterfaceTagIfNotInUseForLB(
                    requires=[constants.LOADBALANCER, a10constants.VTHUNDER]))

        # delete_LB_flow.add(listeners_delete)
        # delete_LB_flow.add(network_tasks.UnplugVIP(
        #    requires=constants.LOADBALANCER))
        delete_LB_flow.add(
            network_tasks.DeallocateVIP(requires=constants.LOADBALANCER))
        if deleteCompute:
            delete_LB_flow.add(
                compute_tasks.DeleteAmphoraeOnLoadBalancer(
                    requires=constants.LOADBALANCER))
        delete_LB_flow.add(
            a10_database_tasks.MarkVThunderStatusInDB(
                name="DELETED",
                requires=a10constants.VTHUNDER,
                inject={"status": constants.DELETED}))
        delete_LB_flow.add(
            database_tasks.MarkLBAmphoraeDeletedInDB(
                requires=constants.LOADBALANCER))
        delete_LB_flow.add(
            database_tasks.DisableLBAmphoraeHealthMonitoring(
                requires=constants.LOADBALANCER))
        delete_LB_flow.add(
            database_tasks.MarkLBDeletedInDB(requires=constants.LOADBALANCER))
        delete_LB_flow.add(
            database_tasks.DecrementLoadBalancerQuota(
                requires=constants.LOADBALANCER))
        delete_LB_flow.add(
            vthunder_tasks.WriteMemory(requires=a10constants.VTHUNDER))
        return (delete_LB_flow, store)
    def get_delete_load_balancer_flow(self, lb, deleteCompute, cascade):
        """Flow to delete load balancer"""

        store = {}
        delete_LB_flow = linear_flow.Flow(constants.DELETE_LOADBALANCER_FLOW)
        delete_LB_flow.add(
            lifecycle_tasks.LoadBalancerToErrorOnRevertTask(
                requires=constants.LOADBALANCER))
        delete_LB_flow.add(
            a10_database_tasks.GetVThunderByLoadBalancer(
                requires=constants.LOADBALANCER,
                provides=a10constants.VTHUNDER))
        delete_LB_flow.add(
            a10_database_tasks.MarkVThunderStatusInDB(
                requires=a10constants.VTHUNDER,
                inject={"status": constants.PENDING_DELETE}))
        delete_LB_flow.add(
            vthunder_tasks.SetupDeviceNetworkMap(
                requires=a10constants.VTHUNDER,
                provides=a10constants.VTHUNDER))
        delete_LB_flow.add(
            compute_tasks.NovaServerGroupDelete(
                requires=constants.SERVER_GROUP_ID))
        delete_LB_flow.add(
            database_tasks.MarkLBAmphoraeHealthBusy(
                requires=constants.LOADBALANCER))
        if cascade:
            (pools_listeners_delete,
             store) = self._get_cascade_delete_pools_listeners_flow(lb)
            delete_LB_flow.add(pools_listeners_delete)
        delete_LB_flow.add(
            a10_database_tasks.GetFlavorData(
                rebind={a10constants.LB_RESOURCE: constants.LOADBALANCER},
                provides=constants.FLAVOR_DATA))
        delete_LB_flow.add(
            a10_database_tasks.CountLoadbalancersWithFlavor(
                requires=(constants.LOADBALANCER, a10constants.VTHUNDER),
                provides=a10constants.LB_COUNT))
        delete_LB_flow.add(self.get_delete_lb_vrid_subflow())
        if CONF.a10_global.network_type == 'vlan':
            delete_LB_flow.add(
                vthunder_tasks.DeleteInterfaceTagIfNotInUseForLB(
                    requires=[constants.LOADBALANCER, a10constants.VTHUNDER]))

        # delete_LB_flow.add(listeners_delete)
        # delete_LB_flow.add(network_tasks.UnplugVIP(
        #    requires=constants.LOADBALANCER))
        delete_LB_flow.add(
            database_tasks.GetAmphoraeFromLoadbalancer(
                requires=constants.LOADBALANCER, provides=constants.AMPHORA))
        delete_LB_flow.add(
            a10_database_tasks.GetLoadBalancerListByProjectID(
                requires=a10constants.VTHUNDER,
                provides=a10constants.LOADBALANCERS_LIST))
        if not deleteCompute:
            delete_LB_flow.add(
                a10_network_tasks.CalculateDelta(
                    requires=(constants.LOADBALANCER,
                              a10constants.LOADBALANCERS_LIST),
                    provides=constants.DELTAS))
            delete_LB_flow.add(
                a10_network_tasks.HandleNetworkDeltas(
                    requires=constants.DELTAS, provides=constants.ADDED_PORTS))
            delete_LB_flow.add(
                vthunder_tasks.AmphoraePostNetworkUnplug(
                    name=a10constants.AMPHORA_POST_NETWORK_UNPLUG,
                    requires=(constants.LOADBALANCER, constants.ADDED_PORTS,
                              a10constants.VTHUNDER)))
            delete_LB_flow.add(
                vthunder_tasks.VThunderComputeConnectivityWait(
                    name=a10constants.VTHUNDER_CONNECTIVITY_WAIT,
                    requires=(a10constants.VTHUNDER, constants.AMPHORA)))
        delete_LB_flow.add(
            virtual_server_tasks.DeleteVirtualServerTask(
                requires=(constants.LOADBALANCER, a10constants.VTHUNDER)))
        delete_LB_flow.add(
            nat_pool_tasks.NatPoolDelete(requires=(constants.LOADBALANCER,
                                                   a10constants.VTHUNDER,
                                                   a10constants.LB_COUNT,
                                                   constants.FLAVOR_DATA)))
        if deleteCompute:
            delete_LB_flow.add(
                compute_tasks.DeleteAmphoraeOnLoadBalancer(
                    requires=constants.LOADBALANCER))
        delete_LB_flow.add(
            a10_database_tasks.MarkVThunderStatusInDB(
                name=a10constants.MARK_VTHUNDER_MASTER_DELETED_IN_DB,
                requires=a10constants.VTHUNDER,
                inject={"status": constants.DELETED}))
        delete_LB_flow.add(
            database_tasks.MarkLBAmphoraeDeletedInDB(
                requires=constants.LOADBALANCER))
        delete_LB_flow.add(
            database_tasks.DisableLBAmphoraeHealthMonitoring(
                requires=constants.LOADBALANCER))
        delete_LB_flow.add(
            database_tasks.MarkLBDeletedInDB(requires=constants.LOADBALANCER))
        delete_LB_flow.add(
            database_tasks.DecrementLoadBalancerQuota(
                requires=constants.LOADBALANCER))
        if not deleteCompute:
            delete_LB_flow.add(
                vthunder_tasks.WriteMemory(requires=a10constants.VTHUNDER))
        delete_LB_flow.add(
            a10_database_tasks.SetThunderUpdatedAt(
                name=a10constants.SET_THUNDER_UPDATE_AT,
                requires=a10constants.VTHUNDER))
        delete_LB_flow.add(
            a10_database_tasks.GetBackupVThunderByLoadBalancer(
                requires=constants.LOADBALANCER,
                provides=a10constants.BACKUP_VTHUNDER))
        delete_LB_flow.add(
            a10_database_tasks.MarkVThunderStatusInDB(
                name=a10constants.MARK_VTHUNDER_BACKUP_DELETED_IN_DB,
                rebind={a10constants.VTHUNDER: a10constants.BACKUP_VTHUNDER},
                inject={"status": constants.DELETED}))
        delete_LB_flow.add(
            a10_database_tasks.SetThunderUpdatedAt(
                name=a10constants.SET_THUNDER_BACKUP_UPDATE_AT,
                rebind={a10constants.VTHUNDER: a10constants.BACKUP_VTHUNDER}))
        return (delete_LB_flow, store)