Esempio n. 1
0
    def _execute_workflow(self,
                          deployment_update,
                          workflow_id,
                          parameters=None,
                          allow_custom_parameters=False,
                          force=False):
        """Executes the specified workflow

        :param deployment_update:
        :param workflow_id:
        :param parameters:
        :param allow_custom_parameters:
        :param force:
        :return:
        """
        deployment_id = deployment_update.deployment_id
        deployment = self.sm.get_deployment(deployment_id)
        blueprint_id = deployment.blueprint_id

        if workflow_id not in deployment.workflows:
            raise manager_exceptions.NonexistentWorkflowError(
                'Workflow {0} does not exist in deployment {1}'.format(
                    workflow_id, deployment_id))
        workflow = deployment.workflows[workflow_id]

        execution_parameters = \
            BlueprintsManager._merge_and_validate_execution_parameters(
                workflow, workflow_id, parameters, allow_custom_parameters)

        execution_id = str(uuid.uuid4())

        new_execution = models.Execution(
            id=execution_id,
            status=models.Execution.PENDING,
            created_at=utils.get_formatted_timestamp(),
            blueprint_id=blueprint_id,
            workflow_id=workflow_id,
            deployment_id=deployment_id,
            error='',
            parameters=BlueprintsManager._get_only_user_execution_parameters(
                execution_parameters),
            is_system_workflow=False)

        self.sm.put_execution(new_execution)

        # executing the user workflow
        workflow_plugins = \
            deployment_update.deployment_plan[
                constants.WORKFLOW_PLUGINS_TO_INSTALL]
        self.workflow_client.execute_workflow(
            workflow_id,
            workflow,
            workflow_plugins=workflow_plugins,
            blueprint_id=blueprint_id,
            deployment_id=deployment_id,
            execution_id=execution_id,
            execution_parameters=execution_parameters)

        return new_execution
    def _execute_workflow(self,
                          deployment_update,
                          workflow_id,
                          parameters=None,
                          allow_custom_parameters=False,
                          force=False):
        """Executes the specified workflow

        :param deployment_update:
        :param workflow_id:
        :param parameters:
        :param allow_custom_parameters:
        :param force:
        :return:
        """
        deployment_id = deployment_update.deployment_id
        deployment = self.sm.get_deployment(deployment_id)
        blueprint_id = deployment.blueprint_id

        if workflow_id not in deployment.workflows:
            raise manager_exceptions.NonexistentWorkflowError(
                'Workflow {0} does not exist in deployment {1}'
                .format(workflow_id, deployment_id))
        workflow = deployment.workflows[workflow_id]

        execution_parameters = \
            BlueprintsManager._merge_and_validate_execution_parameters(
                workflow, workflow_id, parameters, allow_custom_parameters)

        execution_id = str(uuid.uuid4())

        new_execution = models.Execution(
            id=execution_id,
            status=models.Execution.PENDING,
            created_at=utils.get_formatted_timestamp(),
            blueprint_id=blueprint_id,
            workflow_id=workflow_id,
            deployment_id=deployment_id,
            error='',
            parameters=BlueprintsManager._get_only_user_execution_parameters(
                execution_parameters),
            is_system_workflow=False)

        self.sm.put_execution(new_execution.id, new_execution)

        # executing the user workflow
        workflow_plugins = \
            deployment_update.deployment_plan[
                constants.WORKFLOW_PLUGINS_TO_INSTALL]
        self.workflow_client.execute_workflow(
            workflow_id,
            workflow,
            workflow_plugins=workflow_plugins,
            blueprint_id=blueprint_id,
            deployment_id=deployment_id,
            execution_id=execution_id,
            execution_parameters=execution_parameters)

        return new_execution
Esempio n. 3
0
 def get(self, _include=None, **kwargs):
     args = self._args_parser.parse_args()
     deployment_id = args.get("deployment_id")
     deployment_id_filter = BlueprintsManager.create_filters_dict(deployment_id=deployment_id)
     modifications = get_storage_manager().deployment_modifications_list(
         filters=deployment_id_filter, include=_include
     )
     return modifications.items
Esempio n. 4
0
 def get(self, _include=None, **kwargs):
     """
     List node instances
     """
     args = self._args_parser.parse_args()
     deployment_id = args.get("deployment_id")
     node_id = args.get("node_name")
     params_filter = BlueprintsManager.create_filters_dict(deployment_id=deployment_id, node_id=node_id)
     node_instances = get_storage_manager().get_node_instances(filters=params_filter, include=_include)
     return node_instances.items
Esempio n. 5
0
    def get(self, _include=None, **kwargs):
        """List executions"""
        deployment_id = request.args.get("deployment_id")
        if deployment_id:
            get_blueprints_manager().get_deployment(deployment_id, include=["id"])
        is_include_system_workflows = verify_and_convert_bool(
            "include_system_workflows", request.args.get("include_system_workflows", "false")
        )

        deployment_id_filter = BlueprintsManager.create_filters_dict(deployment_id=deployment_id)
        executions = get_blueprints_manager().executions_list(
            is_include_system_workflows=is_include_system_workflows, include=_include, filters=deployment_id_filter
        )
        return executions.items
Esempio n. 6
0
 def get(self, _include=None, **kwargs):
     """
     List nodes
     """
     args = self._args_parser.parse_args()
     deployment_id = args.get("deployment_id")
     node_id = args.get("node_id")
     if deployment_id and node_id:
         try:
             nodes = [get_storage_manager().get_node(deployment_id, node_id)]
         except manager_exceptions.NotFoundError:
             nodes = []
     else:
         deployment_id_filter = BlueprintsManager.create_filters_dict(deployment_id=deployment_id)
         nodes = get_storage_manager().get_nodes(filters=deployment_id_filter, include=_include).items
     return nodes