def _get_delete_load_balancer_flow(self, lb, cascade):
     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))
     if cascade:
         (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.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 test_delete_amphorae_on_load_balancer(self, mock_lb_get, mock_session,
                                              mock_driver):

        delete_amps = compute_tasks.DeleteAmphoraeOnLoadBalancer()
        mock_lb_get.return_value = _db_load_balancer_mock
        delete_amps.execute(_load_balancer_mock)

        mock_driver.delete.assert_called_once_with(COMPUTE_ID)
Beispiel #3
0
    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
        """
        #(listeners_delete, store) = self._get_delete_listeners_flow(lb)
        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(
            a10_database_tasks.GetVThunderByLoadBalancer(
                requires=constants.LOADBALANCER,
                provides=a10constants.VTHUNDER))
        delete_LB_flow.add(
            handler_virtual_server.DeleteVitualServerTask(
                requires=(constants.LOADBALANCER, a10constants.VTHUNDER),
                provides=a10constants.STATUS))
        #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(
            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(
            a10_database_tasks.DeleteVthunderEntry(
                requires=constants.LOADBALANCER))
        delete_LB_flow.add(
            database_tasks.DecrementLoadBalancerQuota(
                requires=constants.LOADBALANCER))

        return (delete_LB_flow, store)
Beispiel #4
0
    def test_delete_amphorae_on_load_balancer(self, mock_lb_get, mock_session,
                                              mock_driver):

        mock_driver.delete.side_effect = [
            mock.DEFAULT, exceptions.OctaviaException('boom')
        ]
        delete_amps = compute_tasks.DeleteAmphoraeOnLoadBalancer()

        mock_lb_get.return_value = _db_load_balancer_mock
        delete_amps.execute(_load_balancer_mock)

        mock_driver.delete.assert_called_once_with(COMPUTE_ID)

        # Test compute driver exception is raised
        self.assertRaises(exceptions.OctaviaException, delete_amps.execute,
                          _load_balancer_mock)
Beispiel #5
0
    def test_delete_amphorae_on_load_balancer(self, mock_driver):

        delete_amps = compute_tasks.DeleteAmphoraeOnLoadBalancer()
        delete_amps.execute(_load_balancer_mock)

        mock_driver.delete.assert_called_once_with(COMPUTE_ID)