Commit cff704c4 authored by Spiros Koulouzis's avatar Spiros Koulouzis

implementing provision service

parent 5dbca3ef
...@@ -22,10 +22,17 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; ...@@ -22,10 +22,17 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator; import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import nl.uva.sne.drip.commons.sure_tosca.client.ApiClient;
import nl.uva.sne.drip.commons.sure_tosca.client.ApiException; import nl.uva.sne.drip.commons.sure_tosca.client.ApiException;
import nl.uva.sne.drip.commons.sure_tosca.client.Configuration;
import nl.uva.sne.drip.commons.sure_tosca.client.DefaultApi; import nl.uva.sne.drip.commons.sure_tosca.client.DefaultApi;
import nl.uva.sne.drip.model.ToscaTemplate; import nl.uva.sne.drip.model.ToscaTemplate;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
/** /**
* *
...@@ -46,11 +53,13 @@ public class ToscaHelper { ...@@ -46,11 +53,13 @@ public class ToscaHelper {
private final Integer id; private final Integer id;
public ToscaHelper(ToscaTemplate toscaTemplate) throws JsonProcessingException, IOException, ApiException { public ToscaHelper(ToscaTemplate toscaTemplate, String sureToscaBasePath) throws JsonProcessingException, IOException, ApiException {
api = new DefaultApi(); Configuration.getDefaultApiClient().setBasePath(sureToscaBasePath);
id = uploadToscaTemplate(toscaTemplate); api = new DefaultApi(Configuration.getDefaultApiClient());
this.objectMapper = new ObjectMapper(new YAMLFactory().disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER)); this.objectMapper = new ObjectMapper(new YAMLFactory().disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER));
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
id = uploadToscaTemplate(toscaTemplate);
} }
private Integer uploadToscaTemplate(ToscaTemplate toscaTemplate) throws JsonProcessingException, IOException, ApiException { private Integer uploadToscaTemplate(ToscaTemplate toscaTemplate) throws JsonProcessingException, IOException, ApiException {
...@@ -58,7 +67,19 @@ public class ToscaHelper { ...@@ -58,7 +67,19 @@ public class ToscaHelper {
File toscaTemplateFile = File.createTempFile("temp-toscaTemplate", ".yml"); File toscaTemplateFile = File.createTempFile("temp-toscaTemplate", ".yml");
FileUtils.writeByteArrayToFile(toscaTemplateFile, ymlStr.getBytes()); FileUtils.writeByteArrayToFile(toscaTemplateFile, ymlStr.getBytes());
String resp = api.uploadToscaTemplate(toscaTemplateFile); String resp = api.uploadToscaTemplate(toscaTemplateFile);
return null; return Integer.valueOf(resp);
}
public List<Map<String, Object>> getProvisionInterfaceDefinitions(List<String> toscaInterfaceTypes) throws ApiException {
List<Map<String, Object>> interfaceDefinitions = new ArrayList<>();
for (String type : toscaInterfaceTypes) {
String derivedFrom = null;
List<Map<String, Object>> interfaces = api.getTypes(String.valueOf(id), "interface_types", null, type, null, null, null, null, null, derivedFrom);
interfaceDefinitions.addAll(interfaces);
}
return interfaceDefinitions;
} }
} }
...@@ -4,6 +4,7 @@ import java.util.Objects; ...@@ -4,6 +4,7 @@ import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.util.HashMap; import java.util.HashMap;
...@@ -18,10 +19,10 @@ import org.springframework.data.annotation.Id; ...@@ -18,10 +19,10 @@ import org.springframework.data.annotation.Id;
* Credentials * Credentials
*/ */
@Validated @Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-11-01T14:10:53.529Z") @JsonInclude(JsonInclude.Include.NON_NULL)
public class Credentials {
public class Credentials { /**
/**
* @return the id * @return the id
*/ */
public String getId() { public String getId() {
...@@ -38,201 +39,205 @@ public class Credentials { ...@@ -38,201 +39,205 @@ public class Credentials {
@Id @Id
@JsonIgnore @JsonIgnore
private String id; private String id;
@JsonProperty("protocol")
private String protocol = null;
@JsonProperty("token_type") @JsonProperty("protocol")
private String tokenType = null; private String protocol = null;
@JsonProperty("token_type")
private String tokenType = null;
@JsonProperty("token")
private String token = null;
@JsonProperty("keys")
@Valid
private Map<String, String> keys = null;
@JsonProperty("token") @JsonProperty("user")
private String token = null; private String user = null;
@JsonProperty("keys") @JsonProperty("cloud_provider_name")
@Valid private String cloudProviderName = null;
private Map<String, String> keys = null;
@JsonProperty("user") public Credentials protocol(String protocol) {
private String user = null; this.protocol = protocol;
return this;
}
/**
* Get protocol
*
* @return protocol
*
*/
@ApiModelProperty(value = "")
@JsonProperty("cloud_provider_name") public String getProtocol() {
private String cloudProviderName = null; return protocol;
}
public Credentials protocol(String protocol) { public void setProtocol(String protocol) {
this.protocol = protocol; this.protocol = protocol;
return this; }
}
/** public Credentials tokenType(String tokenType) {
* Get protocol this.tokenType = tokenType;
* @return protocol return this;
**/ }
@ApiModelProperty(value = "")
/**
* Get tokenType
*
* @return tokenType
*
*/
@ApiModelProperty(value = "")
public String getProtocol() { public String getTokenType() {
return protocol; return tokenType;
} }
public void setProtocol(String protocol) { public void setTokenType(String tokenType) {
this.protocol = protocol; this.tokenType = tokenType;
} }
public Credentials tokenType(String tokenType) { public Credentials token(String token) {
this.tokenType = tokenType; this.token = token;
return this; return this;
} }
/** /**
* Get tokenType * Get token
* @return tokenType *
**/ * @return token
@ApiModelProperty(value = "") *
*/
@ApiModelProperty(value = "")
public String getToken() {
return token;
}
public String getTokenType() { public void setToken(String token) {
return tokenType; this.token = token;
} }
public void setTokenType(String tokenType) { public Credentials keys(Map<String, String> keys) {
this.tokenType = tokenType; this.keys = keys;
} return this;
}
public Credentials token(String token) { public Credentials putKeysItem(String key, String keysItem) {
this.token = token; if (this.keys == null) {
return this; this.keys = new HashMap<String, String>();
} }
this.keys.put(key, keysItem);
return this;
}
/** /**
* Get token * Get keys
* @return token *
**/ * @return keys
@ApiModelProperty(value = "") *
*/
@ApiModelProperty(value = "")
public Map<String, String> getKeys() {
return keys;
}
public String getToken() { public void setKeys(Map<String, String> keys) {
return token; this.keys = keys;
} }
public void setToken(String token) {
this.token = token;
}
public Credentials keys(Map<String, String> keys) {
this.keys = keys;
return this;
}
public Credentials putKeysItem(String key, String keysItem) {
if (this.keys == null) {
this.keys = new HashMap<String, String>();
}
this.keys.put(key, keysItem);
return this;
}
/**
* Get keys
* @return keys
**/
@ApiModelProperty(value = "")
public Map<String, String> getKeys() {
return keys;
}
public void setKeys(Map<String, String> keys) {
this.keys = keys;
}
public Credentials user(String user) {
this.user = user;
return this;
}
/**
* Get user
* @return user
**/
@ApiModelProperty(value = "")
public String getUser() {
return user;
}
public void setUser(String user) {
this.user = user;
}
public Credentials cloudProviderName(String cloudProviderName) {
this.cloudProviderName = cloudProviderName;
return this;
}
/**
* Get cloudProviderName
* @return cloudProviderName
**/
@ApiModelProperty(value = "")
public String getCloudProviderName() {
return cloudProviderName;
}
public void setCloudProviderName(String cloudProviderName) {
this.cloudProviderName = cloudProviderName;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Credentials credentials = (Credentials) o;
return Objects.equals(this.protocol, credentials.protocol) &&
Objects.equals(this.tokenType, credentials.tokenType) &&
Objects.equals(this.token, credentials.token) &&
Objects.equals(this.keys, credentials.keys) &&
Objects.equals(this.user, credentials.user) &&
Objects.equals(this.cloudProviderName, credentials.cloudProviderName);
}
@Override
public int hashCode() {
return Objects.hash(protocol, tokenType, token, keys, user, cloudProviderName);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Credentials {\n");
sb.append(" protocol: ").append(toIndentedString(protocol)).append("\n");
sb.append(" tokenType: ").append(toIndentedString(tokenType)).append("\n");
sb.append(" token: ").append(toIndentedString(token)).append("\n");
sb.append(" keys: ").append(toIndentedString(keys)).append("\n");
sb.append(" user: ").append(toIndentedString(user)).append("\n");
sb.append(" cloudProviderName: ").append(toIndentedString(cloudProviderName)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}
public Credentials user(String user) {
this.user = user;
return this;
}
/**
* Get user
*
* @return user
*
*/
@ApiModelProperty(value = "")
public String getUser() {
return user;
}
public void setUser(String user) {
this.user = user;
}
public Credentials cloudProviderName(String cloudProviderName) {
this.cloudProviderName = cloudProviderName;
return this;
}
/**
* Get cloudProviderName
*
* @return cloudProviderName
*
*/
@ApiModelProperty(value = "")
public String getCloudProviderName() {
return cloudProviderName;
}
public void setCloudProviderName(String cloudProviderName) {
this.cloudProviderName = cloudProviderName;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Credentials credentials = (Credentials) o;
return Objects.equals(this.protocol, credentials.protocol)
&& Objects.equals(this.tokenType, credentials.tokenType)
&& Objects.equals(this.token, credentials.token)
&& Objects.equals(this.keys, credentials.keys)
&& Objects.equals(this.user, credentials.user)
&& Objects.equals(this.cloudProviderName, credentials.cloudProviderName);
}
@Override
public int hashCode() {
return Objects.hash(protocol, tokenType, token, keys, user, cloudProviderName);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Credentials {\n");
sb.append(" protocol: ").append(toIndentedString(protocol)).append("\n");
sb.append(" tokenType: ").append(toIndentedString(tokenType)).append("\n");
sb.append(" token: ").append(toIndentedString(token)).append("\n");
sb.append(" keys: ").append(toIndentedString(keys)).append("\n");
sb.append(" user: ").append(toIndentedString(user)).append("\n");
sb.append(" cloudProviderName: ").append(toIndentedString(cloudProviderName)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}
...@@ -3,6 +3,7 @@ package nl.uva.sne.drip.model; ...@@ -3,6 +3,7 @@ package nl.uva.sne.drip.model;
import java.util.Objects; import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -17,28 +18,26 @@ import javax.validation.constraints.*; ...@@ -17,28 +18,26 @@ import javax.validation.constraints.*;
* NodeTemplate * NodeTemplate
*/ */
@Validated @Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-11-01T14:10:53.529Z") @JsonInclude(JsonInclude.Include.NON_NULL)
public class NodeTemplate { public class NodeTemplate {
@JsonProperty("derived_from") @JsonProperty("derived_from")
private String derivedFrom = null; private String derivedFrom = null;
@JsonProperty("properties") @JsonProperty("properties")
@Valid @Valid
private Map<String, String> properties = null; private Map<String, Object> properties = null;
@JsonProperty("requirements") @JsonProperty("requirements")
@Valid @Valid
private List<Map<String, String>> requirements = null; private List<Map<String, Object>> requirements = null;
@JsonProperty("interfaces") @JsonProperty("interfaces")
@Valid @Valid
private Map<String, String> interfaces = null; private Map<String, Object> interfaces = null;
@JsonProperty("capabilities") @JsonProperty("capabilities")
@Valid @Valid
private Map<String, String> capabilities = null; private Map<String, Object> capabilities = null;
@JsonProperty("type") @JsonProperty("type")
private String type = null; private String type = null;
...@@ -52,11 +51,11 @@ public class NodeTemplate { ...@@ -52,11 +51,11 @@ public class NodeTemplate {
@JsonProperty("attributes") @JsonProperty("attributes")
@Valid @Valid
private Map<String, String> attributes = null; private Map<String, Object> attributes = null;
@JsonProperty("artifacts") @JsonProperty("artifacts")
@Valid @Valid
private Map<String, String> artifacts = null; private Map<String, Object> artifacts = null;
public NodeTemplate derivedFrom(String derivedFrom) { public NodeTemplate derivedFrom(String derivedFrom) {
this.derivedFrom = derivedFrom; this.derivedFrom = derivedFrom;
...@@ -78,14 +77,14 @@ public class NodeTemplate { ...@@ -78,14 +77,14 @@ public class NodeTemplate {
this.derivedFrom = derivedFrom; this.derivedFrom = derivedFrom;
} }
public NodeTemplate properties(Map<String, String> properties) { public NodeTemplate properties(Map<String, Object> properties) {
this.properties = properties; this.properties = properties;
return this; return this;
} }
public NodeTemplate putPropertiesItem(String key, String propertiesItem) { public NodeTemplate putPropertiesItem(String key, Object propertiesItem) {
if (this.properties == null) { if (this.properties == null) {
this.properties = new HashMap<String, String>(); this.properties = new HashMap<String, Object>();
} }
this.properties.put(key, propertiesItem); this.properties.put(key, propertiesItem);
return this; return this;
...@@ -98,22 +97,22 @@ public class NodeTemplate { ...@@ -98,22 +97,22 @@ public class NodeTemplate {
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public Map<String, String> getProperties() { public Map<String, Object> getProperties() {
return properties; return properties;
} }
public void setProperties(Map<String, String> properties) { public void setProperties(Map<String, Object> properties) {
this.properties = properties; this.properties = properties;
} }
public NodeTemplate requirements(List<Map<String, String>> requirements) { public NodeTemplate requirements(List<Map<String, Object>> requirements) {
this.requirements = requirements; this.requirements = requirements;
return this; return this;
} }
public NodeTemplate addRequirementsItem(Map<String, String> requirementsItem) { public NodeTemplate addRequirementsItem(Map<String, Object> requirementsItem) {
if (this.requirements == null) { if (this.requirements == null) {
this.requirements = new ArrayList<Map<String, String>>(); this.requirements = new ArrayList<Map<String, Object>>();
} }
this.requirements.add(requirementsItem); this.requirements.add(requirementsItem);
return this; return this;
...@@ -127,22 +126,22 @@ public class NodeTemplate { ...@@ -127,22 +126,22 @@ public class NodeTemplate {
@Valid @Valid
public List<Map<String, String>> getRequirements() { public List<Map<String, Object>> getRequirements() {
return requirements; return requirements;
} }
public void setRequirements(List<Map<String, String>> requirements) { public void setRequirements(List<Map<String, Object>> requirements) {
this.requirements = requirements; this.requirements = requirements;
} }
public NodeTemplate interfaces(Map<String, String> interfaces) { public NodeTemplate interfaces(Map<String, Object> interfaces) {
this.interfaces = interfaces; this.interfaces = interfaces;
return this; return this;
} }
public NodeTemplate putInterfacesItem(String key, String interfacesItem) { public NodeTemplate putInterfacesItem(String key, Object interfacesItem) {
if (this.interfaces == null) { if (this.interfaces == null) {
this.interfaces = new HashMap<String, String>(); this.interfaces = new HashMap<String, Object>();
} }
this.interfaces.put(key, interfacesItem); this.interfaces.put(key, interfacesItem);
return this; return this;
...@@ -155,22 +154,22 @@ public class NodeTemplate { ...@@ -155,22 +154,22 @@ public class NodeTemplate {
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public Map<String, String> getInterfaces() { public Map<String, Object> getInterfaces() {
return interfaces; return interfaces;
} }
public void setInterfaces(Map<String, String> interfaces) { public void setInterfaces(Map<String, Object> interfaces) {
this.interfaces = interfaces; this.interfaces = interfaces;
} }
public NodeTemplate capabilities(Map<String, String> capabilities) { public NodeTemplate capabilities(Map<String, Object> capabilities) {
this.capabilities = capabilities; this.capabilities = capabilities;
return this; return this;
} }
public NodeTemplate putCapabilitiesItem(String key, String capabilitiesItem) { public NodeTemplate putCapabilitiesItem(String key, Object capabilitiesItem) {
if (this.capabilities == null) { if (this.capabilities == null) {
this.capabilities = new HashMap<String, String>(); this.capabilities = new HashMap<String, Object>();
} }
this.capabilities.put(key, capabilitiesItem); this.capabilities.put(key, capabilitiesItem);
return this; return this;
...@@ -183,11 +182,11 @@ public class NodeTemplate { ...@@ -183,11 +182,11 @@ public class NodeTemplate {
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public Map<String, String> getCapabilities() { public Map<String, Object> getCapabilities() {
return capabilities; return capabilities;
} }
public void setCapabilities(Map<String, String> capabilities) { public void setCapabilities(Map<String, Object> capabilities) {
this.capabilities = capabilities; this.capabilities = capabilities;
} }
...@@ -259,14 +258,14 @@ public class NodeTemplate { ...@@ -259,14 +258,14 @@ public class NodeTemplate {
this.directives = directives; this.directives = directives;
} }
public NodeTemplate attributes(Map<String, String> attributes) { public NodeTemplate attributes(Map<String, Object> attributes) {
this.attributes = attributes; this.attributes = attributes;
return this; return this;
} }
public NodeTemplate putAttributesItem(String key, String attributesItem) { public NodeTemplate putAttributesItem(String key, Object attributesItem) {
if (this.attributes == null) { if (this.attributes == null) {
this.attributes = new HashMap<String, String>(); this.attributes = new HashMap<String, Object>();
} }
this.attributes.put(key, attributesItem); this.attributes.put(key, attributesItem);
return this; return this;
...@@ -279,22 +278,22 @@ public class NodeTemplate { ...@@ -279,22 +278,22 @@ public class NodeTemplate {
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public Map<String, String> getAttributes() { public Map<String, Object> getAttributes() {
return attributes; return attributes;
} }
public void setAttributes(Map<String, String> attributes) { public void setAttributes(Map<String, Object> attributes) {
this.attributes = attributes; this.attributes = attributes;
} }
public NodeTemplate artifacts(Map<String, String> artifacts) { public NodeTemplate artifacts(Map<String, Object> artifacts) {
this.artifacts = artifacts; this.artifacts = artifacts;
return this; return this;
} }
public NodeTemplate putArtifactsItem(String key, String artifactsItem) { public NodeTemplate putArtifactsItem(String key, Object artifactsItem) {
if (this.artifacts == null) { if (this.artifacts == null) {
this.artifacts = new HashMap<String, String>(); this.artifacts = new HashMap<String, Object>();
} }
this.artifacts.put(key, artifactsItem); this.artifacts.put(key, artifactsItem);
return this; return this;
...@@ -307,11 +306,11 @@ public class NodeTemplate { ...@@ -307,11 +306,11 @@ public class NodeTemplate {
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public Map<String, String> getArtifacts() { public Map<String, Object> getArtifacts() {
return artifacts; return artifacts;
} }
public void setArtifacts(Map<String, String> artifacts) { public void setArtifacts(Map<String, Object> artifacts) {
this.artifacts = artifacts; this.artifacts = artifacts;
} }
......
package nl.uva.sne.drip.model;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import java.util.ArrayList;
import java.util.List;
import org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
import org.springframework.data.annotation.Id;
/**
* Provisioner
*/
@Validated
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Provisioner {
/**
* @return the id
*/
public String getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(String id) {
this.id = id;
}
@Id
@JsonIgnore
private String id;
@JsonProperty("version")
private String version = null;
@JsonProperty("name")
private String name = null;
@JsonProperty("description")
private String description = null;
@JsonProperty("tosca_interface_types")
@Valid
private List<String> tosca_interface_types = null;
public Provisioner version(String version) {
this.version = version;
return this;
}
/**
* Get version
*
* @return version
*
*/
@ApiModelProperty(value = "")
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public Provisioner templateName(String templateName) {
this.name = templateName;
return this;
}
/**
* Get name
*
* @return name
*
*/
@ApiModelProperty(value = "")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
/**
* Get description
*
* @return description
*
*/
@ApiModelProperty(value = "")
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Provisioner toscaInterfaceTypes(List<String> imports) {
this.tosca_interface_types = imports;
return this;
}
public Provisioner addToscaInterfaceTypes(String importsItem) {
if (this.tosca_interface_types == null) {
this.tosca_interface_types = new ArrayList();
}
this.tosca_interface_types.add(importsItem);
return this;
}
/**
* Get tosca_interface_types
*
* @return tosca_interface_types
*
*/
@ApiModelProperty(value = "")
@Valid
public List<String> getToscaInterfaceTypes() {
return tosca_interface_types;
}
public void setToscaInterfaceTypes(List<String> tosca_interface_types) {
this.tosca_interface_types = tosca_interface_types;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Provisioner toscaTemplate = (Provisioner) o;
return Objects.equals(this.version, toscaTemplate.version)
&& Objects.equals(this.name, toscaTemplate.name)
&& Objects.equals(this.description, toscaTemplate.description)
&& Objects.equals(this.tosca_interface_types, toscaTemplate.tosca_interface_types);
}
@Override
public int hashCode() {
return Objects.hash(version, name, description, tosca_interface_types);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class ToscaTemplate {\n");
sb.append(" toscaDefinitionsVersion: ").append(toIndentedString(version)).append("\n");
sb.append(" templateName: ").append(toIndentedString(name)).append("\n");
sb.append(" description: ").append(toIndentedString(description)).append("\n");
sb.append(" imports: ").append(toIndentedString(tosca_interface_types)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}
...@@ -2,6 +2,9 @@ package nl.uva.sne.drip.model; ...@@ -2,6 +2,9 @@ package nl.uva.sne.drip.model;
import java.util.Objects; import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
...@@ -9,14 +12,15 @@ import java.util.List; ...@@ -9,14 +12,15 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import javax.validation.Valid; import javax.validation.Valid;
import javax.validation.constraints.*;
/** /**
* TopologyTemplate * TopologyTemplate
*/ */
@Validated @Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-11-01T14:10:53.529Z") @JsonInclude(JsonInclude.Include.NON_NULL)
public class TopologyTemplate { public class TopologyTemplate {
@JsonProperty("description") @JsonProperty("description")
private String description = null; private String description = null;
...@@ -30,23 +34,23 @@ public class TopologyTemplate { ...@@ -30,23 +34,23 @@ public class TopologyTemplate {
@JsonProperty("relationship_templates") @JsonProperty("relationship_templates")
@Valid @Valid
private Map<String, String> relationshipTemplates = null; private Map<String, Object> relationshipTemplates = null;
@JsonProperty("outputs") @JsonProperty("outputs")
@Valid @Valid
private Map<String, String> outputs = null; private Map<String, Object> outputs = null;
@JsonProperty("groups") @JsonProperty("groups")
@Valid @Valid
private Map<String, String> groups = null; private Map<String, Object> groups = null;
@JsonProperty("substitution_mappings") @JsonProperty("substitution_mappings")
@Valid @Valid
private Map<String, String> substitutionMappings = null; private Map<String, Object> substitutionMappings = null;
@JsonProperty("policies") @JsonProperty("policies")
@Valid @Valid
private List<Map<String, String>> policies = null; private List<Map<String, Object>> policies = null;
public TopologyTemplate description(String description) { public TopologyTemplate description(String description) {
this.description = description; this.description = description;
...@@ -125,14 +129,14 @@ public class TopologyTemplate { ...@@ -125,14 +129,14 @@ public class TopologyTemplate {
this.nodeTemplates = nodeTemplates; this.nodeTemplates = nodeTemplates;
} }
public TopologyTemplate relationshipTemplates(Map<String, String> relationshipTemplates) { public TopologyTemplate relationshipTemplates(Map<String, Object> relationshipTemplates) {
this.relationshipTemplates = relationshipTemplates; this.relationshipTemplates = relationshipTemplates;
return this; return this;
} }
public TopologyTemplate putRelationshipTemplatesItem(String key, String relationshipTemplatesItem) { public TopologyTemplate putRelationshipTemplatesItem(String key, Object relationshipTemplatesItem) {
if (this.relationshipTemplates == null) { if (this.relationshipTemplates == null) {
this.relationshipTemplates = new HashMap<String, String>(); this.relationshipTemplates = new HashMap<String, Object>();
} }
this.relationshipTemplates.put(key, relationshipTemplatesItem); this.relationshipTemplates.put(key, relationshipTemplatesItem);
return this; return this;
...@@ -145,22 +149,22 @@ public class TopologyTemplate { ...@@ -145,22 +149,22 @@ public class TopologyTemplate {
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public Map<String, String> getRelationshipTemplates() { public Map<String, Object> getRelationshipTemplates() {
return relationshipTemplates; return relationshipTemplates;
} }
public void setRelationshipTemplates(Map<String, String> relationshipTemplates) { public void setRelationshipTemplates(Map<String, Object> relationshipTemplates) {
this.relationshipTemplates = relationshipTemplates; this.relationshipTemplates = relationshipTemplates;
} }
public TopologyTemplate outputs(Map<String, String> outputs) { public TopologyTemplate outputs(Map<String, Object> outputs) {
this.outputs = outputs; this.outputs = outputs;
return this; return this;
} }
public TopologyTemplate putOutputsItem(String key, String outputsItem) { public TopologyTemplate putOutputsItem(String key, Object outputsItem) {
if (this.outputs == null) { if (this.outputs == null) {
this.outputs = new HashMap<String, String>(); this.outputs = new HashMap<String, Object>();
} }
this.outputs.put(key, outputsItem); this.outputs.put(key, outputsItem);
return this; return this;
...@@ -173,22 +177,22 @@ public class TopologyTemplate { ...@@ -173,22 +177,22 @@ public class TopologyTemplate {
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public Map<String, String> getOutputs() { public Map<String, Object> getOutputs() {
return outputs; return outputs;
} }
public void setOutputs(Map<String, String> outputs) { public void setOutputs(Map<String, Object> outputs) {
this.outputs = outputs; this.outputs = outputs;
} }
public TopologyTemplate groups(Map<String, String> groups) { public TopologyTemplate groups(Map<String, Object> groups) {
this.groups = groups; this.groups = groups;
return this; return this;
} }
public TopologyTemplate putGroupsItem(String key, String groupsItem) { public TopologyTemplate putGroupsItem(String key, Object groupsItem) {
if (this.groups == null) { if (this.groups == null) {
this.groups = new HashMap<String, String>(); this.groups = new HashMap<String, Object>();
} }
this.groups.put(key, groupsItem); this.groups.put(key, groupsItem);
return this; return this;
...@@ -201,22 +205,22 @@ public class TopologyTemplate { ...@@ -201,22 +205,22 @@ public class TopologyTemplate {
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public Map<String, String> getGroups() { public Map<String, Object> getGroups() {
return groups; return groups;
} }
public void setGroups(Map<String, String> groups) { public void setGroups(Map<String, Object> groups) {
this.groups = groups; this.groups = groups;
} }
public TopologyTemplate substitutionMappings(Map<String, String> substitutionMappings) { public TopologyTemplate substitutionMappings(Map<String, Object> substitutionMappings) {
this.substitutionMappings = substitutionMappings; this.substitutionMappings = substitutionMappings;
return this; return this;
} }
public TopologyTemplate putSubstitutionMappingsItem(String key, String substitutionMappingsItem) { public TopologyTemplate putSubstitutionMappingsItem(String key, Object substitutionMappingsItem) {
if (this.substitutionMappings == null) { if (this.substitutionMappings == null) {
this.substitutionMappings = new HashMap<String, String>(); this.substitutionMappings = new HashMap<String, Object>();
} }
this.substitutionMappings.put(key, substitutionMappingsItem); this.substitutionMappings.put(key, substitutionMappingsItem);
return this; return this;
...@@ -229,22 +233,22 @@ public class TopologyTemplate { ...@@ -229,22 +233,22 @@ public class TopologyTemplate {
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public Map<String, String> getSubstitutionMappings() { public Map<String, Object> getSubstitutionMappings() {
return substitutionMappings; return substitutionMappings;
} }
public void setSubstitutionMappings(Map<String, String> substitutionMappings) { public void setSubstitutionMappings(Map<String, Object> substitutionMappings) {
this.substitutionMappings = substitutionMappings; this.substitutionMappings = substitutionMappings;
} }
public TopologyTemplate policies(List<Map<String, String>> policies) { public TopologyTemplate policies(List<Map<String, Object>> policies) {
this.policies = policies; this.policies = policies;
return this; return this;
} }
public TopologyTemplate addPoliciesItem(Map<String, String> policiesItem) { public TopologyTemplate addPoliciesItem(Map<String, Object> policiesItem) {
if (this.policies == null) { if (this.policies == null) {
this.policies = new ArrayList<Map<String, String>>(); this.policies = new ArrayList<Map<String, Object>>();
} }
this.policies.add(policiesItem); this.policies.add(policiesItem);
return this; return this;
...@@ -258,11 +262,11 @@ public class TopologyTemplate { ...@@ -258,11 +262,11 @@ public class TopologyTemplate {
@Valid @Valid
public List<Map<String, String>> getPolicies() { public List<Map<String, Object>> getPolicies() {
return policies; return policies;
} }
public void setPolicies(List<Map<String, String>> policies) { public void setPolicies(List<Map<String, Object>> policies) {
this.policies = policies; this.policies = policies;
} }
......
...@@ -2,9 +2,8 @@ package nl.uva.sne.drip.model; ...@@ -2,9 +2,8 @@ package nl.uva.sne.drip.model;
import java.util.Objects; import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel; import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
...@@ -12,15 +11,13 @@ import java.util.List; ...@@ -12,15 +11,13 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import javax.validation.Valid; import javax.validation.Valid;
import javax.validation.constraints.*;
import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Id;
/** /**
* ToscaTemplate * ToscaTemplate
*/ */
@Validated @Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-11-01T14:10:53.529Z") @JsonInclude(JsonInclude.Include.NON_NULL)
public class ToscaTemplate { public class ToscaTemplate {
/** /**
* @return the id * @return the id
...@@ -63,51 +60,51 @@ public class ToscaTemplate { ...@@ -63,51 +60,51 @@ public class ToscaTemplate {
@JsonProperty("imports") @JsonProperty("imports")
@Valid @Valid
private List<Map<String, String>> imports = null; private List<Map<String, Object>> imports = null;
@JsonProperty("dsl_definitions") @JsonProperty("dsl_definitions")
@Valid @Valid
private Map<String, String> dslDefinitions = null; private Map<String, Object> dslDefinitions = null;
@JsonProperty("node_types") @JsonProperty("node_types")
@Valid @Valid
private Map<String, String> nodeTypes = null; private Map<String, Object> nodeTypes = null;
@JsonProperty("relationship_types") @JsonProperty("relationship_types")
@Valid @Valid
private Map<String, String> relationshipTypes = null; private Map<String, Object> relationshipTypes = null;
@JsonProperty("relationship_templates") @JsonProperty("relationship_templates")
@Valid @Valid
private Map<String, String> relationshipTemplates = null; private Map<String, Object> relationshipTemplates = null;
@JsonProperty("capability_types") @JsonProperty("capability_types")
@Valid @Valid
private Map<String, String> capabilityTypes = null; private Map<String, Object> capabilityTypes = null;
@JsonProperty("artifact_types") @JsonProperty("artifact_types")
@Valid @Valid
private Map<String, String> artifactTypes = null; private Map<String, Object> artifactTypes = null;
@JsonProperty("data_types") @JsonProperty("data_types")
@Valid @Valid
private Map<String, String> dataTypes = null; private Map<String, Object> dataTypes = null;
@JsonProperty("interface_types") @JsonProperty("interface_types")
@Valid @Valid
private Map<String, String> interfaceTypes = null; private Map<String, Object> interfaceTypes = null;
@JsonProperty("policy_types") @JsonProperty("policy_types")
@Valid @Valid
private Map<String, String> policyTypes = null; private Map<String, Object> policyTypes = null;
@JsonProperty("group_types") @JsonProperty("group_types")
@Valid @Valid
private Map<String, String> groupTypes = null; private Map<String, Object> groupTypes = null;
@JsonProperty("repositories") @JsonProperty("repositories")
@Valid @Valid
private Map<String, String> repositories = null; private Map<String, Object> repositories = null;
public ToscaTemplate toscaDefinitionsVersion(String toscaDefinitionsVersion) { public ToscaTemplate toscaDefinitionsVersion(String toscaDefinitionsVersion) {
this.toscaDefinitionsVersion = toscaDefinitionsVersion; this.toscaDefinitionsVersion = toscaDefinitionsVersion;
...@@ -250,14 +247,14 @@ public class ToscaTemplate { ...@@ -250,14 +247,14 @@ public class ToscaTemplate {
this.description = description; this.description = description;
} }
public ToscaTemplate imports(List<Map<String, String>> imports) { public ToscaTemplate imports(List<Map<String, Object>> imports) {
this.imports = imports; this.imports = imports;
return this; return this;
} }
public ToscaTemplate addImportsItem(Map<String, String> importsItem) { public ToscaTemplate addImportsItem(Map<String, Object> importsItem) {
if (this.imports == null) { if (this.imports == null) {
this.imports = new ArrayList<Map<String, String>>(); this.imports = new ArrayList<Map<String, Object>>();
} }
this.imports.add(importsItem); this.imports.add(importsItem);
return this; return this;
...@@ -271,22 +268,22 @@ public class ToscaTemplate { ...@@ -271,22 +268,22 @@ public class ToscaTemplate {
@Valid @Valid
public List<Map<String, String>> getImports() { public List<Map<String, Object>> getImports() {
return imports; return imports;
} }
public void setImports(List<Map<String, String>> imports) { public void setImports(List<Map<String, Object>> imports) {
this.imports = imports; this.imports = imports;
} }
public ToscaTemplate dslDefinitions(Map<String, String> dslDefinitions) { public ToscaTemplate dslDefinitions(Map<String, Object> dslDefinitions) {
this.dslDefinitions = dslDefinitions; this.dslDefinitions = dslDefinitions;
return this; return this;
} }
public ToscaTemplate putDslDefinitionsItem(String key, String dslDefinitionsItem) { public ToscaTemplate putDslDefinitionsItem(String key, Object dslDefinitionsItem) {
if (this.dslDefinitions == null) { if (this.dslDefinitions == null) {
this.dslDefinitions = new HashMap<String, String>(); this.dslDefinitions = new HashMap<String, Object>();
} }
this.dslDefinitions.put(key, dslDefinitionsItem); this.dslDefinitions.put(key, dslDefinitionsItem);
return this; return this;
...@@ -299,22 +296,22 @@ public class ToscaTemplate { ...@@ -299,22 +296,22 @@ public class ToscaTemplate {
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public Map<String, String> getDslDefinitions() { public Map<String, Object> getDslDefinitions() {
return dslDefinitions; return dslDefinitions;
} }
public void setDslDefinitions(Map<String, String> dslDefinitions) { public void setDslDefinitions(Map<String, Object> dslDefinitions) {
this.dslDefinitions = dslDefinitions; this.dslDefinitions = dslDefinitions;
} }
public ToscaTemplate nodeTypes(Map<String, String> nodeTypes) { public ToscaTemplate nodeTypes(Map<String, Object> nodeTypes) {
this.nodeTypes = nodeTypes; this.nodeTypes = nodeTypes;
return this; return this;
} }
public ToscaTemplate putNodeTypesItem(String key, String nodeTypesItem) { public ToscaTemplate putNodeTypesItem(String key, Object nodeTypesItem) {
if (this.nodeTypes == null) { if (this.nodeTypes == null) {
this.nodeTypes = new HashMap<String, String>(); this.nodeTypes = new HashMap<String, Object>();
} }
this.nodeTypes.put(key, nodeTypesItem); this.nodeTypes.put(key, nodeTypesItem);
return this; return this;
...@@ -327,22 +324,22 @@ public class ToscaTemplate { ...@@ -327,22 +324,22 @@ public class ToscaTemplate {
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public Map<String, String> getNodeTypes() { public Map<String, Object> getNodeTypes() {
return nodeTypes; return nodeTypes;
} }
public void setNodeTypes(Map<String, String> nodeTypes) { public void setNodeTypes(Map<String, Object> nodeTypes) {
this.nodeTypes = nodeTypes; this.nodeTypes = nodeTypes;
} }
public ToscaTemplate relationshipTypes(Map<String, String> relationshipTypes) { public ToscaTemplate relationshipTypes(Map<String, Object> relationshipTypes) {
this.relationshipTypes = relationshipTypes; this.relationshipTypes = relationshipTypes;
return this; return this;
} }
public ToscaTemplate putRelationshipTypesItem(String key, String relationshipTypesItem) { public ToscaTemplate putRelationshipTypesItem(String key, Object relationshipTypesItem) {
if (this.relationshipTypes == null) { if (this.relationshipTypes == null) {
this.relationshipTypes = new HashMap<String, String>(); this.relationshipTypes = new HashMap<String, Object>();
} }
this.relationshipTypes.put(key, relationshipTypesItem); this.relationshipTypes.put(key, relationshipTypesItem);
return this; return this;
...@@ -355,22 +352,22 @@ public class ToscaTemplate { ...@@ -355,22 +352,22 @@ public class ToscaTemplate {
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public Map<String, String> getRelationshipTypes() { public Map<String, Object> getRelationshipTypes() {
return relationshipTypes; return relationshipTypes;
} }
public void setRelationshipTypes(Map<String, String> relationshipTypes) { public void setRelationshipTypes(Map<String, Object> relationshipTypes) {
this.relationshipTypes = relationshipTypes; this.relationshipTypes = relationshipTypes;
} }
public ToscaTemplate relationshipTemplates(Map<String, String> relationshipTemplates) { public ToscaTemplate relationshipTemplates(Map<String, Object> relationshipTemplates) {
this.relationshipTemplates = relationshipTemplates; this.relationshipTemplates = relationshipTemplates;
return this; return this;
} }
public ToscaTemplate putRelationshipTemplatesItem(String key, String relationshipTemplatesItem) { public ToscaTemplate putRelationshipTemplatesItem(String key, Object relationshipTemplatesItem) {
if (this.relationshipTemplates == null) { if (this.relationshipTemplates == null) {
this.relationshipTemplates = new HashMap<String, String>(); this.relationshipTemplates = new HashMap<String, Object>();
} }
this.relationshipTemplates.put(key, relationshipTemplatesItem); this.relationshipTemplates.put(key, relationshipTemplatesItem);
return this; return this;
...@@ -383,22 +380,22 @@ public class ToscaTemplate { ...@@ -383,22 +380,22 @@ public class ToscaTemplate {
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public Map<String, String> getRelationshipTemplates() { public Map<String, Object> getRelationshipTemplates() {
return relationshipTemplates; return relationshipTemplates;
} }
public void setRelationshipTemplates(Map<String, String> relationshipTemplates) { public void setRelationshipTemplates(Map<String, Object> relationshipTemplates) {
this.relationshipTemplates = relationshipTemplates; this.relationshipTemplates = relationshipTemplates;
} }
public ToscaTemplate capabilityTypes(Map<String, String> capabilityTypes) { public ToscaTemplate capabilityTypes(Map<String, Object> capabilityTypes) {
this.capabilityTypes = capabilityTypes; this.capabilityTypes = capabilityTypes;
return this; return this;
} }
public ToscaTemplate putCapabilityTypesItem(String key, String capabilityTypesItem) { public ToscaTemplate putCapabilityTypesItem(String key, Object capabilityTypesItem) {
if (this.capabilityTypes == null) { if (this.capabilityTypes == null) {
this.capabilityTypes = new HashMap<String, String>(); this.capabilityTypes = new HashMap<String, Object>();
} }
this.capabilityTypes.put(key, capabilityTypesItem); this.capabilityTypes.put(key, capabilityTypesItem);
return this; return this;
...@@ -411,22 +408,22 @@ public class ToscaTemplate { ...@@ -411,22 +408,22 @@ public class ToscaTemplate {
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public Map<String, String> getCapabilityTypes() { public Map<String, Object> getCapabilityTypes() {
return capabilityTypes; return capabilityTypes;
} }
public void setCapabilityTypes(Map<String, String> capabilityTypes) { public void setCapabilityTypes(Map<String, Object> capabilityTypes) {
this.capabilityTypes = capabilityTypes; this.capabilityTypes = capabilityTypes;
} }
public ToscaTemplate artifactTypes(Map<String, String> artifactTypes) { public ToscaTemplate artifactTypes(Map<String, Object> artifactTypes) {
this.artifactTypes = artifactTypes; this.artifactTypes = artifactTypes;
return this; return this;
} }
public ToscaTemplate putArtifactTypesItem(String key, String artifactTypesItem) { public ToscaTemplate putArtifactTypesItem(String key, Object artifactTypesItem) {
if (this.artifactTypes == null) { if (this.artifactTypes == null) {
this.artifactTypes = new HashMap<String, String>(); this.artifactTypes = new HashMap<String, Object>();
} }
this.artifactTypes.put(key, artifactTypesItem); this.artifactTypes.put(key, artifactTypesItem);
return this; return this;
...@@ -439,22 +436,22 @@ public class ToscaTemplate { ...@@ -439,22 +436,22 @@ public class ToscaTemplate {
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public Map<String, String> getArtifactTypes() { public Map<String, Object> getArtifactTypes() {
return artifactTypes; return artifactTypes;
} }
public void setArtifactTypes(Map<String, String> artifactTypes) { public void setArtifactTypes(Map<String, Object> artifactTypes) {
this.artifactTypes = artifactTypes; this.artifactTypes = artifactTypes;
} }
public ToscaTemplate dataTypes(Map<String, String> dataTypes) { public ToscaTemplate dataTypes(Map<String, Object> dataTypes) {
this.dataTypes = dataTypes; this.dataTypes = dataTypes;
return this; return this;
} }
public ToscaTemplate putDataTypesItem(String key, String dataTypesItem) { public ToscaTemplate putDataTypesItem(String key, Object dataTypesItem) {
if (this.dataTypes == null) { if (this.dataTypes == null) {
this.dataTypes = new HashMap<String, String>(); this.dataTypes = new HashMap<String, Object>();
} }
this.dataTypes.put(key, dataTypesItem); this.dataTypes.put(key, dataTypesItem);
return this; return this;
...@@ -467,22 +464,22 @@ public class ToscaTemplate { ...@@ -467,22 +464,22 @@ public class ToscaTemplate {
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public Map<String, String> getDataTypes() { public Map<String, Object> getDataTypes() {
return dataTypes; return dataTypes;
} }
public void setDataTypes(Map<String, String> dataTypes) { public void setDataTypes(Map<String, Object> dataTypes) {
this.dataTypes = dataTypes; this.dataTypes = dataTypes;
} }
public ToscaTemplate interfaceTypes(Map<String, String> interfaceTypes) { public ToscaTemplate interfaceTypes(Map<String, Object> interfaceTypes) {
this.interfaceTypes = interfaceTypes; this.interfaceTypes = interfaceTypes;
return this; return this;
} }
public ToscaTemplate putInterfaceTypesItem(String key, String interfaceTypesItem) { public ToscaTemplate putInterfaceTypesItem(String key, Object interfaceTypesItem) {
if (this.interfaceTypes == null) { if (this.interfaceTypes == null) {
this.interfaceTypes = new HashMap<String, String>(); this.interfaceTypes = new HashMap<String, Object>();
} }
this.interfaceTypes.put(key, interfaceTypesItem); this.interfaceTypes.put(key, interfaceTypesItem);
return this; return this;
...@@ -495,22 +492,22 @@ public class ToscaTemplate { ...@@ -495,22 +492,22 @@ public class ToscaTemplate {
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public Map<String, String> getInterfaceTypes() { public Map<String, Object> getInterfaceTypes() {
return interfaceTypes; return interfaceTypes;
} }
public void setInterfaceTypes(Map<String, String> interfaceTypes) { public void setInterfaceTypes(Map<String, Object> interfaceTypes) {
this.interfaceTypes = interfaceTypes; this.interfaceTypes = interfaceTypes;
} }
public ToscaTemplate policyTypes(Map<String, String> policyTypes) { public ToscaTemplate policyTypes(Map<String, Object> policyTypes) {
this.policyTypes = policyTypes; this.policyTypes = policyTypes;
return this; return this;
} }
public ToscaTemplate putPolicyTypesItem(String key, String policyTypesItem) { public ToscaTemplate putPolicyTypesItem(String key, Object policyTypesItem) {
if (this.policyTypes == null) { if (this.policyTypes == null) {
this.policyTypes = new HashMap<String, String>(); this.policyTypes = new HashMap<String, Object>();
} }
this.policyTypes.put(key, policyTypesItem); this.policyTypes.put(key, policyTypesItem);
return this; return this;
...@@ -523,22 +520,22 @@ public class ToscaTemplate { ...@@ -523,22 +520,22 @@ public class ToscaTemplate {
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public Map<String, String> getPolicyTypes() { public Map<String, Object> getPolicyTypes() {
return policyTypes; return policyTypes;
} }
public void setPolicyTypes(Map<String, String> policyTypes) { public void setPolicyTypes(Map<String, Object> policyTypes) {
this.policyTypes = policyTypes; this.policyTypes = policyTypes;
} }
public ToscaTemplate groupTypes(Map<String, String> groupTypes) { public ToscaTemplate groupTypes(Map<String, Object> groupTypes) {
this.groupTypes = groupTypes; this.groupTypes = groupTypes;
return this; return this;
} }
public ToscaTemplate putGroupTypesItem(String key, String groupTypesItem) { public ToscaTemplate putGroupTypesItem(String key, Object groupTypesItem) {
if (this.groupTypes == null) { if (this.groupTypes == null) {
this.groupTypes = new HashMap<String, String>(); this.groupTypes = new HashMap<String, Object>();
} }
this.groupTypes.put(key, groupTypesItem); this.groupTypes.put(key, groupTypesItem);
return this; return this;
...@@ -551,22 +548,22 @@ public class ToscaTemplate { ...@@ -551,22 +548,22 @@ public class ToscaTemplate {
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public Map<String, String> getGroupTypes() { public Map<String, Object> getGroupTypes() {
return groupTypes; return groupTypes;
} }
public void setGroupTypes(Map<String, String> groupTypes) { public void setGroupTypes(Map<String, Object> groupTypes) {
this.groupTypes = groupTypes; this.groupTypes = groupTypes;
} }
public ToscaTemplate repositories(Map<String, String> repositories) { public ToscaTemplate repositories(Map<String, Object> repositories) {
this.repositories = repositories; this.repositories = repositories;
return this; return this;
} }
public ToscaTemplate putRepositoriesItem(String key, String repositoriesItem) { public ToscaTemplate putRepositoriesItem(String key, Object repositoriesItem) {
if (this.repositories == null) { if (this.repositories == null) {
this.repositories = new HashMap<String, String>(); this.repositories = new HashMap<String, Object>();
} }
this.repositories.put(key, repositoriesItem); this.repositories.put(key, repositoriesItem);
return this; return this;
...@@ -579,11 +576,11 @@ public class ToscaTemplate { ...@@ -579,11 +576,11 @@ public class ToscaTemplate {
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public Map<String, String> getRepositories() { public Map<String, Object> getRepositories() {
return repositories; return repositories;
} }
public void setRepositories(Map<String, String> repositories) { public void setRepositories(Map<String, Object> repositories) {
this.repositories = repositories; this.repositories = repositories;
} }
......
package nl.uva.sne.drip.model; package nl.uva.sne.drip.model;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.Objects; import java.util.Objects;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import javax.validation.Valid; import javax.validation.Valid;
...@@ -11,8 +12,7 @@ import org.springframework.data.annotation.Id; ...@@ -11,8 +12,7 @@ import org.springframework.data.annotation.Id;
* User * User
*/ */
@Validated @Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-11-01T14:10:53.529Z") @JsonInclude(JsonInclude.Include.NON_NULL)
public class User { public class User {
/** /**
* @return the id * @return the id
......
...@@ -20,8 +20,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2; ...@@ -20,8 +20,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
}) })
@EnableMongoRepositories(basePackageClasses = {ToscaTemplateDAO.class}) @EnableMongoRepositories(basePackageClasses = {ToscaTemplateDAO.class})
@ComponentScan(basePackages = {"nl.uva.sne.drip", "nl.uva.sne.drip.api", @ComponentScan(basePackages = {"nl.uva.sne.drip", "nl.uva.sne.drip.api",
"nl.uva.sne.drip.configuration", "nl.uva.sne.drip.dao", "nl.uva.sne.drip.model", "nl.uva.sne.drip.configuration", "nl.uva.sne.drip.dao", "nl.uva.sne.drip.service"})
"nl.uva.sne.drip.service"})
public class Swagger2SpringBoot implements CommandLineRunner { public class Swagger2SpringBoot implements CommandLineRunner {
@Value("${message.broker.host}") @Value("${message.broker.host}")
......
package nl.uva.sne.drip.api; package nl.uva.sne.drip.api;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -12,6 +13,7 @@ import javax.servlet.http.HttpServletRequest; ...@@ -12,6 +13,7 @@ import javax.servlet.http.HttpServletRequest;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import nl.uva.sne.drip.commons.sure_tosca.client.ApiException;
import nl.uva.sne.drip.service.DRIPService; import nl.uva.sne.drip.service.DRIPService;
import nl.uva.sne.drip.service.ProvisionerService; import nl.uva.sne.drip.service.ProvisionerService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -46,7 +48,7 @@ public class ProvisionerApiController implements ProvisionerApi { ...@@ -46,7 +48,7 @@ public class ProvisionerApiController implements ProvisionerApi {
try { try {
String planedYemplateId = provisionerService.provision(id); String planedYemplateId = provisionerService.provision(id);
return new ResponseEntity<>(planedYemplateId, HttpStatus.OK); return new ResponseEntity<>(planedYemplateId, HttpStatus.OK);
} catch (IOException ex) { } catch (IOException | ApiException ex) {
java.util.logging.Logger.getLogger(ProvisionerApiController.class.getName()).log(Level.SEVERE, null, ex); java.util.logging.Logger.getLogger(ProvisionerApiController.class.getName()).log(Level.SEVERE, null, ex);
} }
} }
......
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package nl.uva.sne.drip.dao;
import nl.uva.sne.drip.model.Provisioner;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;
/**
*
* @author S. Koulouzis
*/
@Repository
public interface ProvisionerDAO extends MongoRepository<Provisioner, String> {
}
...@@ -7,6 +7,7 @@ package nl.uva.sne.drip.service; ...@@ -7,6 +7,7 @@ package nl.uva.sne.drip.service;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -15,8 +16,10 @@ import java.util.logging.Level; ...@@ -15,8 +16,10 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import nl.uva.sne.drip.commons.sure_tosca.client.ApiException; import nl.uva.sne.drip.commons.sure_tosca.client.ApiException;
import nl.uva.sne.drip.commons.utils.ToscaHelper; import nl.uva.sne.drip.commons.utils.ToscaHelper;
import nl.uva.sne.drip.dao.ProvisionerDAO;
import nl.uva.sne.drip.model.Message; import nl.uva.sne.drip.model.Message;
import nl.uva.sne.drip.model.NodeTemplate; import nl.uva.sne.drip.model.NodeTemplate;
import nl.uva.sne.drip.model.Provisioner;
import nl.uva.sne.drip.model.ToscaTemplate; import nl.uva.sne.drip.model.ToscaTemplate;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
...@@ -36,9 +39,15 @@ public class ProvisionerService { ...@@ -36,9 +39,15 @@ public class ProvisionerService {
@Value("${tosca.types.interface}") @Value("${tosca.types.interface}")
private String toscaTypesInterface; private String toscaTypesInterface;
@Value("${sure-tosca.base.path}")
private String sureToscaBasePath;
@Autowired @Autowired
private ToscaTemplateService toscaTemplateService; private ToscaTemplateService toscaTemplateService;
@Autowired
private ProvisionerDAO provisionerDao;
ToscaHelper toscaHelper; ToscaHelper toscaHelper;
private Integer toscaHelperID; private Integer toscaHelperID;
...@@ -46,7 +55,7 @@ public class ProvisionerService { ...@@ -46,7 +55,7 @@ public class ProvisionerService {
String ymlToscaTemplate = toscaTemplateService.findByID(id); String ymlToscaTemplate = toscaTemplateService.findByID(id);
ToscaTemplate toscaTemplate = toscaTemplateService.getYaml2ToscaTemplate(ymlToscaTemplate); ToscaTemplate toscaTemplate = toscaTemplateService.getYaml2ToscaTemplate(ymlToscaTemplate);
toscaHelper = new ToscaHelper(toscaTemplate); toscaHelper = new ToscaHelper(toscaTemplate, sureToscaBasePath);
toscaTemplate = addProvisionInterface(toscaTemplate); toscaTemplate = addProvisionInterface(toscaTemplate);
...@@ -56,8 +65,12 @@ public class ProvisionerService { ...@@ -56,8 +65,12 @@ public class ProvisionerService {
// private List<Map<String, NodeTemplate>> getVmTopologies(ToscaTemplate toscaTemplate) { // private List<Map<String, NodeTemplate>> getVmTopologies(ToscaTemplate toscaTemplate) {
// return ToscaHelper.getNodesByType(toscaTemplate, "tosca.nodes.ARTICONF.VM.topology"); // return ToscaHelper.getNodesByType(toscaTemplate, "tosca.nodes.ARTICONF.VM.topology");
// } // }
protected ToscaTemplate addProvisionInterface(ToscaTemplate toscaTemplate) throws ApiException {
Provisioner provisioner = selectBestProvisioner();
List<Map<String, Object>> definitions = toscaHelper.getProvisionInterfaceDefinitions(provisioner.getToscaInterfaceTypes());
Map<String, Object> def = selectBestInterfaceDefinitions(definitions);
Map<String, Object> provisionInterface = createProvisionInterface(def);
protected ToscaTemplate addProvisionInterface(ToscaTemplate toscaTemplate) {
// List<Map<String, NodeTemplate>> vmTopologies = getVmTopologies(toscaTemplate); // List<Map<String, NodeTemplate>> vmTopologies = getVmTopologies(toscaTemplate);
// for (Map<String, NodeTemplate> vmTopologyMap : vmTopologies) { // for (Map<String, NodeTemplate> vmTopologyMap : vmTopologies) {
// String topologyName = vmTopologyMap.keySet().iterator().next(); // String topologyName = vmTopologyMap.keySet().iterator().next();
...@@ -66,9 +79,31 @@ public class ProvisionerService { ...@@ -66,9 +79,31 @@ public class ProvisionerService {
// Map<String, Object> cloudStormInterface = getCloudStormProvisionInterface(topologyName); // Map<String, Object> cloudStormInterface = getCloudStormProvisionInterface(topologyName);
// interfaces.put("cloudStorm", cloudStormInterface); // interfaces.put("cloudStorm", cloudStormInterface);
// } // }
return toscaTemplate; return toscaTemplate;
} }
private Provisioner selectBestProvisioner() {
if (provisionerDao.count() <= 0) {
Provisioner provisioner = new Provisioner();
provisioner.setDescription("CloudsStorm is a framework for managing an application-defined infrastructure among public IaaS (Infrastructure-as-a-Service) Clouds. It enables the application to customize its underlying infrastructure at software development phase and dynamically control it at operation phase.");
provisioner.setName("CloudsStorm");
provisioner.setVersion("1.0.0");
List<String> toscaInterfaceTypes = new ArrayList<>();
toscaInterfaceTypes.add("tosca.interfaces.ARTICONF.CloudsStorm");
provisioner.setToscaInterfaceTypes(toscaInterfaceTypes);
provisionerDao.save(provisioner);
}
List<Provisioner> all = provisionerDao.findAll();
return all.get(0);
}
private Map<String, Object> selectBestInterfaceDefinitions(List<Map<String, Object>> definitions) {
return definitions.get(0);
}
private Map<String, Object> createProvisionInterface(Map<String, Object> def) {
Map<String, Object> inputs = (Map<String, Object>) def.get("inputs");
return null;
}
} }
...@@ -16,6 +16,8 @@ db.name=drip ...@@ -16,6 +16,8 @@ db.name=drip
db.username=drip-user db.username=drip-user
db.password=drip-pass db.password=drip-pass
sure-tosca.base.path=http://localhost:8081/tosca-sure/1.0.0
spring.jackson.deserialization.UNWRAP_ROOT_VALUE=true spring.jackson.deserialization.UNWRAP_ROOT_VALUE=true
......
...@@ -68,7 +68,7 @@ public class ServiceTests { ...@@ -68,7 +68,7 @@ public class ServiceTests {
@Autowired @Autowired
CredentialService credentialService; CredentialService credentialService;
private String credentialID; private String credentialID;
@Autowired @Autowired
ProvisionerService provisionService; ProvisionerService provisionService;
...@@ -103,8 +103,11 @@ public class ServiceTests { ...@@ -103,8 +103,11 @@ public class ServiceTests {
@Before @Before
public void setUp() { public void setUp() {
DefaultMockMvcBuilder builder = MockMvcBuilders.webAppContextSetup(this.wac); if (mockMvc == null) {
mockMvc = builder.build(); DefaultMockMvcBuilder builder = MockMvcBuilders.webAppContextSetup(this.wac);
mockMvc = builder.build();
}
} }
@After @After
...@@ -112,6 +115,11 @@ public class ServiceTests { ...@@ -112,6 +115,11 @@ public class ServiceTests {
} }
@Test
public void testPass() {
Assert.assertTrue(true);
}
/** /**
* Test of saveFile method, of class ToscaTemplateService. * Test of saveFile method, of class ToscaTemplateService.
* *
...@@ -259,6 +267,11 @@ public class ServiceTests { ...@@ -259,6 +267,11 @@ public class ServiceTests {
@Test @Test
public void testCredentialServiceSave() { public void testCredentialServiceSave() {
Logger.getLogger(ServiceTests.class.getName()).log(Level.INFO, "save"); Logger.getLogger(ServiceTests.class.getName()).log(Level.INFO, "save");
saveCredential();
}
public String saveCredential() {
Logger.getLogger(ServiceTests.class.getName()).log(Level.INFO, "saveCredential");
Credentials document = new Credentials(); Credentials document = new Credentials();
document.setCloudProviderName("exogeni"); document.setCloudProviderName("exogeni");
Map<String, String> keys = new HashMap<>(); Map<String, String> keys = new HashMap<>();
...@@ -267,8 +280,7 @@ public class ServiceTests { ...@@ -267,8 +280,7 @@ public class ServiceTests {
document.setToken("secret"); document.setToken("secret");
document.setTokenType("password"); document.setTokenType("password");
credentialID = credentialService.save(document); return credentialService.save(document);
assertNotNull(credentialID);
} }
/** /**
...@@ -279,10 +291,7 @@ public class ServiceTests { ...@@ -279,10 +291,7 @@ public class ServiceTests {
@Test @Test
public void testCredentialServiceFindByID() throws Exception { public void testCredentialServiceFindByID() throws Exception {
Logger.getLogger(ServiceTests.class.getName()).log(Level.INFO, "findByID"); Logger.getLogger(ServiceTests.class.getName()).log(Level.INFO, "findByID");
if (credentialID == null) { String id = saveCredential();
testCredentialServiceSave();
}
String id = credentialID;
Credentials result = credentialService.findByID(id); Credentials result = credentialService.findByID(id);
assertNotNull(result); assertNotNull(result);
} }
...@@ -293,12 +302,10 @@ public class ServiceTests { ...@@ -293,12 +302,10 @@ public class ServiceTests {
@Test @Test
public void testCredentialServiceDeleteByID() throws JsonProcessingException { public void testCredentialServiceDeleteByID() throws JsonProcessingException {
Logger.getLogger(ServiceTests.class.getName()).log(Level.INFO, "deleteByID"); Logger.getLogger(ServiceTests.class.getName()).log(Level.INFO, "deleteByID");
if (credentialID == null) { String id = saveCredential();
testCredentialServiceSave(); credentialService.deleteByID(id);
}
credentialService.deleteByID(credentialID);
try { try {
Credentials res = credentialService.findByID(credentialID); Credentials res = credentialService.findByID(id);
} catch (Exception ex) { } catch (Exception ex) {
if (!(ex instanceof NoSuchElementException)) { if (!(ex instanceof NoSuchElementException)) {
fail(ex.getMessage()); fail(ex.getMessage());
...@@ -315,7 +322,7 @@ public class ServiceTests { ...@@ -315,7 +322,7 @@ public class ServiceTests {
testCredentialServiceDeleteAll(); testCredentialServiceDeleteAll();
int numOfINst = 3; int numOfINst = 3;
for (int i = 1; i <= numOfINst; i++) { for (int i = 1; i <= numOfINst; i++) {
testCredentialServiceSave(); saveCredential();
} }
List<String> result = credentialService.getAllIds(); List<String> result = credentialService.getAllIds();
assertEquals(numOfINst, result.size()); assertEquals(numOfINst, result.size());
...@@ -330,17 +337,15 @@ public class ServiceTests { ...@@ -330,17 +337,15 @@ public class ServiceTests {
int size = credentialService.getAllIds().size(); int size = credentialService.getAllIds().size();
assertEquals(0, size); assertEquals(0, size);
} }
@Test
@Test public void testProvisionerServiceProvision() throws FileNotFoundException, IOException, ApiException, nl.uva.sne.drip.commons.sure_tosca.client.ApiException {
public void testProvisionerServiceProvision() throws FileNotFoundException, IOException, ApiException {
FileInputStream in = new FileInputStream(testOutputApplicationExampleToscaFilePath); FileInputStream in = new FileInputStream(testOutputApplicationExampleToscaFilePath);
MultipartFile file = new MockMultipartFile("file", in); MultipartFile file = new MockMultipartFile("file", in);
toscaTemplateID = toscaTemplateService.saveFile(file); toscaTemplateID = toscaTemplateService.saveFile(file);
ToscaTemplate toscaTemplate = toscaTemplateService.getYaml2ToscaTemplate(toscaTemplateService.findByID(toscaTemplateID)); ToscaTemplate toscaTemplate = toscaTemplateService.getYaml2ToscaTemplate(toscaTemplateService.findByID(toscaTemplateID));
provisionService.addProvisionInterface(toscaTemplate); // provisionService.addProvisionInterface(toscaTemplate);
} }
} }
...@@ -15,7 +15,6 @@ import java.util.ArrayList; ...@@ -15,7 +15,6 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import nl.uva.sne.drip.commons.utils.TOSCAUtils;
import nl.uva.sne.drip.model.ToscaTemplate; import nl.uva.sne.drip.model.ToscaTemplate;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
...@@ -36,58 +35,15 @@ class ProvisionerRPCService { ...@@ -36,58 +35,15 @@ class ProvisionerRPCService {
} }
buildCloudStormTopTopology(toscaTemplate); buildCloudStormTopTopology(toscaTemplate);
return toscaTemplate; return toscaTemplate;
} }
private Map<String, Object> buildCloudStormTopTopology(ToscaTemplate toscaTemplate) throws JSchException, IOException { private Map<String, Object> buildCloudStormTopTopology(ToscaTemplate toscaTemplate) throws JSchException, IOException {
Map<String, Object> topTopology = new HashMap<>(); Map<String, Object> topTopology = new HashMap<>();
topTopology.put("userName", getVMsUSername(toscaTemplate));
String keysPath = buildSSHKeyPair();
topTopology.put("publicKeyPath", keysPath);
List<Map<String, Object>> subnets = new ArrayList<>();
int counter = 0;
for (Map.Entry vmTopology : getVmTopologies(toscaTemplate)) {
String subnetValue = getSubnets(vmTopology);
if (subnetValue != null) {
Map<String, Object> subnetMap = new HashMap<>();
subnetMap.put("name", "subnet" + counter++);
subnetMap.put("subnet", subnetValue.split("/")[0]);
subnetMap.put("netmask", subnetValue.split("/")[1]);
Object members = null;
subnetMap.put("members", members);
subnets.add(subnetMap);
}
}
if (subnets != null) {
topTopology.put("subnets", subnets);
}
List<Map<String, Object>> subTopologies = buildCloudStormSubTopologies(toscaTemplate);
topTopology.put("topologies", subTopologies);
return topTopology; return topTopology;
} }
private String getVMsUSername(ToscaTemplate toscaTemplate) {
List<Map.Entry> topologyVMs = getTopologyVMs(getVmTopologies(toscaTemplate).get(0), toscaTemplate);
return (String) TOSCAUtils.getNodeProperty(topologyVMs.get(0), "user_name");
}
private List<Map.Entry> getTopologyVMs(Map.Entry topology, ToscaTemplate toscaTemplate) {
List<Map.Entry> topologyVMs = new ArrayList<>();
Map<String, Object> topologyMap = new HashMap<>();
topologyMap.put((String) topology.getKey(), topology.getValue());
List<Map.Entry> relatedNodes = TOSCAUtils.getRelatedNodes(topologyMap, toscaTemplate);
for (Map.Entry node : relatedNodes) {
if (TOSCAUtils.nodeIsOfType(node, "tosca.nodes.ARTICONF.VM.Compute")) {
topologyVMs.add(node);
}
}
return topologyVMs;
}
private String buildSSHKeyPair() throws JSchException, IOException { private String buildSSHKeyPair() throws JSchException, IOException {
String userPublicKeyName = "id_rsa.pub"; String userPublicKeyName = "id_rsa.pub";
String publicKeyPath = "name@" + userPublicKeyName; String publicKeyPath = "name@" + userPublicKeyName;
...@@ -100,31 +56,4 @@ class ProvisionerRPCService { ...@@ -100,31 +56,4 @@ class ProvisionerRPCService {
return publicKeyPath; return publicKeyPath;
} }
private String getSubnets(Map.Entry node) {
return (String) TOSCAUtils.getNodeProperty(node, "subnet");
}
/**
* @return the vmTopologies
*/
public List<Map.Entry> getVmTopologies(ToscaTemplate toscaTemplate) {
if (vmTopologies == null) {
vmTopologies = TOSCAUtils.getNodesByType(toscaTemplate, "tosca.nodes.ARTICONF.VM.topology");
}
return vmTopologies;
}
private List<Map<String, Object>> buildCloudStormSubTopologies(ToscaTemplate toscaTemplate) {
List<Map<String, Object>> cloudStormSubTopologies = new ArrayList<>();
for(Map.Entry topology: getVmTopologies(toscaTemplate)){
Map<String, Object> cloudStormSubTopology = new HashMap<>();
cloudStormSubTopology.put("topology", topology.getKey());
cloudStormSubTopology.put("cloudProvider", TOSCAUtils.getNodeProperty(topology, "provider"));
cloudStormSubTopology.put("domain", TOSCAUtils.getNodeProperty(topology, "domain"));
cloudStormSubTopology.put("status", TOSCAUtils.getNodeProperty(topology, "domain"));
}
return cloudStormSubTopologies;
}
} }
User:
type: "object"
properties:
name:
type: "string"
version:
type: "string"
description:
type: "string"
tosca_interface_types:
type: "string"
password:
type: "string"
userStatus:
type: "array"
items:
type: "string"
...@@ -42,10 +42,8 @@ def query_db(queries, db=None): ...@@ -42,10 +42,8 @@ def query_db(queries, db=None):
updated_results = [] updated_results = []
for res in results: for res in results:
if root_key in res: if root_key in res:
key = res.pop(root_key) key = res[root_key]
node = {key: res} node = {key: res}
else:
node = res
updated_results.append(node) updated_results.append(node)
return updated_results return updated_results
return None return None
...@@ -87,15 +85,27 @@ def save(file): ...@@ -87,15 +85,27 @@ def save(file):
def get_interface_types(id, interface_type=None): def get_interface_types(id, interface_type=None):
if len(interface_types_db) <= 1: if len(interface_types_db) <= 1:
interface_types = get_tosca_template_model_by_id(id).interface_types
if interface_types: tosca_template_model = get_tosca_template_model_by_id(id)
for interface_type_name in interface_types: object_list = tosca_template_model.interface_types
interface = {root_key: interface_type_name} if object_list is None:
interface.update(interface_types[interface_type_name]) object_list = {}
tosca_template = get_tosca_template(tosca_template_model.to_dict())
tosca_node_types = tosca_template.nodetemplates[0].type_definition.TOSCA_DEF
all_custom_def = tosca_template.nodetemplates[0].custom_def
object_list.update(tosca_node_types)
object_list.update(all_custom_def)
if object_list:
for interface_type_name in object_list:
if 'tosca.interfaces' in interface_type_name:
interface = {root_key: interface_type_name}
interface.update(object_list[interface_type_name])
interface_types_db.insert(interface)
queries = [] queries = []
if interface_type: if interface_type:
query = Query() query = Query()
queries.append(query._node_nme == interface_type) queries.append(query.root_key == interface_type)
return query_db(queries, db=interface_types_db) return query_db(queries, db=interface_types_db)
...@@ -352,3 +362,10 @@ def set_node_properties(id, properties, node_name): ...@@ -352,3 +362,10 @@ def set_node_properties(id, properties, node_name):
tosca_template_model.topology_template.node_templates[node_name] = node_template_model tosca_template_model.topology_template.node_templates[node_name] = node_template_model
return update(id,tosca_template_model.to_dict()) return update(id,tosca_template_model.to_dict())
return None return None
def get_types(id, kind_of_type, has_interfaces, type_name, has_properties, has_attributes, has_requirements,
has_capabilities, has_artifacts, derived_from):
if kind_of_type == 'interface_types':
return get_interface_types(id, interface_type=type_name)
return None
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment