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.");
}
}
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;
}
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);
}
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);
}
}
}
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();
}
Aggregations