Commit f7f33f11 authored by Spiros Koulouzis's avatar Spiros Koulouzis

change to NodeTemplateMap

parent a9d61f92
......@@ -28,6 +28,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
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.ToscaTemplate;
import nl.uva.sne.drip.sure.tosca.client.DefaultApi;
......@@ -97,20 +98,21 @@ public class ToscaHelper {
return interfaceDefinitions;
}
public List<NodeTemplate> getVMTopologyTemplates() throws ApiException {
List<NodeTemplate> vmTopologyTemplates = api.getNodeTemplates(String.valueOf(id), "tosca.nodes.ARTICONF.VM.topology", null, null, null, null, null, null, null);
public List<NodeTemplateMap> getVMTopologyTemplates() throws ApiException {
List<NodeTemplateMap> vmTopologyTemplates = api.getNodeTemplates(String.valueOf(id), "tosca.nodes.ARTICONF.VM.topology", null, null, null, null, null, null, null);
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<NodeTemplate> vms = new ArrayList<>();
List<NodeTemplateMap> vms = new ArrayList<>();
for (Map<String, Object> req : requirements) {
String nodeName = req.keySet().iterator().next();
Map<String, Object> node = (Map<String, Object>) req.get(nodeName);
if (node.get("capability").equals(VM_CAPABILITY)) {
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);
}
}
......@@ -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)) {
return (Double) vm.getProperties().get(VM_NUM_OF_CORES);
} else {
......@@ -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)) {
String memScalar = (String) vm.getProperties().get(MEM_SIZE);
String[] memScalarArray = memScalar.split(" ");
......@@ -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)) {
return (String) vm.getProperties().get(VM_OS);
} else {
......@@ -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)) {
return (String) nodeTemplate.getProperties().get("domain");
} 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)) {
return (String) nodeTemplate.getProperties().get("provider");
} else {
......@@ -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)) {
Map<String, Object> att = vmTopology.getAttributes();
if (att == null) {
......@@ -192,13 +200,15 @@ public class ToscaHelper {
toscaCredential.put("cloud_provider_name", credential.getCloudProviderName());
att.put("credential", toscaCredential);
vmTopology.setAttributes(att);
return vmTopology;
vmTopologyMap.setNodeTemplate(vmTopology);
return vmTopologyMap;
} else {
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)) {
Map<String, Object> att = vmTopology.getAttributes();
Object credentialMap = att.get("credential");
......@@ -221,7 +231,7 @@ public class ToscaHelper {
public ToscaTemplate setVMTopologyInToscaTemplate(ToscaTemplate toscaTemplate, NodeTemplate vmTopology) {
Map<String, NodeTemplate> nodes = toscaTemplate.getTopologyTemplate().getNodeTemplates();
Set<String> keys = nodes.keySet();
for(String key :keys){
for (String key : keys) {
NodeTemplate node = nodes.get(key);
}
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,65 +9,68 @@
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
package nl.uva.sne.drip.sure.tosca.auth;
import java.util.Map;
import java.util.List;
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 {
private final String location;
private final String paramName;
private final String location;
private final String paramName;
private String apiKey;
private String apiKeyPrefix;
private String apiKey;
private String apiKeyPrefix;
public ApiKeyAuth(String location, String paramName) {
this.location = location;
this.paramName = paramName;
}
public ApiKeyAuth(String location, String paramName) {
this.location = location;
this.paramName = paramName;
}
public String getLocation() {
return location;
}
public String getLocation() {
return location;
}
public String getParamName() {
return paramName;
}
public String getParamName() {
return paramName;
}
public String getApiKey() {
return apiKey;
}
public String getApiKey() {
return apiKey;
}
public void setApiKey(String apiKey) {
this.apiKey = apiKey;
}
public void setApiKey(String apiKey) {
this.apiKey = apiKey;
}
public String getApiKeyPrefix() {
return apiKeyPrefix;
}
public String getApiKeyPrefix() {
return apiKeyPrefix;
}
public void setApiKeyPrefix(String apiKeyPrefix) {
this.apiKeyPrefix = apiKeyPrefix;
}
public void setApiKeyPrefix(String apiKeyPrefix) {
this.apiKeyPrefix = apiKeyPrefix;
@Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) {
if (apiKey == null) {
return;
}
@Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) {
if (apiKey == null) {
return;
}
String value;
if (apiKeyPrefix != null) {
value = apiKeyPrefix + " " + apiKey;
} else {
value = apiKey;
}
if ("query".equals(location)) {
queryParams.add(new Pair(paramName, value));
} else if ("header".equals(location)) {
headerParams.put(paramName, value);
}
String value;
if (apiKeyPrefix != null) {
value = apiKeyPrefix + " " + apiKey;
} else {
value = apiKey;
}
if ("query".equals(location)) {
queryParams.add(new Pair(paramName, value));
} else if ("header".equals(location)) {
headerParams.put(paramName, value);
}
}
}
......@@ -9,14 +9,17 @@
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
package nl.uva.sne.drip.sure.tosca.auth;
import java.util.Map;
import java.util.List;
import nl.uva.sne.drip.sure.tosca.client.Pair;
public interface Authentication {
/**
* Apply authentication settings to header and query params.
*
......
......@@ -20,6 +20,7 @@ import com.squareup.okhttp.Credentials;
import java.util.Map;
import java.util.List;
import java.io.UnsupportedEncodingException;
import nl.uva.sne.drip.sure.tosca.client.Pair;
public class HttpBasicAuth implements Authentication {
......
......@@ -19,7 +19,7 @@ import java.util.Map;
import java.util.List;
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 {
private String accessToken;
......
......@@ -13,7 +13,6 @@
package nl.uva.sne.drip.sure.tosca.client;
import java.io.IOException;
import java.util.Map;
import java.util.List;
......
......@@ -11,21 +11,17 @@
*/
package nl.uva.sne.drip.sure.tosca.client;
import com.fasterxml.jackson.databind.ObjectMapper;
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.logging.HttpLoggingInterceptor;
import com.squareup.okhttp.logging.HttpLoggingInterceptor.Level;
import okio.BufferedSink;
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.IOException;
import java.io.InputStream;
......@@ -41,14 +37,14 @@ import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.text.DateFormat;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
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.HttpBasicAuth;
import nl.uva.sne.drip.sure.tosca.auth.ApiKeyAuth;
import nl.uva.sne.drip.sure.tosca.auth.OAuth;
public class ApiClient {
......@@ -518,7 +514,7 @@ public class ApiClient {
* @return A list containing a single {@code Pair} object.
*/
public List<Pair> parameterToPair(String name, Object value) {
List<Pair> params = new ArrayList<>();
List<Pair> params = new ArrayList<Pair>();
// preconditions
if (name == null || name.isEmpty() || value == null || value instanceof Collection) {
......
......@@ -16,7 +16,7 @@ package nl.uva.sne.drip.sure.tosca.client;
import java.util.Map;
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 {
private int code = 0;
private Map<String, List<String>> responseHeaders = null;
......
......@@ -13,7 +13,7 @@
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 {
private static ApiClient defaultApiClient = new ApiClient();
......
......@@ -22,17 +22,9 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
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.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 {
......@@ -1297,12 +1289,12 @@ public class DefaultApi {
* @param hasRequirements filter if has requirements (optional)
* @param hasCapabilities filter if has capabilities (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
* 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 {
ApiResponse<List<NodeTemplate>> resp = getNodeTemplatesWithHttpInfo(id, typeName, nodeName, hasInterfaces, hasProperties, hasAttributes, hasRequirements, hasCapabilities, hasArtifacts);
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<NodeTemplateMap>> resp = getNodeTemplatesWithHttpInfo(id, typeName, nodeName, hasInterfaces, hasProperties, hasAttributes, hasRequirements, hasCapabilities, hasArtifacts);
return resp.getData();
}
......@@ -1319,13 +1311,13 @@ public class DefaultApi {
* @param hasRequirements filter if has requirements (optional)
* @param hasCapabilities filter if has capabilities (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
* 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);
Type localVarReturnType = new TypeToken<List<NodeTemplate>>() {
Type localVarReturnType = new TypeToken<List<NodeTemplateMap>>() {
}.getType();
return apiClient.execute(call, localVarReturnType);
}
......@@ -1347,7 +1339,7 @@ public class DefaultApi {
* @throws ApiException If fail to process the API call, e.g. serializing
* 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;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
......@@ -1369,7 +1361,7 @@ public class DefaultApi {
}
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();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
......@@ -1730,12 +1722,12 @@ public class DefaultApi {
*
* @param id ID of topolog template uplodaed (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
* deserialize the response body
*/
public List<NodeTemplate> getRelatedNodes(String id, String nodeName) throws ApiException {
ApiResponse<List<NodeTemplate>> resp = getRelatedNodesWithHttpInfo(id, nodeName);
public List<NodeTemplateMap> getRelatedNodes(String id, String nodeName) throws ApiException {
ApiResponse<List<NodeTemplateMap>> resp = getRelatedNodesWithHttpInfo(id, nodeName);
return resp.getData();
}
......@@ -1745,13 +1737,13 @@ public class DefaultApi {
*
* @param id ID of topolog template uplodaed (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
* 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);
Type localVarReturnType = new TypeToken<List<NodeTemplate>>() {
Type localVarReturnType = new TypeToken<List<NodeTemplateMap>>() {
}.getType();
return apiClient.execute(call, localVarReturnType);
}
......@@ -1766,7 +1758,7 @@ public class DefaultApi {
* @throws ApiException If fail to process the API call, e.g. serializing
* 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;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
......@@ -1788,7 +1780,7 @@ public class DefaultApi {
}
com.squareup.okhttp.Call call = getRelatedNodesValidateBeforeCall(id, nodeName, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken<List<NodeTemplate>>() {
Type localVarReturnType = new TypeToken<List<NodeTemplateMap>>() {
}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
......
......@@ -120,6 +120,7 @@ public class JSON {
* @param returnType The type to deserialize into
* @return The deserialized Java object
*/
@SuppressWarnings("unchecked")
public <T> T deserialize(String body, Type returnType) {
try {
if (isLenientOnJson) {
......
......@@ -13,7 +13,7 @@
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 {
private String name = "";
private String value = "";
......
......@@ -13,7 +13,7 @@
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 {
/**
* Check if the given array contains the given value (with case-insensitive comparison).
......
......@@ -36,6 +36,7 @@ import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import nl.uva.sne.drip.model.NodeTemplate;
import nl.uva.sne.drip.model.NodeTemplateMap;
import nl.uva.sne.drip.model.tosca.ToscaTemplate;
import org.junit.After;
import org.junit.AfterClass;
......@@ -131,10 +132,10 @@ public class ToscaHelperTest {
public void testGetVMTopologyTemplates() throws ApiException {
if (serviceUp) {
System.out.println("getVMTopologyTemplates");
List<NodeTemplate> result = instance.getVMTopologyTemplates();
List<NodeTemplateMap> result = instance.getVMTopologyTemplates();
assertNotNull(result);
for (NodeTemplate nodeTemplate : result) {
assertEquals(nodeTemplate.getType(), "tosca.nodes.ARTICONF.VM.topology");
for (NodeTemplateMap nodeTemplateMap : result) {
assertEquals(nodeTemplateMap.getNodeTemplate().getType(), "tosca.nodes.ARTICONF.VM.topology");
}
}
}
......
......@@ -14,6 +14,7 @@ import java.util.logging.Logger;
import nl.uva.sne.drip.commons.utils.ToscaHelper;
import nl.uva.sne.drip.model.Message;
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.ToscaTemplate;
import nl.uva.sne.drip.rpc.DRIPCaller;
......@@ -94,15 +95,15 @@ public class DRIPService {
private ToscaTemplate addCredentials(ToscaTemplate toscaTemplate) throws IOException, JsonProcessingException, ApiException, Exception {
helper.uploadToscaTemplate(toscaTemplate);
List<NodeTemplate> vmTopologies = helper.getVMTopologyTemplates();
List<NodeTemplateMap> vmTopologies = helper.getVMTopologyTemplates();
List<Credential> credentials = null;
for (NodeTemplate vmTopology : vmTopologies) {
String provider = helper.getTopologyProvider(vmTopology);
for (NodeTemplateMap vmTopologyMap : vmTopologies) {
String provider = helper.getTopologyProvider(vmTopologyMap);
credentials = credentialService.findByProvider(provider.toLowerCase());
if (credentials != null && credentials.size() > 0) {
Credential credential = getBestCredential(vmTopology, credentials);
vmTopology = helper.setCredentialsInVMTopology(vmTopology, credential);
toscaTemplate = helper.setVMTopologyInToscaTemplate(toscaTemplate,vmTopology);
Credential credential = getBestCredential(vmTopologyMap.getNodeTemplate(), credentials);
vmTopologyMap = helper.setCredentialsInVMTopology(vmTopologyMap, credential);
toscaTemplate = helper.setVMTopologyInToscaTemplate(toscaTemplate, vmTopologyMap.getNodeTemplate());
return toscaTemplate;
}
}
......
......@@ -25,6 +25,7 @@ import java.util.Properties;
import nl.uva.sne.drip.commons.utils.ToscaHelper;
import nl.uva.sne.drip.model.cloud.storm.CloudsStormVM;
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.CloudsStormTopTopology;
import nl.uva.sne.drip.model.cloud.storm.CloudsStormVMs;
......@@ -119,15 +120,15 @@ class CloudStormService {
}
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<>();
Map<String, Object> cloudsStormMap = new HashMap<>();
List<CloudsStormVMs> cloudsStormVMsList = new ArrayList<>();
int i = 0;
for (NodeTemplate nodeTemplate : vmTopologyTemplates) {
for (NodeTemplateMap nodeTemplateMap : vmTopologyTemplatesMap) {
CloudsStormSubTopology cloudsStormSubTopology = new CloudsStormSubTopology();
String domain = helper.getTopologyDomain(nodeTemplate);
String provider = helper.getTopologyProvider(nodeTemplate);
String domain = helper.getTopologyDomain(nodeTemplateMap);
String provider = helper.getTopologyProvider(nodeTemplateMap);
cloudsStormSubTopology.setDomain(domain);
cloudsStormSubTopology.setCloudProvider(provider);
cloudsStormSubTopology.setTopology("vm_topology" + i);
......@@ -136,14 +137,14 @@ class CloudStormService {
List<CloudsStormVM> vms = new ArrayList<>();
cloudsStormVMs.setName("vm_topology" + i);
List<NodeTemplate> vmTemplates = helper.getTemplateVMsForVMTopology(nodeTemplate);
List<NodeTemplateMap> vmTemplatesMap = helper.getTemplateVMsForVMTopology(nodeTemplateMap);
int j = 0;
for (NodeTemplate vm : vmTemplates) {
for (NodeTemplateMap vmMap : vmTemplatesMap) {
CloudsStormVM cloudsStormVM = new CloudsStormVM();
String vmType = getVMType(vm, provider);
String vmType = getVMType(vmMap, provider);
cloudsStormVM.setNodeType(vmType);
cloudsStormVM.setName("vm" + j);
String os = helper.getVMNOS(vm);
String os = helper.getVMNOS(vmMap);
cloudsStormVM.setOsType(os);
vms.add(cloudsStormVM);
j++;
......@@ -160,10 +161,10 @@ class CloudStormService {
return cloudsStormMap;
}
private String getVMType(NodeTemplate vm, String provider) throws IOException, Exception {
Double numOfCores = helper.getVMNumOfCores(vm);
Double memSize = helper.getVMNMemSize(vm);
String os = helper.getVMNOS(vm);
private String getVMType(NodeTemplateMap vmMap, String provider) throws IOException, Exception {
Double numOfCores = helper.getVMNumOfCores(vmMap);
Double memSize = helper.getVMNMemSize(vmMap);
String os = helper.getVMNOS(vmMap);
List<VMMetaInfo> vmInfos = cloudStormDAO.findVmMetaInfoByProvider(provider);
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())) {
......@@ -174,9 +175,9 @@ class CloudStormService {
}
private void writeCloudStormCredentialsFiles(ToscaTemplate toscaTemplate, String credentialsTempInputDirPath) throws ApiException, Exception {
List<NodeTemplate> vmTopologies = helper.getVMTopologyTemplates();
for (NodeTemplate vmTopology : vmTopologies) {
Credential credentials = helper.getCredentialsFromVMTopology(vmTopology);
List<NodeTemplateMap> vmTopologiesMaps = helper.getVMTopologyTemplates();
for (NodeTemplateMap vmTopologyMap : vmTopologiesMaps) {
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