Search in sources :

Example 16 with Usage

use of alien4cloud.model.common.Usage in project alien4cloud by alien4cloud.

the class OrchestratorController method disable.

@ApiOperation(value = "Disable an orchestrator. Destroys the instance of the orchestrator connector.", authorizations = { @Authorization("ADMIN") })
@RequestMapping(value = "/{id}/instance", method = RequestMethod.DELETE)
@PreAuthorize("hasAuthority('ADMIN')")
public RestResponse<List<Usage>> disable(@ApiParam(value = "Id of the orchestrator to enable", required = true) @PathVariable String id, @ApiParam(value = "This parameter is useful only when trying to disable the orchestrator, if deployments are performed using this orchestrator disable " + "operation will fail unnless the force flag is true", required = false) @RequestParam(required = false, defaultValue = "false") boolean force, @ApiParam(value = "In case an orchestrator with deployment is forced to be disabled, the user may decide to mark all deployments managed " + "by this orchestrator as ended.", required = false) @RequestParam(required = false, defaultValue = "false") boolean clearDeployments) {
    RestResponseBuilder<List<Usage>> responseBuilder = RestResponseBuilder.<List<Usage>>builder();
    Orchestrator orchestrator = orchestratorService.getOrFail(id);
    List<Usage> usages = orchestratorStateService.disable(orchestrator, force);
    if (CollectionUtils.isEmpty(usages)) {
        return responseBuilder.build();
    }
    return responseBuilder.data(usages).error(new RestError(RestErrorCode.RESOURCE_USED_ERROR.getCode(), "There are actives deployment with the orchestrator. It cannot be disabled.")).build();
}
Also used : Usage(alien4cloud.model.common.Usage) RestError(alien4cloud.rest.model.RestError) List(java.util.List) Orchestrator(alien4cloud.model.orchestrators.Orchestrator) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Usage (alien4cloud.model.common.Usage)16 Csar (org.alien4cloud.tosca.model.Csar)7 Application (alien4cloud.model.application.Application)4 Deployment (alien4cloud.model.deployment.Deployment)3 Location (alien4cloud.model.orchestrators.locations.Location)3 ApiOperation (io.swagger.annotations.ApiOperation)3 List (java.util.List)3 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ServiceResource (alien4cloud.model.service.ServiceResource)2 IOrchestratorPluginFactory (alien4cloud.orchestrators.plugin.IOrchestratorPluginFactory)2 PluginArchive (alien4cloud.orchestrators.plugin.model.PluginArchive)2 ServiceUsageRequestEvent (org.alien4cloud.alm.service.events.ServiceUsageRequestEvent)2 EventListener (org.springframework.context.event.EventListener)2 ApplicationEnvironmentService (alien4cloud.application.ApplicationEnvironmentService)1 Audit (alien4cloud.audit.annotation.Audit)1 FilterUtil.fromKeyValueCouples (alien4cloud.dao.FilterUtil.fromKeyValueCouples)1 IGenericSearchDAO (alien4cloud.dao.IGenericSearchDAO)1 GetMultipleDataResult (alien4cloud.dao.model.GetMultipleDataResult)1 LocationArchiveDeleteRequested (alien4cloud.events.LocationArchiveDeleteRequested)1