Exemple #1
0
    def get_delete_pool_flow(self):
        """Create a flow to delete a pool

        :returns: The flow for deleting a pool
        """
        delete_pool_flow = linear_flow.Flow(constants.DELETE_POOL_FLOW)
        delete_pool_flow.add(lifecycle_tasks.PoolToErrorOnRevertTask(
            requires=[constants.POOL,
                      constants.LISTENERS,
                      constants.LOADBALANCER]))
        delete_pool_flow.add(database_tasks.MarkPoolPendingDeleteInDB(
            requires=constants.POOL))
        delete_pool_flow.add(database_tasks.CountPoolChildrenForQuota(
            requires=constants.POOL, provides=constants.POOL_CHILD_COUNT))
        delete_pool_flow.add(model_tasks.DeleteModelObject(
            rebind={constants.OBJECT: constants.POOL}))
        delete_pool_flow.add(amphora_driver_tasks.ListenersUpdate(
            requires=[constants.LOADBALANCER, constants.LISTENERS]))
        delete_pool_flow.add(database_tasks.DeletePoolInDB(
            requires=constants.POOL))
        delete_pool_flow.add(database_tasks.DecrementPoolQuota(
            requires=[constants.POOL, constants.POOL_CHILD_COUNT]))
        delete_pool_flow.add(database_tasks.MarkLBAndListenersActiveInDB(
            requires=[constants.LOADBALANCER, constants.LISTENERS]))

        return delete_pool_flow
Exemple #2
0
    def get_update_pool_flow(self):
        """Create a flow to update a pool

        :returns: The flow for updating a pool
        """
        update_pool_flow = linear_flow.Flow(constants.UPDATE_POOL_FLOW)
        update_pool_flow.add(
            lifecycle_tasks.PoolToErrorOnRevertTask(requires=[
                constants.POOL, constants.LISTENERS, constants.LOADBALANCER
            ]))
        update_pool_flow.add(
            database_tasks.MarkPoolPendingUpdateInDB(requires=constants.POOL))
        update_pool_flow.add(
            amphora_driver_tasks.ListenersUpdate(
                requires=constants.LOADBALANCER))
        update_pool_flow.add(
            database_tasks.UpdatePoolInDB(
                requires=[constants.POOL, constants.UPDATE_DICT]))
        update_pool_flow.add(
            database_tasks.MarkPoolActiveInDB(requires=constants.POOL))
        update_pool_flow.add(
            database_tasks.MarkLBAndListenersActiveInDB(
                requires=[constants.LOADBALANCER, constants.LISTENERS]))

        return update_pool_flow
Exemple #3
0
    def get_create_pool_flow(self):
        """Create a flow to create a pool

        :returns: The flow for creating a pool
        """
        create_pool_flow = linear_flow.Flow(constants.CREATE_POOL_FLOW)
        create_pool_flow.add(
            lifecycle_tasks.PoolToErrorOnRevertTask(requires=[
                constants.POOL, constants.LISTENERS, constants.LOADBALANCER
            ]))
        create_pool_flow.add(
            database_tasks.MarkPoolPendingCreateInDB(requires=constants.POOL))
        #create_pool_flow.add(amphora_driver_tasks.ListenersUpdate(
        #    requires=[constants.LOADBALANCER, constants.LISTENERS]))
        # Get VThunder details from database
        create_pool_flow.add(
            a10_database_tasks.GetVThunderByLoadBalancer(
                requires=constants.LOADBALANCER,
                provides=a10constants.VTHUNDER))
        create_pool_flow.add(
            handler_service_group.PoolCreate(
                requires=[constants.POOL, a10constants.VTHUNDER]))
        create_pool_flow.add(
            handler_virtual_port.ListenersUpdate(
                requires=[constants.LOADBALANCER, constants.LISTENERS]))
        create_pool_flow.add(
            database_tasks.MarkPoolActiveInDB(requires=constants.POOL))
        create_pool_flow.add(
            database_tasks.MarkLBAndListenersActiveInDB(
                requires=[constants.LOADBALANCER, constants.LISTENERS]))

        return create_pool_flow
Exemple #4
0
    def get_create_pool_flow(self):
        """Create a flow to create a pool

        :returns: The flow for creating a pool
        """
        create_pool_flow = linear_flow.Flow(constants.CREATE_POOL_FLOW)
        create_pool_flow.add(lifecycle_tasks.PoolToErrorOnRevertTask(
            requires=[constants.POOL_ID,
                      constants.LISTENERS,
                      constants.LOADBALANCER]))
        create_pool_flow.add(database_tasks.MarkPoolPendingCreateInDB(
            requires=constants.POOL_ID))
        create_pool_flow.add(amphora_driver_tasks.ListenersUpdate(
            requires=constants.LOADBALANCER_ID))
        create_pool_flow.add(database_tasks.MarkPoolActiveInDB(
            requires=constants.POOL_ID))
        create_pool_flow.add(database_tasks.MarkLBAndListenersActiveInDB(
            requires=(constants.LOADBALANCER_ID, constants.LISTENERS)))

        return create_pool_flow
Exemple #5
0
    def get_delete_pool_flow(self):
        """Create a flow to delete a pool

        :returns: The flow for deleting a pool
        """
        delete_pool_flow = linear_flow.Flow(constants.DELETE_POOL_FLOW)
        delete_pool_flow.add(
            lifecycle_tasks.PoolToErrorOnRevertTask(requires=[
                constants.POOL, constants.LISTENERS, constants.LOADBALANCER
            ]))
        delete_pool_flow.add(
            database_tasks.MarkPoolPendingDeleteInDB(requires=constants.POOL))
        delete_pool_flow.add(
            database_tasks.CountPoolChildrenForQuota(
                requires=constants.POOL, provides=constants.POOL_CHILD_COUNT))
        delete_pool_flow.add(
            model_tasks.DeleteModelObject(
                rebind={constants.OBJECT: constants.POOL}))
        # Get VThunder details from database
        delete_pool_flow.add(
            a10_database_tasks.GetVThunderByLoadBalancer(
                requires=constants.LOADBALANCER,
                provides=a10constants.VTHUNDER))
        delete_pool_flow.add(
            handler_virtual_port.ListenersUpdate(requires=[
                constants.LOADBALANCER, constants.LISTENERS,
                a10constants.VTHUNDER
            ]))
        delete_pool_flow.add(
            handler_service_group.PoolDelete(
                requires=[constants.POOL, a10constants.VTHUNDER]))
        delete_pool_flow.add(
            database_tasks.DeletePoolInDB(requires=constants.POOL))
        delete_pool_flow.add(
            database_tasks.DecrementPoolQuota(
                requires=[constants.POOL, constants.POOL_CHILD_COUNT]))
        delete_pool_flow.add(
            database_tasks.MarkLBAndListenersActiveInDB(
                requires=[constants.LOADBALANCER, constants.LISTENERS]))

        return delete_pool_flow
Exemple #6
0
    def test_PoolToErrorOnRevertTask(self, mock_listener_prov_status_active,
                                     mock_loadbalancer_prov_status_active,
                                     mock_pool_prov_status_error):

        pool_to_error_on_revert = lifecycle_tasks.PoolToErrorOnRevertTask()

        # Execute
        pool_to_error_on_revert.execute(self.POOL_ID, self.LISTENERS,
                                        self.LOADBALANCER)

        self.assertFalse(mock_pool_prov_status_error.called)

        # Revert
        pool_to_error_on_revert.revert(self.POOL_ID, self.LISTENERS,
                                       self.LOADBALANCER)

        mock_pool_prov_status_error.assert_called_once_with(self.POOL_ID)
        mock_loadbalancer_prov_status_active.assert_called_once_with(
            self.LOADBALANCER_ID)
        mock_listener_prov_status_active.assert_called_once_with(
            self.LISTENER_ID)