Search in sources :

Example 1 with LocationResourceTemplateWithDependencies

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()));
}
Also used : PolicyType(org.alien4cloud.tosca.model.types.PolicyType) LocationResourceTemplateWithDependencies(alien4cloud.model.orchestrators.locations.LocationResourceTemplateWithDependencies) PolicyLocationResourceTemplate(alien4cloud.model.orchestrators.locations.PolicyLocationResourceTemplate) Location(alien4cloud.model.orchestrators.locations.Location)

Example 2 with LocationResourceTemplateWithDependencies

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()));
}
Also used : PolicyLocationResourceTemplate(alien4cloud.model.orchestrators.locations.PolicyLocationResourceTemplate) AbstractLocationResourceTemplate(alien4cloud.model.orchestrators.locations.AbstractLocationResourceTemplate) LocationResourceTemplate(alien4cloud.model.orchestrators.locations.LocationResourceTemplate) NodeType(org.alien4cloud.tosca.model.types.NodeType) LocationResourceTemplateWithDependencies(alien4cloud.model.orchestrators.locations.LocationResourceTemplateWithDependencies) Location(alien4cloud.model.orchestrators.locations.Location)

Example 3 with LocationResourceTemplateWithDependencies

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);
}
Also used : CreateLocationResourceTemplateRequest(alien4cloud.rest.orchestrator.model.CreateLocationResourceTemplateRequest) LocationResourceTemplateWithDependencies(alien4cloud.model.orchestrators.locations.LocationResourceTemplateWithDependencies)

Aggregations

LocationResourceTemplateWithDependencies (alien4cloud.model.orchestrators.locations.LocationResourceTemplateWithDependencies)3 Location (alien4cloud.model.orchestrators.locations.Location)2 PolicyLocationResourceTemplate (alien4cloud.model.orchestrators.locations.PolicyLocationResourceTemplate)2 AbstractLocationResourceTemplate (alien4cloud.model.orchestrators.locations.AbstractLocationResourceTemplate)1 LocationResourceTemplate (alien4cloud.model.orchestrators.locations.LocationResourceTemplate)1 CreateLocationResourceTemplateRequest (alien4cloud.rest.orchestrator.model.CreateLocationResourceTemplateRequest)1 NodeType (org.alien4cloud.tosca.model.types.NodeType)1 PolicyType (org.alien4cloud.tosca.model.types.PolicyType)1