예제 #1
0
    def get_create_l7rule_flow(self):
        """Create a flow to create an L7 rule

        :returns: The flow for creating an L7 rule
        """
        create_l7rule_flow = linear_flow.Flow(constants.CREATE_L7RULE_FLOW)
        create_l7rule_flow.add(
            lifecycle_tasks.L7RuleToErrorOnRevertTask(requires=[
                constants.L7RULE, constants.LISTENERS, constants.LOADBALANCER
            ]))
        create_l7rule_flow.add(
            database_tasks.MarkL7RulePendingCreateInDB(
                requires=constants.L7RULE))
        create_l7rule_flow.add(
            amphora_driver_tasks.ListenersUpdate(
                requires=[constants.LOADBALANCER, constants.LISTENERS]))
        create_l7rule_flow.add(
            database_tasks.MarkL7RuleActiveInDB(requires=constants.L7RULE))
        create_l7rule_flow.add(
            database_tasks.MarkL7PolicyActiveInDB(requires=constants.L7POLICY))
        create_l7rule_flow.add(
            database_tasks.MarkLBAndListenersActiveInDB(
                requires=[constants.LOADBALANCER, constants.LISTENERS]))

        return create_l7rule_flow
예제 #2
0
    def get_delete_l7rule_flow(self):
        """Create a flow to delete an L7 rule

        :returns: The flow for deleting an L7 rule
        """
        delete_l7rule_flow = linear_flow.Flow(constants.DELETE_L7RULE_FLOW)
        delete_l7rule_flow.add(
            lifecycle_tasks.L7RuleToErrorOnRevertTask(requires=[
                constants.L7RULE, constants.LISTENERS, constants.LOADBALANCER
            ]))
        delete_l7rule_flow.add(
            database_tasks.MarkL7RulePendingDeleteInDB(
                requires=constants.L7RULE))
        delete_l7rule_flow.add(
            model_tasks.DeleteModelObject(
                rebind={constants.OBJECT: constants.L7RULE}))
        delete_l7rule_flow.add(
            amphora_driver_tasks.ListenersUpdate(
                requires=[constants.LOADBALANCER, constants.LISTENERS]))
        delete_l7rule_flow.add(
            database_tasks.DeleteL7RuleInDB(requires=constants.L7RULE))
        delete_l7rule_flow.add(
            database_tasks.MarkL7PolicyActiveInDB(requires=constants.L7POLICY))
        delete_l7rule_flow.add(
            database_tasks.MarkLBAndListenersActiveInDB(
                requires=[constants.LOADBALANCER, constants.LISTENERS]))

        return delete_l7rule_flow
예제 #3
0
    def get_update_l7rule_flow(self):
        """Create a flow to update an L7 rule

        :returns: The flow for updating an L7 rule
        """
        update_l7rule_flow = linear_flow.Flow(constants.UPDATE_L7RULE_FLOW)
        update_l7rule_flow.add(
            lifecycle_tasks.L7RuleToErrorOnRevertTask(requires=[
                constants.L7RULE, constants.L7POLICY_ID, constants.LISTENERS,
                constants.LOADBALANCER_ID
            ]))
        update_l7rule_flow.add(
            database_tasks.MarkL7RulePendingUpdateInDB(
                requires=constants.L7RULE))
        update_l7rule_flow.add(
            amphora_driver_tasks.ListenersUpdate(
                requires=constants.LOADBALANCER_ID))
        update_l7rule_flow.add(
            database_tasks.UpdateL7RuleInDB(
                requires=[constants.L7RULE, constants.UPDATE_DICT]))
        update_l7rule_flow.add(
            database_tasks.MarkL7RuleActiveInDB(requires=constants.L7RULE))
        update_l7rule_flow.add(
            database_tasks.MarkL7PolicyActiveInDB(requires=constants.L7POLICY))
        update_l7rule_flow.add(
            database_tasks.MarkLBAndListenersActiveInDB(
                requires=(constants.LOADBALANCER_ID, constants.LISTENERS)))

        return update_l7rule_flow
예제 #4
0
    def test_L7RuleToErrorOnRevertTask(self, mock_listener_prov_status_active,
                                       mock_loadbalancer_prov_status_active,
                                       mock_l7rule_prov_status_error):

        l7rule_to_error_on_revert = (
            lifecycle_tasks.L7RuleToErrorOnRevertTask())

        # Execute
        l7rule_to_error_on_revert.execute(self.L7RULE, self.L7POLICY_ID,
                                          self.LISTENERS, self.LOADBALANCER_ID)

        self.assertFalse(mock_l7rule_prov_status_error.called)

        # Revert
        l7rule_to_error_on_revert.revert(self.L7RULE, self.L7POLICY_ID,
                                         self.LISTENERS, self.LOADBALANCER_ID)

        mock_l7rule_prov_status_error.assert_called_once_with(self.L7RULE_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)