Commit f7f33f11 authored by Spiros Koulouzis's avatar Spiros Koulouzis

change to NodeTemplateMap

parent a9d61f92
...@@ -28,6 +28,7 @@ import java.util.List; ...@@ -28,6 +28,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import nl.uva.sne.drip.model.NodeTemplate; import nl.uva.sne.drip.model.NodeTemplate;
import nl.uva.sne.drip.model.NodeTemplateMap;
import nl.uva.sne.drip.model.tosca.Credential; import nl.uva.sne.drip.model.tosca.Credential;
import nl.uva.sne.drip.model.tosca.ToscaTemplate; import nl.uva.sne.drip.model.tosca.ToscaTemplate;
import nl.uva.sne.drip.sure.tosca.client.DefaultApi; import nl.uva.sne.drip.sure.tosca.client.DefaultApi;
...@@ -97,20 +98,21 @@ public class ToscaHelper { ...@@ -97,20 +98,21 @@ public class ToscaHelper {
return interfaceDefinitions; return interfaceDefinitions;
} }
public List<NodeTemplate> getVMTopologyTemplates() throws ApiException { public List<NodeTemplateMap> getVMTopologyTemplates() throws ApiException {
List<NodeTemplate> vmTopologyTemplates = api.getNodeTemplates(String.valueOf(id), "tosca.nodes.ARTICONF.VM.topology", null, null, null, null, null, null, null); List<NodeTemplateMap> vmTopologyTemplates = api.getNodeTemplates(String.valueOf(id), "tosca.nodes.ARTICONF.VM.topology", null, null, null, null, null, null, null);
return vmTopologyTemplates; return vmTopologyTemplates;
} }
public List<NodeTemplate> getTemplateVMsForVMTopology(NodeTemplate nodeTemplate) throws ApiException { public List<NodeTemplateMap> getTemplateVMsForVMTopology(NodeTemplateMap nodeTemplateMap) throws ApiException {
NodeTemplate nodeTemplate = nodeTemplateMap.getNodeTemplate();
List<Map<String, Object>> requirements = nodeTemplate.getRequirements(); List<Map<String, Object>> requirements = nodeTemplate.getRequirements();
List<NodeTemplate> vms = new ArrayList<>(); List<NodeTemplateMap> vms = new ArrayList<>();
for (Map<String, Object> req : requirements) { for (Map<String, Object> req : requirements) {
String nodeName = req.keySet().iterator().next(); String nodeName = req.keySet().iterator().next();
Map<String, Object> node = (Map<String, Object>) req.get(nodeName); Map<String, Object> node = (Map<String, Object>) req.get(nodeName);
if (node.get("capability").equals(VM_CAPABILITY)) { if (node.get("capability").equals(VM_CAPABILITY)) {
String vmName = (String) node.get("node"); String vmName = (String) node.get("node");
List<NodeTemplate> vmNodeTemplates = api.getNodeTemplates(String.valueOf(id), null, vmName, null, null, null, null, null, null); List<NodeTemplateMap> vmNodeTemplates = api.getNodeTemplates(String.valueOf(id), null, vmName, null, null, null, null, null, null);
vms.addAll(vmNodeTemplates); vms.addAll(vmNodeTemplates);
} }
} }
...@@ -118,7 +120,8 @@ public class ToscaHelper { ...@@ -118,7 +120,8 @@ public class ToscaHelper {
} }
public Double getVMNumOfCores(NodeTemplate vm) throws Exception { public Double getVMNumOfCores(NodeTemplateMap vmMap) throws Exception {
NodeTemplate vm = vmMap.getNodeTemplate();
if (vm.getType().equals(VM_TYPE)) { if (vm.getType().equals(VM_TYPE)) {
return (Double) vm.getProperties().get(VM_NUM_OF_CORES); return (Double) vm.getProperties().get(VM_NUM_OF_CORES);
} else { } else {
...@@ -126,7 +129,8 @@ public class ToscaHelper { ...@@ -126,7 +129,8 @@ public class ToscaHelper {
} }
} }
public Double getVMNMemSize(NodeTemplate vm) throws Exception { public Double getVMNMemSize(NodeTemplateMap vmMap) throws Exception {
NodeTemplate vm = vmMap.getNodeTemplate();
if (vm.getType().equals(VM_TYPE)) { if (vm.getType().equals(VM_TYPE)) {
String memScalar = (String) vm.getProperties().get(MEM_SIZE); String memScalar = (String) vm.getProperties().get(MEM_SIZE);
String[] memScalarArray = memScalar.split(" "); String[] memScalarArray = memScalar.split(" ");
...@@ -140,7 +144,8 @@ public class ToscaHelper { ...@@ -140,7 +144,8 @@ public class ToscaHelper {
} }
public String getVMNOS(NodeTemplate vm) throws Exception { public String getVMNOS(NodeTemplateMap vmMap) throws Exception {
NodeTemplate vm = vmMap.getNodeTemplate();
if (vm.getType().equals(VM_TYPE)) { if (vm.getType().equals(VM_TYPE)) {
return (String) vm.getProperties().get(VM_OS); return (String) vm.getProperties().get(VM_OS);
} else { } else {
...@@ -161,15 +166,17 @@ public class ToscaHelper { ...@@ -161,15 +166,17 @@ public class ToscaHelper {
} }
} }
public String getTopologyDomain(NodeTemplate nodeTemplate) throws Exception { public String getTopologyDomain(NodeTemplateMap nodeTemplateMap) throws Exception {
NodeTemplate nodeTemplate = nodeTemplateMap.getNodeTemplate();
if (nodeTemplate.getType().equals(VM_TOPOLOGY)) { if (nodeTemplate.getType().equals(VM_TOPOLOGY)) {
return (String) nodeTemplate.getProperties().get("domain"); return (String) nodeTemplate.getProperties().get("domain");
} else { } else {
throw new Exception("NodeTemplate is not of type: " + VM_TOPOLOGY + " it is of type: " + nodeTemplate.getType()); throw new Exception("NodeTemplateMap is not of type: " + VM_TOPOLOGY + " it is of type: " + nodeTemplate.getType());
} }
} }
public String getTopologyProvider(NodeTemplate nodeTemplate) throws Exception { public String getTopologyProvider(NodeTemplateMap nodeTemplateMap) throws Exception {
NodeTemplate nodeTemplate = nodeTemplateMap.getNodeTemplate();
if (nodeTemplate.getType().equals(VM_TOPOLOGY)) { if (nodeTemplate.getType().equals(VM_TOPOLOGY)) {
return (String) nodeTemplate.getProperties().get("provider"); return (String) nodeTemplate.getProperties().get("provider");
} else { } else {
...@@ -177,7 +184,8 @@ public class ToscaHelper { ...@@ -177,7 +184,8 @@ public class ToscaHelper {
} }
} }
public NodeTemplate setCredentialsInVMTopology(NodeTemplate vmTopology, Credential credential) throws Exception { public NodeTemplateMap setCredentialsInVMTopology(NodeTemplateMap vmTopologyMap, Credential credential) throws Exception {
NodeTemplate vmTopology = vmTopologyMap.getNodeTemplate();
if (vmTopology.getType().equals(VM_TOPOLOGY)) { if (vmTopology.getType().equals(VM_TOPOLOGY)) {
Map<String, Object> att = vmTopology.getAttributes(); Map<String, Object> att = vmTopology.getAttributes();
if (att == null) { if (att == null) {
...@@ -192,13 +200,15 @@ public class ToscaHelper { ...@@ -192,13 +200,15 @@ public class ToscaHelper {
toscaCredential.put("cloud_provider_name", credential.getCloudProviderName()); toscaCredential.put("cloud_provider_name", credential.getCloudProviderName());
att.put("credential", toscaCredential); att.put("credential", toscaCredential);
vmTopology.setAttributes(att); vmTopology.setAttributes(att);
return vmTopology; vmTopologyMap.setNodeTemplate(vmTopology);
return vmTopologyMap;
} else { } else {
throw new Exception("NodeTemplate is not of type: " + VM_TOPOLOGY + " it is of type: " + vmTopology.getType()); throw new Exception("NodeTemplate is not of type: " + VM_TOPOLOGY + " it is of type: " + vmTopology.getType());
} }
} }
public Credential getCredentialsFromVMTopology(NodeTemplate vmTopology) throws Exception { public Credential getCredentialsFromVMTopology(NodeTemplateMap vmTopologyMap) throws Exception {
NodeTemplate vmTopology = vmTopologyMap.getNodeTemplate();
if (vmTopology.getType().equals(VM_TOPOLOGY)) { if (vmTopology.getType().equals(VM_TOPOLOGY)) {
Map<String, Object> att = vmTopology.getAttributes(); Map<String, Object> att = vmTopology.getAttributes();
Object credentialMap = att.get("credential"); Object credentialMap = att.get("credential");
...@@ -221,7 +231,7 @@ public class ToscaHelper { ...@@ -221,7 +231,7 @@ public class ToscaHelper {
public ToscaTemplate setVMTopologyInToscaTemplate(ToscaTemplate toscaTemplate, NodeTemplate vmTopology) { public ToscaTemplate setVMTopologyInToscaTemplate(ToscaTemplate toscaTemplate, NodeTemplate vmTopology) {
Map<String, NodeTemplate> nodes = toscaTemplate.getTopologyTemplate().getNodeTemplates(); Map<String, NodeTemplate> nodes = toscaTemplate.getTopologyTemplate().getNodeTemplates();
Set<String> keys = nodes.keySet(); Set<String> keys = nodes.keySet();
for(String key :keys){ for (String key : keys) {
NodeTemplate node = nodes.get(key); NodeTemplate node = nodes.get(key);
} }
return null; return null;
......
/*
* tosca-sure
* TOSCA Simple qUeRy sErvice (SURE).
*
* OpenAPI spec version: 1.0.0
* Contact: S.Koulouzis@uva.nl
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
package nl.uva.sne.drip.model;
import java.util.Objects;
import com.google.gson.annotations.SerializedName;
import io.swagger.annotations.ApiModelProperty;
/**
* NodeTemplateMap
*/
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2019-12-20T15:53:11.510Z")
public class NodeTemplateMap {
@SerializedName("name")
private String name = null;
@SerializedName("nodeTemplate")
private NodeTemplate nodeTemplate = null;
public NodeTemplateMap name(String name) {
this.name = name;
return this;
}
/**
* Get name
*
* @return name
*
*/
@ApiModelProperty(value = "")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public NodeTemplateMap nodeTemplate(NodeTemplate nodeTemplate) {
this.nodeTemplate = nodeTemplate;
return this;
}
/**
* Get nodeTemplate
*
* @return nodeTemplate
*
*/
@ApiModelProperty(value = "")
public NodeTemplate getNodeTemplate() {
return nodeTemplate;
}
public void setNodeTemplate(NodeTemplate nodeTemplate) {
this.nodeTemplate = nodeTemplate;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
NodeTemplateMap nodeTemplateMap = (NodeTemplateMap) o;
return Objects.equals(this.name, nodeTemplateMap.name)
&& Objects.equals(this.nodeTemplate, nodeTemplateMap.nodeTemplate);
}
@Override
public int hashCode() {
return Objects.hash(name, nodeTemplate);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class NodeTemplateMap {\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" nodeTemplate: ").append(toIndentedString(nodeTemplate)).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 ");
}
}
...@@ -9,15 +9,18 @@ ...@@ -9,15 +9,18 @@
* https://github.com/swagger-api/swagger-codegen.git * https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually. * Do not edit the class manually.
*/ */
package nl.uva.sne.drip.sure.tosca.auth; package nl.uva.sne.drip.sure.tosca.auth;
import java.util.Map; import java.util.Map;
import java.util.List; import java.util.List;
import nl.uva.sne.drip.sure.tosca.client.Pair; import nl.uva.sne.drip.sure.tosca.client.Pair;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2019-12-09T20:19:44.689Z") @javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2019-12-20T15:53:11.510Z")
public class ApiKeyAuth implements Authentication { public class ApiKeyAuth implements Authentication {
private final String location; private final String location;
private final String paramName; private final String paramName;
......
...@@ -9,14 +9,17 @@ ...@@ -9,14 +9,17 @@
* https://github.com/swagger-api/swagger-codegen.git * https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually. * Do not edit the class manually.
*/ */
package nl.uva.sne.drip.sure.tosca.auth; package nl.uva.sne.drip.sure.tosca.auth;
import java.util.Map; import java.util.Map;
import java.util.List; import java.util.List;
import nl.uva.sne.drip.sure.tosca.client.Pair; import nl.uva.sne.drip.sure.tosca.client.Pair;
public interface Authentication { public interface Authentication {
/** /**
* Apply authentication settings to header and query params. * Apply authentication settings to header and query params.
* *
......
...@@ -20,6 +20,7 @@ import com.squareup.okhttp.Credentials; ...@@ -20,6 +20,7 @@ import com.squareup.okhttp.Credentials;
import java.util.Map; import java.util.Map;
import java.util.List; import java.util.List;
import java.io.UnsupportedEncodingException;
import nl.uva.sne.drip.sure.tosca.client.Pair; import nl.uva.sne.drip.sure.tosca.client.Pair;
public class HttpBasicAuth implements Authentication { public class HttpBasicAuth implements Authentication {
......
...@@ -19,7 +19,7 @@ import java.util.Map; ...@@ -19,7 +19,7 @@ import java.util.Map;
import java.util.List; import java.util.List;
import nl.uva.sne.drip.sure.tosca.client.Pair; import nl.uva.sne.drip.sure.tosca.client.Pair;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2019-12-09T20:19:44.689Z") @javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2019-12-20T15:53:11.510Z")
public class OAuth implements Authentication { public class OAuth implements Authentication {
private String accessToken; private String accessToken;
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
package nl.uva.sne.drip.sure.tosca.client; package nl.uva.sne.drip.sure.tosca.client;
import java.io.IOException;
import java.util.Map; import java.util.Map;
import java.util.List; import java.util.List;
......
...@@ -11,21 +11,17 @@ ...@@ -11,21 +11,17 @@
*/ */
package nl.uva.sne.drip.sure.tosca.client; package nl.uva.sne.drip.sure.tosca.client;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.squareup.okhttp.*; import com.squareup.okhttp.*;
import javax.net.ssl.*;
import java.util.*;
import org.threeten.bp.LocalDate;
import org.threeten.bp.OffsetDateTime;
import org.threeten.bp.format.DateTimeFormatter;
import com.squareup.okhttp.internal.http.HttpMethod; import com.squareup.okhttp.internal.http.HttpMethod;
import com.squareup.okhttp.logging.HttpLoggingInterceptor; import com.squareup.okhttp.logging.HttpLoggingInterceptor;
import com.squareup.okhttp.logging.HttpLoggingInterceptor.Level; import com.squareup.okhttp.logging.HttpLoggingInterceptor.Level;
import okio.BufferedSink; import okio.BufferedSink;
import okio.Okio; import okio.Okio;
import org.threeten.bp.LocalDate;
import org.threeten.bp.OffsetDateTime;
import org.threeten.bp.format.DateTimeFormatter;
import javax.net.ssl.*;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
...@@ -41,14 +37,14 @@ import java.security.cert.CertificateException; ...@@ -41,14 +37,14 @@ import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory; import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate; import java.security.cert.X509Certificate;
import java.text.DateFormat; import java.text.DateFormat;
import java.util.*;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import nl.uva.sne.drip.sure.tosca.auth.ApiKeyAuth;
import nl.uva.sne.drip.sure.tosca.auth.Authentication; import nl.uva.sne.drip.sure.tosca.auth.Authentication;
import nl.uva.sne.drip.sure.tosca.auth.HttpBasicAuth; import nl.uva.sne.drip.sure.tosca.auth.HttpBasicAuth;
import nl.uva.sne.drip.sure.tosca.auth.ApiKeyAuth;
import nl.uva.sne.drip.sure.tosca.auth.OAuth; import nl.uva.sne.drip.sure.tosca.auth.OAuth;
public class ApiClient { public class ApiClient {
...@@ -518,7 +514,7 @@ public class ApiClient { ...@@ -518,7 +514,7 @@ public class ApiClient {
* @return A list containing a single {@code Pair} object. * @return A list containing a single {@code Pair} object.
*/ */
public List<Pair> parameterToPair(String name, Object value) { public List<Pair> parameterToPair(String name, Object value) {
List<Pair> params = new ArrayList<>(); List<Pair> params = new ArrayList<Pair>();
// preconditions // preconditions
if (name == null || name.isEmpty() || value == null || value instanceof Collection) { if (name == null || name.isEmpty() || value == null || value instanceof Collection) {
......
...@@ -16,7 +16,7 @@ package nl.uva.sne.drip.sure.tosca.client; ...@@ -16,7 +16,7 @@ package nl.uva.sne.drip.sure.tosca.client;
import java.util.Map; import java.util.Map;
import java.util.List; import java.util.List;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2019-12-09T20:19:44.689Z") @javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2019-12-20T15:53:11.510Z")
public class ApiException extends Exception { public class ApiException extends Exception {
private int code = 0; private int code = 0;
private Map<String, List<String>> responseHeaders = null; private Map<String, List<String>> responseHeaders = null;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
package nl.uva.sne.drip.sure.tosca.client; package nl.uva.sne.drip.sure.tosca.client;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2019-12-09T20:19:44.689Z") @javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2019-12-20T15:53:11.510Z")
public class Configuration { public class Configuration {
private static ApiClient defaultApiClient = new ApiClient(); private static ApiClient defaultApiClient = new ApiClient();
......
...@@ -22,17 +22,9 @@ import java.util.ArrayList; ...@@ -22,17 +22,9 @@ 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.model.NodeTemplate; import nl.uva.sne.drip.model.NodeTemplateMap;
import nl.uva.sne.drip.model.tosca.TopologyTemplate; import nl.uva.sne.drip.model.tosca.TopologyTemplate;
import nl.uva.sne.drip.model.tosca.ToscaTemplate; import nl.uva.sne.drip.model.tosca.ToscaTemplate;
import nl.uva.sne.drip.sure.tosca.client.ApiCallback;
import nl.uva.sne.drip.sure.tosca.client.ApiClient;
import nl.uva.sne.drip.sure.tosca.client.ApiException;
import nl.uva.sne.drip.sure.tosca.client.ApiResponse;
import nl.uva.sne.drip.sure.tosca.client.Configuration;
import nl.uva.sne.drip.sure.tosca.client.Pair;
import nl.uva.sne.drip.sure.tosca.client.ProgressRequestBody;
import nl.uva.sne.drip.sure.tosca.client.ProgressResponseBody;
public class DefaultApi { public class DefaultApi {
...@@ -1297,12 +1289,12 @@ public class DefaultApi { ...@@ -1297,12 +1289,12 @@ public class DefaultApi {
* @param hasRequirements filter if has requirements (optional) * @param hasRequirements filter if has requirements (optional)
* @param hasCapabilities filter if has capabilities (optional) * @param hasCapabilities filter if has capabilities (optional)
* @param hasArtifacts filter if has artifacts (optional) * @param hasArtifacts filter if has artifacts (optional)
* @return List&lt;NodeTemplate&gt; * @return List&lt;NodeTemplateMap&gt;
* @throws ApiException If fail to call the API, e.g. server error or cannot * @throws ApiException If fail to call the API, e.g. server error or cannot
* deserialize the response body * deserialize the response body
*/ */
public List<NodeTemplate> getNodeTemplates(String id, String typeName, String nodeName, Boolean hasInterfaces, Boolean hasProperties, Boolean hasAttributes, Boolean hasRequirements, Boolean hasCapabilities, Boolean hasArtifacts) throws ApiException { public List<NodeTemplateMap> getNodeTemplates(String id, String typeName, String nodeName, Boolean hasInterfaces, Boolean hasProperties, Boolean hasAttributes, Boolean hasRequirements, Boolean hasCapabilities, Boolean hasArtifacts) throws ApiException {
ApiResponse<List<NodeTemplate>> resp = getNodeTemplatesWithHttpInfo(id, typeName, nodeName, hasInterfaces, hasProperties, hasAttributes, hasRequirements, hasCapabilities, hasArtifacts); ApiResponse<List<NodeTemplateMap>> resp = getNodeTemplatesWithHttpInfo(id, typeName, nodeName, hasInterfaces, hasProperties, hasAttributes, hasRequirements, hasCapabilities, hasArtifacts);
return resp.getData(); return resp.getData();
} }
...@@ -1319,13 +1311,13 @@ public class DefaultApi { ...@@ -1319,13 +1311,13 @@ public class DefaultApi {
* @param hasRequirements filter if has requirements (optional) * @param hasRequirements filter if has requirements (optional)
* @param hasCapabilities filter if has capabilities (optional) * @param hasCapabilities filter if has capabilities (optional)
* @param hasArtifacts filter if has artifacts (optional) * @param hasArtifacts filter if has artifacts (optional)
* @return ApiResponse&lt;List&lt;NodeTemplate&gt;&gt; * @return ApiResponse&lt;List&lt;NodeTemplateMap&gt;&gt;
* @throws ApiException If fail to call the API, e.g. server error or cannot * @throws ApiException If fail to call the API, e.g. server error or cannot
* deserialize the response body * deserialize the response body
*/ */
public ApiResponse<List<NodeTemplate>> getNodeTemplatesWithHttpInfo(String id, String typeName, String nodeName, Boolean hasInterfaces, Boolean hasProperties, Boolean hasAttributes, Boolean hasRequirements, Boolean hasCapabilities, Boolean hasArtifacts) throws ApiException { public ApiResponse<List<NodeTemplateMap>> getNodeTemplatesWithHttpInfo(String id, String typeName, String nodeName, Boolean hasInterfaces, Boolean hasProperties, Boolean hasAttributes, Boolean hasRequirements, Boolean hasCapabilities, Boolean hasArtifacts) throws ApiException {
com.squareup.okhttp.Call call = getNodeTemplatesValidateBeforeCall(id, typeName, nodeName, hasInterfaces, hasProperties, hasAttributes, hasRequirements, hasCapabilities, hasArtifacts, null, null); com.squareup.okhttp.Call call = getNodeTemplatesValidateBeforeCall(id, typeName, nodeName, hasInterfaces, hasProperties, hasAttributes, hasRequirements, hasCapabilities, hasArtifacts, null, null);
Type localVarReturnType = new TypeToken<List<NodeTemplate>>() { Type localVarReturnType = new TypeToken<List<NodeTemplateMap>>() {
}.getType(); }.getType();
return apiClient.execute(call, localVarReturnType); return apiClient.execute(call, localVarReturnType);
} }
...@@ -1347,7 +1339,7 @@ public class DefaultApi { ...@@ -1347,7 +1339,7 @@ public class DefaultApi {
* @throws ApiException If fail to process the API call, e.g. serializing * @throws ApiException If fail to process the API call, e.g. serializing
* the request body object * the request body object
*/ */
public com.squareup.okhttp.Call getNodeTemplatesAsync(String id, String typeName, String nodeName, Boolean hasInterfaces, Boolean hasProperties, Boolean hasAttributes, Boolean hasRequirements, Boolean hasCapabilities, Boolean hasArtifacts, final ApiCallback<List<NodeTemplate>> callback) throws ApiException { public com.squareup.okhttp.Call getNodeTemplatesAsync(String id, String typeName, String nodeName, Boolean hasInterfaces, Boolean hasProperties, Boolean hasAttributes, Boolean hasRequirements, Boolean hasCapabilities, Boolean hasArtifacts, final ApiCallback<List<NodeTemplateMap>> callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null; ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
...@@ -1369,7 +1361,7 @@ public class DefaultApi { ...@@ -1369,7 +1361,7 @@ public class DefaultApi {
} }
com.squareup.okhttp.Call call = getNodeTemplatesValidateBeforeCall(id, typeName, nodeName, hasInterfaces, hasProperties, hasAttributes, hasRequirements, hasCapabilities, hasArtifacts, progressListener, progressRequestListener); com.squareup.okhttp.Call call = getNodeTemplatesValidateBeforeCall(id, typeName, nodeName, hasInterfaces, hasProperties, hasAttributes, hasRequirements, hasCapabilities, hasArtifacts, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken<List<NodeTemplate>>() { Type localVarReturnType = new TypeToken<List<NodeTemplateMap>>() {
}.getType(); }.getType();
apiClient.executeAsync(call, localVarReturnType, callback); apiClient.executeAsync(call, localVarReturnType, callback);
return call; return call;
...@@ -1730,12 +1722,12 @@ public class DefaultApi { ...@@ -1730,12 +1722,12 @@ public class DefaultApi {
* *
* @param id ID of topolog template uplodaed (required) * @param id ID of topolog template uplodaed (required)
* @param nodeName node_name (required) * @param nodeName node_name (required)
* @return List&lt;NodeTemplate&gt; * @return List&lt;NodeTemplateMap&gt;
* @throws ApiException If fail to call the API, e.g. server error or cannot * @throws ApiException If fail to call the API, e.g. server error or cannot
* deserialize the response body * deserialize the response body
*/ */
public List<NodeTemplate> getRelatedNodes(String id, String nodeName) throws ApiException { public List<NodeTemplateMap> getRelatedNodes(String id, String nodeName) throws ApiException {
ApiResponse<List<NodeTemplate>> resp = getRelatedNodesWithHttpInfo(id, nodeName); ApiResponse<List<NodeTemplateMap>> resp = getRelatedNodesWithHttpInfo(id, nodeName);
return resp.getData(); return resp.getData();
} }
...@@ -1745,13 +1737,13 @@ public class DefaultApi { ...@@ -1745,13 +1737,13 @@ public class DefaultApi {
* *
* @param id ID of topolog template uplodaed (required) * @param id ID of topolog template uplodaed (required)
* @param nodeName node_name (required) * @param nodeName node_name (required)
* @return ApiResponse&lt;List&lt;NodeTemplate&gt;&gt; * @return ApiResponse&lt;List&lt;NodeTemplateMap&gt;&gt;
* @throws ApiException If fail to call the API, e.g. server error or cannot * @throws ApiException If fail to call the API, e.g. server error or cannot
* deserialize the response body * deserialize the response body
*/ */
public ApiResponse<List<NodeTemplate>> getRelatedNodesWithHttpInfo(String id, String nodeName) throws ApiException { public ApiResponse<List<NodeTemplateMap>> getRelatedNodesWithHttpInfo(String id, String nodeName) throws ApiException {
com.squareup.okhttp.Call call = getRelatedNodesValidateBeforeCall(id, nodeName, null, null); com.squareup.okhttp.Call call = getRelatedNodesValidateBeforeCall(id, nodeName, null, null);
Type localVarReturnType = new TypeToken<List<NodeTemplate>>() { Type localVarReturnType = new TypeToken<List<NodeTemplateMap>>() {
}.getType(); }.getType();
return apiClient.execute(call, localVarReturnType); return apiClient.execute(call, localVarReturnType);
} }
...@@ -1766,7 +1758,7 @@ public class DefaultApi { ...@@ -1766,7 +1758,7 @@ public class DefaultApi {
* @throws ApiException If fail to process the API call, e.g. serializing * @throws ApiException If fail to process the API call, e.g. serializing
* the request body object * the request body object
*/ */
public com.squareup.okhttp.Call getRelatedNodesAsync(String id, String nodeName, final ApiCallback<List<NodeTemplate>> callback) throws ApiException { public com.squareup.okhttp.Call getRelatedNodesAsync(String id, String nodeName, final ApiCallback<List<NodeTemplateMap>> callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null; ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
...@@ -1788,7 +1780,7 @@ public class DefaultApi { ...@@ -1788,7 +1780,7 @@ public class DefaultApi {
} }
com.squareup.okhttp.Call call = getRelatedNodesValidateBeforeCall(id, nodeName, progressListener, progressRequestListener); com.squareup.okhttp.Call call = getRelatedNodesValidateBeforeCall(id, nodeName, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken<List<NodeTemplate>>() { Type localVarReturnType = new TypeToken<List<NodeTemplateMap>>() {
}.getType(); }.getType();
apiClient.executeAsync(call, localVarReturnType, callback); apiClient.executeAsync(call, localVarReturnType, callback);
return call; return call;
......
...@@ -120,6 +120,7 @@ public class JSON { ...@@ -120,6 +120,7 @@ public class JSON {
* @param returnType The type to deserialize into * @param returnType The type to deserialize into
* @return The deserialized Java object * @return The deserialized Java object
*/ */
@SuppressWarnings("unchecked")
public <T> T deserialize(String body, Type returnType) { public <T> T deserialize(String body, Type returnType) {
try { try {
if (isLenientOnJson) { if (isLenientOnJson) {
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
package nl.uva.sne.drip.sure.tosca.client; package nl.uva.sne.drip.sure.tosca.client;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2019-12-09T20:19:44.689Z") @javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2019-12-20T15:53:11.510Z")
public class Pair { public class Pair {
private String name = ""; private String name = "";
private String value = ""; private String value = "";
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
package nl.uva.sne.drip.sure.tosca.client; package nl.uva.sne.drip.sure.tosca.client;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2019-12-09T20:19:44.689Z") @javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2019-12-20T15:53:11.510Z")
public class StringUtil { public class StringUtil {
/** /**
* Check if the given array contains the given value (with case-insensitive comparison). * Check if the given array contains the given value (with case-insensitive comparison).
......
...@@ -36,6 +36,7 @@ import java.util.Set; ...@@ -36,6 +36,7 @@ import java.util.Set;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import nl.uva.sne.drip.model.NodeTemplate; import nl.uva.sne.drip.model.NodeTemplate;
import nl.uva.sne.drip.model.NodeTemplateMap;
import nl.uva.sne.drip.model.tosca.ToscaTemplate; import nl.uva.sne.drip.model.tosca.ToscaTemplate;
import org.junit.After; import org.junit.After;
import org.junit.AfterClass; import org.junit.AfterClass;
...@@ -131,10 +132,10 @@ public class ToscaHelperTest { ...@@ -131,10 +132,10 @@ public class ToscaHelperTest {
public void testGetVMTopologyTemplates() throws ApiException { public void testGetVMTopologyTemplates() throws ApiException {
if (serviceUp) { if (serviceUp) {
System.out.println("getVMTopologyTemplates"); System.out.println("getVMTopologyTemplates");
List<NodeTemplate> result = instance.getVMTopologyTemplates(); List<NodeTemplateMap> result = instance.getVMTopologyTemplates();
assertNotNull(result); assertNotNull(result);
for (NodeTemplate nodeTemplate : result) { for (NodeTemplateMap nodeTemplateMap : result) {
assertEquals(nodeTemplate.getType(), "tosca.nodes.ARTICONF.VM.topology"); assertEquals(nodeTemplateMap.getNodeTemplate().getType(), "tosca.nodes.ARTICONF.VM.topology");
} }
} }
} }
......
...@@ -14,6 +14,7 @@ import java.util.logging.Logger; ...@@ -14,6 +14,7 @@ import java.util.logging.Logger;
import nl.uva.sne.drip.commons.utils.ToscaHelper; import nl.uva.sne.drip.commons.utils.ToscaHelper;
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.NodeTemplateMap;
import nl.uva.sne.drip.model.tosca.Credential; import nl.uva.sne.drip.model.tosca.Credential;
import nl.uva.sne.drip.model.tosca.ToscaTemplate; import nl.uva.sne.drip.model.tosca.ToscaTemplate;
import nl.uva.sne.drip.rpc.DRIPCaller; import nl.uva.sne.drip.rpc.DRIPCaller;
...@@ -94,15 +95,15 @@ public class DRIPService { ...@@ -94,15 +95,15 @@ public class DRIPService {
private ToscaTemplate addCredentials(ToscaTemplate toscaTemplate) throws IOException, JsonProcessingException, ApiException, Exception { private ToscaTemplate addCredentials(ToscaTemplate toscaTemplate) throws IOException, JsonProcessingException, ApiException, Exception {
helper.uploadToscaTemplate(toscaTemplate); helper.uploadToscaTemplate(toscaTemplate);
List<NodeTemplate> vmTopologies = helper.getVMTopologyTemplates(); List<NodeTemplateMap> vmTopologies = helper.getVMTopologyTemplates();
List<Credential> credentials = null; List<Credential> credentials = null;
for (NodeTemplate vmTopology : vmTopologies) { for (NodeTemplateMap vmTopologyMap : vmTopologies) {
String provider = helper.getTopologyProvider(vmTopology); String provider = helper.getTopologyProvider(vmTopologyMap);
credentials = credentialService.findByProvider(provider.toLowerCase()); credentials = credentialService.findByProvider(provider.toLowerCase());
if (credentials != null && credentials.size() > 0) { if (credentials != null && credentials.size() > 0) {
Credential credential = getBestCredential(vmTopology, credentials); Credential credential = getBestCredential(vmTopologyMap.getNodeTemplate(), credentials);
vmTopology = helper.setCredentialsInVMTopology(vmTopology, credential); vmTopologyMap = helper.setCredentialsInVMTopology(vmTopologyMap, credential);
toscaTemplate = helper.setVMTopologyInToscaTemplate(toscaTemplate,vmTopology); toscaTemplate = helper.setVMTopologyInToscaTemplate(toscaTemplate, vmTopologyMap.getNodeTemplate());
return toscaTemplate; return toscaTemplate;
} }
} }
......
...@@ -25,6 +25,7 @@ import java.util.Properties; ...@@ -25,6 +25,7 @@ import java.util.Properties;
import nl.uva.sne.drip.commons.utils.ToscaHelper; import nl.uva.sne.drip.commons.utils.ToscaHelper;
import nl.uva.sne.drip.model.cloud.storm.CloudsStormVM; import nl.uva.sne.drip.model.cloud.storm.CloudsStormVM;
import nl.uva.sne.drip.model.NodeTemplate; import nl.uva.sne.drip.model.NodeTemplate;
import nl.uva.sne.drip.model.NodeTemplateMap;
import nl.uva.sne.drip.model.cloud.storm.CloudsStormSubTopology; import nl.uva.sne.drip.model.cloud.storm.CloudsStormSubTopology;
import nl.uva.sne.drip.model.cloud.storm.CloudsStormTopTopology; import nl.uva.sne.drip.model.cloud.storm.CloudsStormTopTopology;
import nl.uva.sne.drip.model.cloud.storm.CloudsStormVMs; import nl.uva.sne.drip.model.cloud.storm.CloudsStormVMs;
...@@ -119,15 +120,15 @@ class CloudStormService { ...@@ -119,15 +120,15 @@ class CloudStormService {
} }
private Map<String, Object> getCloudsStormSubTopologiesAndVMs(ToscaTemplate toscaTemplate, String tempInputDirPath) throws ApiException, IOException, Exception { private Map<String, Object> getCloudsStormSubTopologiesAndVMs(ToscaTemplate toscaTemplate, String tempInputDirPath) throws ApiException, IOException, Exception {
List<NodeTemplate> vmTopologyTemplates = helper.getVMTopologyTemplates(); List<NodeTemplateMap> vmTopologyTemplatesMap = helper.getVMTopologyTemplates();
List<CloudsStormSubTopology> cloudsStormSubTopologies = new ArrayList<>(); List<CloudsStormSubTopology> cloudsStormSubTopologies = new ArrayList<>();
Map<String, Object> cloudsStormMap = new HashMap<>(); Map<String, Object> cloudsStormMap = new HashMap<>();
List<CloudsStormVMs> cloudsStormVMsList = new ArrayList<>(); List<CloudsStormVMs> cloudsStormVMsList = new ArrayList<>();
int i = 0; int i = 0;
for (NodeTemplate nodeTemplate : vmTopologyTemplates) { for (NodeTemplateMap nodeTemplateMap : vmTopologyTemplatesMap) {
CloudsStormSubTopology cloudsStormSubTopology = new CloudsStormSubTopology(); CloudsStormSubTopology cloudsStormSubTopology = new CloudsStormSubTopology();
String domain = helper.getTopologyDomain(nodeTemplate); String domain = helper.getTopologyDomain(nodeTemplateMap);
String provider = helper.getTopologyProvider(nodeTemplate); String provider = helper.getTopologyProvider(nodeTemplateMap);
cloudsStormSubTopology.setDomain(domain); cloudsStormSubTopology.setDomain(domain);
cloudsStormSubTopology.setCloudProvider(provider); cloudsStormSubTopology.setCloudProvider(provider);
cloudsStormSubTopology.setTopology("vm_topology" + i); cloudsStormSubTopology.setTopology("vm_topology" + i);
...@@ -136,14 +137,14 @@ class CloudStormService { ...@@ -136,14 +137,14 @@ class CloudStormService {
List<CloudsStormVM> vms = new ArrayList<>(); List<CloudsStormVM> vms = new ArrayList<>();
cloudsStormVMs.setName("vm_topology" + i); cloudsStormVMs.setName("vm_topology" + i);
List<NodeTemplate> vmTemplates = helper.getTemplateVMsForVMTopology(nodeTemplate); List<NodeTemplateMap> vmTemplatesMap = helper.getTemplateVMsForVMTopology(nodeTemplateMap);
int j = 0; int j = 0;
for (NodeTemplate vm : vmTemplates) { for (NodeTemplateMap vmMap : vmTemplatesMap) {
CloudsStormVM cloudsStormVM = new CloudsStormVM(); CloudsStormVM cloudsStormVM = new CloudsStormVM();
String vmType = getVMType(vm, provider); String vmType = getVMType(vmMap, provider);
cloudsStormVM.setNodeType(vmType); cloudsStormVM.setNodeType(vmType);
cloudsStormVM.setName("vm" + j); cloudsStormVM.setName("vm" + j);
String os = helper.getVMNOS(vm); String os = helper.getVMNOS(vmMap);
cloudsStormVM.setOsType(os); cloudsStormVM.setOsType(os);
vms.add(cloudsStormVM); vms.add(cloudsStormVM);
j++; j++;
...@@ -160,10 +161,10 @@ class CloudStormService { ...@@ -160,10 +161,10 @@ class CloudStormService {
return cloudsStormMap; return cloudsStormMap;
} }
private String getVMType(NodeTemplate vm, String provider) throws IOException, Exception { private String getVMType(NodeTemplateMap vmMap, String provider) throws IOException, Exception {
Double numOfCores = helper.getVMNumOfCores(vm); Double numOfCores = helper.getVMNumOfCores(vmMap);
Double memSize = helper.getVMNMemSize(vm); Double memSize = helper.getVMNMemSize(vmMap);
String os = helper.getVMNOS(vm); String os = helper.getVMNOS(vmMap);
List<VMMetaInfo> vmInfos = cloudStormDAO.findVmMetaInfoByProvider(provider); List<VMMetaInfo> vmInfos = cloudStormDAO.findVmMetaInfoByProvider(provider);
for (VMMetaInfo vmInfo : vmInfos) { for (VMMetaInfo vmInfo : vmInfos) {
if (Objects.equals(numOfCores, Double.valueOf(vmInfo.getCPU())) && Objects.equals(memSize, Double.valueOf(vmInfo.getMEM())) && os.toLowerCase().equals(vmInfo.getOS().toLowerCase())) { if (Objects.equals(numOfCores, Double.valueOf(vmInfo.getCPU())) && Objects.equals(memSize, Double.valueOf(vmInfo.getMEM())) && os.toLowerCase().equals(vmInfo.getOS().toLowerCase())) {
...@@ -174,9 +175,9 @@ class CloudStormService { ...@@ -174,9 +175,9 @@ class CloudStormService {
} }
private void writeCloudStormCredentialsFiles(ToscaTemplate toscaTemplate, String credentialsTempInputDirPath) throws ApiException, Exception { private void writeCloudStormCredentialsFiles(ToscaTemplate toscaTemplate, String credentialsTempInputDirPath) throws ApiException, Exception {
List<NodeTemplate> vmTopologies = helper.getVMTopologyTemplates(); List<NodeTemplateMap> vmTopologiesMaps = helper.getVMTopologyTemplates();
for (NodeTemplate vmTopology : vmTopologies) { for (NodeTemplateMap vmTopologyMap : vmTopologiesMaps) {
Credential credentials = helper.getCredentialsFromVMTopology(vmTopology); Credential credentials = helper.getCredentialsFromVMTopology(vmTopologyMap);
} }
} }
......
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