use of alien4cloud.model.orchestrators.locations.Location in project alien4cloud by alien4cloud.
the class UndeployService method undeploy.
private void undeploy(SecretProviderConfigurationAndCredentials secretProviderConfigurationAndCredentials, final Deployment deployment) {
deploymentLockService.doWithDeploymentWriteLock(deployment.getOrchestratorDeploymentId(), () -> {
log.info("Un-deploying deployment [{}] on orchestrator [{}]", deployment.getId(), deployment.getOrchestratorId());
IOrchestratorPlugin orchestratorPlugin = orchestratorPluginService.getOrFail(deployment.getOrchestratorId());
DeploymentTopology deployedTopology = deploymentRuntimeStateService.getRuntimeTopology(deployment.getId());
Map<String, String> locationIds = TopologyLocationUtils.getLocationIds(deployedTopology);
Map<String, Location> locations = deploymentTopologyService.getLocations(locationIds);
SecretProviderConfigurationAndCredentials authResponse = null;
if (secretProviderService.isSecretProvided(secretProviderConfigurationAndCredentials)) {
authResponse = secretProviderService.generateToken(locations, secretProviderConfigurationAndCredentials.getSecretProviderConfiguration().getPluginName(), secretProviderConfigurationAndCredentials.getCredentials());
}
PaaSDeploymentContext deploymentContext = new PaaSDeploymentContext(deployment, deployedTopology, authResponse);
orchestratorPlugin.undeploy(deploymentContext, new IPaaSCallback<ResponseEntity>() {
@Override
public void onSuccess(ResponseEntity data) {
deploymentService.markUndeployed(deployment);
log.info("Un-deployed deployment [{}] on orchestrator [{}]", deployment.getId(), deployment.getOrchestratorId());
}
@Override
public void onFailure(Throwable throwable) {
log.warn("Fail while Undeploying deployment [{}] on orchestrator [{}]", deployment.getId(), deployment.getOrchestratorId());
}
});
return null;
});
}
use of alien4cloud.model.orchestrators.locations.Location in project alien4cloud by alien4cloud.
the class LocationResourceService method duplicatePolicyTemplate.
@Override
public LocationResourceTemplateWithDependencies duplicatePolicyTemplate(String resourceId) {
PolicyLocationResourceTemplate policyLocationResourceTemplate = getOrFail(resourceId);
policyLocationResourceTemplate.setId(UUID.randomUUID().toString());
policyLocationResourceTemplate.setName(policyLocationResourceTemplate.getName() + "_" + "copy");
Location location = locationService.getOrFail(policyLocationResourceTemplate.getLocationId());
PolicyType resourceType = csarRepoSearchService.getRequiredElementInDependencies(PolicyType.class, policyLocationResourceTemplate.getTemplate().getType(), location.getDependencies());
publishCreatedEventAndSaveResource(location, policyLocationResourceTemplate, resourceType);
return new LocationResourceTemplateWithDependencies(policyLocationResourceTemplate, Sets.newHashSet(location.getDependencies()));
}
use of alien4cloud.model.orchestrators.locations.Location in project alien4cloud by alien4cloud.
the class LocationResourceService method fillLocationResourceTypes.
private void fillLocationResourceTypes(Collection<? extends AbstractLocationResourceTemplate> resourceTemplates, IResourceTypeFiller resourceTypeFiller) {
Map<String, Set<String>> resourceTypesByLocationId = Maps.newHashMap();
for (AbstractLocationResourceTemplate resourceTemplate : resourceTemplates) {
if (!resourceTemplate.isService()) {
Set<String> locationResourceTypesSet = resourceTypesByLocationId.computeIfAbsent(resourceTemplate.getLocationId(), k -> Sets.newHashSet());
locationResourceTypesSet.add(resourceTemplate.getTemplate().getType());
}
}
for (Map.Entry<String, Set<String>> resourceTypeByLocationIdEntry : resourceTypesByLocationId.entrySet()) {
String locationId = resourceTypeByLocationIdEntry.getKey();
Set<String> exposedTypes = resourceTypeByLocationIdEntry.getValue();
Location location = locationService.getOrFail(locationId);
resourceTypeFiller.process(exposedTypes, location.getDependencies());
}
}
use of alien4cloud.model.orchestrators.locations.Location in project alien4cloud by alien4cloud.
the class LocationResourceService method setTemplateProperty.
/*
* (non-Javadoc)
*
* @see alien4cloud.orchestrators.locations.services.ILocationResourceService#setTemplateProperty(java.lang.String, java.lang.String,
* java.lang.Object)
*/
@Override
public void setTemplateProperty(String resourceId, String propertyName, Object propertyValue) throws ConstraintValueDoNotMatchPropertyTypeException, ConstraintViolationException {
AbstractLocationResourceTemplate resourceTemplate = getOrFail(resourceId);
Location location = locationService.getOrFail(resourceTemplate.getLocationId());
AbstractInheritableToscaType resourceType = (AbstractInheritableToscaType) csarRepoSearchService.getRequiredElementInDependencies(AbstractToscaType.class, resourceTemplate.getTemplate().getType(), location.getDependencies());
if (!safe(resourceType.getProperties()).containsKey(propertyName)) {
throw new NotFoundException("Property [" + propertyName + "] is not found in type [" + resourceType.getElementId() + "]");
}
propertyService.setPropertyValue(location.getDependencies(), resourceTemplate.getTemplate(), resourceType.getProperties().get(propertyName), propertyName, propertyValue);
saveResource(resourceTemplate);
}
use of alien4cloud.model.orchestrators.locations.Location in project alien4cloud by alien4cloud.
the class LocationResourceService method duplicateResourceTemplate.
@Override
public LocationResourceTemplateWithDependencies duplicateResourceTemplate(String resourceId) {
LocationResourceTemplate locationResourceTemplate = getOrFail(resourceId);
locationResourceTemplate.setId(UUID.randomUUID().toString());
locationResourceTemplate.setName(locationResourceTemplate.getName() + "_" + "copy");
locationResourceTemplate.setGenerated(false);
Location location = locationService.getOrFail(locationResourceTemplate.getLocationId());
NodeType resourceType = csarRepoSearchService.getRequiredElementInDependencies(NodeType.class, locationResourceTemplate.getTemplate().getType(), location.getDependencies());
publishCreatedEventAndSaveResource(location, locationResourceTemplate, resourceType);
return new LocationResourceTemplateWithDependencies(locationResourceTemplate, Sets.newHashSet(location.getDependencies()));
}
Aggregations