def _commit(deployment_id):
        manager = get_deployment_updates_manager()
        request_json = request.args
        skip_install = verify_and_convert_bool(
            'skip_install', request_json.get('skip_install', 'false'))
        skip_uninstall = verify_and_convert_bool(
            'skip_uninstall', request_json.get('skip_uninstall', 'false'))
        force = verify_and_convert_bool('force',
                                        request_json.get('force', 'false'))
        workflow_id = request_json.get('workflow_id', None)

        if (skip_install or skip_uninstall) and workflow_id:
            raise manager_exceptions.BadParametersError(
                'skip_install has been set to {0}, skip uninstall has been'
                ' set to {1}, and a custom workflow {2} has been set to '
                'replace "update". However, skip_install and '
                'skip_uninstall are mutually exclusive with a custom '
                'workflow'.format(skip_install, skip_uninstall, workflow_id))

        manager.validate_no_active_updates_per_deployment(
            deployment_id=deployment_id, force=force)

        deployment_update, _ = \
            UploadedBlueprintsDeploymentUpdateManager(). \
            receive_uploaded_data(deployment_id)

        manager.extract_steps_from_deployment_update(deployment_update.id)

        return manager.commit_deployment_update(deployment_update.id,
                                                skip_install=skip_install,
                                                skip_uninstall=skip_uninstall,
                                                workflow_id=workflow_id)
 def post(self, snapshot_id):
     verify_json_content_type()
     request_json = request.json
     verify_parameter_in_request_body('recreate_deployments_envs',
                                      request_json)
     recreate_deployments_envs = verify_and_convert_bool(
         'recreate_deployments_envs',
         request_json['recreate_deployments_envs'])
     force = verify_and_convert_bool('force', request_json['force'])
     execution = get_blueprints_manager().restore_snapshot(
         snapshot_id, recreate_deployments_envs, force)
     return execution, 200
    def put(self, snapshot_id):
        verify_json_content_type()
        request_json = request.json
        include_metrics = verify_and_convert_bool(
            'include_metrics', request_json.get('include_metrics', 'false'))
        include_credentials = verify_and_convert_bool(
            'include_credentials',
            request_json.get('include_credentials', 'true'))

        execution = get_blueprints_manager().create_snapshot(
            snapshot_id, include_metrics, include_credentials)
        return execution, 201
 def post(self, snapshot_id):
     verify_json_content_type()
     request_json = request.json
     verify_parameter_in_request_body('recreate_deployments_envs',
                                      request_json)
     recreate_deployments_envs = verify_and_convert_bool(
         'recreate_deployments_envs',
         request_json['recreate_deployments_envs']
     )
     force = verify_and_convert_bool('force', request_json['force'])
     execution = get_blueprints_manager().restore_snapshot(
         snapshot_id,
         recreate_deployments_envs,
         force
     )
     return execution, 200
Beispiel #5
0
 def post(self, snapshot_id):
     verify_json_content_type()
     request_json = request.json
     verify_parameter_in_request_body('recreate_deployments_envs',
                                      request_json)
     recreate_deployments_envs = verify_and_convert_bool(
         'recreate_deployments_envs',
         request_json['recreate_deployments_envs'])
     bypass_maintenance = is_bypass_maintenance_mode()
     force = verify_and_convert_bool('force', request_json['force'])
     default_timeout_sec = 300
     request_timeout = request_json.get('timeout', default_timeout_sec)
     timeout = convert_to_int(request_timeout)
     execution = get_blueprints_manager().restore_snapshot(
         snapshot_id, recreate_deployments_envs, force, bypass_maintenance,
         timeout)
     return execution, 200
    def put(self, snapshot_id):
        verify_json_content_type()
        request_json = request.json
        include_metrics = verify_and_convert_bool(
            'include_metrics',
            request_json.get('include_metrics', 'false')
        )
        include_credentials = verify_and_convert_bool(
            'include_credentials',
            request_json.get('include_credentials', 'true')
        )

        execution = get_blueprints_manager().create_snapshot(
            snapshot_id,
            include_metrics,
            include_credentials
        )
        return execution, 201
    def _commit(deployment_id):
        manager = get_deployment_updates_manager()
        request_json = request.args
        skip_install = verify_and_convert_bool(
                'skip_install',
                request_json.get('skip_install', 'false'))
        skip_uninstall = verify_and_convert_bool(
                'skip_uninstall',
                request_json.get('skip_uninstall', 'false'))
        force = verify_and_convert_bool(
            'force',
            request_json.get('force', 'false'))
        workflow_id = request_json.get('workflow_id', None)

        if (skip_install or skip_uninstall) and workflow_id:
            raise manager_exceptions.BadParametersError(
                'skip_install has been set to {0}, skip uninstall has been'
                ' set to {1}, and a custom workflow {2} has been set to '
                'replace "update". However, skip_install and '
                'skip_uninstall are mutually exclusive with a custom '
                'workflow'.format(skip_install,
                                  skip_uninstall,
                                  workflow_id))

        manager.validate_no_active_updates_per_deployment(
            deployment_id=deployment_id, force=force)

        deployment_update, _ = \
            UploadedBlueprintsDeploymentUpdateManager(). \
            receive_uploaded_data(deployment_id)

        manager.extract_steps_from_deployment_update(
            deployment_update.id)

        return manager.commit_deployment_update(
            deployment_update.id,
            skip_install=skip_install,
            skip_uninstall=skip_uninstall,
            workflow_id=workflow_id)
 def post(self, snapshot_id):
     verify_json_content_type()
     request_json = request.json
     verify_parameter_in_request_body('recreate_deployments_envs',
                                      request_json)
     recreate_deployments_envs = verify_and_convert_bool(
         'recreate_deployments_envs',
         request_json['recreate_deployments_envs']
     )
     bypass_maintenance = is_bypass_maintenance_mode()
     force = verify_and_convert_bool('force', request_json['force'])
     default_timeout_sec = 300
     request_timeout = request_json.get('timeout', default_timeout_sec)
     timeout = convert_to_int(request_timeout)
     execution = get_blueprints_manager().restore_snapshot(
         snapshot_id,
         recreate_deployments_envs,
         force,
         bypass_maintenance,
         timeout
     )
     return execution, 200
    def get(self, _include=None, filters=None, pagination=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'))

        executions = get_blueprints_manager().executions_list(
            filters=filters, pagination=pagination,
            is_include_system_workflows=is_include_system_workflows,
            include=_include)
        return executions
 def delete(self, plugin_id, **kwargs):
     """
     Delete plugin by ID
     """
     verify_json_content_type()
     request_json = request.json
     force = verify_and_convert_bool('force',
                                     request_json.get('force', False))
     try:
         return get_blueprints_manager().remove_plugin(plugin_id=plugin_id,
                                                       force=force)
     except manager_exceptions.ManagerException:
         raise
     except manager_exceptions.ExecutionTimeout:
         tp, ex, tb = sys.exc_info()
         raise manager_exceptions.PluginInstallationTimeout(
             'Timed out during plugin un-installation. ({0}: {1})'.format(
                 tp.__name__, ex)), None, tb
     except Exception:
         tp, ex, tb = sys.exc_info()
         raise manager_exceptions.PluginInstallationError(
             'Failed during plugin un-installation. ({0}: {1})'.format(
                 tp.__name__, ex)), None, tb
 def delete(self, plugin_id, **kwargs):
     """
     Delete plugin by ID
     """
     verify_json_content_type()
     request_json = request.json
     force = verify_and_convert_bool('force', request_json.get('force',
                                                               False))
     try:
         return get_blueprints_manager().remove_plugin(plugin_id=plugin_id,
                                                       force=force)
     except manager_exceptions.ManagerException:
         raise
     except manager_exceptions.ExecutionTimeout:
         tp, ex, tb = sys.exc_info()
         raise manager_exceptions.PluginInstallationTimeout(
             'Timed out during plugin un-installation. ({0}: {1})'
             .format(tp.__name__, ex)), None, tb
     except Exception:
         tp, ex, tb = sys.exc_info()
         raise manager_exceptions.PluginInstallationError(
             'Failed during plugin un-installation. ({0}: {1})'
             .format(tp.__name__, ex)), None, tb