예제 #1
0
    def post(self, id, phase):
        """
        Supports two stages of a plugin update.
        Phases:
            1. (PHASES.INITIAL) Creates a temporary blueprint and executes a
            deployment update (will update only the plugins) for all the
            deployments of the given blueprint.
            2. (PHASES.FINAL) Updates the original blueprint plan and deletes
            the temp one.

        :param id: the blueprint ID to update it's deployments' plugins if
        phase == PHASES.INITIAL, otherwise (phase == PHASES.FINAL) the plugin
        update ID.
        :param phase: either PHASES.INITIAL or PHASES.FINAL (internal).
        """
        if phase == PHASES.INITIAL:
            args = rest_utils.get_args_and_verify_arguments([
                Argument('force', type=boolean, required=False, default=False)
            ])
            return get_plugins_updates_manager().initiate_plugins_update(
                blueprint_id=id, force=args.get('force'))
        elif phase == PHASES.FINAL:
            return get_plugins_updates_manager().finalize(
                plugins_update_id=id)
예제 #2
0
 def get(self,
         _include=None,
         filters=None,
         pagination=None,
         sort=None,
         search=None,
         **_):
     """List plugins updates"""
     plugins_update = \
         get_plugins_updates_manager().list_plugins_updates(
             include=_include,
             filters=filters,
             pagination=pagination,
             sort=sort,
             substr_filters=search
         )
     return plugins_update
예제 #3
0
    def post(self, id, phase, **kwargs):
        """
        Supports two stages of a plugin update.
        Phases:
            1. (PHASES.INITIAL) Creates a temporary blueprint and executes a
            deployment update (will update only the plugins) for all the
            deployments of the given blueprint.
            2. (PHASES.FINAL) Updates the original blueprint plan and deletes
            the temp one.

        :param id: the blueprint ID to update it's deployments' plugins if
        phase == PHASES.INITIAL, otherwise (phase == PHASES.FINAL) the plugin
        update ID.
        :param phase: either PHASES.INITIAL or PHASES.FINAL (internal).
        """
        try:
            filters = rest_utils.get_json_and_verify_params({
                PLUGIN_NAMES: {
                    'type': list,
                    'optional': True
                },
                ALL_TO_LATEST: {
                    'type': bool,
                    'optional': True
                },
                TO_LATEST: {
                    'type': list,
                    'optional': True
                },
                ALL_TO_MINOR: {
                    'type': bool,
                    'optional': True
                },
                TO_MINOR: {
                    'type': list,
                    'optional': True
                },
                MAPPING: {
                    'type': dict,
                    'optional': True
                },
                FORCE: {
                    'type': bool,
                    'optional': True
                },
                AUTO_CORRECT_TYPES: {
                    'type': bool,
                    'optional': True
                },
                REEVALUATE_ACTIVE_STATUSES: {
                    'type': bool,
                    'optional': True
                },
            })
        except BadRequest:
            filters = {}
        auto_correct_types = filters.pop(AUTO_CORRECT_TYPES, False)
        reevaluate_active_statuses = filters.pop(REEVALUATE_ACTIVE_STATUSES,
                                                 False)
        if phase == PHASES.INITIAL:
            return get_plugins_updates_manager().initiate_plugins_update(
                blueprint_id=id,
                filters=filters,
                auto_correct_types=auto_correct_types,
                reevaluate_active_statuses=reevaluate_active_statuses)
        elif phase == PHASES.FINAL:
            return get_plugins_updates_manager().finalize(plugins_update_id=id)