Commit 8e781faa authored by Spiros Koulouzis's avatar Spiros Koulouzis

added client

parent 9e9ab47b
......@@ -12,6 +12,12 @@
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<springfox-version>2.9.2</springfox-version>
<gson-fire-version>1.8.3</gson-fire-version>
<swagger-core-version>1.5.24</swagger-core-version>
<okhttp-version>2.7.5</okhttp-version>
<gson-version>2.8.6</gson-version>
<threetenbp-version>1.4.0</threetenbp-version>
</properties>
<parent>
<groupId>nl.uva.sne.drip</groupId>
......@@ -51,6 +57,39 @@
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>${swagger-core-version}</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>okhttp</artifactId>
<version>${okhttp-version}</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>logging-interceptor</artifactId>
<version>${okhttp-version}</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${gson-version}</version>
</dependency>
<dependency>
<groupId>io.gsonfire</groupId>
<artifactId>gson-fire</artifactId>
<version>${gson-fire-version}</version>
</dependency>
<dependency>
<groupId>org.threeten</groupId>
<artifactId>threetenbp</artifactId>
<version>1.3.2</version>
<type>jar</type>
</dependency>
<!-- Bean Validation API support -->
<dependency>
......@@ -84,6 +123,12 @@
<version>2.1.10.RELEASE</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
<type>jar</type>
</dependency>
</dependencies>
......
/*
* 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);
}
}
}
/*
* 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;
public interface Authentication {
/**
* Apply authentication settings to header and query params.
*
* @param queryParams List of query parameters
* @param headerParams Map of header parameters
*/
void applyToParams(List<Pair> queryParams, Map<String, String> headerParams);
}
/*
* 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 com.squareup.okhttp.Credentials;
import java.util.Map;
import java.util.List;
import java.io.UnsupportedEncodingException;
public class HttpBasicAuth implements Authentication {
private String username;
private String password;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) {
if (username == null && password == null) {
return;
}
headerParams.put("Authorization", Credentials.basic(
username == null ? "" : username,
password == null ? "" : password));
}
}
/*
* 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 OAuth implements Authentication {
private String accessToken;
public String getAccessToken() {
return accessToken;
}
public void setAccessToken(String accessToken) {
this.accessToken = accessToken;
}
@Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) {
if (accessToken != null) {
headerParams.put("Authorization", "Bearer " + accessToken);
}
}
}
/*
* 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;
public enum OAuthFlow {
accessCode, implicit, password, application
}
package nl.uva.sne.drip.commons.sure_tosca.client;
/*
* 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.
*/
import java.io.IOException;
import java.util.Map;
import java.util.List;
/**
* Callback for asynchronous API call.
*
* @param <T> The return type
*/
public interface ApiCallback<T> {
/**
* This is called when the API call fails.
*
* @param e The exception causing the failure
* @param statusCode Status code of the response if available, otherwise it would be 0
* @param responseHeaders Headers of the response if available, otherwise it would be null
*/
void onFailure(ApiException e, int statusCode, Map<String, List<String>> responseHeaders);
/**
* This is called when the API call succeeded.
*
* @param result The result deserialized from response
* @param statusCode Status code of the response
* @param responseHeaders Headers of the response
*/
void onSuccess(T result, int statusCode, Map<String, List<String>> responseHeaders);
/**
* This is called when the API upload processing.
*
* @param bytesWritten bytes Written
* @param contentLength content length of request body
* @param done write end
*/
void onUploadProgress(long bytesWritten, long contentLength, boolean done);
/**
* This is called when the API downlond processing.
*
* @param bytesRead bytes Read
* @param contentLength content lenngth of the response
* @param done Read end
*/
void onDownloadProgress(long bytesRead, long contentLength, boolean done);
}
/*
* 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.commons.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")
public class ApiException extends Exception {
private int code = 0;
private Map<String, List<String>> responseHeaders = null;
private String responseBody = null;
public ApiException() {}
public ApiException(Throwable throwable) {
super(throwable);
}
public ApiException(String message) {
super(message);
}
public ApiException(String message, Throwable throwable, int code, Map<String, List<String>> responseHeaders, String responseBody) {
super(message, throwable);
this.code = code;
this.responseHeaders = responseHeaders;
this.responseBody = responseBody;
}
public ApiException(String message, int code, Map<String, List<String>> responseHeaders, String responseBody) {
this(message, (Throwable) null, code, responseHeaders, responseBody);
}
public ApiException(String message, Throwable throwable, int code, Map<String, List<String>> responseHeaders) {
this(message, throwable, code, responseHeaders, null);
}
public ApiException(int code, Map<String, List<String>> responseHeaders, String responseBody) {
this((String) null, (Throwable) null, code, responseHeaders, responseBody);
}
public ApiException(int code, String message) {
super(message);
this.code = code;
}
public ApiException(int code, String message, Map<String, List<String>> responseHeaders, String responseBody) {
this(code, message);
this.responseHeaders = responseHeaders;
this.responseBody = responseBody;
}
/**
* Get the HTTP status code.
*
* @return HTTP status code
*/
public int getCode() {
return code;
}
/**
* Get the HTTP response headers.
*
* @return A map of list of string
*/
public Map<String, List<String>> getResponseHeaders() {
return responseHeaders;
}
/**
* Get the HTTP response body.
*
* @return Response body in the form of string
*/
public String getResponseBody() {
return responseBody;
}
}
/*
* 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.commons.sure_tosca.client;
import java.util.List;
import java.util.Map;
/**
* API response returned by API call.
*
* @param <T> The type of data that is deserialized from response body
*/
public class ApiResponse<T> {
final private int statusCode;
final private Map<String, List<String>> headers;
final private T data;
/**
* @param statusCode The status code of HTTP response
* @param headers The headers of HTTP response
*/
public ApiResponse(int statusCode, Map<String, List<String>> headers) {
this(statusCode, headers, null);
}
/**
* @param statusCode The status code of HTTP response
* @param headers The headers of HTTP response
* @param data The object deserialized from response bod
*/
public ApiResponse(int statusCode, Map<String, List<String>> headers, T data) {
this.statusCode = statusCode;
this.headers = headers;
this.data = data;
}
public int getStatusCode() {
return statusCode;
}
public Map<String, List<String>> getHeaders() {
return headers;
}
public T getData() {
return data;
}
}
/*
* 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.commons.sure_tosca.client;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2019-11-01T13:11:24.211Z")
public class Configuration {
private static ApiClient defaultApiClient = new ApiClient();
/**
* Get the default API client, which would be used when creating API
* instances without providing an API client.
*
* @return Default API client
*/
public static ApiClient getDefaultApiClient() {
return defaultApiClient;
}
/**
* Set the default API client, which would be used when creating API
* instances without providing an API client.
*
* @param apiClient API client
*/
public static void setDefaultApiClient(ApiClient apiClient) {
defaultApiClient = apiClient;
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
/*
* 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.commons.sure_tosca.client;
import com.squareup.okhttp.*;
import okio.Buffer;
import okio.BufferedSink;
import okio.GzipSink;
import okio.Okio;
import java.io.IOException;
/**
* Encodes request bodies using gzip.
*
* Taken from https://github.com/square/okhttp/issues/350
*/
class GzipRequestInterceptor implements Interceptor {
@Override public Response intercept(Chain chain) throws IOException {
Request originalRequest = chain.request();
if (originalRequest.body() == null || originalRequest.header("Content-Encoding") != null) {
return chain.proceed(originalRequest);
}
Request compressedRequest = originalRequest.newBuilder()
.header("Content-Encoding", "gzip")
.method(originalRequest.method(), forceContentLength(gzip(originalRequest.body())))
.build();
return chain.proceed(compressedRequest);
}
private RequestBody forceContentLength(final RequestBody requestBody) throws IOException {
final Buffer buffer = new Buffer();
requestBody.writeTo(buffer);
return new RequestBody() {
@Override
public MediaType contentType() {
return requestBody.contentType();
}
@Override
public long contentLength() {
return buffer.size();
}
@Override
public void writeTo(BufferedSink sink) throws IOException {
sink.write(buffer.snapshot());
}
};
}
private RequestBody gzip(final RequestBody body) {
return new RequestBody() {
@Override public MediaType contentType() {
return body.contentType();
}
@Override public long contentLength() {
return -1; // We don't know the compressed length in advance!
}
@Override public void writeTo(BufferedSink sink) throws IOException {
BufferedSink gzipSink = Okio.buffer(new GzipSink(sink));
body.writeTo(gzipSink);
gzipSink.close();
}
};
}
}
\ 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.commons.sure_tosca.client;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2019-11-01T13:11:24.211Z")
public class Pair {
private String name = "";
private String value = "";
public Pair (String name, String value) {
setName(name);
setValue(value);
}
private void setName(String name) {
if (!isValidString(name)) return;
this.name = name;
}
private void setValue(String value) {
if (!isValidString(value)) return;
this.value = value;
}
public String getName() {
return this.name;
}
public String getValue() {
return this.value;
}
private boolean isValidString(String arg) {
if (arg == null) return false;
if (arg.trim().isEmpty()) return false;
return true;
}
}
/*
* 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.commons.sure_tosca.client;
import com.squareup.okhttp.MediaType;
import com.squareup.okhttp.RequestBody;
import java.io.IOException;
import okio.Buffer;
import okio.BufferedSink;
import okio.ForwardingSink;
import okio.Okio;
import okio.Sink;
public class ProgressRequestBody extends RequestBody {
public interface ProgressRequestListener {
void onRequestProgress(long bytesWritten, long contentLength, boolean done);
}
private final RequestBody requestBody;
private final ProgressRequestListener progressListener;
public ProgressRequestBody(RequestBody requestBody, ProgressRequestListener progressListener) {
this.requestBody = requestBody;
this.progressListener = progressListener;
}
@Override
public MediaType contentType() {
return requestBody.contentType();
}
@Override
public long contentLength() throws IOException {
return requestBody.contentLength();
}
@Override
public void writeTo(BufferedSink sink) throws IOException {
BufferedSink bufferedSink = Okio.buffer(sink(sink));
requestBody.writeTo(bufferedSink);
bufferedSink.flush();
}
private Sink sink(Sink sink) {
return new ForwardingSink(sink) {
long bytesWritten = 0L;
long contentLength = 0L;
@Override
public void write(Buffer source, long byteCount) throws IOException {
super.write(source, byteCount);
if (contentLength == 0) {
contentLength = contentLength();
}
bytesWritten += byteCount;
progressListener.onRequestProgress(bytesWritten, contentLength, bytesWritten == contentLength);
}
};
}
}
/*
* 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.commons.sure_tosca.client;
import com.squareup.okhttp.MediaType;
import com.squareup.okhttp.ResponseBody;
import java.io.IOException;
import okio.Buffer;
import okio.BufferedSource;
import okio.ForwardingSource;
import okio.Okio;
import okio.Source;
public class ProgressResponseBody extends ResponseBody {
public interface ProgressListener {
void update(long bytesRead, long contentLength, boolean done);
}
private final ResponseBody responseBody;
private final ProgressListener progressListener;
private BufferedSource bufferedSource;
public ProgressResponseBody(ResponseBody responseBody, ProgressListener progressListener) {
this.responseBody = responseBody;
this.progressListener = progressListener;
}
@Override
public MediaType contentType() {
return responseBody.contentType();
}
@Override
public long contentLength() throws IOException {
return responseBody.contentLength();
}
@Override
public BufferedSource source() throws IOException {
if (bufferedSource == null) {
bufferedSource = Okio.buffer(source(responseBody.source()));
}
return bufferedSource;
}
private Source source(Source source) {
return new ForwardingSource(source) {
long totalBytesRead = 0L;
@Override
public long read(Buffer sink, long byteCount) throws IOException {
long bytesRead = super.read(sink, byteCount);
// read() returns the number of bytes read, or -1 if this source is exhausted.
totalBytesRead += bytesRead != -1 ? bytesRead : 0;
progressListener.update(totalBytesRead, responseBody.contentLength(), bytesRead == -1);
return bytesRead;
}
};
}
}
/*
* 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.commons.sure_tosca.client;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2019-11-01T13:11:24.211Z")
public class StringUtil {
/**
* Check if the given array contains the given value (with case-insensitive comparison).
*
* @param array The array
* @param value The value to search
* @return true if the array contains the value
*/
public static boolean containsIgnoreCase(String[] array, String value) {
for (String str : array) {
if (value == null && str == null) return true;
if (value != null && value.equalsIgnoreCase(str)) return true;
}
return false;
}
/**
* Join an array of strings with the given separator.
* <p>
* Note: This might be replaced by utility method from commons-lang or guava someday
* if one of those libraries is added as dependency.
* </p>
*
* @param array The array of strings
* @param separator The separator
* @return the resulting string
*/
public static String join(String[] array, String separator) {
int len = array.length;
if (len == 0) return "";
StringBuilder out = new StringBuilder();
out.append(array[0]);
for (int i = 1; i < len; i++) {
out.append(separator).append(array[i]);
}
return out.toString();
}
}
/*
* 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 java.util.ArrayList;
import java.util.Base64;
import java.util.HashMap;
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.TopologyTemplate;
import nl.uva.sne.drip.model.ToscaTemplate;
/**
*
* @author S. Koulouzis
*/
public class TOSCAUtils {
private static List<Map<String, NodeTemplate>> getNodes(ToscaTemplate toscaTemplate, String filterType, String filterValue) {
boolean byType = false;
boolean byName = false;
switch (filterType) {
case "type":
byType = true;
break;
case "name":
byName = true;
break;
}
TopologyTemplate topologyTemplate = toscaTemplate.getTopologyTemplate();
Map<String, NodeTemplate> nodeTemplates = topologyTemplate.getNodeTemplates();
List<Map<String, NodeTemplate>> nodeList = new ArrayList<>();
Set<String> keys = nodeTemplates.keySet();
for (String key : keys) {
NodeTemplate node = nodeTemplates.get(key);
if (byName && key.equals(filterValue)) {
Map<String, NodeTemplate> ntMap = new HashMap<>();
ntMap.put(key, node);
nodeList.add(ntMap);
}
if (byType) {
if (node.getType().equals(filterValue)) {
Map<String, NodeTemplate> ntMap = new HashMap<>();
ntMap.put(key, node);
nodeList.add(ntMap);
}
}
}
return nodeList;
}
public static List<Map<String, NodeTemplate>> getNodesByType(ToscaTemplate toscaTemplate, String nodeTypeName) {
return getNodes(toscaTemplate, "type", nodeTypeName);
}
public static Map<String, Object> buildTOSCAOutput(Map<String, Object> outputs, String nodeName, String value, String key, boolean encodeValueToBas64) {
List<Map<String, String>> values;
if (outputs.containsKey(key)) {
values = (List<Map<String, String>>) outputs.get(key);
} else {
values = new ArrayList<>();
}
if (encodeValueToBas64) {
value = Base64.getEncoder().encodeToString(value.getBytes());
}
Map<String, String> map = new HashMap<>();
map.put(nodeName, value);
values.add(map);
outputs.put(key, values);
return outputs;
}
public static Map<String, String> getOutputsForNode(ToscaTemplate toscaTemplate, String nodeName) {
TopologyTemplate topologyTemplate = toscaTemplate.getTopologyTemplate();
List<Map<String, Object>> outputs = topologyTemplate.getOutputs();
List<Map<String, Object>> matchedOutputs = new ArrayList<>();
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
public static List<String> getOutputPair(Map<String, Object> outputs, String key) {
List<String> outputPair = (List<String>) ((Map<String, Object>) ((Map<String, Object>) outputs.get(key)).get("value")).get("get_attribute");
return outputPair;
}
private static List<Map<String, Object>> getImageEnvirmoent(Map<String, Object> properties) {
Map<String, Object> envMap = (Map<String, Object>) properties.get("environment");
List<Map<String, Object>> imageEnv = new ArrayList<>();
Set<String> keys = envMap.keySet();
for (String key : keys) {
Map<String, Object> kubernetesEnvMap = new HashMap();
kubernetesEnvMap.put("name", key);
kubernetesEnvMap.put("value", envMap.get(key));
imageEnv.add(kubernetesEnvMap);
}
return imageEnv;
}
private static String getImageFile(Map<String, Object> dockerValues) {
Map<String, Object> image = (Map<String, Object>) ((Map<String, Object>) dockerValues.get("artifacts")).get("image");
if (image == null) {
image = (Map<String, Object>) ((Map<String, Object>) dockerValues.get("artifacts")).get("my_image");
}
String imageFile = (String) image.get("file");
return imageFile;
}
public static List<Map<String, NodeTemplate>> getRelatedNodes(NodeTemplate node, ToscaTemplate toscaTemplate) {
if (node.getRequirements() != null) {
List<String> nodeNames = new ArrayList<>();
List<Map<String, Object>> requirements = node.getRequirements();
for (Map<String, Object> requirement : requirements) {
String reqName = requirement.keySet().iterator().next();
Map<String, Object> requirementMap = (Map<String, Object>) requirement.get(reqName);
String relatedNode = (String) requirementMap.get("node");
nodeNames.add(relatedNode);
}
List<Map<String, NodeTemplate>> retaltedNodes = new ArrayList<>();
for (String name : nodeNames) {
List<Map<String, NodeTemplate>> relatedNode = getNodesByName(toscaTemplate, name);
for (Map<String, NodeTemplate> rNode : relatedNode) {
retaltedNodes.add(rNode);
}
}
return retaltedNodes;
}
return null;
}
private static List<Map<String, NodeTemplate>> getNodesByName(ToscaTemplate toscaTemplate, String name) {
return getNodes(toscaTemplate, "name", name);
}
public static boolean nodeIsOfType(NodeTemplate node, String type) {
if (node.getType().equals(type)) {
return true;
}
return false;
}
public static Object getNodeProperty(NodeTemplate node, String propertyName) {
if (node.getProperties() != null) {
return node.getProperties().get(propertyName);
}
return null;
}
}
/*
* 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.databind.SerializationFeature;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator;
import java.io.File;
import java.io.IOException;
import nl.uva.sne.drip.commons.sure_tosca.client.ApiException;
import nl.uva.sne.drip.commons.sure_tosca.client.DefaultApi;
import nl.uva.sne.drip.model.ToscaTemplate;
import org.apache.commons.io.FileUtils;
/**
*
* @author S. Koulouzis
*/
public class ToscaHelper {
private final DefaultApi api;
private final ObjectMapper objectMapper;
/**
* @return the id
*/
public Integer getId() {
return id;
}
private final Integer id;
public ToscaHelper(ToscaTemplate toscaTemplate) throws JsonProcessingException, IOException, ApiException {
api = new DefaultApi();
id = uploadToscaTemplate(toscaTemplate);
this.objectMapper = new ObjectMapper(new YAMLFactory().disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER));
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
}
private Integer uploadToscaTemplate(ToscaTemplate toscaTemplate) throws JsonProcessingException, IOException, ApiException {
String ymlStr = objectMapper.writeValueAsString(toscaTemplate);
File toscaTemplateFile = File.createTempFile("temp-toscaTemplate", ".yml");
FileUtils.writeByteArrayToFile(toscaTemplateFile, ymlStr.getBytes());
String resp = api.uploadToscaTemplate(toscaTemplateFile);
return null;
}
}
......@@ -2,6 +2,10 @@ package nl.uva.sne.drip.model;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.ArrayList;
import java.util.HashMap;
......@@ -9,14 +13,32 @@ import java.util.List;
import java.util.Map;
import org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
import javax.validation.constraints.*;
import org.springframework.data.annotation.Id;
/**
* TopologyTemplate
*/
@Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-25T14:47:27.096Z")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class TopologyTemplate {
/**
* @return the id
*/
public String getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(String id) {
this.id = id;
}
@Id
@JsonIgnore
private String id;
@JsonProperty("description")
private String description = null;
......@@ -24,14 +46,6 @@ public class TopologyTemplate {
@Valid
private List<Map<String, Object>> inputs = null;
@JsonProperty("policies")
@Valid
private List<Map<String, Object>> policies = null;
@JsonProperty("outputs")
@Valid
private List<Map<String, Object>> outputs = null;
@JsonProperty("node_templates")
@Valid
private Map<String, NodeTemplate> nodeTemplates = null;
......@@ -40,6 +54,10 @@ public class TopologyTemplate {
@Valid
private Map<String, Object> relationshipTemplates = null;
@JsonProperty("outputs")
@Valid
private List<Map<String, Object>> outputs = null;
@JsonProperty("groups")
@Valid
private Map<String, Object> groups = null;
......@@ -48,6 +66,10 @@ public class TopologyTemplate {
@Valid
private Map<String, Object> substitutionMappings = null;
@JsonProperty("policies")
@Valid
private List<Map<String, Object>> policies = null;
public TopologyTemplate description(String description) {
this.description = description;
return this;
......@@ -97,64 +119,6 @@ public class TopologyTemplate {
this.inputs = inputs;
}
public TopologyTemplate policies(List<Map<String, Object>> policies) {
this.policies = policies;
return this;
}
public TopologyTemplate addPoliciesItem(Map<String, Object> policiesItem) {
if (this.policies == null) {
this.policies = new ArrayList<Map<String, Object>>();
}
this.policies.add(policiesItem);
return this;
}
/**
* Get policies
* @return policies
**/
@ApiModelProperty(value = "")
@Valid
public List<Map<String, Object>> getPolicies() {
return policies;
}
public void setPolicies(List<Map<String, Object>> policies) {
this.policies = policies;
}
public TopologyTemplate outputs(List<Map<String, Object>> outputs) {
this.outputs = outputs;
return this;
}
public TopologyTemplate addOutputsItem(Map<String, Object> outputsItem) {
if (this.outputs == null) {
this.outputs = new ArrayList<Map<String, Object>>();
}
this.outputs.add(outputsItem);
return this;
}
/**
* Get outputs
* @return outputs
**/
@ApiModelProperty(value = "")
@Valid
public List<Map<String, Object>> getOutputs() {
return outputs;
}
public void setOutputs(List<Map<String, Object>> outputs) {
this.outputs = outputs;
}
public TopologyTemplate nodeTemplates(Map<String, NodeTemplate> nodeTemplates) {
this.nodeTemplates = nodeTemplates;
return this;
......@@ -212,6 +176,35 @@ public class TopologyTemplate {
this.relationshipTemplates = relationshipTemplates;
}
public TopologyTemplate outputs(List<Map<String, Object>> outputs) {
this.outputs = outputs;
return this;
}
public TopologyTemplate addOutputsItem(Map<String, Object> outputsItem) {
if (this.outputs == null) {
this.outputs = new ArrayList<Map<String, Object>>();
}
this.outputs.add(outputsItem);
return this;
}
/**
* Get outputs
* @return outputs
**/
@ApiModelProperty(value = "")
@Valid
public List<Map<String, Object>> getOutputs() {
return outputs;
}
public void setOutputs(List<Map<String, Object>> outputs) {
this.outputs = outputs;
}
public TopologyTemplate groups(Map<String, Object> groups) {
this.groups = groups;
return this;
......@@ -268,6 +261,35 @@ public class TopologyTemplate {
this.substitutionMappings = substitutionMappings;
}
public TopologyTemplate policies(List<Map<String, Object>> policies) {
this.policies = policies;
return this;
}
public TopologyTemplate addPoliciesItem(Map<String, Object> policiesItem) {
if (this.policies == null) {
this.policies = new ArrayList<Map<String, Object>>();
}
this.policies.add(policiesItem);
return this;
}
/**
* Get policies
* @return policies
**/
@ApiModelProperty(value = "")
@Valid
public List<Map<String, Object>> getPolicies() {
return policies;
}
public void setPolicies(List<Map<String, Object>> policies) {
this.policies = policies;
}
@Override
public boolean equals(java.lang.Object o) {
......@@ -280,17 +302,17 @@ public class TopologyTemplate {
TopologyTemplate topologyTemplate = (TopologyTemplate) o;
return Objects.equals(this.description, topologyTemplate.description) &&
Objects.equals(this.inputs, topologyTemplate.inputs) &&
Objects.equals(this.policies, topologyTemplate.policies) &&
Objects.equals(this.outputs, topologyTemplate.outputs) &&
Objects.equals(this.nodeTemplates, topologyTemplate.nodeTemplates) &&
Objects.equals(this.relationshipTemplates, topologyTemplate.relationshipTemplates) &&
Objects.equals(this.outputs, topologyTemplate.outputs) &&
Objects.equals(this.groups, topologyTemplate.groups) &&
Objects.equals(this.substitutionMappings, topologyTemplate.substitutionMappings);
Objects.equals(this.substitutionMappings, topologyTemplate.substitutionMappings) &&
Objects.equals(this.policies, topologyTemplate.policies);
}
@Override
public int hashCode() {
return Objects.hash(description, inputs, policies, outputs, nodeTemplates, relationshipTemplates, groups, substitutionMappings);
return Objects.hash(description, inputs, nodeTemplates, relationshipTemplates, outputs, groups, substitutionMappings, policies);
}
@Override
......@@ -300,12 +322,12 @@ public class TopologyTemplate {
sb.append(" description: ").append(toIndentedString(description)).append("\n");
sb.append(" inputs: ").append(toIndentedString(inputs)).append("\n");
sb.append(" policies: ").append(toIndentedString(policies)).append("\n");
sb.append(" outputs: ").append(toIndentedString(outputs)).append("\n");
sb.append(" nodeTemplates: ").append(toIndentedString(nodeTemplates)).append("\n");
sb.append(" relationshipTemplates: ").append(toIndentedString(relationshipTemplates)).append("\n");
sb.append(" outputs: ").append(toIndentedString(outputs)).append("\n");
sb.append(" groups: ").append(toIndentedString(groups)).append("\n");
sb.append(" substitutionMappings: ").append(toIndentedString(substitutionMappings)).append("\n");
sb.append(" policies: ").append(toIndentedString(policies)).append("\n");
sb.append("}");
return sb.toString();
}
......
package nl.uva.sne.drip.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
import javax.validation.constraints.*;
import org.springframework.data.annotation.Id;
/**
* User
*/
@Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-25T14:09:25.182Z")
public class User {
@JsonProperty("id")
private Long id = null;
@JsonProperty("username")
private String username = null;
@JsonProperty("firstName")
private String firstName = null;
@JsonProperty("lastName")
private String lastName = null;
@JsonProperty("email")
private String email = null;
@JsonProperty("password")
private String password = null;
@JsonProperty("userStatus")
private Integer userStatus = null;
public User id(Long id) {
this.id = id;
return this;
}
/**
* Get id
* @return id
**/
@ApiModelProperty(value = "")
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public User username(String username) {
this.username = username;
return this;
}
/**
* Get username
* @return username
**/
@ApiModelProperty(value = "")
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public User firstName(String firstName) {
this.firstName = firstName;
return this;
}
/**
* Get firstName
* @return firstName
**/
@ApiModelProperty(value = "")
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public User lastName(String lastName) {
this.lastName = lastName;
return this;
}
/**
* Get lastName
* @return lastName
**/
@ApiModelProperty(value = "")
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public User email(String email) {
this.email = email;
return this;
}
/**
* Get email
* @return email
**/
@ApiModelProperty(value = "")
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public User password(String password) {
this.password = password;
return this;
}
/**
* Get password
* @return password
**/
@ApiModelProperty(value = "")
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public User userStatus(Integer userStatus) {
this.userStatus = userStatus;
return this;
}
/**
* User Status
* @return userStatus
**/
@ApiModelProperty(value = "User Status")
public Integer getUserStatus() {
return userStatus;
}
public void setUserStatus(Integer userStatus) {
this.userStatus = userStatus;
}
@JsonInclude(JsonInclude.Include.NON_NULL)
public class User {
/**
* @return the id
*/
public String getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(String id) {
this.id = id;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
@Id
@JsonIgnore
private String id;
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
@Override
public int hashCode() {
return Objects.hash();
}
User user = (User) o;
return Objects.equals(this.id, user.id) &&
Objects.equals(this.username, user.username) &&
Objects.equals(this.firstName, user.firstName) &&
Objects.equals(this.lastName, user.lastName) &&
Objects.equals(this.email, user.email) &&
Objects.equals(this.password, user.password) &&
Objects.equals(this.userStatus, user.userStatus);
}
@Override
public int hashCode() {
return Objects.hash(id, username, firstName, lastName, email, password, userStatus);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class User {\n");
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class User {\n");
sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" username: ").append(toIndentedString(username)).append("\n");
sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n");
sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n");
sb.append(" email: ").append(toIndentedString(email)).append("\n");
sb.append(" password: ").append(toIndentedString(password)).append("\n");
sb.append(" userStatus: ").append(toIndentedString(userStatus)).append("\n");
sb.append("}");
return sb.toString();
}
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";
/**
* 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 ");
}
return o.toString().replace("\n", "\n ");
}
}
/*
* Copyright 2017 S. Koulouzis, Wang Junchao, Huan Zhou, Yang Hu
*
* 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.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashMap;
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.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 TOSCAUtilsTest {
private static ToscaTemplate toscaTemplate;
public TOSCAUtilsTest() {
}
@BeforeClass
public static void setUpClass() throws IOException {
String toscaFilePath = "../TOSCA/application_example_output.yaml";
String ymlStr = new String(Files.readAllBytes(Paths.get(toscaFilePath)));
ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory().disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER));
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
toscaTemplate = objectMapper.readValue(ymlStr, ToscaTemplate.class);
}
@AfterClass
public static void tearDownClass() {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/**
* Test of getNodesByType method, of class TOSCAUtils.
*/
@Test
public void testGetNodesByType() {
System.out.println("getNodesByType");
String nodeTypeName = "tosca.nodes.ARTICONF.VM.topology";
List<Map<String, NodeTemplate>> result = testGetNodesByType(nodeTypeName);
assertEquals(1, result.size());
nodeTypeName = "tosca.nodes.ARTICONF.VM.Compute";
result = testGetNodesByType(nodeTypeName);
assertEquals(2, result.size());
}
/**
* Test of getRelatedNodes method, of class TOSCAUtils.
*/
@Test
public void testGetRelatedNodes() {
System.out.println("getRelatedNodes");
String nodeTypeName = "tosca.nodes.ARTICONF.VM.topology";
List<Map<String, NodeTemplate>> vmTopologies = TOSCAUtils.getNodesByType(toscaTemplate, nodeTypeName);
NodeTemplate vmTopology = vmTopologies.get(0).get(vmTopologies.get(0).keySet().iterator().next());
nodeTypeName = "tosca.nodes.ARTICONF.VM.Compute";
List<Map<String, NodeTemplate>> result = TOSCAUtils.getRelatedNodes(vmTopology, toscaTemplate);
assertEquals(2, result.size());
for (Map<String, NodeTemplate> node : result) {
String name = node.keySet().iterator().next();
assertEquals(nodeTypeName, node.get(name).getType());
}
}
/**
* Test of nodeIsOfType method, of class TOSCAUtils.
*/
@Test
public void testNodeIsOfType() {
System.out.println("nodeIsOfType");
String nodeTypeName = "tosca.nodes.ARTICONF.VM.topology";
List<Map<String, NodeTemplate>> vmTopologies = TOSCAUtils.getNodesByType(toscaTemplate, nodeTypeName);
NodeTemplate vmTopology = vmTopologies.get(0).get(vmTopologies.get(0).keySet().iterator().next());
boolean expResult = true;
boolean result = TOSCAUtils.nodeIsOfType(vmTopology, nodeTypeName);
assertEquals(expResult, result);
expResult = false;
nodeTypeName = "tosca.nodes.ARTICONF";
result = TOSCAUtils.nodeIsOfType(vmTopology, nodeTypeName);
assertEquals(expResult, result);
}
/**
* Test of getNodeProperty method, of class TOSCAUtils.
*/
@Test
public void testGetNodeProperty() {
System.out.println("getNodeProperty");
testGetVMProperties();
}
private void testGetVMProperties() {
String nodeTypeName = "tosca.nodes.ARTICONF.VM.Compute";
List<Map<String, NodeTemplate>> vms = TOSCAUtils.getNodesByType(toscaTemplate, nodeTypeName);
assertEquals(2, vms.size());
Map<String, Object> vmProertyMap = new HashMap<>();
vmProertyMap.put("disk_size", "50000 MB");
vmProertyMap.put("host_name", "vm");
vmProertyMap.put("mem_size", "6000 MB");
vmProertyMap.put("num_cores", 2);
vmProertyMap.put("os", "ubuntu 16");
vmProertyMap.put("user_name", "vm_user");
for (Map<String, NodeTemplate> vmMap : vms) {
Set<String> keys = vmProertyMap.keySet();
NodeTemplate vm = vmMap.get(vmMap.keySet().iterator().next());
for (String propName : keys) {
Object result = TOSCAUtils.getNodeProperty(vm, propName);
assertEquals(vmProertyMap.get(propName), result);
}
}
}
private List<Map<String, NodeTemplate>> testGetNodesByType(String nodeTypeName) {
List<Map<String, NodeTemplate>> result = TOSCAUtils.getNodesByType(toscaTemplate, nodeTypeName);
for (Map<String, NodeTemplate> node : result) {
String name = node.keySet().iterator().next();
assertEquals(nodeTypeName, node.get(name).getType());
}
return result;
}
}
......@@ -12,7 +12,7 @@ import java.util.Map;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
import java.util.logging.Logger;
import nl.uva.sne.drip.commons.utils.TOSCAUtils;
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.ToscaTemplate;
......@@ -37,45 +37,36 @@ public class ProvisionerService {
@Autowired
private ToscaTemplateService toscaTemplateService;
ToscaHelper toscaHelper;
private Integer toscaHelperID;
public String provision(String id) throws IOException {
String ymlToscaTemplate = toscaTemplateService.findByID(id);
ToscaTemplate toscaTemplate = toscaTemplateService.getYaml2ToscaTemplate(ymlToscaTemplate);
toscaHelper = new ToscaHelper(toscaTemplate);
toscaTemplate = addProvisionInterface(toscaTemplate);
return null;
}
private List<Map<String, NodeTemplate>> getVmTopologies(ToscaTemplate toscaTemplate) {
return TOSCAUtils.getNodesByType(toscaTemplate, "tosca.nodes.ARTICONF.VM.topology");
}
// private List<Map<String, NodeTemplate>> getVmTopologies(ToscaTemplate toscaTemplate) {
// return ToscaHelper.getNodesByType(toscaTemplate, "tosca.nodes.ARTICONF.VM.topology");
// }
protected ToscaTemplate addProvisionInterface(ToscaTemplate toscaTemplate) {
List<Map<String, NodeTemplate>> vmTopologies = getVmTopologies(toscaTemplate);
for (Map<String, NodeTemplate> vmTopologyMap : vmTopologies) {
String topologyName = vmTopologyMap.keySet().iterator().next();
NodeTemplate vmTopology = vmTopologyMap.get(topologyName);
Map<String, Object> interfaces = vmTopology.getInterfaces();
Map<String, Object> cloudStormInterface = getCloudStormProvisionInterface(topologyName);
interfaces.put("cloudStorm", cloudStormInterface);
}
// List<Map<String, NodeTemplate>> vmTopologies = getVmTopologies(toscaTemplate);
// for (Map<String, NodeTemplate> vmTopologyMap : vmTopologies) {
// String topologyName = vmTopologyMap.keySet().iterator().next();
// NodeTemplate vmTopology = vmTopologyMap.get(topologyName);
// Map<String, Object> interfaces = vmTopology.getInterfaces();
// Map<String, Object> cloudStormInterface = getCloudStormProvisionInterface(topologyName);
// interfaces.put("cloudStorm", cloudStormInterface);
// }
return toscaTemplate;
}
private Map<String, Object> getCloudStormProvisionInterface(String topologyName) {
Map<String, Object> csMap = new HashMap<>();
Map<String, Object> provisionMap = new HashMap<>();
Map<String, Object> inputs = new HashMap<>();
inputs.put("code_type", "SEQ");
inputs.put("object_type", "SubTopology");
inputs.put("objects", topologyName);
provisionMap.put("inputs", inputs);
csMap.put("provision", provisionMap);
return null;
}
}
......@@ -61,7 +61,7 @@ public class ToscaTemplateService {
byte[] bytes = file.getBytes();
String ymlStr = new String(bytes, "UTF-8");
tt = objectMapper.readValue(ymlStr, ToscaTemplate.class);
tt.setID(id);
tt.setId(id);
return save(tt);
}
......
......@@ -4,11 +4,9 @@
description:
type: "string"
inputs:
type: "array"
items:
type: object
additionalProperties:
type: object
type: string
additionalProperties:
type: object
node_templates:
type: object
additionalProperties:
......@@ -18,22 +16,20 @@
additionalProperties:
type: object
outputs:
type: "array"
items:
type: object
additionalProperties:
type: object
type: string
additionalProperties:
type: object
groups:
type: object
type: string
additionalProperties:
type: object
substitution_mappings:
type: object
type: string
additionalProperties:
type: object
policies:
type: "array"
items:
type: object
type: string
additionalProperties:
type: object
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