def patch(self, snapshot_id): """ Update snapshot status by id """ verify_json_content_type() request_json = request.json verify_parameter_in_request_body('status', request_json) get_blueprints_manager().update_snapshot_status( snapshot_id, request_json['status'], request_json.get('error', ''))
def post(self, update_id): verify_json_content_type() request_json = request.json manager = get_deployment_updates_manager() update_step = \ manager.create_deployment_update_step( update_id, request_json.get('operation'), request_json.get('entity_type'), request_json.get('entity_id') ) return update_step
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 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') ) bypass_maintenance = is_bypass_maintenance_mode() execution = get_blueprints_manager().create_snapshot( snapshot_id, include_metrics, include_credentials, bypass_maintenance ) 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'] ) 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 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
def patch(self, **kwargs): """ modifies provider context configuration """ verify_json_content_type() request_json = request.json verify_parameter_in_request_body('global_parallel_executions_limit', request_json) provider_ctx = get_storage_manager().get_provider_context() bootstrap_ctx = provider_ctx.context.get('cloudify', {}) transient_dep_workers_mode_enabled = bootstrap_ctx.get( 'transient_deployment_workers_mode', {}).get( 'enabled', TRANSIENT_WORKERS_MODE_ENABLED_DEFAULT) if not transient_dep_workers_mode_enabled: raise manager_exceptions.BadParametersError( "can't modify global_parallel_executions_limit since transient" ' deployment workers mode is disabled') limit = request_json['global_parallel_executions_limit'] if type(limit) is not int: raise manager_exceptions.BadParametersError( 'global_parallel_executions_limit parameter should be of type' ' int, but is instead of type {0}'.format( type(limit).__name__)) trans_dep_workers_mode = bootstrap_ctx.get( 'transient_deployment_workers_mode', {}) trans_dep_workers_mode['global_parallel_executions_limit'] = limit bootstrap_ctx['transient_deployment_workers_mode'] = \ trans_dep_workers_mode provider_ctx.context['cloudify'] = bootstrap_ctx get_storage_manager().update_provider_context(provider_ctx) return get_storage_manager().get_provider_context()