use of alien4cloud.model.orchestrators.locations.LocationResourceTemplateWithDependencies 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.LocationResourceTemplateWithDependencies 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()));
}
use of alien4cloud.model.orchestrators.locations.LocationResourceTemplateWithDependencies in project alien4cloud by alien4cloud.
the class AbstractLocationResourceSteps method createResourceTemplate.
public void createResourceTemplate(String resourceType, String resourceName, String archiveName, String archiveVersion, String orchestratorName, String locationName) throws IOException {
String orchestratorId = Context.getInstance().getOrchestratorId(orchestratorName);
String locationId = Context.getInstance().getLocationId(orchestratorId, locationName);
String restUrl = String.format(getBaseUrlFormat(), orchestratorId, locationId);
CreateLocationResourceTemplateRequest request = new CreateLocationResourceTemplateRequest();
request.setResourceName(resourceName);
request.setResourceType(resourceType);
request.setArchiveName(archiveName);
request.setArchiveVersion(archiveVersion);
String resp = Context.getRestClientInstance().postJSon(restUrl, JsonUtil.toString(request));
RestResponse<LocationResourceTemplateWithDependencies> response = JsonUtil.read(resp, LocationResourceTemplateWithDependencies.class, Context.getJsonMapper());
if (response.getError() == null && response.getData() != null) {
Context.getInstance().registerOrchestratorLocationResource(orchestratorId, locationId, response.getData().getResourceTemplate().getId(), resourceName);
}
Context.getInstance().registerRestResponse(resp);
}
Aggregations