Пример #1
0
    def _execute_update_workflow(self,
                                 dep_update,
                                 node_instances,
                                 modified_entity_ids,
                                 skip_install=False,
                                 skip_uninstall=False,
                                 skip_reinstall=False,
                                 workflow_id=None,
                                 ignore_failure=False,
                                 install_first=False,
                                 reinstall_list=None,
                                 central_plugins_to_install=None,
                                 central_plugins_to_uninstall=None,
                                 update_plugins=True):
        """Executed the update workflow or a custom workflow

        :param dep_update: deployment update object
        :param node_instances: a dictionary of modification type and
        add_node.modification instances
        :param modified_entity_ids: the entire add_node.modification entities
        list (by id)
        :param skip_install: if to skip installation of node instances.
        :param skip_uninstall: if to skip uninstallation of node instances.
        :param skip_reinstall: if to skip reinstallation of node instances.
        :param workflow_id: the update workflow id
        :param ignore_failure: if to ignore failures.
        :param install_first: if to install the node instances before
        uninstalling them.
        :param reinstall_list: list of node instances to reinstall.
        :param central_plugins_to_install: plugins to install that have the
        central_deployment_agent as the executor.
        :param central_plugins_to_uninstall: plugins to uninstall that have the
        central_deployment_agent as the executor.
        :param update_plugins: whether or not to perform plugin updates.

        :return: an Execution object.
        """
        added_instances = node_instances[NODE_MOD_TYPES.ADDED_AND_RELATED]
        extended_instances = \
            node_instances[NODE_MOD_TYPES.EXTENDED_AND_RELATED]
        reduced_instances = node_instances[NODE_MOD_TYPES.REDUCED_AND_RELATED]
        removed_instances = node_instances[NODE_MOD_TYPES.REMOVED_AND_RELATED]
        added_instance_ids = extract_ids(
            added_instances.get(NODE_MOD_TYPES.AFFECTED))
        removed_instance_ids = extract_ids(
            removed_instances.get(NODE_MOD_TYPES.AFFECTED))
        reinstall_list = self._update_reinstall_list(
            reinstall_list, added_instance_ids, removed_instance_ids,
            modified_entity_ids, dep_update, skip_reinstall)
        parameters = {
            # needed in order to finalize the commit
            'update_id':
            dep_update.id,

            # For any added node instance
            'added_instance_ids':
            added_instance_ids,
            'added_target_instances_ids':
            extract_ids(added_instances.get(NODE_MOD_TYPES.RELATED)),

            # encapsulated all the change entity_ids (in a dictionary with
            # 'node' and 'relationship' keys.
            'modified_entity_ids':
            modified_entity_ids,

            # Any nodes which were extended (positive modification)
            'extended_instance_ids':
            extract_ids(extended_instances.get(NODE_MOD_TYPES.AFFECTED)),
            'extend_target_instance_ids':
            extract_ids(extended_instances.get(NODE_MOD_TYPES.RELATED)),

            # Any nodes which were reduced (negative modification)
            'reduced_instance_ids':
            extract_ids(reduced_instances.get(NODE_MOD_TYPES.AFFECTED)),
            'reduce_target_instance_ids':
            extract_ids(reduced_instances.get(NODE_MOD_TYPES.RELATED)),

            # Any nodes which were removed as a whole
            'removed_instance_ids':
            removed_instance_ids,
            'remove_target_instance_ids':
            extract_ids(removed_instances.get(NODE_MOD_TYPES.RELATED)),

            # Whether or not execute install/uninstall/reinstall,
            # order of execution, behavior in failure while uninstalling, and
            # whether or not to update the plugins.
            'skip_install':
            skip_install,
            'skip_uninstall':
            skip_uninstall,
            'ignore_failure':
            ignore_failure,
            'install_first':
            install_first,
            'update_plugins':
            update_plugins,

            # Plugins that are executed by the central deployment agent and
            # need to be un/installed
            'central_plugins_to_install':
            central_plugins_to_install,
            'central_plugins_to_uninstall':
            central_plugins_to_uninstall,

            # List of node-instances to reinstall
            'node_instances_to_reinstall':
            reinstall_list
        }
        return get_resource_manager().execute_workflow(
            dep_update.deployment.id,
            workflow_id or DEFAULT_DEPLOYMENT_UPDATE_WORKFLOW,
            blueprint_id=dep_update.new_blueprint_id,
            parameters=parameters,
            allow_custom_parameters=True,
            allow_overlapping_running_wf=True)
Пример #2
0
    def _execute_update_workflow(self,
                                 dep_update,
                                 node_instances,
                                 modified_entity_ids,
                                 skip_install=False,
                                 skip_uninstall=False,
                                 workflow_id=None):
        """Executed the update workflow or a custom workflow

        :param dep_update:
        :param node_instances: a dictionary of modification type and
        add_node.modification instances
        :param modified_entity_ids: the entire add_node.modification entities
        list (by id)
        :return:
        """
        added_instances = node_instances[NODE_MOD_TYPES.ADDED_AND_RELATED]
        extended_instances = \
            node_instances[NODE_MOD_TYPES.EXTENDED_AND_RELATED]
        reduced_instances = node_instances[NODE_MOD_TYPES.REDUCED_AND_RELATED]
        removed_instances = node_instances[NODE_MOD_TYPES.REMOVED_AND_RELATED]

        parameters = {
            # needed in order to finalize the commit
            'update_id': dep_update.id,

            # For any added node instance
            'added_instance_ids':
                extract_ids(added_instances.get(NODE_MOD_TYPES.AFFECTED)),
            'added_target_instances_ids':
                extract_ids(added_instances.get(NODE_MOD_TYPES.RELATED)),

            # encapsulated all the change entity_ids (in a dictionary with
            # 'node' and 'relationship' keys.
            'modified_entity_ids': modified_entity_ids,

            # Any nodes which were extended (positive modification)
            'extended_instance_ids':
                extract_ids(extended_instances.get(NODE_MOD_TYPES.AFFECTED)),
            'extend_target_instance_ids':
                extract_ids(extended_instances.get(NODE_MOD_TYPES.RELATED)),

            # Any nodes which were reduced (negative modification)
            'reduced_instance_ids':
                extract_ids(reduced_instances.get(NODE_MOD_TYPES.AFFECTED)),
            'reduce_target_instance_ids':
                extract_ids(reduced_instances.get(NODE_MOD_TYPES.RELATED)),

            # Any nodes which were removed as a whole
            'removed_instance_ids':
                extract_ids(removed_instances.get(NODE_MOD_TYPES.AFFECTED)),
            'remove_target_instance_ids':
                extract_ids(removed_instances.get(NODE_MOD_TYPES.RELATED))
        }

        if not workflow_id:
            # Whether or not execute install or uninstall
            parameters['skip_install'] = skip_install
            parameters['skip_uninstall'] = skip_uninstall

        return self._execute_workflow(
                deployment_update=dep_update,
                workflow_id=workflow_id or DEFAULT_DEPLOYMENT_UPDATE_WORKFLOW,
                parameters=parameters)
Пример #3
0
    def _execute_update_workflow(self,
                                 dep_update,
                                 node_instances,
                                 modified_entity_ids,
                                 skip_install=False,
                                 skip_uninstall=False,
                                 workflow_id=None):
        """Executed the update workflow or a custom workflow

        :param dep_update:
        :param node_instances: a dictionary of modification type and
        add_node.modification instances
        :param modified_entity_ids: the entire add_node.modification entities
        list (by id)
        :return:
        """
        added_instances = node_instances[NODE_MOD_TYPES.ADDED_AND_RELATED]
        extended_instances = \
            node_instances[NODE_MOD_TYPES.EXTENDED_AND_RELATED]
        reduced_instances = node_instances[NODE_MOD_TYPES.REDUCED_AND_RELATED]
        removed_instances = node_instances[NODE_MOD_TYPES.REMOVED_AND_RELATED]

        parameters = {
            # needed in order to finalize the commit
            'update_id': dep_update.id,

            # For any added node instance
            'added_instance_ids':
                extract_ids(added_instances.get(NODE_MOD_TYPES.AFFECTED)),
            'added_target_instances_ids':
                extract_ids(added_instances.get(NODE_MOD_TYPES.RELATED)),

            # encapsulated all the change entity_ids (in a dictionary with
            # 'node' and 'relationship' keys.
            'modified_entity_ids': modified_entity_ids,

            # Any nodes which were extended (positive modification)
            'extended_instance_ids':
                extract_ids(extended_instances.get(NODE_MOD_TYPES.AFFECTED)),
            'extend_target_instance_ids':
                extract_ids(extended_instances.get(NODE_MOD_TYPES.RELATED)),

            # Any nodes which were reduced (negative modification)
            'reduced_instance_ids':
                extract_ids(reduced_instances.get(NODE_MOD_TYPES.AFFECTED)),
            'reduce_target_instance_ids':
                extract_ids(reduced_instances.get(NODE_MOD_TYPES.RELATED)),

            # Any nodes which were removed as a whole
            'removed_instance_ids':
                extract_ids(removed_instances.get(NODE_MOD_TYPES.AFFECTED)),
            'remove_target_instance_ids':
                extract_ids(removed_instances.get(NODE_MOD_TYPES.RELATED))
        }

        if not workflow_id:
            # Whether or not execute install or uninstall
            parameters['skip_install'] = skip_install
            parameters['skip_uninstall'] = skip_uninstall

        return self._execute_workflow(
                deployment_update=dep_update,
                workflow_id=workflow_id or DEFAULT_DEPLOYMENT_UPDATE_WORKFLOW,
                parameters=parameters)
Пример #4
0
    def _execute_update_workflow(self,
                                 dep_update,
                                 node_instances,
                                 modified_entity_ids,
                                 skip_install=False,
                                 skip_uninstall=False,
                                 skip_reinstall=False,
                                 workflow_id=None,
                                 ignore_failure=False,
                                 install_first=False,
                                 reinstall_list=None):
        """Executed the update workflow or a custom workflow

        :param dep_update: deployment update object
        :param node_instances: a dictionary of modification type and
        add_node.modification instances
        :param modified_entity_ids: the entire add_node.modification entities
        list (by id)
        :return: Execution object
        """
        added_instances = node_instances[NODE_MOD_TYPES.ADDED_AND_RELATED]
        extended_instances = \
            node_instances[NODE_MOD_TYPES.EXTENDED_AND_RELATED]
        reduced_instances = node_instances[NODE_MOD_TYPES.REDUCED_AND_RELATED]
        removed_instances = node_instances[NODE_MOD_TYPES.REMOVED_AND_RELATED]
        added_instance_ids = extract_ids(
            added_instances.get(NODE_MOD_TYPES.AFFECTED))
        removed_instance_ids = extract_ids(
            removed_instances.get(NODE_MOD_TYPES.AFFECTED))
        reinstall_list = self._update_reinstall_list(
            reinstall_list, added_instance_ids, removed_instance_ids,
            modified_entity_ids, dep_update, skip_reinstall)
        parameters = {
            # needed in order to finalize the commit
            'update_id':
            dep_update.id,

            # For any added node instance
            'added_instance_ids':
            added_instance_ids,
            'added_target_instances_ids':
            extract_ids(added_instances.get(NODE_MOD_TYPES.RELATED)),

            # encapsulated all the change entity_ids (in a dictionary with
            # 'node' and 'relationship' keys.
            'modified_entity_ids':
            modified_entity_ids,

            # Any nodes which were extended (positive modification)
            'extended_instance_ids':
            extract_ids(extended_instances.get(NODE_MOD_TYPES.AFFECTED)),
            'extend_target_instance_ids':
            extract_ids(extended_instances.get(NODE_MOD_TYPES.RELATED)),

            # Any nodes which were reduced (negative modification)
            'reduced_instance_ids':
            extract_ids(reduced_instances.get(NODE_MOD_TYPES.AFFECTED)),
            'reduce_target_instance_ids':
            extract_ids(reduced_instances.get(NODE_MOD_TYPES.RELATED)),

            # Any nodes which were removed as a whole
            'removed_instance_ids':
            removed_instance_ids,
            'remove_target_instance_ids':
            extract_ids(removed_instances.get(NODE_MOD_TYPES.RELATED)),

            # Whether or not execute install/uninstall/reinstall,
            # order of execution, and behavior in failure while uninstalling
            'skip_install':
            skip_install,
            'skip_uninstall':
            skip_uninstall,
            'ignore_failure':
            ignore_failure,
            'install_first':
            install_first,

            # List of node-instances to reinstall
            'node_instances_to_reinstall':
            reinstall_list
        }
        return self._execute_workflow(deployment_update=dep_update,
                                      workflow_id=workflow_id
                                      or DEFAULT_DEPLOYMENT_UPDATE_WORKFLOW,
                                      parameters=parameters,
                                      allow_custom_parameters=True)
Пример #5
0
    def _execute_update_workflow(self,
                                 dep_update,
                                 node_instances,
                                 modified_entity_ids,
                                 skip_install=False,
                                 skip_uninstall=False,
                                 skip_reinstall=False,
                                 workflow_id=None,
                                 ignore_failure=False,
                                 install_first=False,
                                 reinstall_list=None):
        """Executed the update workflow or a custom workflow

        :param dep_update: deployment update object
        :param node_instances: a dictionary of modification type and
        add_node.modification instances
        :param modified_entity_ids: the entire add_node.modification entities
        list (by id)
        :return: Execution object
        """
        added_instances = node_instances[NODE_MOD_TYPES.ADDED_AND_RELATED]
        extended_instances = \
            node_instances[NODE_MOD_TYPES.EXTENDED_AND_RELATED]
        reduced_instances = node_instances[NODE_MOD_TYPES.REDUCED_AND_RELATED]
        removed_instances = node_instances[NODE_MOD_TYPES.REMOVED_AND_RELATED]
        added_instance_ids = extract_ids(
            added_instances.get(NODE_MOD_TYPES.AFFECTED))
        removed_instance_ids = extract_ids(
            removed_instances.get(NODE_MOD_TYPES.AFFECTED))
        reinstall_list = self._update_reinstall_list(reinstall_list,
                                                     added_instance_ids,
                                                     removed_instance_ids,
                                                     modified_entity_ids,
                                                     dep_update,
                                                     skip_reinstall)
        parameters = {
            # needed in order to finalize the commit
            'update_id': dep_update.id,

            # For any added node instance
            'added_instance_ids': added_instance_ids,
            'added_target_instances_ids':
                extract_ids(added_instances.get(NODE_MOD_TYPES.RELATED)),

            # encapsulated all the change entity_ids (in a dictionary with
            # 'node' and 'relationship' keys.
            'modified_entity_ids': modified_entity_ids,

            # Any nodes which were extended (positive modification)
            'extended_instance_ids':
                extract_ids(extended_instances.get(NODE_MOD_TYPES.AFFECTED)),
            'extend_target_instance_ids':
                extract_ids(extended_instances.get(NODE_MOD_TYPES.RELATED)),

            # Any nodes which were reduced (negative modification)
            'reduced_instance_ids':
                extract_ids(reduced_instances.get(NODE_MOD_TYPES.AFFECTED)),
            'reduce_target_instance_ids':
                extract_ids(reduced_instances.get(NODE_MOD_TYPES.RELATED)),

            # Any nodes which were removed as a whole
            'removed_instance_ids': removed_instance_ids,
            'remove_target_instance_ids':
                extract_ids(removed_instances.get(NODE_MOD_TYPES.RELATED)),

            # Whether or not execute install/uninstall/reinstall,
            # order of execution, and behavior in failure while uninstalling
            'skip_install': skip_install,
            'skip_uninstall': skip_uninstall,
            'ignore_failure': ignore_failure,
            'install_first': install_first,

            # List of node-instances to reinstall
            'node_instances_to_reinstall': reinstall_list
        }
        return self._execute_workflow(
            deployment_update=dep_update,
            workflow_id=workflow_id or DEFAULT_DEPLOYMENT_UPDATE_WORKFLOW,
            parameters=parameters,
            allow_custom_parameters=True
        )