Search in sources :

Example 6 with Location

use of alien4cloud.model.orchestrators.locations.Location in project alien4cloud by alien4cloud.

the class LocationService method ensureMultipleLocations.

/**
 * ensure that we cannot create more locations than supported by the orchestrator
 *
 * @param orchestratorId
 */
private void ensureMultipleLocations(String orchestratorId) {
    LocationSupport locationSupport = orchestratorService.getLocationSupport(orchestratorId);
    List<Location> locations = getAll(orchestratorId);
    if (!locationSupport.isMultipleLocations() && !locations.isEmpty()) {
        throw new LocationSupportException("The orchestrator <" + orchestratorId + "> already has a location and does'nt support multiple locations.");
    }
}
Also used : LocationSupport(alien4cloud.model.orchestrators.locations.LocationSupport) LocationSupportException(alien4cloud.exception.LocationSupportException) Location(alien4cloud.model.orchestrators.locations.Location)

Example 7 with Location

use of alien4cloud.model.orchestrators.locations.Location in project alien4cloud by alien4cloud.

the class LocationService method autoConfigure.

/**
 * Trigger plugin auto-configuration for the given location.
 *
 * @param locationId Id of the location.
 */
public List<LocationResourceTemplate> autoConfigure(String locationId) throws UnsupportedOperationException {
    Location location = getOrFail(locationId);
    Orchestrator orchestrator = orchestratorService.getOrFail(location.getOrchestratorId());
    List<LocationResourceTemplate> generatedLocationResources = autoConfigure(orchestrator, location);
    if (CollectionUtils.isEmpty(generatedLocationResources)) {
        generatedLocationResources = Lists.newArrayList();
    }
    return generatedLocationResources;
}
Also used : LocationResourceTemplate(alien4cloud.model.orchestrators.locations.LocationResourceTemplate) Orchestrator(alien4cloud.model.orchestrators.Orchestrator) Location(alien4cloud.model.orchestrators.locations.Location)

Example 8 with Location

use of alien4cloud.model.orchestrators.locations.Location in project alien4cloud by alien4cloud.

the class LocationService method onLocationResourceUpdated.

@EventListener
public synchronized void onLocationResourceUpdated(OnLocationResourceChangeEvent event) {
    // When a location resource changes we do update the location last edition date
    Location location = getOrFail(event.getLocationId());
    location.setLastUpdateDate(new Date());
    alienDAO.save(location);
}
Also used : Date(java.util.Date) Location(alien4cloud.model.orchestrators.locations.Location) EventListener(org.springframework.context.event.EventListener)

Example 9 with Location

use of alien4cloud.model.orchestrators.locations.Location in project alien4cloud by alien4cloud.

the class LocationService method autoConfigure.

/**
 * Auto-configure locations using the given location auto-configurer.
 *
 * @param orchestrator The id of the orchestrator that own the locations.
 * @param locationAutoConfigurer The auto-configurer to use for getting locations.
 */
public void autoConfigure(Orchestrator orchestrator, ILocationAutoConfigurer locationAutoConfigurer) {
    List<Location> locations = locationAutoConfigurer.getLocations();
    for (Location location : locations) {
        // 
        location.setId(UUID.randomUUID().toString());
        location.setOrchestratorId(orchestrator.getId());
        try {
            createLocation(orchestrator, location, location.getInfrastructureType());
        } catch (AlreadyExistException e) {
            log.debug("Location <" + location.getName() + "> is already configured for this location - skipping", e);
        }
    }
}
Also used : AlreadyExistException(alien4cloud.exception.AlreadyExistException) Location(alien4cloud.model.orchestrators.locations.Location)

Example 10 with Location

use of alien4cloud.model.orchestrators.locations.Location in project alien4cloud by alien4cloud.

the class LocationSecurityController method revokeGroupAccess.

/**
 * Revoke the group's authorisation to access the location
 *
 * @param locationId The id of the location.
 * @param groupId The authorized group.
 * @return A {@link Void} {@link RestResponse}.
 */
@ApiOperation(value = "Revoke the group's authorisation to access the location", notes = "Only user with ADMIN role can revoke access to the location.")
@RequestMapping(value = "/groups/{groupId}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("hasAuthority('ADMIN')")
@Audit
public synchronized RestResponse<List<GroupDTO>> revokeGroupAccess(@PathVariable String orchestratorId, @PathVariable String locationId, @PathVariable String groupId) {
    Location location = locationService.getLocation(orchestratorId, locationId);
    resourcePermissionService.revokePermission(location, Subject.GROUP, groupId);
    List<GroupDTO> groups = GroupDTO.convert(resourcePermissionService.getAuthorizedGroups(location));
    return RestResponseBuilder.<List<GroupDTO>>builder().data(groups).build();
}
Also used : GroupDTO(alien4cloud.rest.orchestrator.model.GroupDTO) List(java.util.List) Location(alien4cloud.model.orchestrators.locations.Location) Audit(alien4cloud.audit.annotation.Audit) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Location (alien4cloud.model.orchestrators.locations.Location)80 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)31 ApiOperation (io.swagger.annotations.ApiOperation)30 List (java.util.List)28 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)28 Audit (alien4cloud.audit.annotation.Audit)21 ApplicationEnvironment (alien4cloud.model.application.ApplicationEnvironment)15 LocationService (alien4cloud.orchestrators.locations.services.LocationService)13 Set (java.util.Set)13 Collectors (java.util.stream.Collectors)13 Application (alien4cloud.model.application.Application)12 AbstractLocationResourceTemplate (alien4cloud.model.orchestrators.locations.AbstractLocationResourceTemplate)12 RestResponse (alien4cloud.rest.model.RestResponse)12 RestResponseBuilder (alien4cloud.rest.model.RestResponseBuilder)12 GroupDTO (alien4cloud.rest.orchestrator.model.GroupDTO)12 UserDTO (alien4cloud.rest.orchestrator.model.UserDTO)12 Resource (javax.annotation.Resource)12 ApplicationEnvironmentService (alien4cloud.application.ApplicationEnvironmentService)11 ResourcePermissionService (alien4cloud.authorization.ResourcePermissionService)11 ApplicationEnvironmentAuthorizationUpdateRequest (alien4cloud.rest.orchestrator.model.ApplicationEnvironmentAuthorizationUpdateRequest)11