From 8b2f66b4067cf45a521e6b9809da1b2e684537fc Mon Sep 17 00:00:00 2001 From: Lorenzo Biava Date: Mon, 13 Jun 2016 14:33:30 +0200 Subject: [PATCH 01/19] Add basic Image ID substitution in TOSCA template NOTE that CMDB image data retrieval is still a stub See #53 --- .../reply/orchestrator/dto/CloudProvider.java | 12 + .../it/reply/orchestrator/dto/cmdb/Image.java | 227 ++++++++++++++++++ .../dto/deployment/DeploymentMessage.java | 11 + .../orchestrator/service/CmdbService.java | 5 + .../orchestrator/service/CmdbServiceImpl.java | 19 ++ .../service/DeploymentServiceImpl.java | 2 + .../orchestrator/service/ToscaService.java | 12 + .../service/ToscaServiceImpl.java | 121 ++++++++++ .../service/commands/GetCMDBData.java | 4 +- .../service/commands/UpdateDeployment.java | 4 + .../deployment/providers/ImServiceImpl.java | 1 + 11 files changed, 417 insertions(+), 1 deletion(-) create mode 100644 src/main/java/it/reply/orchestrator/dto/cmdb/Image.java diff --git a/src/main/java/it/reply/orchestrator/dto/CloudProvider.java b/src/main/java/it/reply/orchestrator/dto/CloudProvider.java index e2e2c3a79e..0dfb5356d9 100644 --- a/src/main/java/it/reply/orchestrator/dto/CloudProvider.java +++ b/src/main/java/it/reply/orchestrator/dto/CloudProvider.java @@ -1,11 +1,14 @@ package it.reply.orchestrator.dto; +import it.reply.orchestrator.dto.cmdb.Image; import it.reply.orchestrator.dto.cmdb.Provider; import it.reply.orchestrator.dto.cmdb.Service; import it.reply.orchestrator.dto.cmdb.Type; import java.io.Serializable; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -24,6 +27,7 @@ public class CloudProvider implements Serializable { private Provider cmdbProviderData; private Map cmdbProviderServices = new HashMap<>(); + private List cmdbProviderImages = new ArrayList<>(); public CloudProvider(String id) { this.id = id; @@ -61,6 +65,14 @@ public void setCmdbProviderServices(Map cmdbProviderServices) { this.cmdbProviderServices = cmdbProviderServices; } + public List getCmdbProviderImages() { + return cmdbProviderImages; + } + + public void setCmdbProviderImages(List cmdbProviderImages) { + this.cmdbProviderImages = cmdbProviderImages; + } + public Service getCmbdProviderServiceByType(Type type) { // FIXME implement getCmbdProviderServiceByType throw new UnsupportedOperationException("NOT IMPLEMENTED"); diff --git a/src/main/java/it/reply/orchestrator/dto/cmdb/Image.java b/src/main/java/it/reply/orchestrator/dto/cmdb/Image.java new file mode 100644 index 0000000000..abeb93357d --- /dev/null +++ b/src/main/java/it/reply/orchestrator/dto/cmdb/Image.java @@ -0,0 +1,227 @@ +package it.reply.orchestrator.dto.cmdb; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.builder.ToStringBuilder; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import javax.annotation.Generated; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@Generated("org.jsonschema2pojo") +@JsonPropertyOrder({ "image_id", "image_name", "architecture", "type", "distribution", "version" }) +public class Image implements Serializable { + + private static final long serialVersionUID = 6029586902515892534L; + + @JsonProperty("image_id") + private String imageId; + @JsonProperty("image_name") + private String imageName; + @JsonProperty("architecture") + private String architecture; + @JsonProperty("type") + private String type; + @JsonProperty("distribution") + private String distribution; + @JsonProperty("version") + private String version; + @JsonIgnore + private Map additionalProperties = new HashMap(); + + /** + * + * @return The imageId + */ + @JsonProperty("image_id") + public String getImageId() { + return imageId; + } + + /** + * + * @param imageId + * The image_id + */ + @JsonProperty("image_id") + public void setImageId(String imageId) { + this.imageId = imageId; + } + + public Image withImageId(String imageId) { + this.imageId = imageId; + return this; + } + + /** + * + * @return The imageName + */ + @JsonProperty("image_name") + public String getImageName() { + return imageName; + } + + /** + * + * @param imageName + * The image_name + */ + @JsonProperty("image_name") + public void setImageName(String imageName) { + this.imageName = imageName; + } + + public Image withImageName(String imageName) { + this.imageName = imageName; + return this; + } + + /** + * + * @return The architecture + */ + @JsonProperty("architecture") + public String getArchitecture() { + return architecture; + } + + /** + * + * @param architecture + * The architecture + */ + @JsonProperty("architecture") + public void setArchitecture(String architecture) { + this.architecture = architecture; + } + + public Image withArchitecture(String architecture) { + this.architecture = architecture; + return this; + } + + /** + * + * @return The type + */ + @JsonProperty("type") + public String getType() { + return type; + } + + /** + * + * @param type + * The type + */ + @JsonProperty("type") + public void setType(String type) { + this.type = type; + } + + public Image withType(String type) { + this.type = type; + return this; + } + + /** + * + * @return The distribution + */ + @JsonProperty("distribution") + public String getDistribution() { + return distribution; + } + + /** + * + * @param distribution + * The distribution + */ + @JsonProperty("distribution") + public void setDistribution(String distribution) { + this.distribution = distribution; + } + + public Image withDistribution(String distribution) { + this.distribution = distribution; + return this; + } + + /** + * + * @return The version + */ + @JsonProperty("version") + public String getVersion() { + return version; + } + + /** + * + * @param version + * The version + */ + @JsonProperty("version") + public void setVersion(String version) { + this.version = version; + } + + public Image withVersion(String version) { + this.version = version; + return this; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public Image withAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + return this; + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(imageId).append(imageName).append(architecture).append(type) + .append(distribution).append(version).append(additionalProperties).toHashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + if ((other instanceof Image) == false) { + return false; + } + Image rhs = ((Image) other); + return new EqualsBuilder().append(imageId, rhs.imageId).append(imageName, rhs.imageName) + .append(architecture, rhs.architecture).append(type, rhs.type) + .append(distribution, rhs.distribution).append(version, rhs.version) + .append(additionalProperties, rhs.additionalProperties).isEquals(); + } + +} \ No newline at end of file diff --git a/src/main/java/it/reply/orchestrator/dto/deployment/DeploymentMessage.java b/src/main/java/it/reply/orchestrator/dto/deployment/DeploymentMessage.java index e44132d1d4..2c1e96a345 100644 --- a/src/main/java/it/reply/orchestrator/dto/deployment/DeploymentMessage.java +++ b/src/main/java/it/reply/orchestrator/dto/deployment/DeploymentMessage.java @@ -2,6 +2,7 @@ import it.reply.orchestrator.dal.entity.Deployment; import it.reply.orchestrator.dal.entity.Resource; +import it.reply.orchestrator.dto.CloudProvider; import it.reply.orchestrator.enums.DeploymentProvider; import it.reply.orchestrator.service.deployment.providers.ChronosServiceImpl.IndigoJob; @@ -35,6 +36,8 @@ public class DeploymentMessage implements Serializable { private boolean pollComplete; private boolean skipPollInterval; + private CloudProvider chosenCloudProvider; + /** * TEMPORARY Chronos Job Graph (to avoid regenerating the template representation each time). */ @@ -113,6 +116,14 @@ public void setSkipPollInterval(boolean skipPollInterval) { this.skipPollInterval = skipPollInterval; } + public CloudProvider getChosenCloudProvider() { + return chosenCloudProvider; + } + + public void setChosenCloudProvider(CloudProvider chosenCloudProvider) { + this.chosenCloudProvider = chosenCloudProvider; + } + @Override public String toString() { return "DeploymentMessage [deploymentId=" + deploymentId + ", deploymentProvider=" diff --git a/src/main/java/it/reply/orchestrator/service/CmdbService.java b/src/main/java/it/reply/orchestrator/service/CmdbService.java index 488598654c..38b917fda2 100644 --- a/src/main/java/it/reply/orchestrator/service/CmdbService.java +++ b/src/main/java/it/reply/orchestrator/service/CmdbService.java @@ -1,13 +1,18 @@ package it.reply.orchestrator.service; +import it.reply.orchestrator.dto.cmdb.Image; import it.reply.orchestrator.dto.cmdb.Provider; import it.reply.orchestrator.dto.cmdb.Service; +import java.util.List; + public interface CmdbService { public Service getServiceById(String id); public Provider getProviderById(String id); + public List getImagesByProvider(String providerId); + public String getUrl(); } diff --git a/src/main/java/it/reply/orchestrator/service/CmdbServiceImpl.java b/src/main/java/it/reply/orchestrator/service/CmdbServiceImpl.java index ff9f9be26d..db95ac7c3b 100644 --- a/src/main/java/it/reply/orchestrator/service/CmdbServiceImpl.java +++ b/src/main/java/it/reply/orchestrator/service/CmdbServiceImpl.java @@ -1,5 +1,6 @@ package it.reply.orchestrator.service; +import it.reply.orchestrator.dto.cmdb.Image; import it.reply.orchestrator.dto.cmdb.Provider; import it.reply.orchestrator.exception.service.DeploymentException; @@ -10,6 +11,9 @@ import org.springframework.stereotype.Service; import org.springframework.web.client.RestTemplate; +import java.util.Arrays; +import java.util.List; + @Service @PropertySource("classpath:cmdb/cmdb.properties") public class CmdbServiceImpl implements CmdbService { @@ -54,4 +58,19 @@ public Provider getProviderById(String id) { + response.getStatusCode().toString() + " " + response.getStatusCode().getReasonPhrase()); } + @Override + public List getImagesByProvider(String providerId) { + providerId = "STUB:" + providerId; + // FIXME: Stub + return Arrays.asList( + new Image().withImageName("indigodatacloud/ubuntu-sshd").withImageId(providerId + "/5") + .withArchitecture("x86_64").withType("linux").withDistribution("ubuntu") + .withVersion("14.04"), + new Image().withImageName("linux-ubuntu-14.04").withImageId(providerId + "/5") + .withArchitecture("x86_64").withType("linux").withDistribution("ubuntu") + .withVersion("14.04"), + new Image().withImageName("indigodatacloudapps/docker-galaxy") + .withImageId(providerId + "/13")); + } + } diff --git a/src/main/java/it/reply/orchestrator/service/DeploymentServiceImpl.java b/src/main/java/it/reply/orchestrator/service/DeploymentServiceImpl.java index 7182978397..e261221ca9 100644 --- a/src/main/java/it/reply/orchestrator/service/DeploymentServiceImpl.java +++ b/src/main/java/it/reply/orchestrator/service/DeploymentServiceImpl.java @@ -184,6 +184,8 @@ public void deleteDeployment(String uuid) { Map params = new HashMap<>(); params.put("DEPLOYMENT_ID", deployment.getId()); + // FIXME: if the WF fails before setting deployment.getDeploymentProvider(), we should just + // delete the failed deployment ? // FIXME: Temporary - just for test params.put(WorkflowConstants.WF_PARAM_DEPLOYMENT_TYPE, deployment.getDeploymentProvider().name()); diff --git a/src/main/java/it/reply/orchestrator/service/ToscaService.java b/src/main/java/it/reply/orchestrator/service/ToscaService.java index 97ee6b418a..2c74686e57 100644 --- a/src/main/java/it/reply/orchestrator/service/ToscaService.java +++ b/src/main/java/it/reply/orchestrator/service/ToscaService.java @@ -12,6 +12,7 @@ import com.sun.istack.NotNull; +import it.reply.orchestrator.dto.CloudProvider; import it.reply.orchestrator.exception.service.ToscaException; import java.io.IOException; @@ -43,6 +44,17 @@ public String customizeTemplate(@Nonnull String toscaTemplate, @NotNull String d public void addDeploymentId(ArchiveRoot parsingResult, String deploymentId); + /** + * Replace images data in 'tosca.capabilities.indigo.OperatingSystem' capabilities in the TOSCA + * template with the provider-specific identifier. + * + * @param parsingResult + * the in-memory TOSCA template. + * @param cloudProvider + * the chosen cloud provider data. + */ + public void contextualizeImages(ArchiveRoot parsingResult, CloudProvider cloudProvider); + /** * Verifies that all the template's required inputs are present in the user's input list. * diff --git a/src/main/java/it/reply/orchestrator/service/ToscaServiceImpl.java b/src/main/java/it/reply/orchestrator/service/ToscaServiceImpl.java index 993690b3c2..b44c40a680 100644 --- a/src/main/java/it/reply/orchestrator/service/ToscaServiceImpl.java +++ b/src/main/java/it/reply/orchestrator/service/ToscaServiceImpl.java @@ -24,6 +24,8 @@ import com.google.common.io.ByteStreams; +import it.reply.orchestrator.dto.CloudProvider; +import it.reply.orchestrator.dto.cmdb.Image; import it.reply.orchestrator.exception.service.ToscaException; import org.apache.logging.log4j.LogManager; @@ -299,6 +301,125 @@ private void checkParsingErrors(List errorList) throws ToscaExcept } + @Override + public void contextualizeImages(ArchiveRoot parsingResult, CloudProvider cloudProvider) { + try { + Map nodes = parsingResult.getTopology().getNodeTemplates(); + for (Map.Entry entry : nodes.entrySet()) { + NodeTemplate node = entry.getValue(); + // Only indigo.Compute nodes are relevant + // FIXME: Check inheritance of tosca.nodes.indigo.Compute + if (node.getType().equals("tosca.nodes.indigo.Compute")) { + Capability osCapability = null; + if (node.getCapabilities() == null + || (osCapability = node.getCapabilities().get("os")) == null) { + // The node doesn't have an OS Capability -> need to add a dummy one to hold a random + // image for underlying deployment systems + LOG.debug(String.format("Generating default OperatingSystem capability for node <%s>", + node.getName())); + if (node.getCapabilities() == null) { + node.setCapabilities(new HashMap<>()); + } + osCapability = new Capability(); + osCapability.setType("tosca.capabilities.indigo.OperatingSystem"); + node.getCapabilities().put("os", osCapability); + } + + // We've got an OS capability -> Check the attributes to find best match for the image + Image imageMetadata = new Image(); + if (osCapability.getProperties().get("image") != null) { + imageMetadata.setImageName( + (String) getCapabilityPropertyValueByName(osCapability, "image").getValue()); + } + if (osCapability.getProperties().get("architecture") != null) { + imageMetadata.setArchitecture( + (String) getCapabilityPropertyValueByName(osCapability, "architecture").getValue()); + } + if (osCapability.getProperties().get("type") != null) { + imageMetadata.setType( + (String) getCapabilityPropertyValueByName(osCapability, "type").getValue()); + } + if (osCapability.getProperties().get("distribution") != null) { + imageMetadata.setDistribution( + (String) getCapabilityPropertyValueByName(osCapability, "distribution").getValue()); + } + if (osCapability.getProperties().get("version") != null) { + imageMetadata.setVersion( + (String) getCapabilityPropertyValueByName(osCapability, "version").getValue()); + } + + Image image = getBestImageForCloudProvider(imageMetadata, cloudProvider); + + // No image match found -> throw error + if (image == null) { + LOG.error( + String.format("Failed to found a match in provider <%s> for image metadata <%s>", + cloudProvider.getId(), imageMetadata)); + throw new IllegalArgumentException( + String.format("Failed to found a match in provider <%s> for image metadata <%s>", + cloudProvider.getId(), imageMetadata)); + } + + // Found a good image -> replace the image attribute with the provider-specific ID + LOG.debug(String.format( + "Found image match in <%s> for image metadata <%s>, provider-specific image id <%s>", + cloudProvider.getId(), imageMetadata, image.getImageId())); + ScalarPropertyValue scalarPropertyValue = new ScalarPropertyValue(image.getImageId()); + scalarPropertyValue.setPrintable(true); + osCapability.getProperties().put("image", scalarPropertyValue); + + } + } + } catch (Exception ex) { + throw new RuntimeException("Failed to contextualize images: " + ex.getMessage(), ex); + } + } + + protected Image getBestImageForCloudProvider(Image imageMetadata, CloudProvider cloudProvider) { + for (Image image : cloudProvider.getCmdbProviderImages()) { + // FIXME: Image name has actually priority on the other fields? + // FIXME: How to handle exact image name not found, but possibility to use a base image + + // Ansible roles? + + // Match image name (has priority) + if (imageMetadata.getImageName() != null) { + if (!imageMetadata.getImageName().equals(image.getImageName())) { + continue; + } + return image; + } + + // Match or skip image based on each additional optional attribute + if (imageMetadata.getType() != null) { + if (!imageMetadata.getType().equals(image.getType())) { + continue; + } + } + + if (imageMetadata.getArchitecture() != null) { + if (!imageMetadata.getArchitecture().equals(image.getArchitecture())) { + continue; + } + } + + if (imageMetadata.getDistribution() != null) { + if (!imageMetadata.getDistribution().equals(image.getDistribution())) { + continue; + } + } + + if (imageMetadata.getVersion() != null) { + if (!imageMetadata.getVersion().equals(image.getVersion())) { + continue; + } + } + + return image; + } + return null; + + } + @Override public void addDeploymentId(ArchiveRoot parsingResult, String deploymentId) { Map nodes = parsingResult.getTopology().getNodeTemplates(); diff --git a/src/main/java/it/reply/orchestrator/service/commands/GetCMDBData.java b/src/main/java/it/reply/orchestrator/service/commands/GetCMDBData.java index f2f2d253b2..8f0f0a276b 100644 --- a/src/main/java/it/reply/orchestrator/service/commands/GetCMDBData.java +++ b/src/main/java/it/reply/orchestrator/service/commands/GetCMDBData.java @@ -34,7 +34,9 @@ public class GetCMDBData extends BaseRankCloudProvidersCommand { serviceEntry.setValue(cmdbService.getServiceById(serviceEntry.getKey())); } - // TODO Get other data (i.e. OneData, Images mapping, etc) + cp.setCmdbProviderImages(cmdbService.getImagesByProvider(cp.getId())); + + // FIXME Get other data (i.e. OneData, Images mapping, etc) } return rankCloudProvidersMessage; diff --git a/src/main/java/it/reply/orchestrator/service/commands/UpdateDeployment.java b/src/main/java/it/reply/orchestrator/service/commands/UpdateDeployment.java index d2ab991f25..62d18b61bf 100644 --- a/src/main/java/it/reply/orchestrator/service/commands/UpdateDeployment.java +++ b/src/main/java/it/reply/orchestrator/service/commands/UpdateDeployment.java @@ -67,6 +67,10 @@ public ExecutionResults customExecute(CommandContext ctx) throws Exception { } LOG.debug("Selected Cloud Provider is: {}", chosenCp); + // Set the chosen CP in deploymentMessage + deploymentMessage.setChosenCloudProvider( + rankCloudProvidersMessage.getCloudProviders().get(chosenCp.getName())); + // Update Deployment Deployment deployment = deploymentRepository.findOne(rankCloudProvidersMessage.getDeploymentId()); diff --git a/src/main/java/it/reply/orchestrator/service/deployment/providers/ImServiceImpl.java b/src/main/java/it/reply/orchestrator/service/deployment/providers/ImServiceImpl.java index 7dd9f82d73..3363cdbb2a 100644 --- a/src/main/java/it/reply/orchestrator/service/deployment/providers/ImServiceImpl.java +++ b/src/main/java/it/reply/orchestrator/service/deployment/providers/ImServiceImpl.java @@ -188,6 +188,7 @@ public boolean doDeploy(DeploymentMessage deploymentMessage) { ArchiveRoot ar = toscaService.prepareTemplate(deployment.getTemplate(), deployment.getParameters()); toscaService.addDeploymentId(ar, deploymentUuid); + toscaService.contextualizeImages(ar, deploymentMessage.getChosenCloudProvider()); String imCustomizedTemplate = toscaService.getTemplateFromTopology(ar); // FIXME this is a trick used only for demo purpose From e0e4b7eac093adb63361302851fd84d89a541d7a Mon Sep 17 00:00:00 2001 From: Lorenzo Biava Date: Wed, 15 Jun 2016 15:06:31 +0200 Subject: [PATCH 02/19] Fix image choice to follow vanilla image + Ansible fallback mode - Basically, for INDIGO use case, if an image with the specified name cannot be found it means that a vanilla image must be used and later the Ansible setup will be run. The vanilla image will be chosen according to the other metadata information(arch, type, distro, version) See #53 --- .../service/ToscaServiceImpl.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/java/it/reply/orchestrator/service/ToscaServiceImpl.java b/src/main/java/it/reply/orchestrator/service/ToscaServiceImpl.java index b44c40a680..16c1af979f 100644 --- a/src/main/java/it/reply/orchestrator/service/ToscaServiceImpl.java +++ b/src/main/java/it/reply/orchestrator/service/ToscaServiceImpl.java @@ -377,16 +377,19 @@ public void contextualizeImages(ArchiveRoot parsingResult, CloudProvider cloudPr protected Image getBestImageForCloudProvider(Image imageMetadata, CloudProvider cloudProvider) { for (Image image : cloudProvider.getCmdbProviderImages()) { - // FIXME: Image name has actually priority on the other fields? - // FIXME: How to handle exact image name not found, but possibility to use a base image + - // Ansible roles? - - // Match image name (has priority) + // Match image name first (for INDIGO specific use case, if the image cannot be found with the + // specified name it means that a base image + Ansible configuration have to be used -> the + // base image will be chosen with the other filters and image metadata - architecture, type, + // distro, version) if (imageMetadata.getImageName() != null) { - if (!imageMetadata.getImageName().equals(image.getImageName())) { - continue; + if (imageMetadata.getImageName().equals(image.getImageName())) { + LOG.debug("Image <{}> found with name <{}>", image.getImageId(), + imageMetadata.getImageName()); + return image; + } else { + LOG.debug("Image not found with name <{}>, trying with other fields: <{}>", + imageMetadata.getImageName(), imageMetadata); } - return image; } // Match or skip image based on each additional optional attribute @@ -414,6 +417,7 @@ protected Image getBestImageForCloudProvider(Image imageMetadata, CloudProvider } } + LOG.debug("Image <{}> found with fields: <{}>", imageMetadata.getImageId(), imageMetadata); return image; } return null; From 0c9e80cc11fe88ae015adeaace33a594c797ff4a Mon Sep 17 00:00:00 2001 From: Lorenzo Biava Date: Thu, 16 Jun 2016 13:03:52 +0200 Subject: [PATCH 03/19] Add image substitution to IM Update deployment logic See #53 --- .../deployment/providers/ImServiceImpl.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main/java/it/reply/orchestrator/service/deployment/providers/ImServiceImpl.java b/src/main/java/it/reply/orchestrator/service/deployment/providers/ImServiceImpl.java index 3363cdbb2a..9b9a0eaeaf 100644 --- a/src/main/java/it/reply/orchestrator/service/deployment/providers/ImServiceImpl.java +++ b/src/main/java/it/reply/orchestrator/service/deployment/providers/ImServiceImpl.java @@ -3,7 +3,6 @@ import alien4cloud.model.topology.NodeTemplate; import alien4cloud.tosca.model.ArchiveRoot; import alien4cloud.tosca.parser.ParsingException; -import alien4cloud.tosca.parser.ParsingResult; import es.upv.i3m.grycap.im.InfrastructureManager; import es.upv.i3m.grycap.im.States; @@ -328,23 +327,28 @@ public boolean doUpdate(DeploymentMessage deploymentMessage, String template) { // Check if count is increased or if there is a removal list, other kinds of update are // discarded - ParsingResult oldParsingResult; - ParsingResult newParsingResult; + ArchiveRoot oldAr; + ArchiveRoot newAr; try { // FIXME Fugly - oldParsingResult = toscaService.getArchiveRootFromTemplate(deployment.getTemplate()); - template = toscaService.customizeTemplate(template, deployment.getId()); - newParsingResult = toscaService.getArchiveRootFromTemplate(template); + + // Get TOSCA in-memory repr. of current template + oldAr = toscaService.prepareTemplate(deployment.getTemplate(), deployment.getParameters()); + + // Get TOSCA in-memory repr. of new template + newAr = toscaService.prepareTemplate(template, deployment.getParameters()); + toscaService.addDeploymentId(newAr, deployment.getId()); + toscaService.contextualizeImages(newAr, deploymentMessage.getChosenCloudProvider()); } catch (ParsingException | IOException | ToscaException ex) { throw new OrchestratorException(ex); } // find Count nodes into new and old template - Map oldNodes = toscaService.getCountNodes(oldParsingResult.getResult()); - Map newNodes = toscaService.getCountNodes(newParsingResult.getResult()); + Map oldNodes = toscaService.getCountNodes(oldAr); + Map newNodes = toscaService.getCountNodes(newAr); try { // Create the new template with the nodes to be added - ArchiveRoot root = newParsingResult.getResult(); + ArchiveRoot root = newAr; Map nodes = new HashMap<>(); // List of vmIds to be removed From b92a7093ad60444b7f30585af79d65bffc758dd3 Mon Sep 17 00:00:00 2001 From: Lorenzo Biava Date: Fri, 17 Jun 2016 11:20:50 +0200 Subject: [PATCH 04/19] Fix integration tests (CloudProviderRanker was using MockServer) CloudProviderRanker was using MockServer, making others fail. See #56 --- .../cloud-provider-ranker.properties | 2 +- .../CloudProviderRankerServiceTest.java | 53 ++++--- .../orchestrator/service/CmdbServiceIT.java | 133 ++++++++---------- .../orchestrator/service/SlamServiceIT.java | 69 ++++----- 4 files changed, 111 insertions(+), 146 deletions(-) diff --git a/src/main/resources/cloud-provider-ranker/cloud-provider-ranker.properties b/src/main/resources/cloud-provider-ranker/cloud-provider-ranker.properties index a511fbeca2..769a77e76e 100644 --- a/src/main/resources/cloud-provider-ranker/cloud-provider-ranker.properties +++ b/src/main/resources/cloud-provider-ranker/cloud-provider-ranker.properties @@ -1 +1 @@ -cloud-provider-ranker.url=http://a.it/ \ No newline at end of file +cloud-provider-ranker.url=http://indigo-ranker.pd.infn.it:8443/rank \ No newline at end of file diff --git a/src/test/java/it/reply/orchestrator/service/CloudProviderRankerServiceTest.java b/src/test/java/it/reply/orchestrator/service/CloudProviderRankerServiceTest.java index 66243a56f4..5eddf5c6cd 100644 --- a/src/test/java/it/reply/orchestrator/service/CloudProviderRankerServiceTest.java +++ b/src/test/java/it/reply/orchestrator/service/CloudProviderRankerServiceTest.java @@ -1,58 +1,55 @@ package it.reply.orchestrator.service; import static org.junit.Assert.assertEquals; -import static org.springframework.test.web.client.match.MockRestRequestMatchers.method; -import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; -import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; import it.reply.orchestrator.config.specific.WebAppConfigurationAwareIT; +import it.reply.orchestrator.dto.RankCloudProvidersMessage; import it.reply.orchestrator.dto.ranker.CloudProviderRankerRequest; +import it.reply.orchestrator.dto.ranker.Monitoring; import it.reply.orchestrator.dto.ranker.RankedCloudProvider; import it.reply.utils.json.JsonUtility; -import org.junit.Before; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpMethod; -import org.springframework.http.MediaType; -import org.springframework.test.web.client.MockRestServiceServer; -import org.springframework.web.client.RestTemplate; import java.util.Arrays; import java.util.List; - +import java.util.stream.Collectors; + +/** + * This integration test makes real request to the CloudProviderRanker APIs. + * + * @author l.biava + * + */ public class CloudProviderRankerServiceTest extends WebAppConfigurationAwareIT { @Autowired private CloudProviderRankerService cloudProviderRankerService; - private MockRestServiceServer mockServer; + @Test + public void rankProviders() throws Exception { - @Autowired - private RestTemplate restTemplate; + RankCloudProvidersMessage rcpm = JsonUtility.deserializeJson( + "{\"deploymentId\":\"mmd34483-d937-4578-bfdb-ebe196bf82dd\",\"slamPreferences\":{\"preferences\":[{\"customer\":\"indigo-dc\",\"preferences\":[{\"service_type\":\"compute\",\"priority\":[{\"sla_id\":\"4401ac5dc8cfbbb737b0a02575ee53f6\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e8040f\",\"weight\":0.5},{\"sla_id\":\"4401ac5dc8cfbbb737b0a02575ee3b58\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e6f4bc\",\"weight\":0.5}]}],\"id\":\"4401ac5dc8cfbbb737b0a02575ee0e55\"}],\"sla\":[{\"customer\":\"indigo-dc\",\"provider\":\"provider-UPV-GRyCAP\",\"start_date\":\"11.01.2016+15:50:00\",\"end_date\":\"11.02.2016+15:50:00\",\"services\":[{\"type\":\"compute\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e6f4bc\",\"targets\":[{\"type\":\"public_ip\",\"unit\":\"none\",\"restrictions\":{\"total_guaranteed\":10}}]}],\"id\":\"4401ac5dc8cfbbb737b0a02575ee3b58\"},{\"customer\":\"indigo-dc\",\"provider\":\"provider-RECAS-BARI\",\"start_date\":\"11.01.2016+15:50:00\",\"end_date\":\"11.02.2016+15:50:00\",\"services\":[{\"type\":\"compute\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e8040f\",\"targets\":[{\"type\":\"computing_time\",\"unit\":\"h\",\"restrictions\":{\"total_guaranteed\":200}}]}],\"id\":\"4401ac5dc8cfbbb737b0a02575ee53f6\"}]},\"cloudProviders\":{\"provider-RECAS-BARI\":{\"name\":\"provider-RECAS-BARI\",\"id\":\"provider-RECAS-BARI\",\"cmdbProviderData\":{\"_id\":\"provider-RECAS-BARI\",\"_rev\":\"1-c7dbe4d8be30aa4c0f14d3ad0411d962\",\"data\":{\"id\":\"476\",\"primary_key\":\"83757G0\",\"name\":\"RECAS-BARI\",\"country\":\"Italy\",\"country_code\":\"IT\",\"roc\":\"NGI_IT\",\"subgrid\":\"\",\"giis_url\":\"ldap://cloud-bdii.recas.ba.infn.it:2170/GLUE2DomainID=RECAS-BARI,o=glue\"},\"type\":\"provider\"},\"cmdbProviderServices\":{\"4401ac5dc8cfbbb737b0a02575e8040f\":{\"_id\":\"4401ac5dc8cfbbb737b0a02575e8040f\",\"_rev\":\"2-be00f87438604f04d353233daabc562c\",\"data\":{\"service_type\":\"eu.egi.cloud.vm-management.occi\",\"endpoint\":\"http://onedock.i3m.upv.es:11443\",\"provider_id\":\"provider-UPV-GRyCAP\",\"type\":\"compute\"},\"type\":\"service\"}}},\"provider-UPV-GRyCAP\":{\"name\":\"provider-UPV-GRyCAP\",\"id\":\"provider-UPV-GRyCAP\",\"cmdbProviderData\":{\"_id\":\"provider-UPV-GRyCAP\",\"_rev\":\"1-0a5ba48b2d6e0c26d36b0e3e81175352\",\"data\":{\"id\":\"458\",\"primary_key\":\"135G0\",\"name\":\"UPV-GRyCAP\",\"country\":\"Spain\",\"country_code\":\"ES\",\"roc\":\"NGI_IBERGRID\",\"subgrid\":\"\",\"giis_url\":\"ldap://ngiesbdii.i3m.upv.es:2170/mds-vo-name=UPV-GRyCAP,o=grid\"},\"type\":\"provider\"},\"cmdbProviderServices\":{\"4401ac5dc8cfbbb737b0a02575e6f4bc\":{\"_id\":\"4401ac5dc8cfbbb737b0a02575e6f4bc\",\"_rev\":\"1-256d36283315ea9bb045e6d5038657b6\",\"data\":{\"service_type\":\"eu.egi.cloud.vm-management.openstack\",\"endpoint\":\"http://cloud.recas.ba.infn.it:5000/v2.0\",\"provider_id\":\"provider-RECAS-BARI\",\"type\":\"compute\"},\"type\":\"service\"}}}},\"cloudProvidersMonitoringData\":{\"provider-RECAS-BARI\":[{\"metricName\":\"OCCI Create VM availability\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI Create VM availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI CreateVM Response Time\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI CreateVM Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI CreateVM Result\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI CreateVM Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI Delete VM Availability\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI Delete VM Availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI DeleteVM Response Time\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI DeleteVM Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI DeleteVM Result\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI DeleteVM Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"General OCCI API Availability\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..General OCCI API Availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"General OCCI API Response Time\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..General OCCI API Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"General OCCI API Result\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..General OCCI API Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI Inspect VM availability\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI Inspect VM availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI InspectVM Response Time\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI InspectVM Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI InspectVM Result\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI InspectVM Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]}],\"provider-UPV-GRyCAP\":[{\"metricName\":\"OCCI Create VM availability\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI Create VM availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI CreateVM Response Time\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI CreateVM Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI CreateVM Result\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI CreateVM Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI Delete VM Availability\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI Delete VM Availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI DeleteVM Response Time\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI DeleteVM Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI DeleteVM Result\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI DeleteVM Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"General OCCI API Availability\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..General OCCI API Availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"General OCCI API Response Time\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..General OCCI API Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"General OCCI API Result\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..General OCCI API Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI Inspect VM availability\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI Inspect VM availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI InspectVM Response Time\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI InspectVM Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI InspectVM Result\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI InspectVM Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]}]},\"rankedCloudProviders\":[]}", + RankCloudProvidersMessage.class); - @Before - public void setUp() { - mockServer = MockRestServiceServer.createServer(restTemplate); - } + // Prepare Ranker's request + List monitoring = rcpm.getCloudProvidersMonitoringData().entrySet().stream() + .map(e -> new Monitoring(e.getKey(), e.getValue())).collect(Collectors.toList()); - @Test - public void doCallback() throws Exception { + CloudProviderRankerRequest cprr = new CloudProviderRankerRequest() + .withPreferences(rcpm.getSlamPreferences().getPreferences().get(0).getPreferences()) + .withSla(rcpm.getSlamPreferences().getSla()).withMonitoring(monitoring); + // WARNING: This is hard-coded and may change in the future! List response = - Arrays.asList(new RankedCloudProvider("Name1", 1, true, ""), - new RankedCloudProvider("Name2", 0, false, "Error msg")); - - mockServer.expect(requestTo(cloudProviderRankerService.getUrl())) - .andExpect(method(HttpMethod.POST)) - .andRespond(withSuccess(JsonUtility.serializeJson(response), MediaType.APPLICATION_JSON)); + Arrays.asList(new RankedCloudProvider("provider-RECAS-BARI", 2.0f, true, ""), + new RankedCloudProvider("provider-UPV-GRyCAP", 1.0f, true, "")); - List result = - cloudProviderRankerService.getProviderRanking(new CloudProviderRankerRequest()); + List result = cloudProviderRankerService.getProviderRanking(cprr); assertEquals(response, result); - mockServer.verify(); - } } diff --git a/src/test/java/it/reply/orchestrator/service/CmdbServiceIT.java b/src/test/java/it/reply/orchestrator/service/CmdbServiceIT.java index 7554e61436..cc2ba27cd8 100644 --- a/src/test/java/it/reply/orchestrator/service/CmdbServiceIT.java +++ b/src/test/java/it/reply/orchestrator/service/CmdbServiceIT.java @@ -1,76 +1,57 @@ -// package it.reply.orchestrator.service; -// -// import static org.junit.Assert.assertEquals; -// -// import it.reply.orchestrator.config.specific.WebAppConfigurationAwareIT; -// import it.reply.orchestrator.dto.cmdb.Data; -// import it.reply.orchestrator.dto.cmdb.Provider; -// import it.reply.orchestrator.dto.cmdb.ProviderData; -// import it.reply.orchestrator.dto.cmdb.Service; -// import it.reply.orchestrator.dto.cmdb.Type; -// -// import org.junit.Before; -// import org.junit.Test; -// import org.springframework.beans.factory.annotation.Autowired; -// import org.springframework.web.client.RestTemplate; -// -// public class CmdbServiceIT extends WebAppConfigurationAwareIT { -// -// private final String recasId = "4401ac5dc8cfbbb737b0a02575e6f4bc"; -// private final String recasProviderName = "provider-RECAS-BARI"; -// -// @Autowired -// private CmdbService service; -// -// // private MockRestServiceServer mockServer; -// -// @Autowired -// private RestTemplate restTemplate; -// -// @Before -// public void setUp() { -// // mockServer = MockRestServiceServer.createServer(restTemplate); -// } -// -// @Test -// public void getServiceTest() throws Exception { -// -// // mockServer.expect(requestTo("http://test-server.com")).andExpect(method(HttpMethod.POST)) -// // .andRespond(withSuccess()); -// -// Service serviceRecas = service.getServiceById(recasId); -// Data data = new Data().withServiceType("eu.egi.cloud.vm-management.openstack") -// .withEndpoint("http://cloud.recas.ba.infn.it:5000/v2.0") -// .withProviderId("provider-RECAS-BARI").withType(Type.COMPUTE); -// -// Service service = new Service().withId(recasId).withRev("1-256d36283315ea9bb045e6d5038657b6") -// .withType("service").withData(data); -// -// assertEquals(service, serviceRecas); -// -// // mockServer.verify(); -// -// } -// -// @Test -// public void getProviderTest() throws Exception { -// -// // mockServer.expect(requestTo("http://test-server.com")).andExpect(method(HttpMethod.POST)) -// // .andRespond(withSuccess()); -// -// Provider providerRecas = service.getProviderById(recasProviderName); -// ProviderData data = -// new ProviderData().withId("476").withPrimaryKey("83757G0").withName("RECAS-BARI") -// .withCountry("Italy").withCountryCode("IT").withRoc("NGI_IT").withSubgrid("") -// .withGiisUrl("ldap://cloud-bdii.recas.ba.infn.it:2170/GLUE2DomainID=RECAS-BARI,o=glue"); -// -// Provider provider = new Provider().withId(recasProviderName) -// .withRev("1-c7dbe4d8be30aa4c0f14d3ad0411d962").withType("provider").withData(data); -// -// assertEquals(provider, providerRecas); -// -// // mockServer.verify(); -// -// } -// -// } +package it.reply.orchestrator.service; + +import static org.junit.Assert.assertEquals; + +import it.reply.orchestrator.config.specific.WebAppConfigurationAwareIT; +import it.reply.orchestrator.dto.cmdb.Data; +import it.reply.orchestrator.dto.cmdb.Provider; +import it.reply.orchestrator.dto.cmdb.ProviderData; +import it.reply.orchestrator.dto.cmdb.Service; +import it.reply.orchestrator.dto.cmdb.Type; + +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * This integration test makes real request to the CMDB APIs. + * + * @author l.biava + * + */ +public class CmdbServiceIT extends WebAppConfigurationAwareIT { + + private final String recasId = "4401ac5dc8cfbbb737b0a02575e6f4bc"; + private final String recasProviderName = "provider-RECAS-BARI"; + + @Autowired + private CmdbService service; + + @Test + public void getServiceTest() throws Exception { + + Service serviceRecas = service.getServiceById(recasId); + Data data = new Data().withServiceType("eu.egi.cloud.vm-management.openstack") + .withEndpoint("http://cloud.recas.ba.infn.it:5000/v2.0") + .withProviderId("provider-RECAS-BARI").withType(Type.COMPUTE); + + Service service = new Service().withId(recasId).withRev("1-256d36283315ea9bb045e6d5038657b6") + .withType("service").withData(data); + + assertEquals(service, serviceRecas); + } + + @Test + public void getProviderTest() throws Exception { + Provider providerRecas = service.getProviderById(recasProviderName); + ProviderData data = + new ProviderData().withId("476").withPrimaryKey("83757G0").withName("RECAS-BARI") + .withCountry("Italy").withCountryCode("IT").withRoc("NGI_IT").withSubgrid("") + .withGiisUrl("ldap://cloud-bdii.recas.ba.infn.it:2170/GLUE2DomainID=RECAS-BARI,o=glue"); + + Provider provider = new Provider().withId(recasProviderName) + .withRev("1-c7dbe4d8be30aa4c0f14d3ad0411d962").withType("provider").withData(data); + + assertEquals(provider, providerRecas); + } + +} diff --git a/src/test/java/it/reply/orchestrator/service/SlamServiceIT.java b/src/test/java/it/reply/orchestrator/service/SlamServiceIT.java index e0124672fd..e1f9742925 100644 --- a/src/test/java/it/reply/orchestrator/service/SlamServiceIT.java +++ b/src/test/java/it/reply/orchestrator/service/SlamServiceIT.java @@ -1,41 +1,28 @@ -// package it.reply.orchestrator.service; -// -// import static org.junit.Assert.assertEquals; -// -// import it.reply.orchestrator.config.specific.WebAppConfigurationAwareIT; -// import it.reply.orchestrator.dto.slam.SlamPreferences; -// -// import org.junit.Before; -// import org.junit.Test; -// import org.springframework.beans.factory.annotation.Autowired; -// -// public class SlamServiceIT extends WebAppConfigurationAwareIT { -// -// @Autowired -// private SlamService service; -// -// // private MockRestServiceServer mockServer; -// -// // @Autowired -// // private RestTemplate restTemplate; -// -// @Before -// public void setUp() { -// // mockServer = MockRestServiceServer.createServer(restTemplate); -// } -// -// @Test -// public void getPreferencesTest() throws Exception { -// -// // mockServer.expect(requestTo("http://test-server.com")).andExpect(method(HttpMethod.POST)) -// // .andRespond(withSuccess()); -// -// SlamPreferences pref = service.getCustomerPreferences(); -// -// assertEquals("4401ac5dc8cfbbb737b0a02575ee3b58", pref.getSla().get(0).getId()); -// -// // mockServer.verify(); -// -// } -// -// } +package it.reply.orchestrator.service; + +import static org.junit.Assert.assertEquals; + +import it.reply.orchestrator.config.specific.WebAppConfigurationAwareIT; +import it.reply.orchestrator.dto.slam.SlamPreferences; + +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * This integration test makes real request to the SLAM APIs. + * + * @author l.biava + * + */ +public class SlamServiceIT extends WebAppConfigurationAwareIT { + + @Autowired + private SlamService service; + + @Test + public void getPreferencesTest() throws Exception { + SlamPreferences pref = service.getCustomerPreferences(); + assertEquals("4401ac5dc8cfbbb737b0a02575ee3b58", pref.getSla().get(0).getId()); + } + +} From f3ec93531cbf01d9603f8593f7cafe0c98264490 Mon Sep 17 00:00:00 2001 From: Lorenzo Biava Date: Fri, 17 Jun 2016 15:00:00 +0200 Subject: [PATCH 05/19] Fix IM deploy failure message going lost The message explaining the failure reason of an IM deploy was being wrongly overwritten, and thus lost. --- .../service/deployment/providers/ImServiceImpl.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/it/reply/orchestrator/service/deployment/providers/ImServiceImpl.java b/src/main/java/it/reply/orchestrator/service/deployment/providers/ImServiceImpl.java index 7dd9f82d73..337a86a7b8 100644 --- a/src/main/java/it/reply/orchestrator/service/deployment/providers/ImServiceImpl.java +++ b/src/main/java/it/reply/orchestrator/service/deployment/providers/ImServiceImpl.java @@ -257,6 +257,7 @@ public boolean isDeployed(DeploymentMessage deploymentMessage) throws Deployment } DeploymentException ex = new DeploymentException(errorMsg); updateOnError(deployment.getId(), ex); + LOG.error(errorMsg); throw ex; default: return false; @@ -279,6 +280,7 @@ public boolean isDeployed(DeploymentMessage deploymentMessage) throws Deployment } catch (Exception ex) { // Do nothing } + LOG.error(errorMsg); throw new DeploymentException(errorMsg); } } @@ -613,7 +615,11 @@ private void logImErrorResponse(ImClientErrorException exception) { * @param message * the error message */ + @Override public void updateOnError(String deploymentUuid, String message) { + // WARNING: In IM we don't have the resource mapping yet, so we update all the resources + // FIXME Remove once IM handles single nodes state update!!!! And pay attention to the + // AbstractDeploymentProviderService.updateOnError method! Deployment deployment = deploymentRepository.findOne(deploymentUuid); switch (deployment.getStatus()) { case CREATE_FAILED: @@ -642,7 +648,12 @@ public void updateOnError(String deploymentUuid, String message) { break; } deployment.setTask(Task.NONE); - deployment.setStatusReason(message); + // Do not delete a previous statusReason if there's no explicit value! (used when isDeploy + // reports an error and then the PollDeploy task calls the finalizeDeploy, which also uses this + // method but does not have any newer statusReason) + if (message != null) { + deployment.setStatusReason(message); + } deploymentRepository.save(deployment); } } From 7772f7ccf2cb07eec66852075c751d586aea5559 Mon Sep 17 00:00:00 2001 From: Lorenzo Biava Date: Mon, 20 Jun 2016 11:17:43 +0200 Subject: [PATCH 06/19] Add chosen Cloud Provider data to DeploymentMessage --- .../dto/deployment/DeploymentMessage.java | 11 +++++++++++ .../service/commands/UpdateDeployment.java | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/src/main/java/it/reply/orchestrator/dto/deployment/DeploymentMessage.java b/src/main/java/it/reply/orchestrator/dto/deployment/DeploymentMessage.java index b906f4a86e..003fecef09 100644 --- a/src/main/java/it/reply/orchestrator/dto/deployment/DeploymentMessage.java +++ b/src/main/java/it/reply/orchestrator/dto/deployment/DeploymentMessage.java @@ -2,6 +2,7 @@ import it.reply.orchestrator.dal.entity.Deployment; import it.reply.orchestrator.dal.entity.Resource; +import it.reply.orchestrator.dto.CloudProvider; import it.reply.orchestrator.enums.DeploymentProvider; import it.reply.orchestrator.service.deployment.providers.ChronosServiceImpl.IndigoJob; @@ -35,6 +36,8 @@ public class DeploymentMessage implements Serializable { private boolean pollComplete; private boolean skipPollInterval; + private CloudProvider chosenCloudProvider; + private String oauth2Token; /** @@ -115,6 +118,14 @@ public void setSkipPollInterval(boolean skipPollInterval) { this.skipPollInterval = skipPollInterval; } + public CloudProvider getChosenCloudProvider() { + return chosenCloudProvider; + } + + public void setChosenCloudProvider(CloudProvider chosenCloudProvider) { + this.chosenCloudProvider = chosenCloudProvider; + } + public String getOauth2Token() { return oauth2Token; } diff --git a/src/main/java/it/reply/orchestrator/service/commands/UpdateDeployment.java b/src/main/java/it/reply/orchestrator/service/commands/UpdateDeployment.java index d2ab991f25..62d18b61bf 100644 --- a/src/main/java/it/reply/orchestrator/service/commands/UpdateDeployment.java +++ b/src/main/java/it/reply/orchestrator/service/commands/UpdateDeployment.java @@ -67,6 +67,10 @@ public ExecutionResults customExecute(CommandContext ctx) throws Exception { } LOG.debug("Selected Cloud Provider is: {}", chosenCp); + // Set the chosen CP in deploymentMessage + deploymentMessage.setChosenCloudProvider( + rankCloudProvidersMessage.getCloudProviders().get(chosenCp.getName())); + // Update Deployment Deployment deployment = deploymentRepository.findOne(rankCloudProvidersMessage.getDeploymentId()); From 4cfaa4554be856d1aea5a7bb98451a20d6620626 Mon Sep 17 00:00:00 2001 From: Lorenzo Biava Date: Mon, 20 Jun 2016 17:14:37 +0200 Subject: [PATCH 07/19] Fix #64: Replace `orchestrator_url` property in `ElasticCluster` nodes Added `orchestrator.url` configuration property and updated README and Dockerfile. Also updated related tests. --- README.md | 18 ++++++++++-------- docker/Dockerfile | 3 ++- docker/launch.sh | 1 + .../orchestrator/service/ToscaService.java | 11 ++++++++++- .../orchestrator/service/ToscaServiceImpl.java | 14 ++++++++++---- .../deployment/providers/ImServiceImpl.java | 2 +- src/main/resources/application.properties | 5 ++++- .../config/ApplicationConfigTest.java | 2 +- .../specific/WebAppConfigurationAware.java | 4 ++-- .../orchestrator/service/ToscaServiceTest.java | 18 +++++++++++++----- .../resources/tosca/galaxy_tosca_clues.yaml | 8 +++++++- 11 files changed, 61 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index fdc8891d3c..777ad0c624 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ INDIGO Orchestrator ============================ -This is the orchestrator of the PaaS layer, a core component of the INDIGO project. It receives high-level deployment requests and coordinates the deployment process over the IaaS platforms or Mesos. +This is the Orchestrator of the PaaS layer, a core component of the INDIGO project. It receives high-level deployment requests and coordinates the deployment process over the IaaS platforms or Mesos. You can find the REST APIs docs [orchestrator-rest-doc] (http://indigo-dc.github.io/orchestrator/restdocs/). @@ -55,30 +55,32 @@ docker build -t indigodatacloud/orchestrator /path/to/the/docker/folder 1.3 RUNNING -------------- ### With MySQL dockerized on the same host -The orchestrator can be run in 3 steps: +The Orchestrator can be run in 3 steps: -1. Run the MySQL deployments database with the command +1. Run the MySQL deployments database with the command: ``` sudo docker run --name databaseOrchestrator -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=orchestrator -d mysql:5.7 ``` -2. Run the MySQL workflow database with the command +2. Run the MySQL workflow database with the command: ``` sudo docker run --name databaseWorkflow -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=workflow -d mysql:5.7 ``` -3. Run the orchestrator with the command +3. Run the Orchestrator with the command: + + **`IMPORTANT`**: Remember to replace `ORCHESTRATOR_URL` with the base URL which the Orchestrator is available to (it MUST be accessible for the ElasticCluster callbacks!). ``` sudo docker run --name orchestrator --link databaseWorkflow:databaseWorkflow --link databaseOrchestrator:databaseOrchestrator \ - -p 80:8080 -d indigodatacloud/orchestrator + -p 80:8080 -e ORCHESTRATOR_URL="" -d indigodatacloud/orchestrator ``` ### With external databases -The orchestrator can also be run using already deployed DBs; you just need to start it with the command +The Orchestrator can also be run using already deployed DBs; you just need to start it with the command ``` sudo docker run --name orchestrator1 -h orchestrator1 -e ORCHESTRATOR_DB_ENDPOINT=DOMAIN_NAME:PORT \ -e ORCHESTRATOR_DB_NAME=SCHEMA_NAME -e ORCHESTRATOR_DB_USER=DB_USER -e ORCHESTRATOR_DB_PWD=DB_USER_PASSWORD \ @@ -89,7 +91,7 @@ using as parameters (`DOMAIN_NAME`, `PORT`, `SCHEMA_NAME`, `DB_USER`, `DB_USER_P 1.4 CONFIGURING -------------- -Besides those used to link the orchestrator to the DBs, there are other environment variables that can be set in order to configure the orchestrator behaviour. +Besides those used to link the Orchestrator to the database, there are other environment variables that can be set in order to configure the Orchestrator behaviour. ### Configure security 1. `SECURITY_ENABLE`: if set to `true` enable AAI OAuth2 authentication and authorization diff --git a/docker/Dockerfile b/docker/Dockerfile index c27a846a2d..323ff49800 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -52,10 +52,11 @@ ENV ORCHESTRATOR_DB_ENDPOINT="databaseorchestrator:3306" \ ORCHESTRATOR_DB_NAME=orchestrator \ ORCHESTRATOR_DB_USER=root \ ORCHESTRATOR_DB_PWD=root \ + ORCHESTRATOR_URL="" \ WORKFLOW_DB_ENDPOINT="databaseworkflow:3306" \ WORKFLOW_DB_NAME=workflow \ WORKFLOW_DB_USER=root \ - WORKFLOW_DB_PWD=root + WORKFLOW_DB_PWD=root ENV IM_URL="" \ PROXY_DIR="" \ diff --git a/docker/launch.sh b/docker/launch.sh index 2e9b9875e9..0c26e2d2bc 100644 --- a/docker/launch.sh +++ b/docker/launch.sh @@ -7,6 +7,7 @@ java -jar /usr/share/java/saxon.jar -o:$JBOSS_HOME/standalone/configuration/$JBO orchestrator.DB.name=$ORCHESTRATOR_DB_NAME \ orchestrator.DB.user=$ORCHESTRATOR_DB_USER \ orchestrator.DB.pwd=$ORCHESTRATOR_DB_PWD \ + orchestrator.url=$ORCHESTRATOR_URL \ workflow.DB.endpoint=$WORKFLOW_DB_ENDPOINT \ workflow.DB.name=$WORKFLOW_DB_NAME \ workflow.DB.user=$WORKFLOW_DB_USER \ diff --git a/src/main/java/it/reply/orchestrator/service/ToscaService.java b/src/main/java/it/reply/orchestrator/service/ToscaService.java index 0a964247a5..27b7c5bcfe 100644 --- a/src/main/java/it/reply/orchestrator/service/ToscaService.java +++ b/src/main/java/it/reply/orchestrator/service/ToscaService.java @@ -57,7 +57,16 @@ public ParsingResult getArchiveRootFromTemplate(@Nonnull String tos public String customizeTemplate(@Nonnull String toscaTemplate, @NotNull String deploymentId) throws IOException, ToscaException; - public void addDeploymentId(ArchiveRoot parsingResult, String deploymentId); + /** + * Adds the parameters needed for 'tosca.nodes.indigo.ElasticCluster' nodes (deployment_id, + * orchestrator_url). + * + * @param parsingResult + * . + * @param deploymentId + * . + */ + public void addElasticClusterParameters(ArchiveRoot parsingResult, String deploymentId); /** * Verifies that all the template's required inputs are present in the user's input list. diff --git a/src/main/java/it/reply/orchestrator/service/ToscaServiceImpl.java b/src/main/java/it/reply/orchestrator/service/ToscaServiceImpl.java index 82ad896e31..be1f3c216d 100644 --- a/src/main/java/it/reply/orchestrator/service/ToscaServiceImpl.java +++ b/src/main/java/it/reply/orchestrator/service/ToscaServiceImpl.java @@ -1,7 +1,5 @@ package it.reply.orchestrator.service; -import com.google.common.io.ByteStreams; - import alien4cloud.component.repository.exception.CSARVersionAlreadyExistsException; import alien4cloud.exception.InvalidArgumentException; import alien4cloud.model.components.AbstractPropertyValue; @@ -24,6 +22,8 @@ import alien4cloud.tosca.serializer.VelocityUtil; import alien4cloud.utils.FileUtil; +import com.google.common.io.ByteStreams; + import it.reply.orchestrator.exception.service.ToscaException; import org.apache.logging.log4j.LogManager; @@ -81,6 +81,8 @@ public class ToscaServiceImpl implements ToscaService { private String normativeLocalName; @Value("${tosca.definitions.indigo}") private String indigoLocalName; + @Value("${orchestrator.url}") + private String orchestratorUrl; /** * Load normative and non-normative types. @@ -183,7 +185,7 @@ public String customizeTemplate(@Nonnull String toscaTemplate, @Nonnull String d ArchiveRoot ar = parseTemplate(toscaTemplate); - addDeploymentId(ar, deploymentId); + addElasticClusterParameters(ar, deploymentId); return getTemplateFromTopology(ar); @@ -285,7 +287,7 @@ private void checkParsingErrors(List errorList) throws ToscaExcept } @Override - public void addDeploymentId(ArchiveRoot parsingResult, String deploymentId) { + public void addElasticClusterParameters(ArchiveRoot parsingResult, String deploymentId) { Map nodes = parsingResult.getTopology().getNodeTemplates(); for (Map.Entry entry : nodes.entrySet()) { if (entry.getValue().getType().equals("tosca.nodes.indigo.ElasticCluster")) { @@ -293,6 +295,10 @@ public void addDeploymentId(ArchiveRoot parsingResult, String deploymentId) { ScalarPropertyValue scalarPropertyValue = new ScalarPropertyValue(deploymentId); scalarPropertyValue.setPrintable(true); entry.getValue().getProperties().put("deployment_id", scalarPropertyValue); + // Create new property with the orchestrator_url and set as printable + scalarPropertyValue = new ScalarPropertyValue(orchestratorUrl); + scalarPropertyValue.setPrintable(true); + entry.getValue().getProperties().put("orchestrator_url", scalarPropertyValue); } } } diff --git a/src/main/java/it/reply/orchestrator/service/deployment/providers/ImServiceImpl.java b/src/main/java/it/reply/orchestrator/service/deployment/providers/ImServiceImpl.java index 337a86a7b8..5ebb69e86f 100644 --- a/src/main/java/it/reply/orchestrator/service/deployment/providers/ImServiceImpl.java +++ b/src/main/java/it/reply/orchestrator/service/deployment/providers/ImServiceImpl.java @@ -187,7 +187,7 @@ public boolean doDeploy(DeploymentMessage deploymentMessage) { ArchiveRoot ar = toscaService.prepareTemplate(deployment.getTemplate(), deployment.getParameters()); - toscaService.addDeploymentId(ar, deploymentUuid); + toscaService.addElasticClusterParameters(ar, deploymentUuid); String imCustomizedTemplate = toscaService.getTemplateFromTopology(ar); // FIXME this is a trick used only for demo purpose diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 125a309b58..c258819962 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -12,4 +12,7 @@ tosca.definitions.indigo=custom_types.yaml # TEMPORARY - Chronos auth file path (default value to read the files as classpath resource) chronos.auth.file.path=classpath:chronos/chronos.properties -orchestrator.chronos.jobChunkSize=100 \ No newline at end of file +orchestrator.chronos.jobChunkSize=100 + +# The base URL which the Orchestrator is available to (it MUST be accessible for the ElasticCluster callbacks!) +orchestrator.url=http://localhost:8081 \ No newline at end of file diff --git a/src/test/java/it/reply/orchestrator/config/ApplicationConfigTest.java b/src/test/java/it/reply/orchestrator/config/ApplicationConfigTest.java index a0a8b948cb..27faebeb5b 100644 --- a/src/test/java/it/reply/orchestrator/config/ApplicationConfigTest.java +++ b/src/test/java/it/reply/orchestrator/config/ApplicationConfigTest.java @@ -10,7 +10,7 @@ @ComponentScan(basePackages = { "it.reply.orchestrator", "it.reply.workflowmanager" }, excludeFilters = { @ComponentScan.Filter(type = FilterType.REGEX, pattern = "it.reply.orchestrator.config.specific.*") }) -public class ApplicationConfigTest { +public class ApplicationConfigTest extends ApplicationConfig { @Bean public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { diff --git a/src/test/java/it/reply/orchestrator/config/specific/WebAppConfigurationAware.java b/src/test/java/it/reply/orchestrator/config/specific/WebAppConfigurationAware.java index 5906595b84..0d5c84c5b5 100644 --- a/src/test/java/it/reply/orchestrator/config/specific/WebAppConfigurationAware.java +++ b/src/test/java/it/reply/orchestrator/config/specific/WebAppConfigurationAware.java @@ -4,7 +4,7 @@ import com.github.springtestdbunit.DbUnitTestExecutionListener; -import it.reply.orchestrator.config.ApplicationConfig; +import it.reply.orchestrator.config.ApplicationConfigTest; import it.reply.orchestrator.config.PersistenceConfigTest; import it.reply.orchestrator.config.WebAppInitializer; import it.reply.orchestrator.config.WebMvcConfig; @@ -37,7 +37,7 @@ @WebAppConfiguration @ContextHierarchy({ @ContextConfiguration(name = "baseContext", - classes = { ApplicationConfig.class, WebAppInitializer.class, WebMvcConfig.class, + classes = { ApplicationConfigTest.class, WebAppInitializer.class, WebMvcConfig.class, PersistenceConfigTest.class, WorklfowPersistenceConfigTest.class }), @ContextConfiguration(name = "workflowContext", classes = { WebAppConfigurationAware.Config.class }) }) diff --git a/src/test/java/it/reply/orchestrator/service/ToscaServiceTest.java b/src/test/java/it/reply/orchestrator/service/ToscaServiceTest.java index ad92a424e4..374e990263 100644 --- a/src/test/java/it/reply/orchestrator/service/ToscaServiceTest.java +++ b/src/test/java/it/reply/orchestrator/service/ToscaServiceTest.java @@ -2,6 +2,7 @@ import static org.hamcrest.CoreMatchers.instanceOf; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; import alien4cloud.model.components.AbstractPropertyValue; @@ -26,6 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired; import java.io.IOException; +import java.net.URL; import java.nio.file.Paths; import java.util.Arrays; import java.util.HashMap; @@ -46,7 +48,7 @@ public class ToscaServiceTest extends WebAppConfigurationAware { private String deploymentId = "deployment_id"; @Test(expected = ToscaException.class) - public void customizeTemplateWithError() throws Exception { + public void customizeTemplateWithInvalidTemplate() throws Exception { String template = getFileContentAsString(TEMPLATES_BASE_DIR + "galaxy_tosca_clues_error.yaml"); toscaService.customizeTemplate(template, deploymentId); @@ -54,22 +56,28 @@ public void customizeTemplateWithError() throws Exception { @SuppressWarnings("unchecked") @Test - public void customizeTemplateWithDeplymentIdSuccessfully() throws Exception { + public void customizeTemplate() throws Exception { String template = getFileContentAsString(TEMPLATES_BASE_DIR + "galaxy_tosca_clues.yaml"); String customizedTemplate = toscaService.customizeTemplate(template, deploymentId); - String templateDeploymentId = ""; Map nodes = toscaService.getArchiveRootFromTemplate(customizedTemplate) .getResult().getTopology().getNodeTemplates(); + for (Map.Entry entry : nodes.entrySet()) { if (entry.getValue().getType().equals("tosca.nodes.indigo.ElasticCluster")) { - templateDeploymentId = + String templateDeploymentId = ((PropertyValue) entry.getValue().getProperties().get("deployment_id")) .getValue(); + + String templateOrchestratorUrl = + ((PropertyValue) entry.getValue().getProperties().get("orchestrator_url")) + .getValue(); + + assertEquals(deploymentId, templateDeploymentId); + assertNotNull(new URL(templateOrchestratorUrl)); } } - assertEquals(deploymentId, templateDeploymentId); } @Test diff --git a/src/test/resources/tosca/galaxy_tosca_clues.yaml b/src/test/resources/tosca/galaxy_tosca_clues.yaml index 17600e5458..ea10aa4471 100644 --- a/src/test/resources/tosca/galaxy_tosca_clues.yaml +++ b/src/test/resources/tosca/galaxy_tosca_clues.yaml @@ -19,6 +19,12 @@ topology_template: - lrms: torque_front_end - wn: wn_node + elastic_cluster_front_end_2: + type: tosca.nodes.indigo.ElasticCluster + requirements: + - lrms: torque_front_end + - wn: wn_node + torque_front_end: type: tosca.nodes.indigo.LRMS.FrontEnd.Torque properties: @@ -51,7 +57,7 @@ topology_template: min_instances: 0 requirements: - host: torque_wn - + torque_wn: type: tosca.nodes.indigo.Compute capabilities: From 57819652a0c723119717632f9c35bb78a2d6396f Mon Sep 17 00:00:00 2001 From: Lorenzo Biava Date: Mon, 20 Jun 2016 17:59:27 +0200 Subject: [PATCH 08/19] Update dependencies to stable (workflow-manager, chronos-client) - workflow-manager=0.0.3-FINAL - chronos-client=0.0.1-BETA.1 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 72547edf82..7ab42a8bff 100644 --- a/pom.xml +++ b/pom.xml @@ -40,9 +40,9 @@ 2.1.0 ${project.build.directory}\generated-snippets 2.17 - 0.0.3-SNAPSHOT + 0.0.3-FINAL 1.1.0-INDIGO2-SNAPSHOT - 0.0.1-SNAPSHOT + 0.0.1-BETA.1 From 645f2b3ae603a10b571d17487558fb7892a2166e Mon Sep 17 00:00:00 2001 From: Lorenzo Biava Date: Mon, 20 Jun 2016 18:23:27 +0200 Subject: [PATCH 09/19] Fix CheckStyle --- .../java/it/reply/orchestrator/service/ToscaServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/it/reply/orchestrator/service/ToscaServiceImpl.java b/src/main/java/it/reply/orchestrator/service/ToscaServiceImpl.java index be1f3c216d..8caf21fad9 100644 --- a/src/main/java/it/reply/orchestrator/service/ToscaServiceImpl.java +++ b/src/main/java/it/reply/orchestrator/service/ToscaServiceImpl.java @@ -1,5 +1,7 @@ package it.reply.orchestrator.service; +import com.google.common.io.ByteStreams; + import alien4cloud.component.repository.exception.CSARVersionAlreadyExistsException; import alien4cloud.exception.InvalidArgumentException; import alien4cloud.model.components.AbstractPropertyValue; @@ -22,8 +24,6 @@ import alien4cloud.tosca.serializer.VelocityUtil; import alien4cloud.utils.FileUtil; -import com.google.common.io.ByteStreams; - import it.reply.orchestrator.exception.service.ToscaException; import org.apache.logging.log4j.LogManager; From 870590d485241d88529ce55b0174a99031ea6212 Mon Sep 17 00:00:00 2001 From: Lorenzo Biava Date: Thu, 23 Jun 2016 11:54:07 +0200 Subject: [PATCH 10/19] Improve Images match with tag in name check and case-insensitive meta - Docker tag in image was not explicitly checked - Other metadata were matched in case-sensitive mode See #53 --- .../service/ToscaServiceImpl.java | 32 ++++++++++++++++--- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/main/java/it/reply/orchestrator/service/ToscaServiceImpl.java b/src/main/java/it/reply/orchestrator/service/ToscaServiceImpl.java index 4241679548..c4c43d1ea9 100644 --- a/src/main/java/it/reply/orchestrator/service/ToscaServiceImpl.java +++ b/src/main/java/it/reply/orchestrator/service/ToscaServiceImpl.java @@ -369,7 +369,8 @@ protected Image getBestImageForCloudProvider(Image imageMetadata, CloudProvider // base image will be chosen with the other filters and image metadata - architecture, type, // distro, version) if (imageMetadata.getImageName() != null) { - if (imageMetadata.getImageName().equals(image.getImageName())) { + + if (matchImageNameAndTag(imageMetadata.getImageName(), image.getImageName())) { LOG.debug("Image <{}> found with name <{}>", image.getImageId(), imageMetadata.getImageName()); return image; @@ -381,25 +382,25 @@ protected Image getBestImageForCloudProvider(Image imageMetadata, CloudProvider // Match or skip image based on each additional optional attribute if (imageMetadata.getType() != null) { - if (!imageMetadata.getType().equals(image.getType())) { + if (!imageMetadata.getType().equalsIgnoreCase(image.getType())) { continue; } } if (imageMetadata.getArchitecture() != null) { - if (!imageMetadata.getArchitecture().equals(image.getArchitecture())) { + if (!imageMetadata.getArchitecture().equalsIgnoreCase(image.getArchitecture())) { continue; } } if (imageMetadata.getDistribution() != null) { - if (!imageMetadata.getDistribution().equals(image.getDistribution())) { + if (!imageMetadata.getDistribution().equalsIgnoreCase(image.getDistribution())) { continue; } } if (imageMetadata.getVersion() != null) { - if (!imageMetadata.getVersion().equals(image.getVersion())) { + if (!imageMetadata.getVersion().equalsIgnoreCase(image.getVersion())) { continue; } } @@ -411,6 +412,27 @@ protected Image getBestImageForCloudProvider(Image imageMetadata, CloudProvider } + protected boolean matchImageNameAndTag(String requiredImageName, String availableImageName) { + // Extract Docker tag if available + String[] requiredImageNameSplit = requiredImageName.split(":"); + String requiredImageBaseName = requiredImageNameSplit[0]; + String requiredImageTag = + (requiredImageNameSplit.length > 1 ? requiredImageNameSplit[1] : null); + + String[] availableImageNameSplit = availableImageName.split(":"); + String availableImageBaseName = availableImageNameSplit[0]; + String availableImageTag = + (availableImageNameSplit.length > 1 ? availableImageNameSplit[1] : null); + + // Match name + boolean nameMatch = requiredImageBaseName.equals(availableImageBaseName); + // Match tag (if not given the match is true) + boolean tagMatch = + (requiredImageTag != null ? requiredImageTag.equals(availableImageTag) : true); + + return nameMatch && tagMatch; + } + @Override public void addElasticClusterParameters(ArchiveRoot parsingResult, String deploymentId) { Map nodes = parsingResult.getTopology().getNodeTemplates(); From 4db64cc1d9358e11fb272502fabfd62f16af689d Mon Sep 17 00:00:00 2001 From: Lorenzo Biava Date: Thu, 23 Jun 2016 11:55:35 +0200 Subject: [PATCH 11/19] Retrieve Provider's Service's Image list from CMDB (plus tests) See #53 --- .../reply/orchestrator/dto/CloudProvider.java | 15 +- .../dto/cmdb/CmdbHasManyList.java | 147 +++++++++++++++ .../orchestrator/dto/cmdb/CmdbImage.java | 170 ++++++++++++++++++ .../orchestrator/dto/cmdb/CmdbImageRow.java | 102 +++++++++++ .../it/reply/orchestrator/dto/cmdb/Image.java | 32 +++- .../orchestrator/service/CmdbService.java | 18 +- .../orchestrator/service/CmdbServiceImpl.java | 70 ++++++-- .../service/commands/GetCmdbData.java | 62 +++++++ .../orchestrator/service/CmdbServiceIT.java | 20 +++ .../RankCloudProvidersWorkflowTest.java | 18 ++ 10 files changed, 634 insertions(+), 20 deletions(-) create mode 100644 src/main/java/it/reply/orchestrator/dto/cmdb/CmdbHasManyList.java create mode 100644 src/main/java/it/reply/orchestrator/dto/cmdb/CmdbImage.java create mode 100644 src/main/java/it/reply/orchestrator/dto/cmdb/CmdbImageRow.java create mode 100644 src/main/java/it/reply/orchestrator/service/commands/GetCmdbData.java diff --git a/src/main/java/it/reply/orchestrator/dto/CloudProvider.java b/src/main/java/it/reply/orchestrator/dto/CloudProvider.java index 6197cae791..6af44fe4ee 100644 --- a/src/main/java/it/reply/orchestrator/dto/CloudProvider.java +++ b/src/main/java/it/reply/orchestrator/dto/CloudProvider.java @@ -76,9 +76,20 @@ public void setCmdbProviderImages(List cmdbProviderImages) { this.cmdbProviderImages = cmdbProviderImages; } + /** + * Look for a Service in the current Provider of the given Type. + * + * @param type + * the type. + * @return the Service if found, null otherwise. + */ public Service getCmbdProviderServiceByType(Type type) { - // FIXME implement getCmbdProviderServiceByType - throw new UnsupportedOperationException("NOT IMPLEMENTED"); + for (Service service : cmdbProviderServices.values()) { + if (service.getData().getType().equals(type)) { + return service; + } + } + return null; } } diff --git a/src/main/java/it/reply/orchestrator/dto/cmdb/CmdbHasManyList.java b/src/main/java/it/reply/orchestrator/dto/cmdb/CmdbHasManyList.java new file mode 100644 index 0000000000..03bf3da646 --- /dev/null +++ b/src/main/java/it/reply/orchestrator/dto/cmdb/CmdbHasManyList.java @@ -0,0 +1,147 @@ +package it.reply.orchestrator.dto.cmdb; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.builder.ToStringBuilder; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.annotation.Generated; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@Generated("org.jsonschema2pojo") +@JsonPropertyOrder({ "total_rows", "offset", "rows" }) +public class CmdbHasManyList { + + @JsonProperty("total_rows") + private Long totalRows; + @JsonProperty("offset") + private Long offset; + @JsonProperty("rows") + private List rows = new ArrayList<>(); + @JsonIgnore + private Map additionalProperties = new HashMap(); + + /** + * + * @return The totalRows + */ + @JsonProperty("total_rows") + public Long getTotalRows() { + return totalRows; + } + + /** + * + * @param totalRows + * The total_rows + */ + @JsonProperty("total_rows") + public void setTotalRows(Long totalRows) { + this.totalRows = totalRows; + } + + public CmdbHasManyList withTotalRows(Long totalRows) { + this.totalRows = totalRows; + return this; + } + + /** + * + * @return The offset + */ + @JsonProperty("offset") + public Long getOffset() { + return offset; + } + + /** + * + * @param offset + * The offset + */ + @JsonProperty("offset") + public void setOffset(Long offset) { + this.offset = offset; + } + + public CmdbHasManyList withOffset(Long offset) { + this.offset = offset; + return this; + } + + /** + * + * @return The rows + */ + @JsonProperty("rows") + public List getRows() { + return rows; + } + + /** + * + * @param rows + * The rows + */ + @JsonProperty("rows") + public void setRows(List rows) { + this.rows = rows; + } + + public CmdbHasManyList withRows(List rows) { + this.rows = rows; + return this; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public CmdbHasManyList withAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + return this; + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(totalRows).append(offset).append(rows) + .append(additionalProperties).toHashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + if ((other instanceof CmdbHasManyList) == false) { + return false; + } + @SuppressWarnings("unchecked") + CmdbHasManyList rhs = ((CmdbHasManyList) other); + return new EqualsBuilder().append(totalRows, rhs.totalRows).append(offset, rhs.offset) + .append(rows, rhs.rows).append(additionalProperties, rhs.additionalProperties).isEquals(); + } + +} \ No newline at end of file diff --git a/src/main/java/it/reply/orchestrator/dto/cmdb/CmdbImage.java b/src/main/java/it/reply/orchestrator/dto/cmdb/CmdbImage.java new file mode 100644 index 0000000000..7aae4577ea --- /dev/null +++ b/src/main/java/it/reply/orchestrator/dto/cmdb/CmdbImage.java @@ -0,0 +1,170 @@ +package it.reply.orchestrator.dto.cmdb; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.builder.ToStringBuilder; + +import java.util.HashMap; +import java.util.Map; + +import javax.annotation.Generated; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@Generated("org.jsonschema2pojo") +@JsonPropertyOrder({ "_id", "_rev", "type", "data" }) +public class CmdbImage { + + @JsonProperty("_id") + private String id; + @JsonProperty("_rev") + private String rev; + @JsonProperty("type") + private String type; + @JsonProperty("data") + private Image data; + @JsonIgnore + private Map additionalProperties = new HashMap(); + + /** + * + * @return The id + */ + @JsonProperty("_id") + public String getId() { + return id; + } + + /** + * + * @param id + * The _id + */ + @JsonProperty("_id") + public void setId(String id) { + this.id = id; + } + + public CmdbImage withId(String id) { + this.id = id; + return this; + } + + /** + * + * @return The rev + */ + @JsonProperty("_rev") + public String getRev() { + return rev; + } + + /** + * + * @param rev + * The _rev + */ + @JsonProperty("_rev") + public void setRev(String rev) { + this.rev = rev; + } + + public CmdbImage withRev(String rev) { + this.rev = rev; + return this; + } + + /** + * + * @return The type + */ + @JsonProperty("type") + public String getType() { + return type; + } + + /** + * + * @param type + * The type + */ + @JsonProperty("type") + public void setType(String type) { + this.type = type; + } + + public CmdbImage withType(String type) { + this.type = type; + return this; + } + + /** + * + * @return The data + */ + @JsonProperty("data") + public Image getData() { + return data; + } + + /** + * + * @param data + * The data + */ + @JsonProperty("data") + public void setData(Image data) { + this.data = data; + } + + public CmdbImage withData(Image data) { + this.data = data; + return this; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public CmdbImage withAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + return this; + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(id).append(rev).append(type).append(data) + .append(additionalProperties).toHashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + if ((other instanceof CmdbImage) == false) { + return false; + } + CmdbImage rhs = ((CmdbImage) other); + return new EqualsBuilder().append(id, rhs.id).append(rev, rhs.rev).append(type, rhs.type) + .append(data, rhs.data).append(additionalProperties, rhs.additionalProperties).isEquals(); + } + +} \ No newline at end of file diff --git a/src/main/java/it/reply/orchestrator/dto/cmdb/CmdbImageRow.java b/src/main/java/it/reply/orchestrator/dto/cmdb/CmdbImageRow.java new file mode 100644 index 0000000000..fcfcd46986 --- /dev/null +++ b/src/main/java/it/reply/orchestrator/dto/cmdb/CmdbImageRow.java @@ -0,0 +1,102 @@ +package it.reply.orchestrator.dto.cmdb; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import org.apache.commons.lang.builder.ToStringBuilder; + +import java.util.ArrayList; +import java.util.List; + +import javax.annotation.Generated; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@Generated("org.jsonschema2pojo") +@JsonPropertyOrder({ "id", "key", "value", "doc" }) +public class CmdbImageRow { + + @JsonProperty("id") + private String id; + @JsonProperty("key") + private List key = new ArrayList(); + @JsonProperty("doc") + private CmdbImage image; + + /** + * + * @return The id + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * + * @param id + * The id + */ + @JsonProperty("id") + public void setId(String id) { + this.id = id; + } + + public CmdbImageRow withId(String id) { + this.id = id; + return this; + } + + /** + * + * @return The key + */ + @JsonProperty("key") + public List getKey() { + return key; + } + + /** + * + * @param key + * The key + */ + @JsonProperty("key") + public void setKey(List key) { + this.key = key; + } + + public CmdbImageRow withKey(List key) { + this.key = key; + return this; + } + + /** + * + * @return The image + */ + @JsonProperty("doc") + public CmdbImage getImage() { + return image; + } + + /** + * + * @param image + * The image + */ + @JsonProperty("doc") + public void setImage(CmdbImage image) { + this.image = image; + } + + public CmdbImageRow withImage(CmdbImage image) { + this.image = image; + return this; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this); + } +} \ No newline at end of file diff --git a/src/main/java/it/reply/orchestrator/dto/cmdb/Image.java b/src/main/java/it/reply/orchestrator/dto/cmdb/Image.java index abeb93357d..5180712e09 100644 --- a/src/main/java/it/reply/orchestrator/dto/cmdb/Image.java +++ b/src/main/java/it/reply/orchestrator/dto/cmdb/Image.java @@ -36,6 +36,8 @@ public class Image implements Serializable { private String distribution; @JsonProperty("version") private String version; + @JsonProperty("service") + private String service; @JsonIgnore private Map additionalProperties = new HashMap(); @@ -183,6 +185,30 @@ public Image withVersion(String version) { return this; } + /** + * + * @return The service + */ + @JsonProperty("service") + public String getService() { + return service; + } + + /** + * + * @param service + * The service + */ + @JsonProperty("service") + public void setService(String service) { + this.service = service; + } + + public Image withService(String service) { + this.service = service; + return this; + } + @Override public String toString() { return ToStringBuilder.reflectionToString(this); @@ -206,7 +232,8 @@ public Image withAdditionalProperty(String name, Object value) { @Override public int hashCode() { return new HashCodeBuilder().append(imageId).append(imageName).append(architecture).append(type) - .append(distribution).append(version).append(additionalProperties).toHashCode(); + .append(distribution).append(version).append(service).append(additionalProperties) + .toHashCode(); } @Override @@ -221,7 +248,8 @@ public boolean equals(Object other) { return new EqualsBuilder().append(imageId, rhs.imageId).append(imageName, rhs.imageName) .append(architecture, rhs.architecture).append(type, rhs.type) .append(distribution, rhs.distribution).append(version, rhs.version) - .append(additionalProperties, rhs.additionalProperties).isEquals(); + .append(service, rhs.service).append(additionalProperties, rhs.additionalProperties) + .isEquals(); } } \ No newline at end of file diff --git a/src/main/java/it/reply/orchestrator/service/CmdbService.java b/src/main/java/it/reply/orchestrator/service/CmdbService.java index 38b917fda2..7af81012ca 100644 --- a/src/main/java/it/reply/orchestrator/service/CmdbService.java +++ b/src/main/java/it/reply/orchestrator/service/CmdbService.java @@ -1,6 +1,6 @@ package it.reply.orchestrator.service; -import it.reply.orchestrator.dto.cmdb.Image; +import it.reply.orchestrator.dto.cmdb.CmdbImage; import it.reply.orchestrator.dto.cmdb.Provider; import it.reply.orchestrator.dto.cmdb.Service; @@ -12,7 +12,21 @@ public interface CmdbService { public Provider getProviderById(String id); - public List getImagesByProvider(String providerId); + // /** + // * Complex method to retrieve {@link Image}s with all metadata for a given provider.
+ // * Currently, it is needed to extract the correct service from the provider and the query the + // CMDB + // * to retrieve metadata of each single image (because only ID and Name are listed in the API). + // * + // * @param providerId + // * . + // * @return . + // */ + // public List getImagesByProvider(String providerId); + + public List getImagesByService(String serviceId); + + public CmdbImage getImageById(String imageId); public String getUrl(); } diff --git a/src/main/java/it/reply/orchestrator/service/CmdbServiceImpl.java b/src/main/java/it/reply/orchestrator/service/CmdbServiceImpl.java index db95ac7c3b..0c57fe0a19 100644 --- a/src/main/java/it/reply/orchestrator/service/CmdbServiceImpl.java +++ b/src/main/java/it/reply/orchestrator/service/CmdbServiceImpl.java @@ -1,18 +1,22 @@ package it.reply.orchestrator.service; -import it.reply.orchestrator.dto.cmdb.Image; +import it.reply.orchestrator.dto.cmdb.CmdbHasManyList; +import it.reply.orchestrator.dto.cmdb.CmdbImage; +import it.reply.orchestrator.dto.cmdb.CmdbImageRow; import it.reply.orchestrator.dto.cmdb.Provider; import it.reply.orchestrator.exception.service.DeploymentException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.PropertySource; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import org.springframework.web.client.RestTemplate; -import java.util.Arrays; import java.util.List; +import java.util.stream.Collectors; @Service @PropertySource("classpath:cmdb/cmdb.properties") @@ -59,18 +63,56 @@ public Provider getProviderById(String id) { } @Override - public List getImagesByProvider(String providerId) { - providerId = "STUB:" + providerId; - // FIXME: Stub - return Arrays.asList( - new Image().withImageName("indigodatacloud/ubuntu-sshd").withImageId(providerId + "/5") - .withArchitecture("x86_64").withType("linux").withDistribution("ubuntu") - .withVersion("14.04"), - new Image().withImageName("linux-ubuntu-14.04").withImageId(providerId + "/5") - .withArchitecture("x86_64").withType("linux").withDistribution("ubuntu") - .withVersion("14.04"), - new Image().withImageName("indigodatacloudapps/docker-galaxy") - .withImageId(providerId + "/13")); + public CmdbImage getImageById(String imageId) { + ResponseEntity response = + restTemplate.getForEntity(url.concat("image/id").concat(imageId), CmdbImage.class); + if (response.getStatusCode().is2xxSuccessful()) { + return response.getBody(); + } + throw new DeploymentException("Unable to find image <" + imageId + "> in the CMDB." + + response.getStatusCode().toString() + " " + response.getStatusCode().getReasonPhrase()); + } + + @Override + public List getImagesByService(String serviceId) { + ResponseEntity> response = restTemplate.exchange( + url.concat(serviceIdUrlPath).concat(serviceId).concat("/has_many/images?include_docs=true"), + HttpMethod.GET, null, new ParameterizedTypeReference>() { + }); + + if (response.getStatusCode().is2xxSuccessful()) { + return response.getBody().getRows().stream().map(e -> e.getImage()) + .collect(Collectors.toList()); + } + throw new DeploymentException("Unable to find images for service <" + serviceId + + "> in the CMDB." + response.getStatusCode().toString() + " " + + response.getStatusCode().getReasonPhrase()); } + // @Override + // public List getImagesAndMetadataByService(String serviceId) { + // List images = new ArrayList<>(); + // for (CmdbImage image : getImagesByService(serviceId)) { + // images.add(getImageById(image.getId())); + // } + // return images; + // } + + // @Override + // public List getImagesByProvider(String providerId) { + // + // + // providerId = "STUB:" + providerId; + // // FIXME: Stub + // return Arrays.asList( + // new Image().withImageName("indigodatacloud/ubuntu-sshd").withImageId(providerId + "/5") + // .withArchitecture("x86_64").withType("linux").withDistribution("ubuntu") + // .withVersion("14.04"), + // new Image().withImageName("linux-ubuntu-14.04").withImageId(providerId + "/5") + // .withArchitecture("x86_64").withType("linux").withDistribution("ubuntu") + // .withVersion("14.04"), + // new Image().withImageName("indigodatacloudapps/docker-galaxy") + // .withImageId(providerId + "/13")); + // } + } diff --git a/src/main/java/it/reply/orchestrator/service/commands/GetCmdbData.java b/src/main/java/it/reply/orchestrator/service/commands/GetCmdbData.java new file mode 100644 index 0000000000..9497c4719f --- /dev/null +++ b/src/main/java/it/reply/orchestrator/service/commands/GetCmdbData.java @@ -0,0 +1,62 @@ +package it.reply.orchestrator.service.commands; + +import it.reply.orchestrator.dto.CloudProvider; +import it.reply.orchestrator.dto.RankCloudProvidersMessage; +import it.reply.orchestrator.dto.cmdb.Service; +import it.reply.orchestrator.dto.cmdb.Type; +import it.reply.orchestrator.service.CmdbService; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.Map; +import java.util.stream.Collectors; + +@Component +public class GetCmdbData extends BaseRankCloudProvidersCommand { + + private static final Logger LOG = LogManager.getLogger(GetCmdbData.class); + + @Autowired + private CmdbService cmdbService; + + @Override + protected RankCloudProvidersMessage + customExecute(RankCloudProvidersMessage rankCloudProvidersMessage) { + + // Get CMDB data for each Cloud Provider + for (Map.Entry providerEntry : rankCloudProvidersMessage + .getCloudProviders().entrySet()) { + CloudProvider cp = providerEntry.getValue(); + // Get provider's data + cp.setCmdbProviderData(cmdbService.getProviderById(providerEntry.getKey())); + cp.setId(providerEntry.getKey()); + cp.setName(cp.getCmdbProviderData().getId()); + + // Get provider's services' data + for (Map.Entry serviceEntry : cp.getCmdbProviderServices().entrySet()) { + serviceEntry.setValue(cmdbService.getServiceById(serviceEntry.getKey())); + } + + // FIXME Get other data (i.e. OneData, Images mapping, etc) + + // Get images for provider (requires to know the compute service) + // FIXME: What if there are multiple compute service for a provider (remember that those are + // SLAM given)? + Service imageService = cp.getCmbdProviderServiceByType(Type.COMPUTE); + if (imageService != null) { + LOG.debug("Retrieving image list for service <{}> of provider <{}>", imageService.getId(), + cp.getId()); + cp.setCmdbProviderImages(cmdbService.getImagesByService(imageService.getId()).stream() + .map(e -> e.getData()).collect(Collectors.toList())); + } else { + LOG.debug("No image service to retrieve image list from for provider <{}>", cp.getId()); + } + } + + return rankCloudProvidersMessage; + } + +} diff --git a/src/test/java/it/reply/orchestrator/service/CmdbServiceIT.java b/src/test/java/it/reply/orchestrator/service/CmdbServiceIT.java index cc2ba27cd8..db30e27a56 100644 --- a/src/test/java/it/reply/orchestrator/service/CmdbServiceIT.java +++ b/src/test/java/it/reply/orchestrator/service/CmdbServiceIT.java @@ -3,6 +3,7 @@ import static org.junit.Assert.assertEquals; import it.reply.orchestrator.config.specific.WebAppConfigurationAwareIT; +import it.reply.orchestrator.dto.cmdb.CmdbImage; import it.reply.orchestrator.dto.cmdb.Data; import it.reply.orchestrator.dto.cmdb.Provider; import it.reply.orchestrator.dto.cmdb.ProviderData; @@ -12,6 +13,8 @@ import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; +import java.util.List; + /** * This integration test makes real request to the CMDB APIs. * @@ -54,4 +57,21 @@ public void getProviderTest() throws Exception { assertEquals(provider, providerRecas); } + @Test + public void getImageForServiceTest() throws Exception { + + List recasImages = service.getImagesByService(recasId); + + // ProviderData data = + // new ProviderData().withId("476").withPrimaryKey("83757G0").withName("RECAS-BARI") + // .withCountry("Italy").withCountryCode("IT").withRoc("NGI_IT").withSubgrid("") + // .withGiisUrl("ldap://cloud-bdii.recas.ba.infn.it:2170/GLUE2DomainID=RECAS-BARI,o=glue"); + // + // Provider p = new Provider().withId(recasProviderName) + // .withRev("1-c7dbe4d8be30aa4c0f14d3ad0411d962").withType("provider").withData(data); + + // assertEquals(p, providerRecas); + + } + } diff --git a/src/test/java/it/reply/orchestrator/workflow/RankCloudProvidersWorkflowTest.java b/src/test/java/it/reply/orchestrator/workflow/RankCloudProvidersWorkflowTest.java index 3e9575541d..78c43eae0f 100644 --- a/src/test/java/it/reply/orchestrator/workflow/RankCloudProvidersWorkflowTest.java +++ b/src/test/java/it/reply/orchestrator/workflow/RankCloudProvidersWorkflowTest.java @@ -154,6 +154,15 @@ public static void mockCmdb(MockRestServiceServer mockServer, String baseUrl) th "{\"_id\":\"4401ac5dc8cfbbb737b0a02575e8040f\",\"_rev\":\"2-be00f87438604f04d353233daabc562c\",\"data\":{\"service_type\":\"eu.egi.cloud.vm-management.occi\",\"endpoint\":\"http://onedock.i3m.upv.es:11443\",\"provider_id\":\"provider-UPV-GRyCAP\",\"type\":\"compute\"},\"type\":\"service\"}", MediaType.APPLICATION_JSON)); + // Images: Compute service on provider-RECAS-BARI + mockServer + .expect(requestTo(baseUrl + + "service/id/4401ac5dc8cfbbb737b0a02575e8040f/has_many/images?include_docs=true")) + .andExpect(method(HttpMethod.GET)) + .andRespond(withSuccess( + "{\n \"total_rows\": 42,\n \"offset\": 0,\n \"rows\": [\n {\n \"id\": \"7efc59c5db69ea67c5100de0f7236866\",\n \"key\": [\n \"4401ac5dc8cfbbb737b0a02575e8040f\",\n \"images\"\n ],\n \"value\": {\n \"image_id\": \"1\",\n \"image_name\": \"indigodatacloud/ubuntu-sshd:14.04-devel\",\n \"service\": \"4401ac5dc8cfbbb737b0a02575e8040f\"\n },\n \"doc\": {\n \"_id\": \"7efc59c5db69ea67c5100de0f7236866\",\n \"_rev\": \"2-105db8faf961d5aa0a215b67942c1821\",\n \"type\": \"image\",\n \"data\": {\n \"image_id\": \"1\",\n \"image_name\": \"indigodatacloud/ubuntu-sshd:14.04-devel\",\n \"architecture\": \"x86_64\",\n \"type\": \"linux\",\n \"distribution\": \"ubuntu\",\n \"version\": \"14.04\",\n \"service\": \"4401ac5dc8cfbbb737b0a02575e8040f\"\n }\n }\n },\n {\n \"id\": \"7efc59c5db69ea67c5100de0f724f37a\",\n \"key\": [\n \"4401ac5dc8cfbbb737b0a02575e8040f\",\n \"images\"\n ],\n \"value\": {\n \"image_id\": \"1\",\n \"image_name\": \"image-create-test\",\n \"service\": \"4401ac5dc8cfbbb737b0a02575e8040f\"\n },\n \"doc\": {\n \"_id\": \"7efc59c5db69ea67c5100de0f724f37a\",\n \"_rev\": \"1-c9bf9d0d3f69738da930d97b8002b2c4\",\n \"type\": \"image\",\n \"data\": {\n \"image_id\": \"1\",\n \"image_name\": \"image-create-test\",\n \"architecture\": \"x86_64\",\n \"type\": \"linux\",\n \"distribution\": \"ubuntu\",\n \"version\": \"14.04\",\n \"service\": \"4401ac5dc8cfbbb737b0a02575e8040f\"\n }\n }\n },\n {\n \"id\": \"7efc59c5db69ea67c5100de0f72580e9\",\n \"key\": [\n \"4401ac5dc8cfbbb737b0a02575e8040f\",\n \"images\"\n ],\n \"value\": {\n \"image_id\": \"xxx\",\n \"image_name\": \"image-create-test\",\n \"service\": \"4401ac5dc8cfbbb737b0a02575e8040f\"\n },\n \"doc\": {\n \"_id\": \"7efc59c5db69ea67c5100de0f72580e9\",\n \"_rev\": \"1-180d402f4985bbd00692937a9bcf717c\",\n \"type\": \"image\",\n \"data\": {\n \"image_id\": \"xxx\",\n \"image_name\": \"image-create-test\",\n \"architecture\": \"x86_64\",\n \"type\": \"linux\",\n \"distribution\": \"ubuntu\",\n \"version\": \"14.04\",\n \"service\": \"4401ac5dc8cfbbb737b0a02575e8040f\"\n }\n }\n }\n ]\n}", + MediaType.APPLICATION_JSON)); + // Provider: provider-UPV-GRyCAP mockServer.expect(requestTo(baseUrl + "provider/id/provider-UPV-GRyCAP")) .andExpect(method(HttpMethod.GET)) @@ -168,6 +177,15 @@ public static void mockCmdb(MockRestServiceServer mockServer, String baseUrl) th "{\"_id\":\"4401ac5dc8cfbbb737b0a02575e6f4bc\",\"_rev\":\"1-256d36283315ea9bb045e6d5038657b6\",\"data\":{\"service_type\":\"eu.egi.cloud.vm-management.openstack\",\"endpoint\":\"http://cloud.recas.ba.infn.it:5000/v2.0\",\"provider_id\":\"provider-RECAS-BARI\",\"type\":\"compute\"},\"type\":\"service\"}", MediaType.APPLICATION_JSON)); + // Images: Compute service on provider-UPV-GRyCAP + mockServer + .expect(requestTo(baseUrl + + "service/id/4401ac5dc8cfbbb737b0a02575e6f4bc/has_many/images?include_docs=true")) + .andExpect(method(HttpMethod.GET)) + .andRespond(withSuccess( + "{\n \"total_rows\": 42,\n \"offset\": 0,\n \"rows\": [\n {\n \"id\": \"7efc59c5db69ea67c5100de0f7236866\",\n \"key\": [\n \"4401ac5dc8cfbbb737b0a02575e8040f\",\n \"images\"\n ],\n \"value\": {\n \"image_id\": \"1\",\n \"image_name\": \"indigodatacloud/ubuntu-sshd:14.04-devel\",\n \"service\": \"4401ac5dc8cfbbb737b0a02575e8040f\"\n },\n \"doc\": {\n \"_id\": \"7efc59c5db69ea67c5100de0f7236866\",\n \"_rev\": \"2-105db8faf961d5aa0a215b67942c1821\",\n \"type\": \"image\",\n \"data\": {\n \"image_id\": \"1\",\n \"image_name\": \"indigodatacloud/ubuntu-sshd:14.04-devel\",\n \"architecture\": \"x86_64\",\n \"type\": \"linux\",\n \"distribution\": \"ubuntu\",\n \"version\": \"14.04\",\n \"service\": \"4401ac5dc8cfbbb737b0a02575e8040f\"\n }\n }\n },\n {\n \"id\": \"7efc59c5db69ea67c5100de0f724f37a\",\n \"key\": [\n \"4401ac5dc8cfbbb737b0a02575e8040f\",\n \"images\"\n ],\n \"value\": {\n \"image_id\": \"1\",\n \"image_name\": \"image-create-test\",\n \"service\": \"4401ac5dc8cfbbb737b0a02575e8040f\"\n },\n \"doc\": {\n \"_id\": \"7efc59c5db69ea67c5100de0f724f37a\",\n \"_rev\": \"1-c9bf9d0d3f69738da930d97b8002b2c4\",\n \"type\": \"image\",\n \"data\": {\n \"image_id\": \"1\",\n \"image_name\": \"image-create-test\",\n \"architecture\": \"x86_64\",\n \"type\": \"linux\",\n \"distribution\": \"ubuntu\",\n \"version\": \"14.04\",\n \"service\": \"4401ac5dc8cfbbb737b0a02575e8040f\"\n }\n }\n },\n {\n \"id\": \"7efc59c5db69ea67c5100de0f72580e9\",\n \"key\": [\n \"4401ac5dc8cfbbb737b0a02575e8040f\",\n \"images\"\n ],\n \"value\": {\n \"image_id\": \"xxx\",\n \"image_name\": \"image-create-test\",\n \"service\": \"4401ac5dc8cfbbb737b0a02575e8040f\"\n },\n \"doc\": {\n \"_id\": \"7efc59c5db69ea67c5100de0f72580e9\",\n \"_rev\": \"1-180d402f4985bbd00692937a9bcf717c\",\n \"type\": \"image\",\n \"data\": {\n \"image_id\": \"xxx\",\n \"image_name\": \"image-create-test\",\n \"architecture\": \"x86_64\",\n \"type\": \"linux\",\n \"distribution\": \"ubuntu\",\n \"version\": \"14.04\",\n \"service\": \"4401ac5dc8cfbbb737b0a02575e8040f\"\n }\n }\n }\n ]\n}", + MediaType.APPLICATION_JSON)); + } public static void mockMonitoring(MockRestServiceServer mockServer, String baseUrl) From e163ce1002ba69b3c04fa8526e689e8afd69b170 Mon Sep 17 00:00:00 2001 From: Lorenzo Biava Date: Thu, 23 Jun 2016 16:03:50 +0200 Subject: [PATCH 12/19] Filter Cloud Providers based on Images required in Deployment See #53 --- .../orchestrator/service/ToscaService.java | 18 +++- .../service/ToscaServiceImpl.java | 14 ++- .../BaseRankCloudProvidersCommand.java | 2 +- .../commands/PrefilterCloudProviders.java | 88 ++++++++++++++++++- 4 files changed, 115 insertions(+), 7 deletions(-) diff --git a/src/main/java/it/reply/orchestrator/service/ToscaService.java b/src/main/java/it/reply/orchestrator/service/ToscaService.java index 5205d38841..461e39d496 100644 --- a/src/main/java/it/reply/orchestrator/service/ToscaService.java +++ b/src/main/java/it/reply/orchestrator/service/ToscaService.java @@ -1,5 +1,7 @@ package it.reply.orchestrator.service; +import com.sun.istack.NotNull; + import alien4cloud.model.components.AbstractPropertyValue; import alien4cloud.model.components.PropertyDefinition; import alien4cloud.model.components.PropertyValue; @@ -10,8 +12,6 @@ import alien4cloud.tosca.parser.ParsingException; import alien4cloud.tosca.parser.ParsingResult; -import com.sun.istack.NotNull; - import it.reply.orchestrator.dto.CloudProvider; import it.reply.orchestrator.exception.service.ToscaException; @@ -80,6 +80,20 @@ public String customizeTemplate(@Nonnull String toscaTemplate, @NotNull String d */ public void contextualizeImages(ArchiveRoot parsingResult, CloudProvider cloudProvider); + /** + * Find matches for images data in 'tosca.capabilities.indigo.OperatingSystem' capabilities in the + * TOSCA template with the provider-specific identifier. + * + * @param parsingResult + * the in-memory TOSCA template. + * @param cloudProvider + * the chosen cloud provider data. + * @param replace + * whether to actually replace the image IDs or just do a dry-run. + */ + public void contextualizeImages(ArchiveRoot parsingResult, CloudProvider cloudProvider, + boolean replace); + /** * Verifies that all the template's required inputs are present in the user's input list. * diff --git a/src/main/java/it/reply/orchestrator/service/ToscaServiceImpl.java b/src/main/java/it/reply/orchestrator/service/ToscaServiceImpl.java index c4c43d1ea9..ac39d7172f 100644 --- a/src/main/java/it/reply/orchestrator/service/ToscaServiceImpl.java +++ b/src/main/java/it/reply/orchestrator/service/ToscaServiceImpl.java @@ -290,6 +290,12 @@ private void checkParsingErrors(List errorList) throws ToscaExcept @Override public void contextualizeImages(ArchiveRoot parsingResult, CloudProvider cloudProvider) { + contextualizeImages(parsingResult, cloudProvider, true); + } + + @Override + public void contextualizeImages(ArchiveRoot parsingResult, CloudProvider cloudProvider, + boolean replace) { try { Map nodes = parsingResult.getTopology().getNodeTemplates(); for (Map.Entry entry : nodes.entrySet()) { @@ -351,9 +357,11 @@ public void contextualizeImages(ArchiveRoot parsingResult, CloudProvider cloudPr LOG.debug(String.format( "Found image match in <%s> for image metadata <%s>, provider-specific image id <%s>", cloudProvider.getId(), imageMetadata, image.getImageId())); - ScalarPropertyValue scalarPropertyValue = new ScalarPropertyValue(image.getImageId()); - scalarPropertyValue.setPrintable(true); - osCapability.getProperties().put("image", scalarPropertyValue); + if (replace) { + ScalarPropertyValue scalarPropertyValue = new ScalarPropertyValue(image.getImageId()); + scalarPropertyValue.setPrintable(true); + osCapability.getProperties().put("image", scalarPropertyValue); + } } } diff --git a/src/main/java/it/reply/orchestrator/service/commands/BaseRankCloudProvidersCommand.java b/src/main/java/it/reply/orchestrator/service/commands/BaseRankCloudProvidersCommand.java index a3ac564a31..6c79996412 100644 --- a/src/main/java/it/reply/orchestrator/service/commands/BaseRankCloudProvidersCommand.java +++ b/src/main/java/it/reply/orchestrator/service/commands/BaseRankCloudProvidersCommand.java @@ -60,6 +60,6 @@ protected ExecutionResults customExecute(CommandContext ctx) throws Exception { } protected abstract RankCloudProvidersMessage - customExecute(RankCloudProvidersMessage rankCloudProvidersMessage); + customExecute(RankCloudProvidersMessage rankCloudProvidersMessage) throws Exception; } diff --git a/src/main/java/it/reply/orchestrator/service/commands/PrefilterCloudProviders.java b/src/main/java/it/reply/orchestrator/service/commands/PrefilterCloudProviders.java index 093c477422..421e4fdf08 100644 --- a/src/main/java/it/reply/orchestrator/service/commands/PrefilterCloudProviders.java +++ b/src/main/java/it/reply/orchestrator/service/commands/PrefilterCloudProviders.java @@ -1,16 +1,102 @@ package it.reply.orchestrator.service.commands; +import alien4cloud.tosca.model.ArchiveRoot; + +import it.reply.orchestrator.dal.entity.Deployment; +import it.reply.orchestrator.dal.repository.DeploymentRepository; +import it.reply.orchestrator.dto.CloudProvider; import it.reply.orchestrator.dto.RankCloudProvidersMessage; +import it.reply.orchestrator.dto.slam.Preference; +import it.reply.orchestrator.dto.slam.PreferenceCustomer; +import it.reply.orchestrator.dto.slam.Priority; +import it.reply.orchestrator.dto.slam.Sla; +import it.reply.orchestrator.service.ToscaService; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + @Component public class PrefilterCloudProviders extends BaseRankCloudProvidersCommand { + private static final Logger LOG = LogManager.getLogger(PrefilterCloudProviders.class); + + @Autowired + private DeploymentRepository deploymentRepository; + + @Autowired + private ToscaService toscaService; + @Override protected RankCloudProvidersMessage - customExecute(RankCloudProvidersMessage rankCloudProvidersMessage) { + customExecute(RankCloudProvidersMessage rankCloudProvidersMessage) throws Exception { // TODO Filter cloud providers (i.e. based on OneData) + + Deployment deployment = + deploymentRepository.findOne(rankCloudProvidersMessage.getDeploymentId()); + + // Filter out providers that do not support the requested images + ArchiveRoot ar = toscaService.parseTemplate(deployment.getTemplate()); + Iterator> it = + rankCloudProvidersMessage.getCloudProviders().entrySet().iterator(); + List providersToDiscard = new ArrayList<>(); + List servicesToDiscard = new ArrayList<>(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + try { + toscaService.contextualizeImages(ar, entry.getValue(), false); + } catch (Exception ex) { + // Failed to match all required images -> discard provider + LOG.debug("Discarded provider {} because it doesn't match images requirements" + + " for deployment {}: {}", entry.getKey(), deployment.getId(), ex.getMessage()); + providersToDiscard.add(entry.getKey()); + servicesToDiscard.addAll(entry.getValue().getCmdbProviderServices().keySet()); + it.remove(); + } + + } + + // Remove discarded provider from SLAs and Preferences + for (String providerName : providersToDiscard) { + Iterator slaIt = rankCloudProvidersMessage.getSlamPreferences().getSla().iterator(); + while (slaIt.hasNext()) { + if (providerName.equals(slaIt.next().getProvider())) { + slaIt.remove(); + } + } + } + + for (String serviceId : servicesToDiscard) { + Iterator extPrefIt = + rankCloudProvidersMessage.getSlamPreferences().getPreferences().iterator(); + while (extPrefIt.hasNext()) { + Preference extPreference = extPrefIt.next(); + Iterator intPrefIt = extPreference.getPreferences().iterator(); + while (intPrefIt.hasNext()) { + PreferenceCustomer intPreference = intPrefIt.next(); + Iterator priorityIt = intPreference.getPriority().iterator(); + while (priorityIt.hasNext()) { + if (serviceId.equals(priorityIt.next().getServiceId())) { + priorityIt.remove(); + } + } + if (intPreference.getPriority().isEmpty()) { + intPrefIt.remove(); + } + } + if (extPreference.getPreferences().isEmpty()) { + extPrefIt.remove(); + } + + } + } + return rankCloudProvidersMessage; } From 17cb4a3b54459cce659fea8a6d3a695a15c6e6b4 Mon Sep 17 00:00:00 2001 From: Lorenzo Biava Date: Thu, 23 Jun 2016 17:26:59 +0200 Subject: [PATCH 13/19] Fix failing tests (updated demo Service IDs) --- .../command/GetCMDBDataCommandTest.java | 2 +- .../command/GetMonitoringDataCommandTest.java | 2 +- .../command/GetProvidersRankCommandTest.java | 2 +- .../CloudProviderRankerServiceTest.java | 2 +- .../RankCloudProvidersWorkflowTest.java | 18 +++++++++--------- .../slam/preferences-indigo-demo.json | 4 ++-- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/test/java/it/reply/orchestrator/command/GetCMDBDataCommandTest.java b/src/test/java/it/reply/orchestrator/command/GetCMDBDataCommandTest.java index 44d1c283eb..48b3db4264 100644 --- a/src/test/java/it/reply/orchestrator/command/GetCMDBDataCommandTest.java +++ b/src/test/java/it/reply/orchestrator/command/GetCMDBDataCommandTest.java @@ -37,7 +37,7 @@ public void doexecuteSuccesfully() throws Exception { RankCloudProvidersWorkflowTest.mockCmdb(mockServer, cmdbService.getUrl()); ExecutionResults er = executeCommand(JsonUtility.deserializeJson( - "{\"deploymentId\":\"mmd34483-d937-4578-bfdb-ebe196bf82dd\",\"slamPreferences\":{\"preferences\":[{\"customer\":\"indigo-dc\",\"preferences\":[{\"service_type\":\"compute\",\"priority\":[{\"sla_id\":\"4401ac5dc8cfbbb737b0a02575ee53f6\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e8040f\",\"weight\":0.5},{\"sla_id\":\"4401ac5dc8cfbbb737b0a02575ee3b58\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e6f4bc\",\"weight\":0.5}]}],\"id\":\"4401ac5dc8cfbbb737b0a02575ee0e55\"}],\"sla\":[{\"customer\":\"indigo-dc\",\"provider\":\"provider-UPV-GRyCAP\",\"start_date\":\"11.01.2016+15:50:00\",\"end_date\":\"11.02.2016+15:50:00\",\"services\":[{\"type\":\"compute\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e6f4bc\",\"targets\":[{\"type\":\"public_ip\",\"unit\":\"none\",\"restrictions\":{\"total_guaranteed\":10}}]}],\"id\":\"4401ac5dc8cfbbb737b0a02575ee3b58\"},{\"customer\":\"indigo-dc\",\"provider\":\"provider-RECAS-BARI\",\"start_date\":\"11.01.2016+15:50:00\",\"end_date\":\"11.02.2016+15:50:00\",\"services\":[{\"type\":\"compute\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e8040f\",\"targets\":[{\"type\":\"computing_time\",\"unit\":\"h\",\"restrictions\":{\"total_guaranteed\":200}}]}],\"id\":\"4401ac5dc8cfbbb737b0a02575ee53f6\"}]},\"cloudProviders\":{\"provider-RECAS-BARI\":{\"name\":null,\"id\":\"provider-RECAS-BARI\",\"cmdbProviderData\":null,\"cmdbProviderServices\":{\"4401ac5dc8cfbbb737b0a02575e8040f\":null}},\"provider-UPV-GRyCAP\":{\"name\":null,\"id\":\"provider-UPV-GRyCAP\",\"cmdbProviderData\":null,\"cmdbProviderServices\":{\"4401ac5dc8cfbbb737b0a02575e6f4bc\":null}}},\"cloudProvidersMonitoringData\":{},\"rankedCloudProviders\":[]}", + "{\"deploymentId\":\"mmd34483-d937-4578-bfdb-ebe196bf82dd\",\"slamPreferences\":{\"preferences\":[{\"customer\":\"indigo-dc\",\"preferences\":[{\"service_type\":\"compute\",\"priority\":[{\"sla_id\":\"4401ac5dc8cfbbb737b0a02575ee53f6\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e81d9b\",\"weight\":0.5},{\"sla_id\":\"4401ac5dc8cfbbb737b0a02575ee3b58\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e6f4bc\",\"weight\":0.5}]}],\"id\":\"4401ac5dc8cfbbb737b0a02575ee0e55\"}],\"sla\":[{\"customer\":\"indigo-dc\",\"provider\":\"provider-UPV-GRyCAP\",\"start_date\":\"11.01.2016+15:50:00\",\"end_date\":\"11.02.2016+15:50:00\",\"services\":[{\"type\":\"compute\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e81d9b\",\"targets\":[{\"type\":\"public_ip\",\"unit\":\"none\",\"restrictions\":{\"total_guaranteed\":10}}]}],\"id\":\"4401ac5dc8cfbbb737b0a02575ee3b58\"},{\"customer\":\"indigo-dc\",\"provider\":\"provider-RECAS-BARI\",\"start_date\":\"11.01.2016+15:50:00\",\"end_date\":\"11.02.2016+15:50:00\",\"services\":[{\"type\":\"compute\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e6f4bc\",\"targets\":[{\"type\":\"computing_time\",\"unit\":\"h\",\"restrictions\":{\"total_guaranteed\":200}}]}],\"id\":\"4401ac5dc8cfbbb737b0a02575ee53f6\"}]},\"cloudProviders\":{\"provider-RECAS-BARI\":{\"name\":null,\"id\":\"provider-RECAS-BARI\",\"cmdbProviderData\":null,\"cmdbProviderServices\":{\"4401ac5dc8cfbbb737b0a02575e6f4bc\":null},\"cmdbProviderImages\":[]},\"provider-UPV-GRyCAP\":{\"name\":null,\"id\":\"provider-UPV-GRyCAP\",\"cmdbProviderData\":null,\"cmdbProviderServices\":{\"4401ac5dc8cfbbb737b0a02575e81d9b\":null},\"cmdbProviderImages\":[]}},\"cloudProvidersMonitoringData\":{},\"rankedCloudProviders\":[]}", RankCloudProvidersMessage.class)); assertEquals(true, commandSucceeded(er)); diff --git a/src/test/java/it/reply/orchestrator/command/GetMonitoringDataCommandTest.java b/src/test/java/it/reply/orchestrator/command/GetMonitoringDataCommandTest.java index fdea53f357..b9422b6217 100644 --- a/src/test/java/it/reply/orchestrator/command/GetMonitoringDataCommandTest.java +++ b/src/test/java/it/reply/orchestrator/command/GetMonitoringDataCommandTest.java @@ -37,7 +37,7 @@ public void doexecuteSuccesfully() throws Exception { RankCloudProvidersWorkflowTest.mockMonitoring(mockServer, monitoringService.getUrl()); ExecutionResults er = executeCommand(JsonUtility.deserializeJson( - "{\"deploymentId\":\"mmd34483-d937-4578-bfdb-ebe196bf82dd\",\"slamPreferences\":{\"preferences\":[{\"customer\":\"indigo-dc\",\"preferences\":[{\"service_type\":\"compute\",\"priority\":[{\"sla_id\":\"4401ac5dc8cfbbb737b0a02575ee53f6\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e8040f\",\"weight\":0.5},{\"sla_id\":\"4401ac5dc8cfbbb737b0a02575ee3b58\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e6f4bc\",\"weight\":0.5}]}],\"id\":\"4401ac5dc8cfbbb737b0a02575ee0e55\"}],\"sla\":[{\"customer\":\"indigo-dc\",\"provider\":\"provider-UPV-GRyCAP\",\"start_date\":\"11.01.2016+15:50:00\",\"end_date\":\"11.02.2016+15:50:00\",\"services\":[{\"type\":\"compute\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e6f4bc\",\"targets\":[{\"type\":\"public_ip\",\"unit\":\"none\",\"restrictions\":{\"total_guaranteed\":10}}]}],\"id\":\"4401ac5dc8cfbbb737b0a02575ee3b58\"},{\"customer\":\"indigo-dc\",\"provider\":\"provider-RECAS-BARI\",\"start_date\":\"11.01.2016+15:50:00\",\"end_date\":\"11.02.2016+15:50:00\",\"services\":[{\"type\":\"compute\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e8040f\",\"targets\":[{\"type\":\"computing_time\",\"unit\":\"h\",\"restrictions\":{\"total_guaranteed\":200}}]}],\"id\":\"4401ac5dc8cfbbb737b0a02575ee53f6\"}]},\"cloudProviders\":{\"provider-RECAS-BARI\":{\"name\":\"provider-RECAS-BARI\",\"id\":\"provider-RECAS-BARI\",\"cmdbProviderData\":{\"_id\":\"provider-RECAS-BARI\",\"_rev\":\"1-c7dbe4d8be30aa4c0f14d3ad0411d962\",\"data\":{\"id\":\"476\",\"primary_key\":\"83757G0\",\"name\":\"RECAS-BARI\",\"country\":\"Italy\",\"country_code\":\"IT\",\"roc\":\"NGI_IT\",\"subgrid\":\"\",\"giis_url\":\"ldap://cloud-bdii.recas.ba.infn.it:2170/GLUE2DomainID=RECAS-BARI,o=glue\"},\"type\":\"provider\"},\"cmdbProviderServices\":{\"4401ac5dc8cfbbb737b0a02575e8040f\":{\"_id\":\"4401ac5dc8cfbbb737b0a02575e8040f\",\"_rev\":\"2-be00f87438604f04d353233daabc562c\",\"data\":{\"service_type\":\"eu.egi.cloud.vm-management.occi\",\"endpoint\":\"http://onedock.i3m.upv.es:11443\",\"provider_id\":\"provider-UPV-GRyCAP\",\"type\":\"compute\"},\"type\":\"service\"}}},\"provider-UPV-GRyCAP\":{\"name\":\"provider-UPV-GRyCAP\",\"id\":\"provider-UPV-GRyCAP\",\"cmdbProviderData\":{\"_id\":\"provider-UPV-GRyCAP\",\"_rev\":\"1-0a5ba48b2d6e0c26d36b0e3e81175352\",\"data\":{\"id\":\"458\",\"primary_key\":\"135G0\",\"name\":\"UPV-GRyCAP\",\"country\":\"Spain\",\"country_code\":\"ES\",\"roc\":\"NGI_IBERGRID\",\"subgrid\":\"\",\"giis_url\":\"ldap://ngiesbdii.i3m.upv.es:2170/mds-vo-name=UPV-GRyCAP,o=grid\"},\"type\":\"provider\"},\"cmdbProviderServices\":{\"4401ac5dc8cfbbb737b0a02575e6f4bc\":{\"_id\":\"4401ac5dc8cfbbb737b0a02575e6f4bc\",\"_rev\":\"1-256d36283315ea9bb045e6d5038657b6\",\"data\":{\"service_type\":\"eu.egi.cloud.vm-management.openstack\",\"endpoint\":\"http://cloud.recas.ba.infn.it:5000/v2.0\",\"provider_id\":\"provider-RECAS-BARI\",\"type\":\"compute\"},\"type\":\"service\"}}}},\"cloudProvidersMonitoringData\":{},\"rankedCloudProviders\":[]}", + "{\"deploymentId\":\"mmd34483-d937-4578-bfdb-ebe196bf82dd\",\"slamPreferences\":{\"preferences\":[{\"customer\":\"indigo-dc\",\"preferences\":[{\"service_type\":\"compute\",\"priority\":[{\"sla_id\":\"4401ac5dc8cfbbb737b0a02575ee53f6\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e81d9b\",\"weight\":0.5},{\"sla_id\":\"4401ac5dc8cfbbb737b0a02575ee3b58\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e6f4bc\",\"weight\":0.5}]}],\"id\":\"4401ac5dc8cfbbb737b0a02575ee0e55\"}],\"sla\":[{\"customer\":\"indigo-dc\",\"provider\":\"provider-UPV-GRyCAP\",\"start_date\":\"11.01.2016+15:50:00\",\"end_date\":\"11.02.2016+15:50:00\",\"services\":[{\"type\":\"compute\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e6f4bc\",\"targets\":[{\"type\":\"public_ip\",\"unit\":\"none\",\"restrictions\":{\"total_guaranteed\":10}}]}],\"id\":\"4401ac5dc8cfbbb737b0a02575ee3b58\"},{\"customer\":\"indigo-dc\",\"provider\":\"provider-RECAS-BARI\",\"start_date\":\"11.01.2016+15:50:00\",\"end_date\":\"11.02.2016+15:50:00\",\"services\":[{\"type\":\"compute\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e6f4bc\",\"targets\":[{\"type\":\"computing_time\",\"unit\":\"h\",\"restrictions\":{\"total_guaranteed\":200}}]}],\"id\":\"4401ac5dc8cfbbb737b0a02575ee53f6\"}]},\"cloudProviders\":{\"provider-RECAS-BARI\":{\"name\":\"provider-RECAS-BARI\",\"id\":\"provider-RECAS-BARI\",\"cmdbProviderData\":{\"_id\":\"provider-RECAS-BARI\",\"_rev\":\"1-c7dbe4d8be30aa4c0f14d3ad0411d962\",\"data\":{\"id\":\"476\",\"primary_key\":\"83757G0\",\"name\":\"RECAS-BARI\",\"country\":\"Italy\",\"country_code\":\"IT\",\"roc\":\"NGI_IT\",\"subgrid\":\"\",\"giis_url\":\"ldap://cloud-bdii.recas.ba.infn.it:2170/GLUE2DomainID=RECAS-BARI,o=glue\"},\"type\":\"provider\"},\"cmdbProviderServices\":{\"4401ac5dc8cfbbb737b0a02575e81d9b\":{\"_id\":\"4401ac5dc8cfbbb737b0a02575e81d9b\",\"_rev\":\"2-be00f87438604f04d353233daabc562c\",\"data\":{\"service_type\":\"eu.egi.cloud.vm-management.occi\",\"endpoint\":\"http://onedock.i3m.upv.es:11443\",\"provider_id\":\"provider-UPV-GRyCAP\",\"type\":\"compute\"},\"type\":\"service\"}}},\"provider-UPV-GRyCAP\":{\"name\":\"provider-UPV-GRyCAP\",\"id\":\"provider-UPV-GRyCAP\",\"cmdbProviderData\":{\"_id\":\"provider-UPV-GRyCAP\",\"_rev\":\"1-0a5ba48b2d6e0c26d36b0e3e81175352\",\"data\":{\"id\":\"458\",\"primary_key\":\"135G0\",\"name\":\"UPV-GRyCAP\",\"country\":\"Spain\",\"country_code\":\"ES\",\"roc\":\"NGI_IBERGRID\",\"subgrid\":\"\",\"giis_url\":\"ldap://ngiesbdii.i3m.upv.es:2170/mds-vo-name=UPV-GRyCAP,o=grid\"},\"type\":\"provider\"},\"cmdbProviderServices\":{\"4401ac5dc8cfbbb737b0a02575e81d9b\":{\"_id\":\"4401ac5dc8cfbbb737b0a02575e6f4bc\",\"_rev\":\"1-256d36283315ea9bb045e6d5038657b6\",\"data\":{\"service_type\":\"eu.egi.cloud.vm-management.openstack\",\"endpoint\":\"http://cloud.recas.ba.infn.it:5000/v2.0\",\"provider_id\":\"provider-RECAS-BARI\",\"type\":\"compute\"},\"type\":\"service\"}}}},\"cloudProvidersMonitoringData\":{},\"rankedCloudProviders\":[]}", RankCloudProvidersMessage.class)); assertEquals(true, commandSucceeded(er)); diff --git a/src/test/java/it/reply/orchestrator/command/GetProvidersRankCommandTest.java b/src/test/java/it/reply/orchestrator/command/GetProvidersRankCommandTest.java index 71dcba2a02..da42d2b8aa 100644 --- a/src/test/java/it/reply/orchestrator/command/GetProvidersRankCommandTest.java +++ b/src/test/java/it/reply/orchestrator/command/GetProvidersRankCommandTest.java @@ -37,7 +37,7 @@ public void doexecuteSuccesfully() throws Exception { RankCloudProvidersWorkflowTest.mockCpr(mockServer, cloudProviderRankerService.getUrl()); ExecutionResults er = executeCommand(JsonUtility.deserializeJson( - "{\"deploymentId\":\"mmd34483-d937-4578-bfdb-ebe196bf82dd\",\"slamPreferences\":{\"preferences\":[{\"customer\":\"indigo-dc\",\"preferences\":[{\"service_type\":\"compute\",\"priority\":[{\"sla_id\":\"4401ac5dc8cfbbb737b0a02575ee53f6\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e8040f\",\"weight\":0.5},{\"sla_id\":\"4401ac5dc8cfbbb737b0a02575ee3b58\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e6f4bc\",\"weight\":0.5}]}],\"id\":\"4401ac5dc8cfbbb737b0a02575ee0e55\"}],\"sla\":[{\"customer\":\"indigo-dc\",\"provider\":\"provider-UPV-GRyCAP\",\"start_date\":\"11.01.2016+15:50:00\",\"end_date\":\"11.02.2016+15:50:00\",\"services\":[{\"type\":\"compute\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e6f4bc\",\"targets\":[{\"type\":\"public_ip\",\"unit\":\"none\",\"restrictions\":{\"total_guaranteed\":10}}]}],\"id\":\"4401ac5dc8cfbbb737b0a02575ee3b58\"},{\"customer\":\"indigo-dc\",\"provider\":\"provider-RECAS-BARI\",\"start_date\":\"11.01.2016+15:50:00\",\"end_date\":\"11.02.2016+15:50:00\",\"services\":[{\"type\":\"compute\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e8040f\",\"targets\":[{\"type\":\"computing_time\",\"unit\":\"h\",\"restrictions\":{\"total_guaranteed\":200}}]}],\"id\":\"4401ac5dc8cfbbb737b0a02575ee53f6\"}]},\"cloudProviders\":{\"provider-RECAS-BARI\":{\"name\":\"provider-RECAS-BARI\",\"id\":\"provider-RECAS-BARI\",\"cmdbProviderData\":{\"_id\":\"provider-RECAS-BARI\",\"_rev\":\"1-c7dbe4d8be30aa4c0f14d3ad0411d962\",\"data\":{\"id\":\"476\",\"primary_key\":\"83757G0\",\"name\":\"RECAS-BARI\",\"country\":\"Italy\",\"country_code\":\"IT\",\"roc\":\"NGI_IT\",\"subgrid\":\"\",\"giis_url\":\"ldap://cloud-bdii.recas.ba.infn.it:2170/GLUE2DomainID=RECAS-BARI,o=glue\"},\"type\":\"provider\"},\"cmdbProviderServices\":{\"4401ac5dc8cfbbb737b0a02575e8040f\":{\"_id\":\"4401ac5dc8cfbbb737b0a02575e8040f\",\"_rev\":\"2-be00f87438604f04d353233daabc562c\",\"data\":{\"service_type\":\"eu.egi.cloud.vm-management.occi\",\"endpoint\":\"http://onedock.i3m.upv.es:11443\",\"provider_id\":\"provider-UPV-GRyCAP\",\"type\":\"compute\"},\"type\":\"service\"}}},\"provider-UPV-GRyCAP\":{\"name\":\"provider-UPV-GRyCAP\",\"id\":\"provider-UPV-GRyCAP\",\"cmdbProviderData\":{\"_id\":\"provider-UPV-GRyCAP\",\"_rev\":\"1-0a5ba48b2d6e0c26d36b0e3e81175352\",\"data\":{\"id\":\"458\",\"primary_key\":\"135G0\",\"name\":\"UPV-GRyCAP\",\"country\":\"Spain\",\"country_code\":\"ES\",\"roc\":\"NGI_IBERGRID\",\"subgrid\":\"\",\"giis_url\":\"ldap://ngiesbdii.i3m.upv.es:2170/mds-vo-name=UPV-GRyCAP,o=grid\"},\"type\":\"provider\"},\"cmdbProviderServices\":{\"4401ac5dc8cfbbb737b0a02575e6f4bc\":{\"_id\":\"4401ac5dc8cfbbb737b0a02575e6f4bc\",\"_rev\":\"1-256d36283315ea9bb045e6d5038657b6\",\"data\":{\"service_type\":\"eu.egi.cloud.vm-management.openstack\",\"endpoint\":\"http://cloud.recas.ba.infn.it:5000/v2.0\",\"provider_id\":\"provider-RECAS-BARI\",\"type\":\"compute\"},\"type\":\"service\"}}}},\"cloudProvidersMonitoringData\":{\"provider-RECAS-BARI\":[{\"metricName\":\"OCCI Create VM availability\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI Create VM availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI CreateVM Response Time\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI CreateVM Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI CreateVM Result\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI CreateVM Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI Delete VM Availability\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI Delete VM Availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI DeleteVM Response Time\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI DeleteVM Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI DeleteVM Result\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI DeleteVM Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"General OCCI API Availability\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..General OCCI API Availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"General OCCI API Response Time\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..General OCCI API Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"General OCCI API Result\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..General OCCI API Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI Inspect VM availability\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI Inspect VM availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI InspectVM Response Time\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI InspectVM Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI InspectVM Result\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI InspectVM Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]}],\"provider-UPV-GRyCAP\":[{\"metricName\":\"OCCI Create VM availability\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI Create VM availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI CreateVM Response Time\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI CreateVM Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI CreateVM Result\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI CreateVM Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI Delete VM Availability\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI Delete VM Availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI DeleteVM Response Time\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI DeleteVM Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI DeleteVM Result\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI DeleteVM Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"General OCCI API Availability\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..General OCCI API Availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"General OCCI API Response Time\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..General OCCI API Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"General OCCI API Result\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..General OCCI API Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI Inspect VM availability\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI Inspect VM availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI InspectVM Response Time\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI InspectVM Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI InspectVM Result\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI InspectVM Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]}]},\"rankedCloudProviders\":[]}", + "{\"deploymentId\":\"mmd34483-d937-4578-bfdb-ebe196bf82dd\",\"slamPreferences\":{\"preferences\":[{\"customer\":\"indigo-dc\",\"preferences\":[{\"service_type\":\"compute\",\"priority\":[{\"sla_id\":\"4401ac5dc8cfbbb737b0a02575ee53f6\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e81d9b\",\"weight\":0.5},{\"sla_id\":\"4401ac5dc8cfbbb737b0a02575ee3b58\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e6f4bc\",\"weight\":0.5}]}],\"id\":\"4401ac5dc8cfbbb737b0a02575ee0e55\"}],\"sla\":[{\"customer\":\"indigo-dc\",\"provider\":\"provider-UPV-GRyCAP\",\"start_date\":\"11.01.2016+15:50:00\",\"end_date\":\"11.02.2016+15:50:00\",\"services\":[{\"type\":\"compute\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e6f4bc\",\"targets\":[{\"type\":\"public_ip\",\"unit\":\"none\",\"restrictions\":{\"total_guaranteed\":10}}]}],\"id\":\"4401ac5dc8cfbbb737b0a02575ee3b58\"},{\"customer\":\"indigo-dc\",\"provider\":\"provider-RECAS-BARI\",\"start_date\":\"11.01.2016+15:50:00\",\"end_date\":\"11.02.2016+15:50:00\",\"services\":[{\"type\":\"compute\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e6f4bc\",\"targets\":[{\"type\":\"computing_time\",\"unit\":\"h\",\"restrictions\":{\"total_guaranteed\":200}}]}],\"id\":\"4401ac5dc8cfbbb737b0a02575ee53f6\"}]},\"cloudProviders\":{\"provider-RECAS-BARI\":{\"name\":\"provider-RECAS-BARI\",\"id\":\"provider-RECAS-BARI\",\"cmdbProviderData\":{\"_id\":\"provider-RECAS-BARI\",\"_rev\":\"1-c7dbe4d8be30aa4c0f14d3ad0411d962\",\"data\":{\"id\":\"476\",\"primary_key\":\"83757G0\",\"name\":\"RECAS-BARI\",\"country\":\"Italy\",\"country_code\":\"IT\",\"roc\":\"NGI_IT\",\"subgrid\":\"\",\"giis_url\":\"ldap://cloud-bdii.recas.ba.infn.it:2170/GLUE2DomainID=RECAS-BARI,o=glue\"},\"type\":\"provider\"},\"cmdbProviderServices\":{\"4401ac5dc8cfbbb737b0a02575e81d9b\":{\"_id\":\"4401ac5dc8cfbbb737b0a02575e81d9b\",\"_rev\":\"2-be00f87438604f04d353233daabc562c\",\"data\":{\"service_type\":\"eu.egi.cloud.vm-management.occi\",\"endpoint\":\"http://onedock.i3m.upv.es:11443\",\"provider_id\":\"provider-UPV-GRyCAP\",\"type\":\"compute\"},\"type\":\"service\"}}},\"provider-UPV-GRyCAP\":{\"name\":\"provider-UPV-GRyCAP\",\"id\":\"provider-UPV-GRyCAP\",\"cmdbProviderData\":{\"_id\":\"provider-UPV-GRyCAP\",\"_rev\":\"1-0a5ba48b2d6e0c26d36b0e3e81175352\",\"data\":{\"id\":\"458\",\"primary_key\":\"135G0\",\"name\":\"UPV-GRyCAP\",\"country\":\"Spain\",\"country_code\":\"ES\",\"roc\":\"NGI_IBERGRID\",\"subgrid\":\"\",\"giis_url\":\"ldap://ngiesbdii.i3m.upv.es:2170/mds-vo-name=UPV-GRyCAP,o=grid\"},\"type\":\"provider\"},\"cmdbProviderServices\":{\"4401ac5dc8cfbbb737b0a02575e81d9b\":{\"_id\":\"4401ac5dc8cfbbb737b0a02575e6f4bc\",\"_rev\":\"1-256d36283315ea9bb045e6d5038657b6\",\"data\":{\"service_type\":\"eu.egi.cloud.vm-management.openstack\",\"endpoint\":\"http://cloud.recas.ba.infn.it:5000/v2.0\",\"provider_id\":\"provider-RECAS-BARI\",\"type\":\"compute\"},\"type\":\"service\"}}}},\"cloudProvidersMonitoringData\":{\"provider-RECAS-BARI\":[{\"metricName\":\"OCCI Create VM availability\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI Create VM availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI CreateVM Response Time\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI CreateVM Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI CreateVM Result\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI CreateVM Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI Delete VM Availability\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI Delete VM Availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI DeleteVM Response Time\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI DeleteVM Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI DeleteVM Result\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI DeleteVM Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"General OCCI API Availability\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..General OCCI API Availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"General OCCI API Response Time\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..General OCCI API Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"General OCCI API Result\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..General OCCI API Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI Inspect VM availability\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI Inspect VM availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI InspectVM Response Time\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI InspectVM Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI InspectVM Result\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI InspectVM Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]}],\"provider-UPV-GRyCAP\":[{\"metricName\":\"OCCI Create VM availability\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI Create VM availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI CreateVM Response Time\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI CreateVM Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI CreateVM Result\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI CreateVM Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI Delete VM Availability\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI Delete VM Availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI DeleteVM Response Time\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI DeleteVM Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI DeleteVM Result\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI DeleteVM Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"General OCCI API Availability\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..General OCCI API Availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"General OCCI API Response Time\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..General OCCI API Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"General OCCI API Result\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..General OCCI API Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI Inspect VM availability\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI Inspect VM availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI InspectVM Response Time\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI InspectVM Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI InspectVM Result\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI InspectVM Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]}]},\"rankedCloudProviders\":[]}", RankCloudProvidersMessage.class)); assertEquals(true, commandSucceeded(er)); diff --git a/src/test/java/it/reply/orchestrator/service/CloudProviderRankerServiceTest.java b/src/test/java/it/reply/orchestrator/service/CloudProviderRankerServiceTest.java index 5eddf5c6cd..a87476e446 100644 --- a/src/test/java/it/reply/orchestrator/service/CloudProviderRankerServiceTest.java +++ b/src/test/java/it/reply/orchestrator/service/CloudProviderRankerServiceTest.java @@ -31,7 +31,7 @@ public class CloudProviderRankerServiceTest extends WebAppConfigurationAwareIT { public void rankProviders() throws Exception { RankCloudProvidersMessage rcpm = JsonUtility.deserializeJson( - "{\"deploymentId\":\"mmd34483-d937-4578-bfdb-ebe196bf82dd\",\"slamPreferences\":{\"preferences\":[{\"customer\":\"indigo-dc\",\"preferences\":[{\"service_type\":\"compute\",\"priority\":[{\"sla_id\":\"4401ac5dc8cfbbb737b0a02575ee53f6\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e8040f\",\"weight\":0.5},{\"sla_id\":\"4401ac5dc8cfbbb737b0a02575ee3b58\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e6f4bc\",\"weight\":0.5}]}],\"id\":\"4401ac5dc8cfbbb737b0a02575ee0e55\"}],\"sla\":[{\"customer\":\"indigo-dc\",\"provider\":\"provider-UPV-GRyCAP\",\"start_date\":\"11.01.2016+15:50:00\",\"end_date\":\"11.02.2016+15:50:00\",\"services\":[{\"type\":\"compute\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e6f4bc\",\"targets\":[{\"type\":\"public_ip\",\"unit\":\"none\",\"restrictions\":{\"total_guaranteed\":10}}]}],\"id\":\"4401ac5dc8cfbbb737b0a02575ee3b58\"},{\"customer\":\"indigo-dc\",\"provider\":\"provider-RECAS-BARI\",\"start_date\":\"11.01.2016+15:50:00\",\"end_date\":\"11.02.2016+15:50:00\",\"services\":[{\"type\":\"compute\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e8040f\",\"targets\":[{\"type\":\"computing_time\",\"unit\":\"h\",\"restrictions\":{\"total_guaranteed\":200}}]}],\"id\":\"4401ac5dc8cfbbb737b0a02575ee53f6\"}]},\"cloudProviders\":{\"provider-RECAS-BARI\":{\"name\":\"provider-RECAS-BARI\",\"id\":\"provider-RECAS-BARI\",\"cmdbProviderData\":{\"_id\":\"provider-RECAS-BARI\",\"_rev\":\"1-c7dbe4d8be30aa4c0f14d3ad0411d962\",\"data\":{\"id\":\"476\",\"primary_key\":\"83757G0\",\"name\":\"RECAS-BARI\",\"country\":\"Italy\",\"country_code\":\"IT\",\"roc\":\"NGI_IT\",\"subgrid\":\"\",\"giis_url\":\"ldap://cloud-bdii.recas.ba.infn.it:2170/GLUE2DomainID=RECAS-BARI,o=glue\"},\"type\":\"provider\"},\"cmdbProviderServices\":{\"4401ac5dc8cfbbb737b0a02575e8040f\":{\"_id\":\"4401ac5dc8cfbbb737b0a02575e8040f\",\"_rev\":\"2-be00f87438604f04d353233daabc562c\",\"data\":{\"service_type\":\"eu.egi.cloud.vm-management.occi\",\"endpoint\":\"http://onedock.i3m.upv.es:11443\",\"provider_id\":\"provider-UPV-GRyCAP\",\"type\":\"compute\"},\"type\":\"service\"}}},\"provider-UPV-GRyCAP\":{\"name\":\"provider-UPV-GRyCAP\",\"id\":\"provider-UPV-GRyCAP\",\"cmdbProviderData\":{\"_id\":\"provider-UPV-GRyCAP\",\"_rev\":\"1-0a5ba48b2d6e0c26d36b0e3e81175352\",\"data\":{\"id\":\"458\",\"primary_key\":\"135G0\",\"name\":\"UPV-GRyCAP\",\"country\":\"Spain\",\"country_code\":\"ES\",\"roc\":\"NGI_IBERGRID\",\"subgrid\":\"\",\"giis_url\":\"ldap://ngiesbdii.i3m.upv.es:2170/mds-vo-name=UPV-GRyCAP,o=grid\"},\"type\":\"provider\"},\"cmdbProviderServices\":{\"4401ac5dc8cfbbb737b0a02575e6f4bc\":{\"_id\":\"4401ac5dc8cfbbb737b0a02575e6f4bc\",\"_rev\":\"1-256d36283315ea9bb045e6d5038657b6\",\"data\":{\"service_type\":\"eu.egi.cloud.vm-management.openstack\",\"endpoint\":\"http://cloud.recas.ba.infn.it:5000/v2.0\",\"provider_id\":\"provider-RECAS-BARI\",\"type\":\"compute\"},\"type\":\"service\"}}}},\"cloudProvidersMonitoringData\":{\"provider-RECAS-BARI\":[{\"metricName\":\"OCCI Create VM availability\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI Create VM availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI CreateVM Response Time\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI CreateVM Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI CreateVM Result\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI CreateVM Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI Delete VM Availability\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI Delete VM Availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI DeleteVM Response Time\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI DeleteVM Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI DeleteVM Result\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI DeleteVM Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"General OCCI API Availability\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..General OCCI API Availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"General OCCI API Response Time\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..General OCCI API Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"General OCCI API Result\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..General OCCI API Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI Inspect VM availability\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI Inspect VM availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI InspectVM Response Time\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI InspectVM Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI InspectVM Result\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI InspectVM Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]}],\"provider-UPV-GRyCAP\":[{\"metricName\":\"OCCI Create VM availability\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI Create VM availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI CreateVM Response Time\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI CreateVM Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI CreateVM Result\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI CreateVM Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI Delete VM Availability\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI Delete VM Availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI DeleteVM Response Time\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI DeleteVM Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI DeleteVM Result\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI DeleteVM Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"General OCCI API Availability\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..General OCCI API Availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"General OCCI API Response Time\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..General OCCI API Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"General OCCI API Result\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..General OCCI API Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI Inspect VM availability\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI Inspect VM availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI InspectVM Response Time\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI InspectVM Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI InspectVM Result\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI InspectVM Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]}]},\"rankedCloudProviders\":[]}", + "{\"deploymentId\":\"mmd34483-d937-4578-bfdb-ebe196bf82dd\",\"slamPreferences\":{\"preferences\":[{\"customer\":\"indigo-dc\",\"preferences\":[{\"service_type\":\"compute\",\"priority\":[{\"sla_id\":\"4401ac5dc8cfbbb737b0a02575ee53f6\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e81d9b\",\"weight\":0.5},{\"sla_id\":\"4401ac5dc8cfbbb737b0a02575ee3b58\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e6f4bc\",\"weight\":0.5}]}],\"id\":\"4401ac5dc8cfbbb737b0a02575ee0e55\"}],\"sla\":[{\"customer\":\"indigo-dc\",\"provider\":\"provider-UPV-GRyCAP\",\"start_date\":\"11.01.2016+15:50:00\",\"end_date\":\"11.02.2016+15:50:00\",\"services\":[{\"type\":\"compute\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e6f4bc\",\"targets\":[{\"type\":\"public_ip\",\"unit\":\"none\",\"restrictions\":{\"total_guaranteed\":10}}]}],\"id\":\"4401ac5dc8cfbbb737b0a02575ee3b58\"},{\"customer\":\"indigo-dc\",\"provider\":\"provider-RECAS-BARI\",\"start_date\":\"11.01.2016+15:50:00\",\"end_date\":\"11.02.2016+15:50:00\",\"services\":[{\"type\":\"compute\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e6f4bc\",\"targets\":[{\"type\":\"computing_time\",\"unit\":\"h\",\"restrictions\":{\"total_guaranteed\":200}}]}],\"id\":\"4401ac5dc8cfbbb737b0a02575ee53f6\"}]},\"cloudProviders\":{\"provider-RECAS-BARI\":{\"name\":\"provider-RECAS-BARI\",\"id\":\"provider-RECAS-BARI\",\"cmdbProviderData\":{\"_id\":\"provider-RECAS-BARI\",\"_rev\":\"1-c7dbe4d8be30aa4c0f14d3ad0411d962\",\"data\":{\"id\":\"476\",\"primary_key\":\"83757G0\",\"name\":\"RECAS-BARI\",\"country\":\"Italy\",\"country_code\":\"IT\",\"roc\":\"NGI_IT\",\"subgrid\":\"\",\"giis_url\":\"ldap://cloud-bdii.recas.ba.infn.it:2170/GLUE2DomainID=RECAS-BARI,o=glue\"},\"type\":\"provider\"},\"cmdbProviderServices\":{\"4401ac5dc8cfbbb737b0a02575e81d9b\":{\"_id\":\"4401ac5dc8cfbbb737b0a02575e81d9b\",\"_rev\":\"2-be00f87438604f04d353233daabc562c\",\"data\":{\"service_type\":\"eu.egi.cloud.vm-management.occi\",\"endpoint\":\"http://onedock.i3m.upv.es:11443\",\"provider_id\":\"provider-UPV-GRyCAP\",\"type\":\"compute\"},\"type\":\"service\"}}},\"provider-UPV-GRyCAP\":{\"name\":\"provider-UPV-GRyCAP\",\"id\":\"provider-UPV-GRyCAP\",\"cmdbProviderData\":{\"_id\":\"provider-UPV-GRyCAP\",\"_rev\":\"1-0a5ba48b2d6e0c26d36b0e3e81175352\",\"data\":{\"id\":\"458\",\"primary_key\":\"135G0\",\"name\":\"UPV-GRyCAP\",\"country\":\"Spain\",\"country_code\":\"ES\",\"roc\":\"NGI_IBERGRID\",\"subgrid\":\"\",\"giis_url\":\"ldap://ngiesbdii.i3m.upv.es:2170/mds-vo-name=UPV-GRyCAP,o=grid\"},\"type\":\"provider\"},\"cmdbProviderServices\":{\"4401ac5dc8cfbbb737b0a02575e81d9b\":{\"_id\":\"4401ac5dc8cfbbb737b0a02575e6f4bc\",\"_rev\":\"1-256d36283315ea9bb045e6d5038657b6\",\"data\":{\"service_type\":\"eu.egi.cloud.vm-management.openstack\",\"endpoint\":\"http://cloud.recas.ba.infn.it:5000/v2.0\",\"provider_id\":\"provider-RECAS-BARI\",\"type\":\"compute\"},\"type\":\"service\"}}}},\"cloudProvidersMonitoringData\":{\"provider-RECAS-BARI\":[{\"metricName\":\"OCCI Create VM availability\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI Create VM availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI CreateVM Response Time\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI CreateVM Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI CreateVM Result\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI CreateVM Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI Delete VM Availability\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI Delete VM Availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI DeleteVM Response Time\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI DeleteVM Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI DeleteVM Result\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI DeleteVM Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"General OCCI API Availability\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..General OCCI API Availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"General OCCI API Response Time\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..General OCCI API Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"General OCCI API Result\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..General OCCI API Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI Inspect VM availability\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI Inspect VM availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI InspectVM Response Time\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI InspectVM Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI InspectVM Result\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI InspectVM Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]}],\"provider-UPV-GRyCAP\":[{\"metricName\":\"OCCI Create VM availability\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI Create VM availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI CreateVM Response Time\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI CreateVM Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI CreateVM Result\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI CreateVM Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI Delete VM Availability\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI Delete VM Availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI DeleteVM Response Time\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI DeleteVM Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI DeleteVM Result\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI DeleteVM Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"General OCCI API Availability\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..General OCCI API Availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"General OCCI API Response Time\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..General OCCI API Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"General OCCI API Result\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..General OCCI API Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI Inspect VM availability\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI Inspect VM availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI InspectVM Response Time\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI InspectVM Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI InspectVM Result\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI InspectVM Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]}]},\"rankedCloudProviders\":[]}", RankCloudProvidersMessage.class); // Prepare Ranker's request diff --git a/src/test/java/it/reply/orchestrator/workflow/RankCloudProvidersWorkflowTest.java b/src/test/java/it/reply/orchestrator/workflow/RankCloudProvidersWorkflowTest.java index 78c43eae0f..38ecdb2aa4 100644 --- a/src/test/java/it/reply/orchestrator/workflow/RankCloudProvidersWorkflowTest.java +++ b/src/test/java/it/reply/orchestrator/workflow/RankCloudProvidersWorkflowTest.java @@ -132,7 +132,7 @@ public void testProcess() throws Exception { public static void mockSlam(MockRestServiceServer mockServer, String baseUrl) throws Exception { String response = - "{\"preferences\":[{\"customer\":\"indigo-dc\",\"preferences\":[{\"service_type\":\"compute\",\"priority\":[{\"sla_id\":\"4401ac5dc8cfbbb737b0a02575ee53f6\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e8040f\",\"weight\":0.5},{\"sla_id\":\"4401ac5dc8cfbbb737b0a02575ee3b58\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e6f4bc\",\"weight\":0.5}]}],\"id\":\"4401ac5dc8cfbbb737b0a02575ee0e55\"}],\"sla\":[{\"customer\":\"indigo-dc\",\"provider\":\"provider-UPV-GRyCAP\",\"start_date\":\"11.01.2016+15:50:00\",\"end_date\":\"11.02.2016+15:50:00\",\"services\":[{\"type\":\"compute\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e6f4bc\",\"targets\":[{\"type\":\"public_ip\",\"unit\":\"none\",\"restrictions\":{\"total_limit\":100,\"total_guaranteed\":10}}]}],\"id\":\"4401ac5dc8cfbbb737b0a02575ee3b58\"},{\"customer\":\"indigo-dc\",\"provider\":\"provider-RECAS-BARI\",\"start_date\":\"11.01.2016+15:50:00\",\"end_date\":\"11.02.2016+15:50:00\",\"services\":[{\"type\":\"compute\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e8040f\",\"targets\":[{\"type\":\"computing_time\",\"unit\":\"h\",\"restrictions\":{\"total_guaranteed\":200}}]}],\"id\":\"4401ac5dc8cfbbb737b0a02575ee53f6\"}]}"; + "{\"preferences\":[{\"customer\":\"indigo-dc\",\"preferences\":[{\"service_type\":\"compute\",\"priority\":[{\"sla_id\":\"4401ac5dc8cfbbb737b0a02575ee53f6\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e81d9b\",\"weight\":0.5},{\"sla_id\":\"4401ac5dc8cfbbb737b0a02575ee3b58\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e6f4bc\",\"weight\":0.5}]}],\"id\":\"4401ac5dc8cfbbb737b0a02575ee0e55\"}],\"sla\":[{\"customer\":\"indigo-dc\",\"provider\":\"provider-UPV-GRyCAP\",\"start_date\":\"11.01.2016+15:50:00\",\"end_date\":\"11.02.2016+15:50:00\",\"services\":[{\"type\":\"compute\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e81d9b\",\"targets\":[{\"type\":\"public_ip\",\"unit\":\"none\",\"restrictions\":{\"total_limit\":100,\"total_guaranteed\":10}}]}],\"id\":\"4401ac5dc8cfbbb737b0a02575ee3b58\"},{\"customer\":\"indigo-dc\",\"provider\":\"provider-RECAS-BARI\",\"start_date\":\"11.01.2016+15:50:00\",\"end_date\":\"11.02.2016+15:50:00\",\"services\":[{\"type\":\"compute\",\"service_id\":\"4401ac5dc8cfbbb737b0a02575e6f4bc\",\"targets\":[{\"type\":\"computing_time\",\"unit\":\"h\",\"restrictions\":{\"total_guaranteed\":200}}]}],\"id\":\"4401ac5dc8cfbbb737b0a02575ee53f6\"}]}"; mockServer.expect(requestTo(baseUrl + "preferences/indigo-dc")) .andExpect(method(HttpMethod.GET)) @@ -148,19 +148,19 @@ public static void mockCmdb(MockRestServiceServer mockServer, String baseUrl) th MediaType.APPLICATION_JSON)); // Service: Compute on provider-RECAS-BARI - mockServer.expect(requestTo(baseUrl + "service/id/4401ac5dc8cfbbb737b0a02575e8040f")) + mockServer.expect(requestTo(baseUrl + "service/id/4401ac5dc8cfbbb737b0a02575e6f4bc")) .andExpect(method(HttpMethod.GET)) .andRespond(withSuccess( - "{\"_id\":\"4401ac5dc8cfbbb737b0a02575e8040f\",\"_rev\":\"2-be00f87438604f04d353233daabc562c\",\"data\":{\"service_type\":\"eu.egi.cloud.vm-management.occi\",\"endpoint\":\"http://onedock.i3m.upv.es:11443\",\"provider_id\":\"provider-UPV-GRyCAP\",\"type\":\"compute\"},\"type\":\"service\"}", + "{\"_id\":\"4401ac5dc8cfbbb737b0a02575e6f4bc\",\"_rev\":\"1-256d36283315ea9bb045e6d5038657b6\",\"data\":{\"service_type\":\"eu.egi.cloud.vm-management.openstack\",\"endpoint\":\"http://cloud.recas.ba.infn.it:5000/v2.0\",\"provider_id\":\"provider-RECAS-BARI\",\"type\":\"compute\"},\"type\":\"service\"}", MediaType.APPLICATION_JSON)); // Images: Compute service on provider-RECAS-BARI mockServer .expect(requestTo(baseUrl - + "service/id/4401ac5dc8cfbbb737b0a02575e8040f/has_many/images?include_docs=true")) + + "service/id/4401ac5dc8cfbbb737b0a02575e6f4bc/has_many/images?include_docs=true")) .andExpect(method(HttpMethod.GET)) .andRespond(withSuccess( - "{\n \"total_rows\": 42,\n \"offset\": 0,\n \"rows\": [\n {\n \"id\": \"7efc59c5db69ea67c5100de0f7236866\",\n \"key\": [\n \"4401ac5dc8cfbbb737b0a02575e8040f\",\n \"images\"\n ],\n \"value\": {\n \"image_id\": \"1\",\n \"image_name\": \"indigodatacloud/ubuntu-sshd:14.04-devel\",\n \"service\": \"4401ac5dc8cfbbb737b0a02575e8040f\"\n },\n \"doc\": {\n \"_id\": \"7efc59c5db69ea67c5100de0f7236866\",\n \"_rev\": \"2-105db8faf961d5aa0a215b67942c1821\",\n \"type\": \"image\",\n \"data\": {\n \"image_id\": \"1\",\n \"image_name\": \"indigodatacloud/ubuntu-sshd:14.04-devel\",\n \"architecture\": \"x86_64\",\n \"type\": \"linux\",\n \"distribution\": \"ubuntu\",\n \"version\": \"14.04\",\n \"service\": \"4401ac5dc8cfbbb737b0a02575e8040f\"\n }\n }\n },\n {\n \"id\": \"7efc59c5db69ea67c5100de0f724f37a\",\n \"key\": [\n \"4401ac5dc8cfbbb737b0a02575e8040f\",\n \"images\"\n ],\n \"value\": {\n \"image_id\": \"1\",\n \"image_name\": \"image-create-test\",\n \"service\": \"4401ac5dc8cfbbb737b0a02575e8040f\"\n },\n \"doc\": {\n \"_id\": \"7efc59c5db69ea67c5100de0f724f37a\",\n \"_rev\": \"1-c9bf9d0d3f69738da930d97b8002b2c4\",\n \"type\": \"image\",\n \"data\": {\n \"image_id\": \"1\",\n \"image_name\": \"image-create-test\",\n \"architecture\": \"x86_64\",\n \"type\": \"linux\",\n \"distribution\": \"ubuntu\",\n \"version\": \"14.04\",\n \"service\": \"4401ac5dc8cfbbb737b0a02575e8040f\"\n }\n }\n },\n {\n \"id\": \"7efc59c5db69ea67c5100de0f72580e9\",\n \"key\": [\n \"4401ac5dc8cfbbb737b0a02575e8040f\",\n \"images\"\n ],\n \"value\": {\n \"image_id\": \"xxx\",\n \"image_name\": \"image-create-test\",\n \"service\": \"4401ac5dc8cfbbb737b0a02575e8040f\"\n },\n \"doc\": {\n \"_id\": \"7efc59c5db69ea67c5100de0f72580e9\",\n \"_rev\": \"1-180d402f4985bbd00692937a9bcf717c\",\n \"type\": \"image\",\n \"data\": {\n \"image_id\": \"xxx\",\n \"image_name\": \"image-create-test\",\n \"architecture\": \"x86_64\",\n \"type\": \"linux\",\n \"distribution\": \"ubuntu\",\n \"version\": \"14.04\",\n \"service\": \"4401ac5dc8cfbbb737b0a02575e8040f\"\n }\n }\n }\n ]\n}", + "{\n \"total_rows\": 44,\n \"offset\": 3,\n \"rows\": [\n {\n \"id\": \"7efc59c5db69ea67c5100de0f726d41e\",\n \"key\": [\n \"4401ac5dc8cfbbb737b0a02575e6f4bc\",\n \"images\"\n ],\n \"value\": {\n \"image_id\": \"303d8324-69a7-4372-be24-1d68703affd7\",\n \"image_name\": \"indigodatacloud/ubuntu-sshd:14.04-devel\",\n \"service\": \"4401ac5dc8cfbbb737b0a02575e6f4bc\"\n },\n \"doc\": {\n \"_id\": \"7efc59c5db69ea67c5100de0f726d41e\",\n \"_rev\": \"1-583b38e80f989b7f39b8ddd5d28c4c76\",\n \"type\": \"image\",\n \"data\": {\n \"image_id\": \"303d8324-69a7-4372-be24-1d68703affd7\",\n \"image_name\": \"indigodatacloud/ubuntu-sshd:14.04-devel\",\n \"architecture\": \"x86_64\",\n \"type\": \"linux\",\n \"distribution\": \"ubuntu\",\n \"version\": \"14.04\",\n \"service\": \"4401ac5dc8cfbbb737b0a02575e6f4bc\"\n }\n }\n },\n {\n \"id\": \"7efc59c5db69ea67c5100de0f726e0a0\",\n \"key\": [\n \"4401ac5dc8cfbbb737b0a02575e6f4bc\",\n \"images\"\n ],\n \"value\": {\n \"image_id\": \"0de96743-4a12-4470-b8b2-6dc260977a40\",\n \"image_name\": \"indigodatacloud/centos-sshd:7-devel\",\n \"service\": \"4401ac5dc8cfbbb737b0a02575e6f4bc\"\n },\n \"doc\": {\n \"_id\": \"7efc59c5db69ea67c5100de0f726e0a0\",\n \"_rev\": \"1-948dae5f4b7e1096036af3f0cca37f89\",\n \"type\": \"image\",\n \"data\": {\n \"image_id\": \"0de96743-4a12-4470-b8b2-6dc260977a40\",\n \"image_name\": \"indigodatacloud/centos-sshd:7-devel\",\n \"architecture\": \"x86_64\",\n \"type\": \"linux\",\n \"distribution\": \"centos\",\n \"version\": \"7\",\n \"service\": \"4401ac5dc8cfbbb737b0a02575e6f4bc\"\n }\n }\n }\n ]\n}", MediaType.APPLICATION_JSON)); // Provider: provider-UPV-GRyCAP @@ -171,19 +171,19 @@ public static void mockCmdb(MockRestServiceServer mockServer, String baseUrl) th MediaType.APPLICATION_JSON)); // Service: Compute on provider-UPV-GRyCAP - mockServer.expect(requestTo(baseUrl + "service/id/4401ac5dc8cfbbb737b0a02575e6f4bc")) + mockServer.expect(requestTo(baseUrl + "service/id/4401ac5dc8cfbbb737b0a02575e81d9b")) .andExpect(method(HttpMethod.GET)) .andRespond(withSuccess( - "{\"_id\":\"4401ac5dc8cfbbb737b0a02575e6f4bc\",\"_rev\":\"1-256d36283315ea9bb045e6d5038657b6\",\"data\":{\"service_type\":\"eu.egi.cloud.vm-management.openstack\",\"endpoint\":\"http://cloud.recas.ba.infn.it:5000/v2.0\",\"provider_id\":\"provider-RECAS-BARI\",\"type\":\"compute\"},\"type\":\"service\"}", + "{\"_id\":\"4401ac5dc8cfbbb737b0a02575e81d9b\",\"_rev\":\"2-be00f87438604f04d353233daabc562c\",\"data\":{\"service_type\":\"eu.egi.cloud.vm-management.occi\",\"endpoint\":\"http://onedock.i3m.upv.es:11443\",\"provider_id\":\"provider-UPV-GRyCAP\",\"type\":\"compute\"},\"type\":\"service\"}", MediaType.APPLICATION_JSON)); // Images: Compute service on provider-UPV-GRyCAP mockServer .expect(requestTo(baseUrl - + "service/id/4401ac5dc8cfbbb737b0a02575e6f4bc/has_many/images?include_docs=true")) + + "service/id/4401ac5dc8cfbbb737b0a02575e81d9b/has_many/images?include_docs=true")) .andExpect(method(HttpMethod.GET)) .andRespond(withSuccess( - "{\n \"total_rows\": 42,\n \"offset\": 0,\n \"rows\": [\n {\n \"id\": \"7efc59c5db69ea67c5100de0f7236866\",\n \"key\": [\n \"4401ac5dc8cfbbb737b0a02575e8040f\",\n \"images\"\n ],\n \"value\": {\n \"image_id\": \"1\",\n \"image_name\": \"indigodatacloud/ubuntu-sshd:14.04-devel\",\n \"service\": \"4401ac5dc8cfbbb737b0a02575e8040f\"\n },\n \"doc\": {\n \"_id\": \"7efc59c5db69ea67c5100de0f7236866\",\n \"_rev\": \"2-105db8faf961d5aa0a215b67942c1821\",\n \"type\": \"image\",\n \"data\": {\n \"image_id\": \"1\",\n \"image_name\": \"indigodatacloud/ubuntu-sshd:14.04-devel\",\n \"architecture\": \"x86_64\",\n \"type\": \"linux\",\n \"distribution\": \"ubuntu\",\n \"version\": \"14.04\",\n \"service\": \"4401ac5dc8cfbbb737b0a02575e8040f\"\n }\n }\n },\n {\n \"id\": \"7efc59c5db69ea67c5100de0f724f37a\",\n \"key\": [\n \"4401ac5dc8cfbbb737b0a02575e8040f\",\n \"images\"\n ],\n \"value\": {\n \"image_id\": \"1\",\n \"image_name\": \"image-create-test\",\n \"service\": \"4401ac5dc8cfbbb737b0a02575e8040f\"\n },\n \"doc\": {\n \"_id\": \"7efc59c5db69ea67c5100de0f724f37a\",\n \"_rev\": \"1-c9bf9d0d3f69738da930d97b8002b2c4\",\n \"type\": \"image\",\n \"data\": {\n \"image_id\": \"1\",\n \"image_name\": \"image-create-test\",\n \"architecture\": \"x86_64\",\n \"type\": \"linux\",\n \"distribution\": \"ubuntu\",\n \"version\": \"14.04\",\n \"service\": \"4401ac5dc8cfbbb737b0a02575e8040f\"\n }\n }\n },\n {\n \"id\": \"7efc59c5db69ea67c5100de0f72580e9\",\n \"key\": [\n \"4401ac5dc8cfbbb737b0a02575e8040f\",\n \"images\"\n ],\n \"value\": {\n \"image_id\": \"xxx\",\n \"image_name\": \"image-create-test\",\n \"service\": \"4401ac5dc8cfbbb737b0a02575e8040f\"\n },\n \"doc\": {\n \"_id\": \"7efc59c5db69ea67c5100de0f72580e9\",\n \"_rev\": \"1-180d402f4985bbd00692937a9bcf717c\",\n \"type\": \"image\",\n \"data\": {\n \"image_id\": \"xxx\",\n \"image_name\": \"image-create-test\",\n \"architecture\": \"x86_64\",\n \"type\": \"linux\",\n \"distribution\": \"ubuntu\",\n \"version\": \"14.04\",\n \"service\": \"4401ac5dc8cfbbb737b0a02575e8040f\"\n }\n }\n }\n ]\n}", + "{\n \"total_rows\": 42,\n \"offset\": 0,\n \"rows\": [\n {\n \"id\": \"7efc59c5db69ea67c5100de0f7236866\",\n \"key\": [\n \"4401ac5dc8cfbbb737b0a02575e81d9b\",\n \"images\"\n ],\n \"value\": {\n \"image_id\": \"1\",\n \"image_name\": \"indigodatacloud/ubuntu-sshd:14.04-devel\",\n \"service\": \"4401ac5dc8cfbbb737b0a02575e81d9b\"\n },\n \"doc\": {\n \"_id\": \"7efc59c5db69ea67c5100de0f7236866\",\n \"_rev\": \"2-105db8faf961d5aa0a215b67942c1821\",\n \"type\": \"image\",\n \"data\": {\n \"image_id\": \"1\",\n \"image_name\": \"indigodatacloud/ubuntu-sshd:14.04-devel\",\n \"architecture\": \"x86_64\",\n \"type\": \"linux\",\n \"distribution\": \"ubuntu\",\n \"version\": \"14.04\",\n \"service\": \"4401ac5dc8cfbbb737b0a02575e81d9b\"\n }\n }\n },\n {\n \"id\": \"7efc59c5db69ea67c5100de0f724f37a\",\n \"key\": [\n \"4401ac5dc8cfbbb737b0a02575e81d9b\",\n \"images\"\n ],\n \"value\": {\n \"image_id\": \"1\",\n \"image_name\": \"image-create-test\",\n \"service\": \"4401ac5dc8cfbbb737b0a02575e81d9b\"\n },\n \"doc\": {\n \"_id\": \"7efc59c5db69ea67c5100de0f724f37a\",\n \"_rev\": \"1-c9bf9d0d3f69738da930d97b8002b2c4\",\n \"type\": \"image\",\n \"data\": {\n \"image_id\": \"1\",\n \"image_name\": \"image-create-test\",\n \"architecture\": \"x86_64\",\n \"type\": \"linux\",\n \"distribution\": \"ubuntu\",\n \"version\": \"14.04\",\n \"service\": \"4401ac5dc8cfbbb737b0a02575e81d9b\"\n }\n }\n },\n {\n \"id\": \"7efc59c5db69ea67c5100de0f72580e9\",\n \"key\": [\n \"4401ac5dc8cfbbb737b0a02575e81d9b\",\n \"images\"\n ],\n \"value\": {\n \"image_id\": \"xxx\",\n \"image_name\": \"image-create-test\",\n \"service\": \"4401ac5dc8cfbbb737b0a02575e81d9b\"\n },\n \"doc\": {\n \"_id\": \"7efc59c5db69ea67c5100de0f72580e9\",\n \"_rev\": \"1-180d402f4985bbd00692937a9bcf717c\",\n \"type\": \"image\",\n \"data\": {\n \"image_id\": \"xxx\",\n \"image_name\": \"image-create-test\",\n \"architecture\": \"x86_64\",\n \"type\": \"linux\",\n \"distribution\": \"ubuntu\",\n \"version\": \"14.04\",\n \"service\": \"4401ac5dc8cfbbb737b0a02575e81d9b\"\n }\n }\n }\n ]\n}", MediaType.APPLICATION_JSON)); } diff --git a/src/test/resources/slam/preferences-indigo-demo.json b/src/test/resources/slam/preferences-indigo-demo.json index 9b90335084..cb7b876041 100644 --- a/src/test/resources/slam/preferences-indigo-demo.json +++ b/src/test/resources/slam/preferences-indigo-demo.json @@ -8,7 +8,7 @@ "priority": [ { "sla_id": "4401ac5dc8cfbbb737b0a02575ee53f6", - "service_id": "4401ac5dc8cfbbb737b0a02575e8040f" + "service_id": "4401ac5dc8cfbbb737b0a02575e81d9b" }, { "sla_id": "4401ac5dc8cfbbb737b0a02575ee3b58", @@ -52,7 +52,7 @@ "services": [ { "type": "compute", - "service_id": "4401ac5dc8cfbbb737b0a02575e8040f", + "service_id": "4401ac5dc8cfbbb737b0a02575e81d9b", "targets": [ { "type": "computing_time", From 0d280ef87fca12a8b318482e8dda6e4cdce89f73 Mon Sep 17 00:00:00 2001 From: Lorenzo Biava Date: Mon, 20 Jun 2016 16:25:40 +0200 Subject: [PATCH 14/19] Extracted, generated (with stub) and persisted chosen CP endpoint The chosen CloudProvider endpoint are generated after the choice has been made, using the Provider and its Services from CMDB. The CloudProviderEndpoint information is the passed through the WF in the DeploymentMessage. It can be used by IM to generated authentication data accordingly (NOT DONE YET). The information is also persisted (serialized) in the Deployment for other WFs (Update/Undeploy). See #51 --- .../orchestrator/dal/entity/Deployment.java | 36 +++++ .../dto/CloudProviderEndpoint.java | 55 +++++++ .../dto/deployment/DeploymentMessage.java | 10 ++ .../CloudProviderEndpointServiceImpl.java | 104 +++++++++++++ .../service/DeploymentServiceImpl.java | 33 ++--- .../service/commands/UpdateDeployment.java | 34 +++-- .../deployment/providers/ImServiceImpl.java | 137 +++++++++--------- 7 files changed, 313 insertions(+), 96 deletions(-) create mode 100644 src/main/java/it/reply/orchestrator/dto/CloudProviderEndpoint.java create mode 100644 src/main/java/it/reply/orchestrator/service/CloudProviderEndpointServiceImpl.java diff --git a/src/main/java/it/reply/orchestrator/dal/entity/Deployment.java b/src/main/java/it/reply/orchestrator/dal/entity/Deployment.java index 0051c3ca6a..a5b48615ed 100644 --- a/src/main/java/it/reply/orchestrator/dal/entity/Deployment.java +++ b/src/main/java/it/reply/orchestrator/dal/entity/Deployment.java @@ -1,5 +1,6 @@ package it.reply.orchestrator.dal.entity; +import it.reply.orchestrator.dto.CloudProviderEndpoint; import it.reply.orchestrator.enums.DeploymentProvider; import it.reply.orchestrator.enums.Status; import it.reply.orchestrator.enums.Task; @@ -52,6 +53,9 @@ public class Deployment extends AbstractResourceEntity { @Column(name = "template", columnDefinition = "LONGTEXT") private String template; + @Column(name = "cloudProviderEndpoint", columnDefinition = "TEXT") + private String cloudProviderEndpoint; + /** * The user's inputs to the template. */ @@ -192,6 +196,38 @@ public synchronized void setParameters(Map parameters) { this.unserializedParameters = null; } + /** + * + * @return . + */ + public synchronized CloudProviderEndpoint getCloudProviderEndpoint() { + + CloudProviderEndpoint cpe = null; + + if (cloudProviderEndpoint != null) { + try { + cpe = JsonUtility.deserializeJson(cloudProviderEndpoint, CloudProviderEndpoint.class); + } catch (IOException ex) { + throw new RuntimeException("Failed to deserialize CloudProviderEndpoint in JSON", ex); + } + } + return cpe; + } + + /** + * . + * + */ + public synchronized void setCloudProviderEndpoint(CloudProviderEndpoint cpe) { + if (cpe != null) { + try { + cloudProviderEndpoint = JsonUtility.serializeJson(cpe); + } catch (IOException ex) { + throw new RuntimeException("Failed to serialize CloudProviderEndpoint in JSON", ex); + } + } + } + public Map getOutputs() { return outputs; } diff --git a/src/main/java/it/reply/orchestrator/dto/CloudProviderEndpoint.java b/src/main/java/it/reply/orchestrator/dto/CloudProviderEndpoint.java new file mode 100644 index 0000000000..2d771ed000 --- /dev/null +++ b/src/main/java/it/reply/orchestrator/dto/CloudProviderEndpoint.java @@ -0,0 +1,55 @@ +package it.reply.orchestrator.dto; + +import java.io.Serializable; + +/** + * This class holds information to connect (and authenticate) to a CloudProvider. + * + * @author l.biava + * + */ +public class CloudProviderEndpoint implements Serializable { + + private static final long serialVersionUID = -2585914648218602033L; + + public enum IaaSType { + // @formatter:off + OPENSTACK, OPENNEBULA, ONEDOCK + // @formatter:on + } + + private String imEndpoint; + private String cpEndpoint; + private IaaSType iaasType; + + public String getImEndpoint() { + return imEndpoint; + } + + public void setImEndpoint(String imEndpoint) { + this.imEndpoint = imEndpoint; + } + + public String getCpEndpoint() { + return cpEndpoint; + } + + public void setCpEndpoint(String cpEndpoint) { + this.cpEndpoint = cpEndpoint; + } + + public IaaSType getIaasType() { + return iaasType; + } + + public void setIaasType(IaaSType iaasType) { + this.iaasType = iaasType; + } + + @Override + public String toString() { + return "CloudProviderEndpoint [imEndpoint=" + imEndpoint + ", cpEndpoint=" + cpEndpoint + + ", iaasType=" + iaasType + "]"; + } + +} diff --git a/src/main/java/it/reply/orchestrator/dto/deployment/DeploymentMessage.java b/src/main/java/it/reply/orchestrator/dto/deployment/DeploymentMessage.java index 473da01cb1..a4b2d3ba14 100644 --- a/src/main/java/it/reply/orchestrator/dto/deployment/DeploymentMessage.java +++ b/src/main/java/it/reply/orchestrator/dto/deployment/DeploymentMessage.java @@ -3,6 +3,7 @@ import it.reply.orchestrator.dal.entity.Deployment; import it.reply.orchestrator.dal.entity.Resource; import it.reply.orchestrator.dto.CloudProvider; +import it.reply.orchestrator.dto.CloudProviderEndpoint; import it.reply.orchestrator.enums.DeploymentProvider; import it.reply.orchestrator.service.deployment.providers.ChronosServiceImpl.IndigoJob; @@ -37,6 +38,7 @@ public class DeploymentMessage implements Serializable { private boolean skipPollInterval; private CloudProvider chosenCloudProvider; + private CloudProviderEndpoint chosenCloudProviderEndpoint; private String oauth2Token; @@ -126,6 +128,14 @@ public void setChosenCloudProvider(CloudProvider chosenCloudProvider) { this.chosenCloudProvider = chosenCloudProvider; } + public CloudProviderEndpoint getChosenCloudProviderEndpoint() { + return chosenCloudProviderEndpoint; + } + + public void setChosenCloudProviderEndpoint(CloudProviderEndpoint chosenCloudProviderEndpoint) { + this.chosenCloudProviderEndpoint = chosenCloudProviderEndpoint; + } + public String getOauth2Token() { return oauth2Token; } diff --git a/src/main/java/it/reply/orchestrator/service/CloudProviderEndpointServiceImpl.java b/src/main/java/it/reply/orchestrator/service/CloudProviderEndpointServiceImpl.java new file mode 100644 index 0000000000..035be0b927 --- /dev/null +++ b/src/main/java/it/reply/orchestrator/service/CloudProviderEndpointServiceImpl.java @@ -0,0 +1,104 @@ +package it.reply.orchestrator.service; + +import it.reply.orchestrator.dal.entity.Deployment; +import it.reply.orchestrator.dto.CloudProviderEndpoint; +import it.reply.orchestrator.dto.CloudProviderEndpoint.IaaSType; +import it.reply.orchestrator.dto.RankCloudProvidersMessage; +import it.reply.orchestrator.dto.cmdb.Type; +import it.reply.orchestrator.dto.ranker.RankedCloudProvider; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.stereotype.Service; + +@Service +public class CloudProviderEndpointServiceImpl { + private static final Logger LOG = LogManager.getLogger(CloudProviderEndpointServiceImpl.class); + + public RankedCloudProvider chooseCloudProvider(Deployment deployment, + RankCloudProvidersMessage rankCloudProvidersMessage) { + // Choose Cloud Provider + IaaSType iaasType = getIaaSTypeFromTosca(deployment.getTemplate()); + + LOG.debug("Choosing Cloud Provider based on: {}, IaaSType: {}", + rankCloudProvidersMessage.getRankedCloudProviders(), iaasType); + + // TODO Check ranker errors (i.e. providers with ranked = false) + RankedCloudProvider chosenCp = null; + for (RankedCloudProvider rcp : rankCloudProvidersMessage.getRankedCloudProviders()) { + // Choose the one with lowest rank AND that matches iaasType (TEMPORARY) + if ((isCompatible(iaasType, getProviderIaaSType(rankCloudProvidersMessage, rcp.getName()))) + && (chosenCp == null || rcp.getRank() < chosenCp.getRank())) { + chosenCp = rcp; + } + } + + if (chosenCp == null) { + String errorMsg = String.format("No Cloud Provider found for: {}, IaaSType: {}", + rankCloudProvidersMessage.getRankedCloudProviders(), iaasType); + LOG.error(errorMsg); + throw new IllegalArgumentException(errorMsg); + } + + LOG.debug("Selected Cloud Provider is: {}", chosenCp); + return chosenCp; + } + + public CloudProviderEndpoint getCloudProviderEndpoint(Deployment deployment, + RankCloudProvidersMessage rankCloudProvidersMessage, RankedCloudProvider chosenCp) { + + IaaSType iaasType = getIaaSTypeFromTosca(deployment.getTemplate()); + + CloudProviderEndpoint cpe = new CloudProviderEndpoint(); + + it.reply.orchestrator.dto.cmdb.Service computeService = rankCloudProvidersMessage + .getCloudProviders().get(chosenCp.getName()).getCmbdProviderServiceByType(Type.COMPUTE); + + cpe.setCpEndpoint(computeService.getData().getEndpoint()); + cpe.setIaasType(iaasType); + // FIXME Add IM EP, if available + + return cpe; + } + + /** + * TEMPORARY method to decide whether it is needed to coerce CP choice based on template content + * (i.e. currently used to force Mesos cluster deployment on OpenStack). + * + * @param template + * . + * @return . + */ + public IaaSType getIaaSTypeFromTosca(String template) { + + if (template.contains("tosca.nodes.indigo.MesosMaster")) { + return IaaSType.OPENSTACK; + } else if (template.contains("onedock.i3m.upv.es")) { + return IaaSType.ONEDOCK; + } else { + return IaaSType.OPENNEBULA; + } + } + + protected boolean isCompatible(IaaSType requiredType, IaaSType providerType) { + if (requiredType == providerType) { + return true; + } else if (requiredType == IaaSType.ONEDOCK && providerType == IaaSType.OPENNEBULA) { + // OneDock is a special case of OneNebula -.- + return true; + } else { + return false; + } + } + + protected IaaSType getProviderIaaSType(RankCloudProvidersMessage rankCloudProvidersMessage, + String providerName) { + String serviceType = rankCloudProvidersMessage.getCloudProviders().get(providerName) + .getCmbdProviderServiceByType(Type.COMPUTE).getData().getServiceType(); + if (serviceType.contains("openstack")) { + return IaaSType.OPENSTACK; + } + + return IaaSType.OPENNEBULA; + } +} diff --git a/src/main/java/it/reply/orchestrator/service/DeploymentServiceImpl.java b/src/main/java/it/reply/orchestrator/service/DeploymentServiceImpl.java index 0a223d4d4d..58dddb7239 100644 --- a/src/main/java/it/reply/orchestrator/service/DeploymentServiceImpl.java +++ b/src/main/java/it/reply/orchestrator/service/DeploymentServiceImpl.java @@ -122,11 +122,7 @@ public Deployment createDeployment(DeploymentRequest request) { (isChronosDeployment ? DEPLOYMENT_TYPE_CHRONOS : DEPLOYMENT_TYPE_TOSCA)); // Build deployment message - DeploymentMessage deploymentMessage = new DeploymentMessage(); - if (oauth2TokenService.isSecurityEnabled()) { - deploymentMessage.setOauth2Token(oauth2TokenService.getOAuth2Token()); - } - deploymentMessage.setDeploymentId(deployment.getId()); + DeploymentMessage deploymentMessage = buildDeploymentMessage(deployment); deploymentMessage.setDeploymentProvider( (isChronosDeployment ? DeploymentProvider.CHRONOS : DeploymentProvider.IM)); params.put(WorkflowConstants.WF_PARAM_DEPLOYMENT_MESSAGE, deploymentMessage); @@ -145,6 +141,19 @@ public Deployment createDeployment(DeploymentRequest request) { } + protected DeploymentMessage buildDeploymentMessage(Deployment deployment) { + DeploymentMessage deploymentMessage = new DeploymentMessage(); + if (oauth2TokenService.isSecurityEnabled()) { + deploymentMessage.setOauth2Token(oauth2TokenService.getOAuth2Token()); + } + deploymentMessage.setDeploymentId(deployment.getId()); + deploymentMessage.setDeploymentProvider(deployment.getDeploymentProvider()); + deploymentMessage.setChosenCloudProviderEndpoint(deployment.getCloudProviderEndpoint()); + + return deploymentMessage; + + } + /** * Temporary method to decide whether a given deployment has to be deployed using Chronos (just * for experiments).
@@ -198,12 +207,7 @@ public void deleteDeployment(String uuid) { deployment.getDeploymentProvider().name()); // Build deployment message - DeploymentMessage deploymentMessage = new DeploymentMessage(); - if (oauth2TokenService.isSecurityEnabled()) { - deploymentMessage.setOauth2Token(oauth2TokenService.getOAuth2Token()); - } - deploymentMessage.setDeploymentId(deployment.getId()); - deploymentMessage.setDeploymentProvider(deployment.getDeploymentProvider()); + DeploymentMessage deploymentMessage = buildDeploymentMessage(deployment); params.put(WorkflowConstants.WF_PARAM_DEPLOYMENT_MESSAGE, deploymentMessage); ProcessInstance pi = null; @@ -258,12 +262,7 @@ public void updateDeployment(String id, DeploymentRequest request) { params.put("TOSCA_TEMPLATE", request.getTemplate()); // Build deployment message - DeploymentMessage deploymentMessage = new DeploymentMessage(); - if (oauth2TokenService.isSecurityEnabled()) { - deploymentMessage.setOauth2Token(oauth2TokenService.getOAuth2Token()); - } - deploymentMessage.setDeploymentId(deployment.getId()); - deploymentMessage.setDeploymentProvider(deployment.getDeploymentProvider()); + DeploymentMessage deploymentMessage = buildDeploymentMessage(deployment); params.put(WorkflowConstants.WF_PARAM_DEPLOYMENT_MESSAGE, deploymentMessage); ProcessInstance pi = null; diff --git a/src/main/java/it/reply/orchestrator/service/commands/UpdateDeployment.java b/src/main/java/it/reply/orchestrator/service/commands/UpdateDeployment.java index 62d18b61bf..fc0262d28b 100644 --- a/src/main/java/it/reply/orchestrator/service/commands/UpdateDeployment.java +++ b/src/main/java/it/reply/orchestrator/service/commands/UpdateDeployment.java @@ -2,9 +2,11 @@ import it.reply.orchestrator.dal.entity.Deployment; import it.reply.orchestrator.dal.repository.DeploymentRepository; +import it.reply.orchestrator.dto.CloudProviderEndpoint; import it.reply.orchestrator.dto.RankCloudProvidersMessage; import it.reply.orchestrator.dto.deployment.DeploymentMessage; import it.reply.orchestrator.dto.ranker.RankedCloudProvider; +import it.reply.orchestrator.service.CloudProviderEndpointServiceImpl; import it.reply.orchestrator.service.WorkflowConstants; import it.reply.orchestrator.service.deployment.providers.DeploymentStatusHelper; import it.reply.workflowmanager.spring.orchestrator.bpm.ejbcommands.BaseCommand; @@ -33,6 +35,9 @@ public class UpdateDeployment extends BaseCommand { @Autowired private DeploymentStatusHelper deploymentStatusHelper; + @Autowired + private CloudProviderEndpointServiceImpl cloudProviderEndpointServiceImpl; + @Override public ExecutionResults customExecute(CommandContext ctx) throws Exception { @@ -53,31 +58,32 @@ public ExecutionResults customExecute(CommandContext ctx) throws Exception { WorkflowConstants.WF_PARAM_DEPLOYMENT_MESSAGE)); } - // TODO: Move elsewhere + Deployment deployment = + deploymentRepository.findOne(rankCloudProvidersMessage.getDeploymentId()); + // Choose Cloud Provider - LOG.debug("Choosing Cloud Provider based on: {}", - rankCloudProvidersMessage.getRankedCloudProviders()); - - // TODO Check ranker errors (i.e. providers with ranked = false) - RankedCloudProvider chosenCp = null; - for (RankedCloudProvider rcp : rankCloudProvidersMessage.getRankedCloudProviders()) { - if (chosenCp == null || rcp.getRank() < chosenCp.getRank()) { - chosenCp = rcp; - } - } - LOG.debug("Selected Cloud Provider is: {}", chosenCp); + RankedCloudProvider chosenCp = cloudProviderEndpointServiceImpl + .chooseCloudProvider(deployment, rankCloudProvidersMessage); // Set the chosen CP in deploymentMessage deploymentMessage.setChosenCloudProvider( rankCloudProvidersMessage.getCloudProviders().get(chosenCp.getName())); // Update Deployment - Deployment deployment = - deploymentRepository.findOne(rankCloudProvidersMessage.getDeploymentId()); deployment.setCloudProviderName(chosenCp.getName()); // FIXME Set/update all required selected CP data + // FIXME Generate + CloudProviderEndpoint chosenCloudProviderEndpoint = cloudProviderEndpointServiceImpl + .getCloudProviderEndpoint(deployment, rankCloudProvidersMessage, chosenCp); + deploymentMessage.setChosenCloudProviderEndpoint(chosenCloudProviderEndpoint); + LOG.debug("Generated Cloud Provider Endpoint is: {}", chosenCloudProviderEndpoint); + + // FIXME Use another method to hold CP Endpoint (i.e. CMDB service ID reference?) + // Save CPE in Deployment for future use + deployment.setCloudProviderEndpoint(chosenCloudProviderEndpoint); + exResults.getData().putAll(resultOccurred(true).getData()); exResults.setData(WorkflowConstants.WF_PARAM_DEPLOYMENT_MESSAGE, deploymentMessage); } catch (Exception ex) { diff --git a/src/main/java/it/reply/orchestrator/service/deployment/providers/ImServiceImpl.java b/src/main/java/it/reply/orchestrator/service/deployment/providers/ImServiceImpl.java index 15f112f89c..910270b82e 100644 --- a/src/main/java/it/reply/orchestrator/service/deployment/providers/ImServiceImpl.java +++ b/src/main/java/it/reply/orchestrator/service/deployment/providers/ImServiceImpl.java @@ -21,6 +21,7 @@ import it.reply.orchestrator.dal.entity.Resource; import it.reply.orchestrator.dal.repository.DeploymentRepository; import it.reply.orchestrator.dal.repository.ResourceRepository; +import it.reply.orchestrator.dto.CloudProviderEndpoint.IaaSType; import it.reply.orchestrator.dto.deployment.DeploymentMessage; import it.reply.orchestrator.enums.DeploymentProvider; import it.reply.orchestrator.enums.NodeStates; @@ -99,23 +100,44 @@ public class ImServiceImpl extends AbstractDeploymentProviderService { @Autowired private ResourceRepository resourceRepository; - public enum IaaSSite { - // @formatter:off - OPENSTACK, OPENNEBULA, ONEDOCK - // @formatter:on - } - - private InfrastructureManager getClient(IaaSSite iaaSSite) { + private InfrastructureManager getClient(DeploymentMessage dm) { + // LOG.debug("Load {} credentials", cpe.getIaasType()); + // switch (cpe.getIaasType()) { + // case ONEDOCK: + // break; + // case OPENNEBULA: + // InfrastructureManager im = new InfrastructureManager(imUrl, tmp.toPath()); + // break; + // case OPENSTACK: + // InfrastructureManager im = new InfrastructureManager(imUrl, tmp.toPath()); + // break; + // + // } + // + // AuthorizationHeader ah = new AuthorizationHeader(); + // // Authenticate to IM with the OAuth2 token + // Credential cred = ImTokenCredential.getBuilder().withToken(dm.getOauth2Token()).build(); + // ah.addCredential(cred); + // + // cred = VmrcCredential.getBuilder().withUsername("demo").withPassword("pwd") + // .withHost("http://servproject.i3m.upv.es:8080/vmrc/vmrc").build(); + // ah.addCredential(cred); + // cred = OpenstackCredential.getBuilder().withId("ost").withUsername("usr").withPassword("pwd") + // .withTenant("tenant").withServiceRegion("recas-cloud") + // .withHost("https://cloud.recas.ba.infn.it:5000").build(); + // InfrastructureManager im = new InfrastructureManager(imUrl, ah); + // } + // FIXME Use CMDB EP! + + IaaSType iaasType = dm.getChosenCloudProviderEndpoint().getIaasType(); InputStream inputStream = null; try { - switch (iaaSSite) { + LOG.debug("Load {} credentials with: {}", iaasType, dm.getChosenCloudProviderEndpoint()); + switch (iaasType) { case OPENSTACK: - LOG.debug("Load {} credentials", IaaSSite.OPENSTACK.toString()); - inputStream = ctx.getResource(openstackAuthFilePath).getInputStream(); break; case ONEDOCK: - LOG.debug("Load {} credentials", IaaSSite.ONEDOCK.toString()); // Read the proxy file String proxy; try (InputStream in = ctx.getResource(proxyPath).getInputStream()) { @@ -135,13 +157,11 @@ private InfrastructureManager getClient(IaaSSite iaaSSite) { inputStream = IOUtils.toInputStream(authFile, StandardCharsets.UTF_8.toString()); break; case OPENNEBULA: - LOG.debug("Load {} credentials", IaaSSite.OPENNEBULA.toString()); inputStream = ctx.getResource(opennebulaAuthFilePath).getInputStream(); break; default: - LOG.debug("Load fake credentials"); - inputStream = ctx.getResource(authFilePath).getInputStream(); - break; + throw new IllegalArgumentException( + String.format("Unsupported provider type <%s>", iaasType)); } File tmp = File.createTempFile("authFileTmp", ".tmp"); @@ -163,17 +183,6 @@ private InfrastructureManager getClient(IaaSSite iaaSSite) { } } - private IaaSSite getIaaSSiteFromTosca(String template) { - - if (template.contains("tosca.nodes.indigo.MesosMaster")) { - return IaaSSite.OPENSTACK; - } else if (template.contains("onedock.i3m.upv.es")) { - return IaaSSite.ONEDOCK; - } else { - return IaaSSite.OPENNEBULA; - } - } - @Override public boolean doDeploy(DeploymentMessage deploymentMessage) { Deployment deployment = deploymentMessage.getDeployment(); @@ -190,8 +199,8 @@ public boolean doDeploy(DeploymentMessage deploymentMessage) { toscaService.contextualizeImages(ar, deploymentMessage.getChosenCloudProvider()); String imCustomizedTemplate = toscaService.getTemplateFromTopology(ar); - // FIXME this is a trick used only for demo purpose - InfrastructureManager im = getClient(getIaaSSiteFromTosca(deployment.getTemplate())); + // Generate IM Client + InfrastructureManager im = getClient(deploymentMessage); // Deploy on IM InfrastructureUri infrastructureUri = @@ -230,8 +239,8 @@ public boolean isDeployed(DeploymentMessage deploymentMessage) throws Deployment Deployment deployment = deploymentMessage.getDeployment(); InfrastructureManager im = null; try { - // FIXME this is a trick used only for demo purpose - im = getClient(getIaaSSiteFromTosca(deployment.getTemplate())); + // Generate IM Client + im = getClient(deploymentMessage); InfrastructureState infrastructureState = im.getInfrastructureState(deployment.getEndpoint()); LOG.debug(infrastructureState.toString()); @@ -291,8 +300,9 @@ public void finalizeDeploy(DeploymentMessage deploymentMessage, boolean deployed Deployment deployment = deploymentMessage.getDeployment(); if (deployed) { try { - // FIXME this is a trick used only for demo purpose - InfrastructureManager im = getClient(getIaaSSiteFromTosca(deployment.getTemplate())); + // Generate IM Client + InfrastructureManager im = getClient(deploymentMessage); + if (deployment.getOutputs().isEmpty()) { InfOutputValues outputValues = im.getInfrastructureOutputs(deployment.getEndpoint()); Map outputs = new HashMap(); @@ -305,7 +315,7 @@ public void finalizeDeploy(DeploymentMessage deploymentMessage, boolean deployed } deployment.setOutputs(outputs); } - bindResources(deployment, deployment.getEndpoint()); + bindResources(deployment, deployment.getEndpoint(), im); updateOnSuccess(deployment.getId()); @@ -411,13 +421,14 @@ public boolean doUpdate(DeploymentMessage deploymentMessage, String template) { } } + // Generate IM Client + InfrastructureManager im = getClient(deploymentMessage); + // Pulisco gli output e aggiungo i nodi da creare root.getTopology().setOutputs(null); root.getTopology().setNodeTemplates(nodes); if (!root.getTopology().isEmpty()) { try { - InfrastructureManager im = getClient(getIaaSSiteFromTosca(deployment.getTemplate())); - im.addResource(deployment.getEndpoint(), toscaService.getTemplateFromTopology(root), BodyContentType.TOSCA); } catch (ImClientErrorException exception) { @@ -428,8 +439,6 @@ public boolean doUpdate(DeploymentMessage deploymentMessage, String template) { // DELETE if (vmIds.size() > 0) { try { - // FIXME this is a trick used only for demo purpose - InfrastructureManager im = getClient(getIaaSSiteFromTosca(deployment.getTemplate())); im.removeResource(deployment.getEndpoint(), vmIds); } catch (ImClientErrorException exception) { throw new DeploymentException( @@ -454,8 +463,9 @@ public boolean doUndeploy(DeploymentMessage deploymentMessage) { deployment.setTask(Task.DEPLOYER); deployment = deploymentRepository.save(deployment); - // FIXME this is a trick used only for demo purpose - InfrastructureManager im = getClient(getIaaSSiteFromTosca(deployment.getTemplate())); + // Generate IM Client + InfrastructureManager im = getClient(deploymentMessage); + if (deployment.getEndpoint() == null) { // updateOnSuccess(deploymentUuid); deploymentMessage.setDeleteComplete(true); @@ -489,8 +499,8 @@ public boolean isUndeployed(DeploymentMessage deploymentMessage) { Deployment deployment = deploymentMessage.getDeployment(); try { - // FIXME this is a trick used only for demo purpose - InfrastructureManager im = getClient(getIaaSSiteFromTosca(deployment.getTemplate())); + // Generate IM Client + InfrastructureManager im = getClient(deploymentMessage); // TODO verificare if (deployment.getEndpoint() == null) { @@ -525,35 +535,32 @@ public void finalizeUndeploy(DeploymentMessage deploymentMessage, boolean undepl } } - private boolean isResourceDeleted(Resource resource) { - try { - Deployment deployment = resource.getDeployment(); - // FIXME this is a trick used only for demo purpose - InfrastructureManager im = getClient(getIaaSSiteFromTosca(deployment.getTemplate())); - - im.getVmInfo(deployment.getEndpoint(), resource.getIaasId()); - return false; - - } catch (ImClientErrorException exception) { - ResponseError error = getImResponseError(exception); - return error.is404Error(); - - } catch (ImClientException ex) { - // TODO improve exception handling - LOG.error(ex); - return false; - } - } + // private boolean isResourceDeleted(Resource resource) { + // try { + // Deployment deployment = resource.getDeployment(); + // // Generate IM Client + // InfrastructureManager im = getClient(deploymentMessage); + // + // im.getVmInfo(deployment.getEndpoint(), resource.getIaasId()); + // return false; + // + // } catch (ImClientErrorException exception) { + // ResponseError error = getImResponseError(exception); + // return error.is404Error(); + // + // } catch (ImClientException ex) { + // // TODO improve exception handling + // LOG.error(ex); + // return false; + // } + // } /** * Match the {@link Resource} to IM vms. * */ - private void bindResources(Deployment deployment, String infrastructureId) - throws ImClientException { - - // FIXME this is a trick used only for demo purpose - InfrastructureManager im = getClient(getIaaSSiteFromTosca(deployment.getTemplate())); + private void bindResources(Deployment deployment, String infrastructureId, + InfrastructureManager im) throws ImClientException { // Get the URLs of the VMs composing the virtual infrastructure // TODO test in case of errors From a2c247817f1bb735e5bdab42da11f750f921e177 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Brigand=C3=AC?= Date: Thu, 23 Jun 2016 16:16:43 +0200 Subject: [PATCH 15/19] Add OAuth2 authentication --- .../dto/CloudProviderEndpoint.java | 2 +- .../CloudProviderEndpointServiceImpl.java | 5 +- .../deployment/providers/ImServiceImpl.java | 114 +++++++----------- 3 files changed, 47 insertions(+), 74 deletions(-) diff --git a/src/main/java/it/reply/orchestrator/dto/CloudProviderEndpoint.java b/src/main/java/it/reply/orchestrator/dto/CloudProviderEndpoint.java index 2d771ed000..94c3699e11 100644 --- a/src/main/java/it/reply/orchestrator/dto/CloudProviderEndpoint.java +++ b/src/main/java/it/reply/orchestrator/dto/CloudProviderEndpoint.java @@ -14,7 +14,7 @@ public class CloudProviderEndpoint implements Serializable { public enum IaaSType { // @formatter:off - OPENSTACK, OPENNEBULA, ONEDOCK + OPENSTACK, OPENNEBULA // @formatter:on } diff --git a/src/main/java/it/reply/orchestrator/service/CloudProviderEndpointServiceImpl.java b/src/main/java/it/reply/orchestrator/service/CloudProviderEndpointServiceImpl.java index 035be0b927..536b286de0 100644 --- a/src/main/java/it/reply/orchestrator/service/CloudProviderEndpointServiceImpl.java +++ b/src/main/java/it/reply/orchestrator/service/CloudProviderEndpointServiceImpl.java @@ -73,8 +73,6 @@ public IaaSType getIaaSTypeFromTosca(String template) { if (template.contains("tosca.nodes.indigo.MesosMaster")) { return IaaSType.OPENSTACK; - } else if (template.contains("onedock.i3m.upv.es")) { - return IaaSType.ONEDOCK; } else { return IaaSType.OPENNEBULA; } @@ -83,8 +81,7 @@ public IaaSType getIaaSTypeFromTosca(String template) { protected boolean isCompatible(IaaSType requiredType, IaaSType providerType) { if (requiredType == providerType) { return true; - } else if (requiredType == IaaSType.ONEDOCK && providerType == IaaSType.OPENNEBULA) { - // OneDock is a special case of OneNebula -.- + } else if (providerType == IaaSType.OPENNEBULA) { return true; } else { return false; diff --git a/src/main/java/it/reply/orchestrator/service/deployment/providers/ImServiceImpl.java b/src/main/java/it/reply/orchestrator/service/deployment/providers/ImServiceImpl.java index 910270b82e..565c296212 100644 --- a/src/main/java/it/reply/orchestrator/service/deployment/providers/ImServiceImpl.java +++ b/src/main/java/it/reply/orchestrator/service/deployment/providers/ImServiceImpl.java @@ -6,6 +6,10 @@ import es.upv.i3m.grycap.im.InfrastructureManager; import es.upv.i3m.grycap.im.States; +import es.upv.i3m.grycap.im.auth.AuthorizationHeader; +import es.upv.i3m.grycap.im.auth.credential.Credential; +import es.upv.i3m.grycap.im.auth.credential.im.ImCredential.ImTokenCredential; +import es.upv.i3m.grycap.im.auth.credential.opennebula.OpenNebulaTokenCredential; import es.upv.i3m.grycap.im.exceptions.ImClientErrorException; import es.upv.i3m.grycap.im.exceptions.ImClientException; import es.upv.i3m.grycap.im.pojo.InfOutputValues; @@ -31,6 +35,7 @@ import it.reply.orchestrator.exception.service.DeploymentException; import it.reply.orchestrator.exception.service.ToscaException; import it.reply.orchestrator.service.ToscaService; +import it.reply.orchestrator.service.security.OAuth2TokenService; import it.reply.utils.json.JsonUtility; import org.apache.commons.io.IOUtils; @@ -44,11 +49,8 @@ import org.springframework.data.domain.Page; import org.springframework.stereotype.Service; -import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.io.OutputStream; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.HashMap; @@ -70,6 +72,9 @@ public class ImServiceImpl extends AbstractDeploymentProviderService { @Autowired private ApplicationContext ctx; + @Autowired + private OAuth2TokenService oauth2TokenService; + @Value("${onedock.proxy.file.path}") private String proxyPath; @@ -79,9 +84,6 @@ public class ImServiceImpl extends AbstractDeploymentProviderService { @Value("${auth.file.path}") private String authFilePath; - @Value("${opennebula.auth.file.path}") - private String opennebulaAuthFilePath; - @Value("${openstack.auth.file.path}") private String openstackAuthFilePath; @@ -101,85 +103,59 @@ public class ImServiceImpl extends AbstractDeploymentProviderService { private ResourceRepository resourceRepository; private InfrastructureManager getClient(DeploymentMessage dm) { - // LOG.debug("Load {} credentials", cpe.getIaasType()); - // switch (cpe.getIaasType()) { - // case ONEDOCK: - // break; - // case OPENNEBULA: - // InfrastructureManager im = new InfrastructureManager(imUrl, tmp.toPath()); - // break; - // case OPENSTACK: - // InfrastructureManager im = new InfrastructureManager(imUrl, tmp.toPath()); - // break; - // - // } - // - // AuthorizationHeader ah = new AuthorizationHeader(); - // // Authenticate to IM with the OAuth2 token - // Credential cred = ImTokenCredential.getBuilder().withToken(dm.getOauth2Token()).build(); - // ah.addCredential(cred); - // - // cred = VmrcCredential.getBuilder().withUsername("demo").withPassword("pwd") - // .withHost("http://servproject.i3m.upv.es:8080/vmrc/vmrc").build(); - // ah.addCredential(cred); - // cred = OpenstackCredential.getBuilder().withId("ost").withUsername("usr").withPassword("pwd") - // .withTenant("tenant").withServiceRegion("recas-cloud") - // .withHost("https://cloud.recas.ba.infn.it:5000").build(); - // InfrastructureManager im = new InfrastructureManager(imUrl, ah); - // } - // FIXME Use CMDB EP! - IaaSType iaasType = dm.getChosenCloudProviderEndpoint().getIaasType(); - InputStream inputStream = null; + String authString = null; try { LOG.debug("Load {} credentials with: {}", iaasType, dm.getChosenCloudProviderEndpoint()); switch (iaasType) { case OPENSTACK: - inputStream = ctx.getResource(openstackAuthFilePath).getInputStream(); - break; - case ONEDOCK: - // Read the proxy file - String proxy; - try (InputStream in = ctx.getResource(proxyPath).getInputStream()) { - proxy = IOUtils.toString(in); - proxy = proxy.replace(System.lineSeparator(), "\\\\n"); - } catch (Exception ex) { - throw new OrchestratorException("Cannot load proxy file", ex); + try (InputStream is = ctx.getResource(openstackAuthFilePath).getInputStream()) { + authString = IOUtils.toString(is); + } + if (oauth2TokenService.isSecurityEnabled()) { + authString.replaceAll("InfrastructureManager; username = .+; password = .+", + "InfrastructureManager; token = " + dm.getOauth2Token()); } - // read onedock auth file - inputStream = ctx.getResource(onedockAuthFilePath).getInputStream(); - String authFile = IOUtils.toString(inputStream, StandardCharsets.UTF_8.toString()); - inputStream.close(); - - // replace the proxy as string - authFile = authFile.replace("{proxy}", proxy); - - inputStream = IOUtils.toInputStream(authFile, StandardCharsets.UTF_8.toString()); break; case OPENNEBULA: - inputStream = ctx.getResource(opennebulaAuthFilePath).getInputStream(); + if (oauth2TokenService.isSecurityEnabled()) { + AuthorizationHeader ah = new AuthorizationHeader(); + Credential cred = + ImTokenCredential.getBuilder().withToken(dm.getOauth2Token()).build(); + ah.addCredential(cred); + cred = OpenNebulaTokenCredential.getBuilder().withId("onedock") + .withHost(dm.getChosenCloudProviderEndpoint().getCpEndpoint()) + .withToken(dm.getOauth2Token()).build(); + ah.addCredential(cred); + InfrastructureManager im = new InfrastructureManager(imUrl, ah); + return im; + } else { + // Read the proxy file + String proxy; + try (InputStream in = ctx.getResource(proxyPath).getInputStream()) { + proxy = IOUtils.toString(in); + proxy = proxy.replace(System.lineSeparator(), "\\\\n"); + } catch (Exception ex) { + throw new OrchestratorException("Cannot load proxy file", ex); + } + // read onedock auth file + try (InputStream in = ctx.getResource(onedockAuthFilePath).getInputStream()) { + authString = IOUtils.toString(in, StandardCharsets.UTF_8.toString()); + } + // replace the proxy as string + authString = authString.replace("{proxy}", proxy); + } break; + // inputStream = ctx.getResource(opennebulaAuthFilePath).getInputStream(); + // break; default: throw new IllegalArgumentException( String.format("Unsupported provider type <%s>", iaasType)); } - - File tmp = File.createTempFile("authFileTmp", ".tmp"); - try (OutputStream outStream = new FileOutputStream(tmp)) { - IOUtils.copy(inputStream, outStream); - } - InfrastructureManager im = new InfrastructureManager(imUrl, tmp.toPath()); + InfrastructureManager im = new InfrastructureManager(imUrl, authString); return im; } catch (IOException | ImClientException ex) { throw new OrchestratorException("Cannot load IM auth file", ex); - } finally { - if (inputStream != null) { - try { - inputStream.close(); - } catch (IOException ex) { - LOG.catching(ex); - } - } } } From 0f2849c9ddb2bd793ac90d0cbacc2bf42c4f6038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Brigand=C3=AC?= Date: Thu, 23 Jun 2016 17:01:45 +0200 Subject: [PATCH 16/19] Remove cloud site hardcoded choice --- .../CloudProviderEndpointServiceImpl.java | 66 +++++++++---------- .../deployment/providers/ImServiceImpl.java | 5 +- 2 files changed, 33 insertions(+), 38 deletions(-) diff --git a/src/main/java/it/reply/orchestrator/service/CloudProviderEndpointServiceImpl.java b/src/main/java/it/reply/orchestrator/service/CloudProviderEndpointServiceImpl.java index 536b286de0..e69ceeb259 100644 --- a/src/main/java/it/reply/orchestrator/service/CloudProviderEndpointServiceImpl.java +++ b/src/main/java/it/reply/orchestrator/service/CloudProviderEndpointServiceImpl.java @@ -17,25 +17,19 @@ public class CloudProviderEndpointServiceImpl { public RankedCloudProvider chooseCloudProvider(Deployment deployment, RankCloudProvidersMessage rankCloudProvidersMessage) { - // Choose Cloud Provider - IaaSType iaasType = getIaaSTypeFromTosca(deployment.getTemplate()); - - LOG.debug("Choosing Cloud Provider based on: {}, IaaSType: {}", - rankCloudProvidersMessage.getRankedCloudProviders(), iaasType); // TODO Check ranker errors (i.e. providers with ranked = false) RankedCloudProvider chosenCp = null; for (RankedCloudProvider rcp : rankCloudProvidersMessage.getRankedCloudProviders()) { // Choose the one with lowest rank AND that matches iaasType (TEMPORARY) - if ((isCompatible(iaasType, getProviderIaaSType(rankCloudProvidersMessage, rcp.getName()))) - && (chosenCp == null || rcp.getRank() < chosenCp.getRank())) { + if (chosenCp == null || rcp.getRank() < chosenCp.getRank()) { chosenCp = rcp; } } if (chosenCp == null) { - String errorMsg = String.format("No Cloud Provider found for: {}, IaaSType: {}", - rankCloudProvidersMessage.getRankedCloudProviders(), iaasType); + String errorMsg = String.format("No Cloud Provider found for: {}", + rankCloudProvidersMessage.getRankedCloudProviders()); LOG.error(errorMsg); throw new IllegalArgumentException(errorMsg); } @@ -47,7 +41,7 @@ public RankedCloudProvider chooseCloudProvider(Deployment deployment, public CloudProviderEndpoint getCloudProviderEndpoint(Deployment deployment, RankCloudProvidersMessage rankCloudProvidersMessage, RankedCloudProvider chosenCp) { - IaaSType iaasType = getIaaSTypeFromTosca(deployment.getTemplate()); + IaaSType iaasType = getProviderIaaSType(rankCloudProvidersMessage, chosenCp.getName()); CloudProviderEndpoint cpe = new CloudProviderEndpoint(); @@ -61,32 +55,32 @@ public CloudProviderEndpoint getCloudProviderEndpoint(Deployment deployment, return cpe; } - /** - * TEMPORARY method to decide whether it is needed to coerce CP choice based on template content - * (i.e. currently used to force Mesos cluster deployment on OpenStack). - * - * @param template - * . - * @return . - */ - public IaaSType getIaaSTypeFromTosca(String template) { - - if (template.contains("tosca.nodes.indigo.MesosMaster")) { - return IaaSType.OPENSTACK; - } else { - return IaaSType.OPENNEBULA; - } - } - - protected boolean isCompatible(IaaSType requiredType, IaaSType providerType) { - if (requiredType == providerType) { - return true; - } else if (providerType == IaaSType.OPENNEBULA) { - return true; - } else { - return false; - } - } + // /** + // * TEMPORARY method to decide whether it is needed to coerce CP choice based on template content + // * (i.e. currently used to force Mesos cluster deployment on OpenStack). + // * + // * @param template + // * . + // * @return . + // */ + // public IaaSType getIaaSTypeFromTosca(String template) { + // + // if (template.contains("tosca.nodes.indigo.MesosMaster")) { + // return IaaSType.OPENSTACK; + // } else { + // return IaaSType.OPENNEBULA; + // } + // } + + // protected boolean isCompatible(IaaSType requiredType, IaaSType providerType) { + // if (requiredType == providerType) { + // return true; + // } else if (providerType == IaaSType.OPENNEBULA) { + // return true; + // } else { + // return false; + // } + // } protected IaaSType getProviderIaaSType(RankCloudProvidersMessage rankCloudProvidersMessage, String providerName) { diff --git a/src/main/java/it/reply/orchestrator/service/deployment/providers/ImServiceImpl.java b/src/main/java/it/reply/orchestrator/service/deployment/providers/ImServiceImpl.java index 565c296212..df7422e1ae 100644 --- a/src/main/java/it/reply/orchestrator/service/deployment/providers/ImServiceImpl.java +++ b/src/main/java/it/reply/orchestrator/service/deployment/providers/ImServiceImpl.java @@ -113,8 +113,9 @@ private InfrastructureManager getClient(DeploymentMessage dm) { authString = IOUtils.toString(is); } if (oauth2TokenService.isSecurityEnabled()) { - authString.replaceAll("InfrastructureManager; username = .+; password = .+", - "InfrastructureManager; token = " + dm.getOauth2Token()); + authString = + authString.replaceAll("InfrastructureManager; username = .+; password = .+", + "InfrastructureManager; token = " + dm.getOauth2Token()); } break; case OPENNEBULA: From e5c7f241c10d2f84569b76a9214e5e6ee458d53b Mon Sep 17 00:00:00 2001 From: Lorenzo Biava Date: Thu, 23 Jun 2016 17:48:10 +0200 Subject: [PATCH 17/19] Fix Image match (was not prioritizing image name match correctly) See #53 --- .../service/ToscaServiceImpl.java | 43 ++++++++++++------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/src/main/java/it/reply/orchestrator/service/ToscaServiceImpl.java b/src/main/java/it/reply/orchestrator/service/ToscaServiceImpl.java index ac39d7172f..bff53c49d1 100644 --- a/src/main/java/it/reply/orchestrator/service/ToscaServiceImpl.java +++ b/src/main/java/it/reply/orchestrator/service/ToscaServiceImpl.java @@ -371,23 +371,26 @@ public void contextualizeImages(ArchiveRoot parsingResult, CloudProvider cloudPr } protected Image getBestImageForCloudProvider(Image imageMetadata, CloudProvider cloudProvider) { - for (Image image : cloudProvider.getCmdbProviderImages()) { - // Match image name first (for INDIGO specific use case, if the image cannot be found with the - // specified name it means that a base image + Ansible configuration have to be used -> the - // base image will be chosen with the other filters and image metadata - architecture, type, - // distro, version) - if (imageMetadata.getImageName() != null) { - - if (matchImageNameAndTag(imageMetadata.getImageName(), image.getImageName())) { - LOG.debug("Image <{}> found with name <{}>", image.getImageId(), - imageMetadata.getImageName()); - return image; - } else { - LOG.debug("Image not found with name <{}>, trying with other fields: <{}>", - imageMetadata.getImageName(), imageMetadata); - } + + // Match image name first (for INDIGO specific use case, if the image cannot be found with the + // specified name it means that a base image + Ansible configuration have to be used -> the + // base image will be chosen with the other filters and image metadata - architecture, type, + // distro, version) + if (imageMetadata.getImageName() != null) { + Image imageWithName = + findImageWithNameOnCloudProvider(imageMetadata.getImageName(), cloudProvider); + + if (imageWithName != null) { + LOG.debug("Image <{}> found with name <{}>", imageWithName.getImageId(), + imageMetadata.getImageName()); + return imageWithName; + } else { + LOG.debug("Image not found with name <{}>, trying with other fields: <{}>", + imageMetadata.getImageName(), imageMetadata); } + } + for (Image image : cloudProvider.getCmdbProviderImages()) { // Match or skip image based on each additional optional attribute if (imageMetadata.getType() != null) { if (!imageMetadata.getType().equalsIgnoreCase(image.getType())) { @@ -420,6 +423,16 @@ protected Image getBestImageForCloudProvider(Image imageMetadata, CloudProvider } + protected Image findImageWithNameOnCloudProvider(String requiredImageName, + CloudProvider cloudProvider) { + for (Image image : cloudProvider.getCmdbProviderImages()) { + if (matchImageNameAndTag(requiredImageName, image.getImageName())) { + return image; + } + } + return null; + } + protected boolean matchImageNameAndTag(String requiredImageName, String availableImageName) { // Extract Docker tag if available String[] requiredImageNameSplit = requiredImageName.split(":"); From fde867f503e14985f9fa3f9dd0c3d087c3be1c8f Mon Sep 17 00:00:00 2001 From: Lorenzo Biava Date: Thu, 23 Jun 2016 18:11:32 +0200 Subject: [PATCH 18/19] Update dependencies to stable (alien4cloud) - alien4cloud=1.1.0-INDIGO2-ALPHA.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7ab42a8bff..6ef8bb60f1 100644 --- a/pom.xml +++ b/pom.xml @@ -41,7 +41,7 @@ ${project.build.directory}\generated-snippets 2.17 0.0.3-FINAL - 1.1.0-INDIGO2-SNAPSHOT + 1.1.0-INDIGO2-ALPHA.1 0.0.1-BETA.1 From bde496b27c4d054c1a2f5584bc16f684eb19c743 Mon Sep 17 00:00:00 2001 From: Lorenzo Biava Date: Thu, 23 Jun 2016 19:00:24 +0200 Subject: [PATCH 19/19] Fix CheckStyle --- .../dto/cmdb/CmdbHasManyList.java | 45 +++---------- .../orchestrator/dto/cmdb/CmdbImage.java | 36 ----------- .../orchestrator/dto/cmdb/CmdbImageRow.java | 27 -------- .../it/reply/orchestrator/dto/cmdb/Image.java | 63 ------------------- .../dto/deployment/DeploymentMessage.java | 2 +- .../CloudProviderEndpointServiceImpl.java | 20 ++++++ .../orchestrator/service/ToscaService.java | 4 +- 7 files changed, 32 insertions(+), 165 deletions(-) diff --git a/src/main/java/it/reply/orchestrator/dto/cmdb/CmdbHasManyList.java b/src/main/java/it/reply/orchestrator/dto/cmdb/CmdbHasManyList.java index 03bf3da646..252ca922a6 100644 --- a/src/main/java/it/reply/orchestrator/dto/cmdb/CmdbHasManyList.java +++ b/src/main/java/it/reply/orchestrator/dto/cmdb/CmdbHasManyList.java @@ -21,85 +21,58 @@ @JsonInclude(JsonInclude.Include.NON_NULL) @Generated("org.jsonschema2pojo") @JsonPropertyOrder({ "total_rows", "offset", "rows" }) -public class CmdbHasManyList { +public class CmdbHasManyList { @JsonProperty("total_rows") private Long totalRows; @JsonProperty("offset") private Long offset; @JsonProperty("rows") - private List rows = new ArrayList<>(); + private List rows = new ArrayList<>(); @JsonIgnore private Map additionalProperties = new HashMap(); - /** - * - * @return The totalRows - */ @JsonProperty("total_rows") public Long getTotalRows() { return totalRows; } - /** - * - * @param totalRows - * The total_rows - */ @JsonProperty("total_rows") public void setTotalRows(Long totalRows) { this.totalRows = totalRows; } - public CmdbHasManyList withTotalRows(Long totalRows) { + public CmdbHasManyList withTotalRows(Long totalRows) { this.totalRows = totalRows; return this; } - /** - * - * @return The offset - */ @JsonProperty("offset") public Long getOffset() { return offset; } - /** - * - * @param offset - * The offset - */ @JsonProperty("offset") public void setOffset(Long offset) { this.offset = offset; } - public CmdbHasManyList withOffset(Long offset) { + public CmdbHasManyList withOffset(Long offset) { this.offset = offset; return this; } - /** - * - * @return The rows - */ @JsonProperty("rows") - public List getRows() { + public List getRows() { return rows; } - /** - * - * @param rows - * The rows - */ @JsonProperty("rows") - public void setRows(List rows) { + public void setRows(List rows) { this.rows = rows; } - public CmdbHasManyList withRows(List rows) { + public CmdbHasManyList withRows(List rows) { this.rows = rows; return this; } @@ -119,7 +92,7 @@ public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } - public CmdbHasManyList withAdditionalProperty(String name, Object value) { + public CmdbHasManyList withAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); return this; } @@ -139,7 +112,7 @@ public boolean equals(Object other) { return false; } @SuppressWarnings("unchecked") - CmdbHasManyList rhs = ((CmdbHasManyList) other); + CmdbHasManyList rhs = ((CmdbHasManyList) other); return new EqualsBuilder().append(totalRows, rhs.totalRows).append(offset, rhs.offset) .append(rows, rhs.rows).append(additionalProperties, rhs.additionalProperties).isEquals(); } diff --git a/src/main/java/it/reply/orchestrator/dto/cmdb/CmdbImage.java b/src/main/java/it/reply/orchestrator/dto/cmdb/CmdbImage.java index 7aae4577ea..f337893788 100644 --- a/src/main/java/it/reply/orchestrator/dto/cmdb/CmdbImage.java +++ b/src/main/java/it/reply/orchestrator/dto/cmdb/CmdbImage.java @@ -32,20 +32,11 @@ public class CmdbImage { @JsonIgnore private Map additionalProperties = new HashMap(); - /** - * - * @return The id - */ @JsonProperty("_id") public String getId() { return id; } - /** - * - * @param id - * The _id - */ @JsonProperty("_id") public void setId(String id) { this.id = id; @@ -56,20 +47,11 @@ public CmdbImage withId(String id) { return this; } - /** - * - * @return The rev - */ @JsonProperty("_rev") public String getRev() { return rev; } - /** - * - * @param rev - * The _rev - */ @JsonProperty("_rev") public void setRev(String rev) { this.rev = rev; @@ -80,20 +62,11 @@ public CmdbImage withRev(String rev) { return this; } - /** - * - * @return The type - */ @JsonProperty("type") public String getType() { return type; } - /** - * - * @param type - * The type - */ @JsonProperty("type") public void setType(String type) { this.type = type; @@ -104,20 +77,11 @@ public CmdbImage withType(String type) { return this; } - /** - * - * @return The data - */ @JsonProperty("data") public Image getData() { return data; } - /** - * - * @param data - * The data - */ @JsonProperty("data") public void setData(Image data) { this.data = data; diff --git a/src/main/java/it/reply/orchestrator/dto/cmdb/CmdbImageRow.java b/src/main/java/it/reply/orchestrator/dto/cmdb/CmdbImageRow.java index fcfcd46986..f43c8f28ab 100644 --- a/src/main/java/it/reply/orchestrator/dto/cmdb/CmdbImageRow.java +++ b/src/main/java/it/reply/orchestrator/dto/cmdb/CmdbImageRow.java @@ -23,20 +23,11 @@ public class CmdbImageRow { @JsonProperty("doc") private CmdbImage image; - /** - * - * @return The id - */ @JsonProperty("id") public String getId() { return id; } - /** - * - * @param id - * The id - */ @JsonProperty("id") public void setId(String id) { this.id = id; @@ -47,20 +38,11 @@ public CmdbImageRow withId(String id) { return this; } - /** - * - * @return The key - */ @JsonProperty("key") public List getKey() { return key; } - /** - * - * @param key - * The key - */ @JsonProperty("key") public void setKey(List key) { this.key = key; @@ -71,20 +53,11 @@ public CmdbImageRow withKey(List key) { return this; } - /** - * - * @return The image - */ @JsonProperty("doc") public CmdbImage getImage() { return image; } - /** - * - * @param image - * The image - */ @JsonProperty("doc") public void setImage(CmdbImage image) { this.image = image; diff --git a/src/main/java/it/reply/orchestrator/dto/cmdb/Image.java b/src/main/java/it/reply/orchestrator/dto/cmdb/Image.java index 5180712e09..9bda899c7b 100644 --- a/src/main/java/it/reply/orchestrator/dto/cmdb/Image.java +++ b/src/main/java/it/reply/orchestrator/dto/cmdb/Image.java @@ -41,20 +41,11 @@ public class Image implements Serializable { @JsonIgnore private Map additionalProperties = new HashMap(); - /** - * - * @return The imageId - */ @JsonProperty("image_id") public String getImageId() { return imageId; } - /** - * - * @param imageId - * The image_id - */ @JsonProperty("image_id") public void setImageId(String imageId) { this.imageId = imageId; @@ -65,20 +56,11 @@ public Image withImageId(String imageId) { return this; } - /** - * - * @return The imageName - */ @JsonProperty("image_name") public String getImageName() { return imageName; } - /** - * - * @param imageName - * The image_name - */ @JsonProperty("image_name") public void setImageName(String imageName) { this.imageName = imageName; @@ -89,20 +71,11 @@ public Image withImageName(String imageName) { return this; } - /** - * - * @return The architecture - */ @JsonProperty("architecture") public String getArchitecture() { return architecture; } - /** - * - * @param architecture - * The architecture - */ @JsonProperty("architecture") public void setArchitecture(String architecture) { this.architecture = architecture; @@ -113,20 +86,11 @@ public Image withArchitecture(String architecture) { return this; } - /** - * - * @return The type - */ @JsonProperty("type") public String getType() { return type; } - /** - * - * @param type - * The type - */ @JsonProperty("type") public void setType(String type) { this.type = type; @@ -137,20 +101,11 @@ public Image withType(String type) { return this; } - /** - * - * @return The distribution - */ @JsonProperty("distribution") public String getDistribution() { return distribution; } - /** - * - * @param distribution - * The distribution - */ @JsonProperty("distribution") public void setDistribution(String distribution) { this.distribution = distribution; @@ -161,20 +116,11 @@ public Image withDistribution(String distribution) { return this; } - /** - * - * @return The version - */ @JsonProperty("version") public String getVersion() { return version; } - /** - * - * @param version - * The version - */ @JsonProperty("version") public void setVersion(String version) { this.version = version; @@ -185,20 +131,11 @@ public Image withVersion(String version) { return this; } - /** - * - * @return The service - */ @JsonProperty("service") public String getService() { return service; } - /** - * - * @param service - * The service - */ @JsonProperty("service") public void setService(String service) { this.service = service; diff --git a/src/main/java/it/reply/orchestrator/dto/deployment/DeploymentMessage.java b/src/main/java/it/reply/orchestrator/dto/deployment/DeploymentMessage.java index a4b2d3ba14..dbfcc9aeef 100644 --- a/src/main/java/it/reply/orchestrator/dto/deployment/DeploymentMessage.java +++ b/src/main/java/it/reply/orchestrator/dto/deployment/DeploymentMessage.java @@ -120,7 +120,7 @@ public void setSkipPollInterval(boolean skipPollInterval) { this.skipPollInterval = skipPollInterval; } - public CloudProvider getChosenCloudProvider() { + public CloudProvider getChosenCloudProvider() { return chosenCloudProvider; } diff --git a/src/main/java/it/reply/orchestrator/service/CloudProviderEndpointServiceImpl.java b/src/main/java/it/reply/orchestrator/service/CloudProviderEndpointServiceImpl.java index e69ceeb259..a30bbe920c 100644 --- a/src/main/java/it/reply/orchestrator/service/CloudProviderEndpointServiceImpl.java +++ b/src/main/java/it/reply/orchestrator/service/CloudProviderEndpointServiceImpl.java @@ -15,6 +15,15 @@ public class CloudProviderEndpointServiceImpl { private static final Logger LOG = LogManager.getLogger(CloudProviderEndpointServiceImpl.class); + /** + * Choose a Cloud Provider. + * + * @param deployment + * . + * @param rankCloudProvidersMessage + * . + * @return . + */ public RankedCloudProvider chooseCloudProvider(Deployment deployment, RankCloudProvidersMessage rankCloudProvidersMessage) { @@ -38,6 +47,17 @@ public RankedCloudProvider chooseCloudProvider(Deployment deployment, return chosenCp; } + /** + * . + * + * @param deployment + * . + * @param rankCloudProvidersMessage + * . + * @param chosenCp + * . + * @return . + */ public CloudProviderEndpoint getCloudProviderEndpoint(Deployment deployment, RankCloudProvidersMessage rankCloudProvidersMessage, RankedCloudProvider chosenCp) { diff --git a/src/main/java/it/reply/orchestrator/service/ToscaService.java b/src/main/java/it/reply/orchestrator/service/ToscaService.java index 461e39d496..41f8a1c427 100644 --- a/src/main/java/it/reply/orchestrator/service/ToscaService.java +++ b/src/main/java/it/reply/orchestrator/service/ToscaService.java @@ -1,7 +1,5 @@ package it.reply.orchestrator.service; -import com.sun.istack.NotNull; - import alien4cloud.model.components.AbstractPropertyValue; import alien4cloud.model.components.PropertyDefinition; import alien4cloud.model.components.PropertyValue; @@ -12,6 +10,8 @@ import alien4cloud.tosca.parser.ParsingException; import alien4cloud.tosca.parser.ParsingResult; +import com.sun.istack.NotNull; + import it.reply.orchestrator.dto.CloudProvider; import it.reply.orchestrator.exception.service.ToscaException;