Commit 3dc7c5e2 authored by Spiros Koulouzis's avatar Spiros Koulouzis

rebuild client

parent 4cf842b3
......@@ -45,4 +45,5 @@
/spring-server-generated/target/
/manager-services/target/
/drip-manager-services/nbproject/
/drip-manager-services/target/
\ No newline at end of file
/drip-manager-services/target/
/drip-provisioner/nbproject/
\ No newline at end of file
/*
* 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.auth;
import nl.uva.sne.drip.commons.sure_tosca.client.Pair;
import java.util.Map;
import java.util.List;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2019-11-01T13:11:24.211Z")
public class ApiKeyAuth implements Authentication {
private final String location;
private final String paramName;
private String apiKey;
private String apiKeyPrefix;
public ApiKeyAuth(String location, String paramName) {
this.location = location;
this.paramName = paramName;
}
public String getLocation() {
return location;
}
public String getParamName() {
return paramName;
}
public String getApiKey() {
return apiKey;
}
public void setApiKey(String apiKey) {
this.apiKey = apiKey;
}
public String getApiKeyPrefix() {
return apiKeyPrefix;
}
public void setApiKeyPrefix(String apiKeyPrefix) {
this.apiKeyPrefix = apiKeyPrefix;
}
@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);
}
}
}
......@@ -25,12 +25,12 @@ 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.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.model.NodeTemplate;
import nl.uva.sne.drip.model.ToscaTemplate;
import nl.uva.sne.drip.sure_tosca.DefaultApi;
import org.apache.commons.io.FileUtils;
import nl.uva.sne.drip.sure_tosca.client.ApiException;
import nl.uva.sne.drip.sure_tosca.client.Configuration;
/**
*
......@@ -80,9 +80,13 @@ public class ToscaHelper {
return interfaceDefinitions;
}
public List<NodeTemplate> getVMTopologyTemplates(ToscaTemplate toscaTemplate) throws ApiException {
List<NodeTemplate> vmTopologyTemplates = api.getNodeTemplates(String.valueOf(id), "tosca.nodes.ARTICONF.VM.topology", null, null, null, null, null, null, null, null);
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);
return vmTopologyTemplates;
}
public ToscaTemplate execute() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}
package nl.uva.sne.drip.commons.sure_tosca.client;
/*
* tosca-sure
* TOSCA Simple qUeRy sErvice (SURE).
......@@ -11,6 +9,7 @@ package nl.uva.sne.drip.commons.sure_tosca.client;
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
package nl.uva.sne.drip.sure_tosca;
import com.google.gson.reflect.TypeToken;
......@@ -26,6 +25,14 @@ import java.util.Map;
import nl.uva.sne.drip.model.NodeTemplate;
import nl.uva.sne.drip.model.TopologyTemplate;
import nl.uva.sne.drip.model.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 {
......@@ -1193,13 +1200,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)
* @param derivedFrom derived from (optional)
* @param progressListener Progress listener
* @param progressRequestListener Progress request listener
* @return Call to execute
* @throws ApiException If fail to serialize the request body object
*/
public com.squareup.okhttp.Call getNodeTemplatesCall(String id, String typeName, String nodeName, Boolean hasInterfaces, Boolean hasProperties, Boolean hasAttributes, Boolean hasRequirements, Boolean hasCapabilities, Boolean hasArtifacts, String derivedFrom, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
public com.squareup.okhttp.Call getNodeTemplatesCall(String id, String typeName, String nodeName, Boolean hasInterfaces, Boolean hasProperties, Boolean hasAttributes, Boolean hasRequirements, Boolean hasCapabilities, Boolean hasArtifacts, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
Object localVarPostBody = null;
// create path and map variables
......@@ -1232,9 +1238,6 @@ public class DefaultApi {
if (hasArtifacts != null) {
localVarQueryParams.addAll(apiClient.parameterToPair("has_artifacts", hasArtifacts));
}
if (derivedFrom != null) {
localVarQueryParams.addAll(apiClient.parameterToPair("derived_from", derivedFrom));
}
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
......@@ -1269,14 +1272,14 @@ public class DefaultApi {
}
@SuppressWarnings("rawtypes")
private com.squareup.okhttp.Call getNodeTemplatesValidateBeforeCall(String id, String typeName, String nodeName, Boolean hasInterfaces, Boolean hasProperties, Boolean hasAttributes, Boolean hasRequirements, Boolean hasCapabilities, Boolean hasArtifacts, String derivedFrom, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
private com.squareup.okhttp.Call getNodeTemplatesValidateBeforeCall(String id, String typeName, String nodeName, Boolean hasInterfaces, Boolean hasProperties, Boolean hasAttributes, Boolean hasRequirements, Boolean hasCapabilities, Boolean hasArtifacts, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
// verify the required parameter 'id' is set
if (id == null) {
throw new ApiException("Missing the required parameter 'id' when calling getNodeTemplates(Async)");
}
com.squareup.okhttp.Call call = getNodeTemplatesCall(id, typeName, nodeName, hasInterfaces, hasProperties, hasAttributes, hasRequirements, hasCapabilities, hasArtifacts, derivedFrom, progressListener, progressRequestListener);
com.squareup.okhttp.Call call = getNodeTemplatesCall(id, typeName, nodeName, hasInterfaces, hasProperties, hasAttributes, hasRequirements, hasCapabilities, hasArtifacts, progressListener, progressRequestListener);
return call;
}
......@@ -1294,13 +1297,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)
* @param derivedFrom derived from (optional)
* @return List&lt;NodeTemplate&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, String derivedFrom) throws ApiException {
ApiResponse<List<NodeTemplate>> resp = getNodeTemplatesWithHttpInfo(id, typeName, nodeName, hasInterfaces, hasProperties, hasAttributes, hasRequirements, hasCapabilities, hasArtifacts, derivedFrom);
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);
return resp.getData();
}
......@@ -1317,13 +1319,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)
* @param derivedFrom derived from (optional)
* @return ApiResponse&lt;List&lt;NodeTemplate&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, String derivedFrom) throws ApiException {
com.squareup.okhttp.Call call = getNodeTemplatesValidateBeforeCall(id, typeName, nodeName, hasInterfaces, hasProperties, hasAttributes, hasRequirements, hasCapabilities, hasArtifacts, derivedFrom, null, null);
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 {
com.squareup.okhttp.Call call = getNodeTemplatesValidateBeforeCall(id, typeName, nodeName, hasInterfaces, hasProperties, hasAttributes, hasRequirements, hasCapabilities, hasArtifacts, null, null);
Type localVarReturnType = new TypeToken<List<NodeTemplate>>() {
}.getType();
return apiClient.execute(call, localVarReturnType);
......@@ -1341,13 +1342,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)
* @param derivedFrom derived from (optional)
* @param callback The callback to be executed when the API call finishes
* @return The request call
* @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, String derivedFrom, 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<NodeTemplate>> callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
......@@ -1368,7 +1368,7 @@ public class DefaultApi {
};
}
com.squareup.okhttp.Call call = getNodeTemplatesValidateBeforeCall(id, typeName, nodeName, hasInterfaces, hasProperties, hasAttributes, hasRequirements, hasCapabilities, hasArtifacts, derivedFrom, 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>>() {
}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
......
/*
* 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.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")
public class ApiKeyAuth implements Authentication {
private final String location;
private final String paramName;
private String apiKey;
private String apiKeyPrefix;
public ApiKeyAuth(String location, String paramName) {
this.location = location;
this.paramName = paramName;
}
public String getLocation() {
return location;
}
public String getParamName() {
return paramName;
}
public String getApiKey() {
return apiKey;
}
public void setApiKey(String apiKey) {
this.apiKey = apiKey;
}
public String getApiKeyPrefix() {
return apiKeyPrefix;
}
public void setApiKeyPrefix(String apiKeyPrefix) {
this.apiKeyPrefix = apiKeyPrefix;
}
@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);
}
}
}
......@@ -9,16 +9,14 @@
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
package nl.uva.sne.drip.auth;
import nl.uva.sne.drip.commons.sure_tosca.client.Pair;
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.
*
......
......@@ -11,16 +11,16 @@
*/
package nl.uva.sne.drip.auth;
package nl.uva.sne.drip.sure_tosca.auth;
import nl.uva.sne.drip.commons.sure_tosca.client.Pair;
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 {
private String username;
......
......@@ -11,14 +11,15 @@
*/
package nl.uva.sne.drip.auth;
package nl.uva.sne.drip.sure_tosca.auth;
import nl.uva.sne.drip.commons.sure_tosca.client.Pair;
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-11-01T13:11:24.211Z")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2019-12-09T20:19:44.689Z")
public class OAuth implements Authentication {
private String accessToken;
......
......@@ -11,7 +11,7 @@
*/
package nl.uva.sne.drip.auth;
package nl.uva.sne.drip.sure_tosca.auth;
public enum OAuthFlow {
accessCode, implicit, password, application
......
package nl.uva.sne.drip.commons.sure_tosca.client;
/*
* tosca-sure
* TOSCA Simple qUeRy sErvice (SURE).
......@@ -12,6 +11,8 @@ package nl.uva.sne.drip.commons.sure_tosca.client;
*/
package nl.uva.sne.drip.sure_tosca.client;
import java.io.IOException;
import java.util.Map;
......
......@@ -11,12 +11,12 @@
*/
package nl.uva.sne.drip.commons.sure_tosca.client;
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-11-01T13:11:24.211Z")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2019-12-09T20:19:44.689Z")
public class ApiException extends Exception {
private int code = 0;
private Map<String, List<String>> responseHeaders = null;
......
......@@ -11,7 +11,7 @@
*/
package nl.uva.sne.drip.commons.sure_tosca.client;
package nl.uva.sne.drip.sure_tosca.client;
import java.util.List;
import java.util.Map;
......
......@@ -11,9 +11,9 @@
*/
package nl.uva.sne.drip.commons.sure_tosca.client;
package nl.uva.sne.drip.sure_tosca.client;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2019-11-01T13:11:24.211Z")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2019-12-09T20:19:44.689Z")
public class Configuration {
private static ApiClient defaultApiClient = new ApiClient();
......
......@@ -11,7 +11,7 @@
*/
package nl.uva.sne.drip.commons.sure_tosca.client;
package nl.uva.sne.drip.sure_tosca.client;
import com.squareup.okhttp.*;
import okio.Buffer;
......
......@@ -11,7 +11,7 @@
*/
package nl.uva.sne.drip.commons.sure_tosca.client;
package nl.uva.sne.drip.sure_tosca.client;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
......
......@@ -11,9 +11,9 @@
*/
package nl.uva.sne.drip.commons.sure_tosca.client;
package nl.uva.sne.drip.sure_tosca.client;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2019-11-01T13:11:24.211Z")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2019-12-09T20:19:44.689Z")
public class Pair {
private String name = "";
private String value = "";
......
......@@ -11,7 +11,7 @@
*/
package nl.uva.sne.drip.commons.sure_tosca.client;
package nl.uva.sne.drip.sure_tosca.client;
import com.squareup.okhttp.MediaType;
import com.squareup.okhttp.RequestBody;
......
......@@ -11,7 +11,7 @@
*/
package nl.uva.sne.drip.commons.sure_tosca.client;
package nl.uva.sne.drip.sure_tosca.client;
import com.squareup.okhttp.MediaType;
import com.squareup.okhttp.ResponseBody;
......
......@@ -11,9 +11,9 @@
*/
package nl.uva.sne.drip.commons.sure_tosca.client;
package nl.uva.sne.drip.sure_tosca.client;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2019-11-01T13:11:24.211Z")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2019-12-09T20:19:44.689Z")
public class StringUtil {
/**
* Check if the given array contains the given value (with case-insensitive comparison).
......
/*
* Copyright 2019 S. Koulouzis
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.commons.utils;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator;
import java.io.File;
import java.io.FileInputStream;
import java.nio.file.Files;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import nl.uva.sne.drip.model.NodeTemplate;
import nl.uva.sne.drip.model.ToscaTemplate;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
import nl.uva.sne.drip.sure_tosca.client.ApiException;
/**
*
* @author S.Koulouzis
*/
public class ToscaHelperTest {
private static ObjectMapper objectMapper;
private static final String testUpdatedApplicationExampleToscaFilePath = ".." + File.separator + "TOSCA" + File.separator + "application_example_2_topologies.yaml";
private static ToscaHelper instance;
private static ToscaTemplate toscaTemplate;
public ToscaHelperTest() {
}
@BeforeClass
public static void setUpClass() throws UnsupportedEncodingException, JsonProcessingException, IOException, ApiException {
Properties prop = new Properties();
String resourceName = "src/test/resources/application.properties";
prop.load(new FileInputStream(resourceName));
byte[] bytes = Files.readAllBytes(Paths.get(testUpdatedApplicationExampleToscaFilePath));
String ymlStr = new String(bytes, "UTF-8");
objectMapper = new ObjectMapper(new YAMLFactory().disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER));
toscaTemplate = objectMapper.readValue(ymlStr, ToscaTemplate.class);
instance = new ToscaHelper(toscaTemplate, prop.getProperty("sure-tosca.base.path"));
}
@AfterClass
public static void tearDownClass() {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/**
* Test of getId method, of class ToscaHelper.
*/
@Test
public void testGetId() {
System.out.println("getId");
Integer result = instance.getId();
assertNotNull(result);
}
/**
* Test of getProvisionInterfaceDefinitions method, of class ToscaHelper.
*/
@Test
public void testGetProvisionInterfaceDefinitions() throws Exception {
System.out.println("getProvisionInterfaceDefinitions");
List<String> toscaInterfaceTypes = new ArrayList<>();
toscaInterfaceTypes.add("tosca.interfaces.ARTICONF.CloudsStorm");
List<Map<String, Object>> result = instance.getProvisionInterfaceDefinitions(toscaInterfaceTypes);
assertNotNull(result);
}
/**
* Test of getVMTopologyTemplates method, of class ToscaHelper.
*/
@Test
public void testGetVMTopologyTemplates() throws Exception {
System.out.println("getVMTopologyTemplates");
List<NodeTemplate> result = instance.getVMTopologyTemplates();
assertNotNull(result);
for(NodeTemplate nodeTemplate:result){
assertEquals(nodeTemplate.getType(), "tosca.nodes.ARTICONF.VM.topology");
}
}
}
message.broker.host=127.0.0.1
message.broker.username=guest
message.broker.password=guest
message.broker.queue.provisioner=provisioner
message.broker.queue.planner=planner
message.broker.queue.deployer=deployer
sure-tosca.base.path=http://localhost:8081/tosca-sure/1.0.0
......@@ -49,6 +49,18 @@
<version>0.1.54</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
</dependencies>
......
......@@ -13,14 +13,12 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import nl.uva.sne.drip.commons.sure_tosca.client.ApiException;
import nl.uva.sne.drip.commons.utils.ToscaHelper;
import nl.uva.sne.drip.model.CloudsStormSubTopology;
import nl.uva.sne.drip.model.CloudsStormTopTopology;
import nl.uva.sne.drip.model.CloudsStormVM;
import nl.uva.sne.drip.model.NodeTemplate;
import nl.uva.sne.drip.model.ToscaTemplate;
import org.apache.commons.io.FilenameUtils;
......@@ -30,41 +28,41 @@ import org.apache.commons.io.FilenameUtils;
* @author S. Koulouzis
*/
class CloudStormService {
private List<Map.Entry> vmTopologies;
private String tempInputDirPath;
private final ToscaTemplate toscaTemplate;
private final ToscaHelper helper;
CloudStormService(String sureToscaBasePath,ToscaTemplate toscaTemplate) throws IOException, JsonProcessingException, ApiException {
this.toscaTemplate = toscaTemplate;
this.helper = new ToscaHelper(toscaTemplate, sureToscaBasePath);
CloudStormService(String sureToscaBasePath, ToscaTemplate toscaTemplate) throws IOException, JsonProcessingException, ApiException {
this.toscaTemplate = toscaTemplate;
this.helper = new ToscaHelper(toscaTemplate, sureToscaBasePath);
}
ToscaTemplate execute() throws FileNotFoundException, JSchException, IOException {
public ToscaTemplate execute() throws FileNotFoundException, JSchException, IOException, ApiException {
tempInputDirPath = System.getProperty("java.io.tmpdir") + File.separator + "Input-" + Long.toString(System.nanoTime()) + File.separator;
File tempInputDir = new File(tempInputDirPath);
if (!(tempInputDir.mkdirs())) {
throw new FileNotFoundException("Could not create input directory: " + tempInputDir.getAbsolutePath());
}
buildCloudStormTopTopology(toscaTemplate);
return toscaTemplate;
}
private CloudsStormTopTopology buildCloudStormTopTopology(ToscaTemplate toscaTemplate) throws JSchException, IOException {
private CloudsStormTopTopology buildCloudStormTopTopology(ToscaTemplate toscaTemplate) throws JSchException, IOException, ApiException {
CloudsStormTopTopology topTopology = new CloudsStormTopTopology();
String publicKeyPath = buildSSHKeyPair();
topTopology.setPublicKeyPath(publicKeyPath);
topTopology.setUserName(getUserName());
List<CloudsStormSubTopology> topologies = getCloudsStormSubTopologies(toscaTemplate);
topTopology.setTopologies(topologies);
return topTopology;
}
private String buildSSHKeyPair() throws JSchException, IOException {
String userPublicKeyName = "id_rsa.pub";
String publicKeyPath = "name@" + userPublicKeyName;
......@@ -76,29 +74,32 @@ class CloudStormService {
kpair.dispose();
return publicKeyPath;
}
private String getUserName() {
return "vm_user";
}
private List<CloudsStormSubTopology> getCloudsStormSubTopologies(ToscaTemplate toscaTemplate) throws ApiException {
List<NodeTemplate> vmTopologyTemplates = helper.getVMTopologyTemplates(toscaTemplate);
List<NodeTemplate> vmTopologyTemplates = helper.getVMTopologyTemplates();
List<CloudsStormSubTopology> cloudsStormSubTopologies = new ArrayList<>();
for(NodeTemplate nodeTemplate: vmTopologyTemplates){
int i = 0;
for (NodeTemplate nodeTemplate : vmTopologyTemplates) {
CloudsStormSubTopology cloudsStormSubTopology = new CloudsStormSubTopology();
Map<String, Object> properties = nodeTemplate.getProperties();
String domain = (String) properties.get("domain");
String provider = (String) properties.get("provider");
cloudsStormSubTopology.setCloudProvider(domain);
cloudsStormSubTopology.setCloudProvider(provider);
cloudsStormSubTopology.setTopology("vm");
cloudsStormSubTopology.setTopology("vm_topology" + i);
// List<NodeTemplate> vmTopologyTemplates = helper.getVMTemplatesForTopology();
// CloudsStormVM cloudsStormVM = new CloudsStormVM();
// cloudsStormVM.setName("node"+i);
// cloudsStormVM.setNodeType(domain);
i++;
}
// List<CloudsStormVM> vms = new ArrayList<>();
// CloudsStormVM cloudsStormVM = new CloudsStormVM();
// cloudsStormVM.setName("Node1");
......@@ -106,5 +107,5 @@ class CloudStormService {
// vms.add(cloudsStormVM);
return cloudsStormSubTopologies;
}
}
message.broker.host=127.0.0.1
message.broker.username=guest
message.broker.password=guest
message.broker.queue.provisioner=provisioner
\ No newline at end of file
message.broker.queue.provisioner=provisioner
message.broker.queue.planner=planner
message.broker.queue.deployer=deployer
sure-tosca.base.path=http://localhost:8081/tosca-sure/1.0.0
/*
* 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.provisioner;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Properties;
import nl.uva.sne.drip.commons.sure_tosca.client.ApiException;
import nl.uva.sne.drip.commons.utils.ToscaHelper;
import nl.uva.sne.drip.model.ToscaTemplate;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author alogo
*/
public class CloudStormServiceTest {
private static ObjectMapper objectMapper;
private static final String testUpdatedApplicationExampleToscaFilePath = ".." + File.separator + "TOSCA" + File.separator + "application_example_2_topologies.yaml";
private static CloudStormService instance;
private static ToscaTemplate toscaTemplate;
public CloudStormServiceTest() {
}
@BeforeClass
public static void setUpClass() throws FileNotFoundException, IOException, JsonProcessingException, ApiException {
Properties prop = new Properties();
String resourceName = "src/test/resources/application.properies";
prop.load(new FileInputStream(resourceName));
byte[] bytes = Files.readAllBytes(Paths.get(testUpdatedApplicationExampleToscaFilePath));
String ymlStr = new String(bytes, "UTF-8");
objectMapper = new ObjectMapper(new YAMLFactory().disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER));
toscaTemplate = objectMapper.readValue(ymlStr, ToscaTemplate.class);
instance = new CloudStormService(prop.getProperty("sure-tosca.base.path"), toscaTemplate);
}
@AfterClass
public static void tearDownClass() {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/**
* Test of execute method, of class CloudStormService.
*/
@Test
public void testExecute() throws Exception {
System.out.println("execute");
ToscaTemplate expResult = null;
ToscaTemplate result = instance.execute();
}
}
message.broker.host=127.0.0.1
message.broker.username=guest
message.broker.password=guest
message.broker.queue.provisioner=provisioner
message.broker.queue.planner=planner
message.broker.queue.deployer=deployer
sure-tosca.base.path=http://localhost:8081/tosca-sure/1.0.0
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