Commit 958e45a4 authored by Spiros Koulouzis's avatar Spiros Koulouzis

moved data types to separate project

parent ced0bfc0
......@@ -72,7 +72,7 @@
<h1 class="page-header">Files and Libraries</h1>
<h3 id="artifact_gwt_json_overlay">GWT JSON Overlay</h3>
<p class="lead">Created April 25, 2017</p>
<p class="lead">Created April 26, 2017</p>
<p> <p>
The <a href="http://code.google.com/webtoolkit/">Google Web Toolkit</a> JSON Overlay library provides the JSON Overlays that
can be used to access the Web service API for this application.
......@@ -97,7 +97,7 @@
</tbody>
</table>
<h3 id="artifact_java_json_client_library">Java JSON Client Library</h3>
<p class="lead">Created April 25, 2017</p>
<p class="lead">Created April 26, 2017</p>
<p><p>
The Java client-side library is used to provide the set of Java objects that can be serialized
to/from JSON using <a href="http://jackson.codehaus.org/">Jackson</a>. This is useful for accessing the
......@@ -127,7 +127,7 @@
</tbody>
</table>
<h3 id="artifact_java_xml_client_library">Java XML Client Library</h3>
<p class="lead">Created April 25, 2017</p>
<p class="lead">Created April 26, 2017</p>
<p><p>
The Java client-side library is used to access the Web service API for this application using Java.
</p>
......@@ -155,7 +155,7 @@
</tbody>
</table>
<h3 id="artifact_js_client_library">JavaScript Client Library</h3>
<p class="lead">Created April 25, 2017</p>
<p class="lead">Created April 26, 2017</p>
<p><p>
The JavaScript client-side library defines classes that can be (de)serialized to/from JSON.
This is useful for accessing the resources that are published by this application, but only
......@@ -184,13 +184,13 @@
<tbody data-link="row" class="rowlink">
<tr class="clickable-row" data-href="drip-api-js.zip">
<td><span class="downloadfile-name">drip-api-js.zip</span></td>
<td><span class="downloadfile-size">7.17K</span></td>
<td><span class="downloadfile-size">7.18K</span></td>
<td><span class="downloadfile-description">&nbsp;</span></td>
</tr>
</tbody>
</table>
<h3 id="artifact_php_json_client_library">PHP JSON Client Library</h3>
<p class="lead">Created April 25, 2017</p>
<p class="lead">Created April 26, 2017</p>
<p><p>
The PHP JSON client-side library defines the PHP classes that can be (de)serialized to/from JSON.
This is useful for accessing the resources that are published by this application, but only
......@@ -219,7 +219,7 @@
</tbody>
</table>
<h3 id="artifact_php_xml_client_library">PHP XML Client Library</h3>
<p class="lead">Created April 25, 2017</p>
<p class="lead">Created April 26, 2017</p>
<p><p>
The PHP client-side library defines the PHP classes that can be (de)serialized to/from XML.
This is useful for accessing the resources that are published by this application, but only
......@@ -251,7 +251,7 @@
</tbody>
</table>
<h3 id="artifact_ruby_json_client_library">Ruby JSON Client Library</h3>
<p class="lead">Created April 25, 2017</p>
<p class="lead">Created April 26, 2017</p>
<p><p>
The Ruby JSON client-side library defines the Ruby classes that can be (de)serialized to/from JSON.
This is useful for accessing the REST endpoints that are published by this application, but only
......
This diff is collapsed.
......@@ -69,7 +69,7 @@ class</p>
<dl class="dl-horizontal">
<dt>Subtypes</dt>
<dd><a href="json_DeployRequest.html">DeployRequest</a>, <a href="json_ProvisionRequest.html">ProvisionRequest</a>, <a href="json_KeyPair.html">KeyPair</a>, <a href="json_AnsibleOutput.html">AnsibleOutput</a>, <a href="json_PlanResponse.html">PlanResponse</a>, <a href="json_KeyValueHolder.html">KeyValueHolder</a>, <a href="json_SysbenchCPUBenchmark.html">SysbenchCPUBenchmark</a>, <a href="json_PlaybookRepresentation.html">PlaybookRepresentation</a>, <a href="json_ProvisionResponse.html">ProvisionResponse</a>, <a href="json_Script.html">Script</a>, <a href="json_DeployResponse.html">DeployResponse</a>, <a href="json_BenchmarkResult.html">BenchmarkResult</a>, <a href="json_ToscaRepresentation.html">ToscaRepresentation</a>, <a href="json_CloudCredentials.html">CloudCredentials</a></dd>
<dd><a href="json_DeployRequest.html">DeployRequest</a>, <a href="json_KeyPair.html">KeyPair</a>, <a href="json_ProvisionRequest.html">ProvisionRequest</a>, <a href="json_AnsibleOutput.html">AnsibleOutput</a>, <a href="json_SysbenchCPUBenchmark.html">SysbenchCPUBenchmark</a>, <a href="json_KeyValueHolder.html">KeyValueHolder</a>, <a href="json_PlanResponse.html">PlanResponse</a>, <a href="json_PlaybookRepresentation.html">PlaybookRepresentation</a>, <a href="json_ProvisionResponse.html">ProvisionResponse</a>, <a href="json_Script.html">Script</a>, <a href="json_DeployResponse.html">DeployResponse</a>, <a href="json_BenchmarkResult.html">BenchmarkResult</a>, <a href="json_ToscaRepresentation.html">ToscaRepresentation</a>, <a href="json_CloudCredentials.html">CloudCredentials</a></dd>
</dl>
<table class="table datatype-properties">
......
......@@ -21,7 +21,12 @@
</properties>
<dependencies>
<dependency>
<groupId>nl.uva.sne.drip</groupId>
<artifactId>drip-commons</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
......
......@@ -15,7 +15,9 @@
*/
package nl.uva.sne.drip.api.service;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
......@@ -140,7 +142,7 @@ public class ProvisionService {
if (cred == null) {
throw new CloudCredentialsNotFoundException();
}
MessageParameter conf = buildCloudConfParam(cred);
MessageParameter conf = buildCloudCredentialParam(cred, 0).get(0);
parameters.add(conf);
List<MessageParameter> certs = buildCertificatesParam(cred);
......@@ -160,18 +162,38 @@ public class ProvisionService {
return invokationMessage;
}
private MessageParameter buildCloudConfParam(CloudCredentials cred) throws JsonProcessingException, JSONException, IOException {
MessageParameter conf = null;
String provider = cred.getCloudProviderName();
if (provider == null) {
throw new BadRequestException("Provider name can't be null. Check the cloud credentials: " + cred.getId());
private List<MessageParameter> buildCloudCredentialParam(CloudCredentials cred, int version) throws JsonProcessingException, JSONException, IOException {
List<MessageParameter> cloudCredentialParams = new ArrayList<>();
if (version == 0) {
MessageParameter cloudCredentialParam = new MessageParameter();
String provider = cred.getCloudProviderName();
if (provider == null) {
throw new BadRequestException("Provider name can't be null. Check the cloud credentials: " + cred.getId());
}
switch (cred.getCloudProviderName().toLowerCase()) {
case "ec2":
cloudCredentialParam = buildEC2Conf(cred);
break;
}
cloudCredentialParams.add(cloudCredentialParam);
return cloudCredentialParams;
}
switch (cred.getCloudProviderName().toLowerCase()) {
case "ec2":
conf = buildEC2Conf(cred);
break;
if (version == 1) {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
String jsonInString = mapper.writeValueAsString(cred);
MessageParameter cloudCred = new MessageParameter();
cloudCred.setName("cloud_credential");
cloudCred.setValue("\"" + jsonInString + "\"");
cloudCred.setEncoding("UTF-8");
cloudCredentialParams.add(cloudCred);
return cloudCredentialParams;
}
return conf;
return null;
}
private List<MessageParameter> buildCertificatesParam(CloudCredentials cred) {
......@@ -361,21 +383,40 @@ public class ProvisionService {
}
private ProvisionResponse callProvisioner1(ProvisionRequest provisionRequest) throws IOException, TimeoutException, JSONException {
private ProvisionResponse callProvisioner1(ProvisionRequest provisionRequest) throws IOException, TimeoutException, JSONException, InterruptedException {
try (DRIPCaller provisioner = new ProvisionerCaller1(messageBrokerHost);) {
Message provisionerInvokationMessage = buildProvisioner1Message(provisionRequest);
Message response = (provisioner.call(provisionerInvokationMessage));
}
return null;
}
private Message buildProvisioner1Message(ProvisionRequest provisionRequest) throws JSONException, FileNotFoundException {
private Message buildProvisioner1Message(ProvisionRequest provisionRequest) throws JSONException, FileNotFoundException, IOException {
Message invokationMessage = new Message();
List<MessageParameter> parameters = new ArrayList();
List<MessageParameter> topologies = buildTopologyParams(provisionRequest.getPlanID());
parameters.addAll(topologies);
List<String> userKeyIDs = provisionRequest.getKeyPairIDs();
for (String keyID : userKeyIDs) {
if (userKeyIDs != null) {
List<MessageParameter> userKeys = buildKeysParams(keyID);
parameters.addAll(userKeys);
}
}
for (String id : provisionRequest.getCloudCredentialsIDs()) {
CloudCredentials cred = cloudCredentialsService.findOne(id);
if (cred == null) {
throw new CloudCredentialsNotFoundException();
}
List<MessageParameter> cloudCredentialParams = buildCloudCredentialParam(cred, 1);
parameters.addAll(cloudCredentialParams);
}
invokationMessage.setParameters(parameters);
invokationMessage.setCreationDate((System.currentTimeMillis()));
return invokationMessage;
......
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>nl.uva.sne.drip</groupId>
<artifactId>drip</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>drip-commons</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.8.6</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>1.8.0.RELEASE</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-rest-core</artifactId>
<version>2.5.6.RELEASE</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>com.webcohesion.enunciate</groupId>
<artifactId>enunciate-core-annotations</artifactId>
<version>2.8.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.17</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>4.2.1.RELEASE</version>
<type>jar</type>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project>
\ No newline at end of file
/*
* 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;
/**
*
* @author S. Koulouzis
*/
public class Constants {
public static final int[] BAD_CHARS = {0x80};
}
/*
* 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.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import nl.uva.sne.drip.drip.commons.data.v1.external.CloudCredentials;
import org.apache.commons.io.FilenameUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.yaml.snakeyaml.Yaml;
import nl.uva.sne.drip.drip.commons.data.internal.Message;
import nl.uva.sne.drip.drip.commons.data.internal.MessageParameter;
import nl.uva.sne.drip.drip.commons.data.v0.external.Attribute;
import nl.uva.sne.drip.drip.commons.data.v1.external.PlanResponse;
/**
*
* @author S. Koulouzis
*/
public class Converter {
private static final Map<String, String> EC2_NAME_MAP = new HashMap();
public static String ymlString2Json(String yamlString) {
JSONObject jsonObject = new JSONObject(ymlString2Map(yamlString));
return jsonObject.toString();
}
public static Map<String, Object> ymlString2Map(String yamlString) {
Yaml yaml = new Yaml();
Object object = yaml.load(yamlString);
if (object instanceof List) {
Map<String, Object> map = new HashMap<>();
map.put("---", object);
return map;
}
return (Map<String, Object>) object;
}
public static Map<String, Object> ymlStream2Map(InputStream in) {
Yaml yaml = new Yaml();
Map<String, Object> map = (Map<String, Object>) yaml.load(in);
return map;
}
public static String map2YmlString(Map<String, Object> map) throws JSONException {
JSONObject jsonObject = new JSONObject(map);
String yamlStr = json2Yml2(jsonObject.toString());
return yamlStr;
}
public static String map2JsonString(Map<String, Object> map) {
JSONObject jsonObject = new JSONObject(map);
return jsonObject.toString();
}
public static Map<String, Object> jsonString2Map(String jsonString) throws JSONException {
JSONObject jsonObject = new JSONObject(jsonString);
return jsonObject2Map(jsonObject);
}
public static Map<String, Object> jsonObject2Map(JSONObject object) throws JSONException {
Map<String, Object> map = new HashMap();
Iterator<String> keysItr = object.keys();
while (keysItr.hasNext()) {
String key = keysItr.next();
Object value = object.get(key);
if (value instanceof JSONArray) {
value = jsonArray2List((JSONArray) value);
} else if (value instanceof JSONObject) {
value = jsonObject2Map((JSONObject) value);
}
map.put(key, value);
}
return map;
}
public static List<Object> jsonArray2List(JSONArray array) throws JSONException {
List<Object> list = new ArrayList();
for (int i = 0; i < array.length(); i++) {
Object value = array.get(i);
if (value instanceof JSONArray) {
value = jsonArray2List((JSONArray) value);
} else if (value instanceof JSONObject) {
value = jsonObject2Map((JSONObject) value);
}
list.add(value);
}
return list;
}
public static String json2Yml2(String jsonString) throws JSONException {
Yaml yaml = new Yaml();
String yamlStr = yaml.dump(ymlString2Map(jsonString));
return yamlStr;
}
public static Properties Object2Properties(Object obj) throws JsonProcessingException, JSONException {
ObjectMapper mapper = new ObjectMapper();
String jsonInString = mapper.writeValueAsString(obj);
return Property.toProperties(new JSONObject(jsonInString));
}
public static Properties getEC2Properties(CloudCredentials cred) throws JsonProcessingException, JSONException {
Properties prop = Object2Properties(cred);
Enumeration<String> names = (Enumeration<String>) prop.propertyNames();
Properties ec2Props = new Properties();
if (EC2_NAME_MAP.isEmpty()) {
initEC2_NAME_MAP();
}
while (names.hasMoreElements()) {
String name = names.nextElement();
String ec2Name = EC2_NAME_MAP.get(name);
if (ec2Name != null) {
ec2Props.setProperty(ec2Name, prop.getProperty(name));
}
}
return ec2Props;
}
private static void initEC2_NAME_MAP() {
EC2_NAME_MAP.put(CloudCredentials.ACCESS_KEY_NAME, "AWSAccessKeyId");
EC2_NAME_MAP.put(CloudCredentials.SECRET_KEY_NAME, "AWSSecretKey");
}
public static Message string2Message(String clean) throws JSONException, IOException {
Message mess = new Message();
JSONObject jsonObj = new JSONObject(clean);
long creationDate = jsonObj.getLong("creationDate");
mess.setCreationDate(creationDate);
JSONArray jsonParams = (JSONArray) jsonObj.get("parameters");
List<MessageParameter> params = new ArrayList<>();
for (int i = 0; i < jsonParams.length(); i++) {
MessageParameter p = new MessageParameter();
JSONObject jsonParam = (JSONObject) jsonParams.get(i);
String url;
if (!jsonObj.isNull("url")) {
p.setURL((String) jsonObj.get("url"));
}
if (!jsonObj.isNull("encoding")) {
p.setEncoding(jsonObj.getString("encoding"));
}
if (!jsonObj.isNull("attributes")) {
Map<String, String> attributes = new ObjectMapper().readValue("", Map.class);
p.setAttributes(attributes);
}
String val = jsonParam.getString("value");
val = val.replaceAll("\"", "\\\"");
p.setValue(val);
params.add(p);
}
mess.setParameters(params);
return mess;
}
public static Attribute plan1toFile(PlanResponse plan1) throws JSONException {
Attribute e = new Attribute();
e.level = String.valueOf(plan1.getLevel());
String p1Name = FilenameUtils.getBaseName(plan1.getName());
if (p1Name == null) {
p1Name = "Planned_tosca_file_" + plan1.getLevel();
plan1.setName(p1Name);
}
e.name = p1Name;
String ymlString = Converter.map2YmlString(plan1.getKeyValue());
e.content = ymlString.replaceAll("\n", "\\\\n");
return e;
}
public static PlanResponse File2Plan1(Attribute p0) {
PlanResponse p1 = new PlanResponse();
p1.setTimestamp(System.currentTimeMillis());
p1.setLevel(Integer.valueOf(p0.level));
p1.setName(p0.name);
String yaml = p0.content.replaceAll("\\\\n", "\n");
p1.setKvMap(ymlString2Map(yaml));
return p1;
}
}
/*
* 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 java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
/**
*
* @author S. Koulouzis
*/
public class FileHash {
/**
* Code from: http://www.mkyong.com/java/java-sha-hashing-example/
*
* @param filePath
* @return
* @throws NoSuchAlgorithmException
* @throws FileNotFoundException
* @throws IOException
*/
public static String getSHA256(String filePath) throws NoSuchAlgorithmException, FileNotFoundException, IOException {
MessageDigest md = MessageDigest.getInstance("SHA-256");
FileInputStream fis = new FileInputStream(filePath);
byte[] dataBytes = new byte[1024];
int nread;
while ((nread = fis.read(dataBytes)) != -1) {
md.update(dataBytes, 0, nread);
}
byte[] mdbytes = md.digest();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < mdbytes.length; i++) {
sb.append(Integer.toString((mdbytes[i] & 0xff) + 0x100, 16).substring(1));
}
return sb.toString();
}
}
/*
* 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.core.JsonParser;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.TimeoutException;
import org.apache.commons.io.FileUtils;
import org.json.JSONException;
import nl.uva.sne.drip.drip.commons.data.internal.Message;
import nl.uva.sne.drip.drip.commons.data.internal.MessageParameter;
/**
*
* @author S. Koulouzis
*/
public class MessageGenerator {
public static Message generateArtificialMessage(String path) throws IOException, TimeoutException, InterruptedException, JSONException {
String strResponse = FileUtils.readFileToString(new File(path));
String clean = strResponse;
if (strResponse.contains("'null'")) {
clean = strResponse.replaceAll("'null'", "null").replaceAll("\'", "\"").replaceAll(" ", "");
}
if (clean.contains("\"value\":{\"")) {
return Converter.string2Message(clean);
}
if (clean.contains("\"null\"")) {
clean = clean.replaceAll("\"null\"", "null");
}
ObjectMapper mapper = new ObjectMapper();
mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
return mapper.readValue(clean, Message.class);
}
}
/*
Copyright (c) 2002 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The Software shall be used for Good, not Evil.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package nl.uva.sne.drip.commons.utils;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.Properties;
import org.json.JSONException;
import org.json.JSONObject;
/**
*
* Code from https://github.com/stleary/JSON-java/blob/master/Property.java
*/
public class Property {
/**
* Converts a property file object into a JSONObject. The property file
* object is a table of name value pairs.
*
* @param properties java.util.Properties
* @return JSONObject
* @throws JSONException
*/
public static JSONObject toJSONObject(java.util.Properties properties) throws JSONException {
JSONObject jo = new JSONObject();
if (properties != null && !properties.isEmpty()) {
Enumeration<?> enumProperties = properties.propertyNames();
while (enumProperties.hasMoreElements()) {
String name = (String) enumProperties.nextElement();
jo.put(name, properties.getProperty(name));
}
}
return jo;
}
/**
* Converts the JSONObject into a property file object.
*
* @param jo JSONObject
* @return java.util.Properties
* @throws JSONException
*/
public static Properties toProperties(JSONObject jo) throws JSONException {
Properties properties = new Properties();
if (jo != null) {
Iterator<String> keys = jo.keys();
while (keys.hasNext()) {
String name = keys.next();
properties.put(name, jo.getString(name));
}
}
return properties;
}
}
/*
* Copyright 2017 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.drip.commons.data.internal;
import java.io.Serializable;
import java.util.List;
//import javax.persistence.Column;
//import javax.persistence.Entity;
//import javax.persistence.GeneratedValue;
//import javax.persistence.GenerationType;
//import javax.persistence.Id;
//import javax.persistence.Temporal;
//import javax.persistence.TemporalType;
/**
*
*
*
* @author S. Koulouzis.
*/
public class Message implements Serializable {
private Long creationDate;
private List<MessageParameter> parameters;
public Long getCreationDate() {
return this.creationDate;
}
public void setParameters(List<MessageParameter> parameters) {
this.parameters = parameters;
}
public List<MessageParameter> getParameters() {
return this.parameters;
}
public void setCreationDate(Long creationDate) {
this.creationDate = creationDate;
}
}
/*
* Copyright 2017 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.drip.commons.data.internal;
import java.io.Serializable;
import java.util.Map;
/**
*
* @author S. Koulouzis.
*/
public class MessageParameter implements Serializable {
private String url;
private String encoding;
private String value;
private String name;
private Map<String, String> attributes;
public static final String NAME = "name";
public static final String URL = "url";
public static final String VALUE = "value";
public static final String ENCODING = "encoding";
public String getURL() {
return this.url;
}
public void setURL(String url) {
this.url = url;
}
public String getEncoding() {
return this.encoding;
}
public void setEncoding(String encoding) {
this.encoding = encoding;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
public String getValue() {
return this.value;
}
public void setValue(String value) {
this.value = value;
}
/**
* @return the attributes
*/
public Map<String, String> getAttributes() {
return attributes;
}
/**
* @param attributes the attributes to set
*/
public void setAttributes(Map<String, String> attributes) {
this.attributes = attributes;
}
}
/*
* 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.drip.commons.data.v0.external;
import com.webcohesion.enunciate.metadata.DocumentationExample;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlValue;
/**
*
* @author S. Koulouzis
*/
public class Attribute {
/**
* Name of the file/public key.
*/
@DocumentationExample("planner_output_all")
@XmlAttribute
public String name;
/**
* There are two levels of description files for topologies designed by users.
* If the level attribute for the element file is 1, then this file is the top-level description,
* which defines how the sub-topologies are connected to each other.
* If the level attribute is 0, then the file is the low-level description,
* which describes the topology in one data center in detail.
* On the other hand, the name of low-level description file must be the
* sub-topology name appeared in the high-level description file. (For example, here should be zh_a and zh_b.)
*/
@DocumentationExample("0")
@XmlAttribute
public String level;
@XmlValue
public String content;
}
/*
* 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.drip.commons.data.v0.external;
import com.webcohesion.enunciate.metadata.DocumentationExample;
import javax.xml.bind.annotation.XmlRootElement;
/**
*
* @author S. Koulouzis
*/
@XmlRootElement
public class ConfScript extends Execute {
/**
* The script contents with new lines replace by '\n'
*/
@DocumentationExample("#!/bin/bash\\n\\nlogstashScript=/root/runLogstash.sh\\nscreen -S logstash -dm /bin/bash \"$logstashScript\"\\n\\n\\nlogLevelPath=/root/\\nlogLevelFile=$logLevelPath/logstash_loglevel.csv\\nremotePath=/media/lobcder/skoulouz/\\nremoteLogPath=$remotePath/logs\\nlocalLogPath=/root/logs\\n\\nmkdir $localLogPath\\n\\n\\nfor logArchPath in $remoteLogPath/*.gz; do\\n echo \"File -> $logArchPath\"\\n if [ ! -f $logArchPath.lock ]; then\\n touch $logArchPath.lock\\n cp $logArchPath $localLogPath\\n logArchName=$(basename $logArchPath)\\n tar -xvf $localLogPath/$logArchName -C $localLogPath\\n sleep 120\\n modTime=-100\\n while [ ! -f $logLevelFile ]\\n do\\n sleep 5\\n done\\n while [ $modTime -lt 120 ]\\n do\\n moddate=$(stat -c %Y $logLevelFile)\\n moddate=${moddate%% *}\\n now=$(date +%s)\\n modTime=\"$(( $now - $moddate))\"\\n echo $modTime\\n sleep 5\\n done\\n rm $localLogPath/*.tar.gz\\n rm $localLogPath/*.log\\n modTime=-100\\n fi\\ndone\\n \\n\\nscreen -X -S logstash quit\\nsleep 5\\n\\nuid=`ifconfig | grep eth0 | awk '{print $NF}' | sed 's/://g'`\\n\\nfor csvFiles in $logLevelPath/*.csv; do\\n echo $csvFiles $csvFiles$uid.csv\\n mv $csvFiles $csvFiles$uid.csv\\n cp $csvFiles$uid.csv $remotePath\\ndone\\n\\nkillall java \\n")
public String script;
}
/*
* 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.drip.commons.data.v0.external;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
/**
*
* @author S. Koulouzis
*/
@XmlRootElement
public class ConfUserKey extends Execute {
@XmlElement(name = "userKey")
public List<Attribute> file;
}
/*
* 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.drip.commons.data.v0.external;
import com.webcohesion.enunciate.metadata.DocumentationExample;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
/**
*
* @author S. Koulouzis
*/
@XmlRootElement
public class Configure {
/**
* Not used. It's there for backwards compatibility.
*/
@DocumentationExample("user")
public String user;
/**
* Not used. It's there for backwards compatibility.
*/
@DocumentationExample("123")
public String pwd;
/**
* The key id for the cloud provider.
*
*/
@DocumentationExample("AKIAITY3K5ZUQ6M7YBSQ")
public String keyid;
/**
* The key for the cloud provider.
*/
@DocumentationExample("6J7uo99ifrff45126Gsy5vgb3bmrtwY6hBxtYt9y")
public String key;
@XmlElement(name = "loginKey")
public List<LoginKey0> loginKey;
/**
* The binary keystore (user.jks) for the cloud provider encoded in base64
*/
@DocumentationExample("/u3+7QAAAAIAAAABAWuf2AAACvDCCArgwDgYKKwYBBEBAQUABIIC\\npKlNUfpKLNCy0h8P4L5XeECwwIN/tezeaOVsjvzLsXeiBsB/luYv9gttoeKFbcJb/IDpZr\\nfpL1tjF8Sed6g38kNoWwnVVoNZ1ILpITjESL6FkZW+gGAPS+XHp8l52/2DjeECQlx+38GlFUftWP\\nn3QH9bDYD+7sRtm4P0YWnekX67ltQHMV+Cyrg0HAFm+GUzJJoxu64MccURLBMw0If9gCmTOuVoRj\\nprPukU+cMY8torQ3+WmzC0S6U10HjQ2AkJ80HwM6CcS82qflHIBfQ/o7ep76rCDN22widcLGOihU\\nbJiNQtNdF6KRCJk0emVIvRHDHctsmmt2ao2Qx6ub2mA/eUZtlphHMVN5VQtSxdd87tKrH9FvaOe3\\nGX/irmBBopS2mfFee4LPn3FT/F5bl9YunygX3sWLGNsCl8G15hzgSSVn4As37czUulj8hks/Qpvu\\nqoVpegs2+m5mXbSMmif+cUPqyJZ8UL5slIGZMKQ7MJG1XVG6vFIHk3cS+L+NpDd2j8DZqBP5FXIO\\nCt/IxZxR2ZfPHHmIbOhwdnaznOoyAEGDzFTXnyTClGTDTW/6zxOe/ynNPlnBQaNqVJYqPtFG4AVs\\nhrSNuvYjm1xsVDROQI5LYF/nryU4VvqMTo2sjVP2g6Qw7E5ENWiYUAl2W+bk4H6WGDTdQgLm2J65\\ngdZpQTQtubzWi8Fxrptqul5eq96l0xH15XQ9lBKV0J8PEMa1jKOW/9s2U++hAtKTixssVntaNyUY\\n9dnXNYHnQRKXDrQr/izerNEhvlVcz6foWDurtjAIjxafyEBbXJ5TAyT4rxmkPxDg88LPXKCzpf1x\\n3WwD8MBUNBC9nfB37rHxEl7StvnK3IXBHmEksg7X6xhmUsrsQo8mfP05XDmqt+lsiYoAAAACAAVY\\nLjUwOQAAAz8wggM7MIICpKADAgECAgJFBDANBgkqhkiG9w0BAQUFADCBiTEUMBIGA1UEChMLY2gu\\nZ2VuaS5uZXQxEjAQBgNVBAsTCWF1dGhvcml0eTELMAkGA1UECxMCbWExLTArBgNVBAMTJDMxYzBm\\nMDlmLTk1ZjctNDUxMC1hMzBiLWQ5M2RmMmJkMDJjOTEhMB8GCSqGSIb3DQEJARYSY2gtYWRtaW5z\\nQGdlbmkubmV0MB4XDTE3MDEyNTE0NTY0OVoXDTE4MDEyNTE0NTY0OVowUjEtMCsGA1UEAxMkYmY4\\nYThhNTQtN2FjOS00NTEzLWIyZTItYjJjN2U2YWUwMDVkMSEwHwYJKoZIhvcNAQkBFhJzLmtvdWxv\\ndXppc0B1dmEubmwwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANmwnBJETSZSQm67FxQHL0s6\\n84SYlYh6ltgi8DfwRu/wMA8sL5PsuupNvgKJCVHHZzPVwIrUy8JxpFrX3BItaDX+VPR+6sBJqUan\\nBeb3vojU6CyEZzwCAOhn9OxB8ZFyoMD6SwsykPBOeXhGKpWsOoBwQDx8i6xpto1AP3KY8DpxAgMB\\nAAGjgecwgeQwHQYDVR0OBBYEFNTBvaP5OnG0h8exiS8Ob0ZvfF8FMD4GA1UdIwQ3MDWAFHGlguYe\\n8bTQK4umhY/oGl1ifTGuoRqkGDAWMRQwEgYDVQQDEwtjaC5nZW5pLm5ldIIBAzAJBgNVHRMEAjAA\\nMHgGA1UdEQRxMG+BEnMua291bG91emlzQHV2YS5ubIYqdXJuOnB1YmxpY2lkOklETitjaC5nZW5p\\nLm5ldCt1c2VyK3Nrb3Vsb3V6hi11cm46dXVpZDpiZjhhOGE1NC03YWM5LTQ1MTMtYjJlMi1iMmM3\\nZTZhZTAwNWQwDQYJKoZIhvcNAQEFBQADgYEAP/9ihMCaalsPRBMDozgX2Wd6eFCNYuDIMFTeNkKa\\nkWJp156oQ4iAmbtP2R9r4W02gjEQRtUxvBhYI2Rp32wl1ZLdpSwnuZAE1H89dIHTct48VkiI1Zp9\\n5BtV4olBUAf2K2hd46pH3ObUAYZvWQGoT+oOlfcacAaEUNp01afC8voABVguNTA5AAADUzCCA08w\\nggK4oAMCAQICAQMwDQYJKoZIhvcNAQEFBQAwFjEUMBIGA1UEAxMLY2guZ2VuaS5uZXQwHhcNMTMw\\nNTIwMTMxODI3WhcNMTgwNTE5MTMxODI3WjCBiTEUMBIGA1UEChMLY2guZ2VuaS5uZXQxEjAQBgNV\\nBAsTCWF1dGhvcml0eTELMAkGA1UECxMCbWExLTArBgNVBAMTJDMxYzBmMDlmLTk1ZjctNDUxMC1h\\nMzBiLWQ5M2RmMmJkMDJjOTEhMB8GCSqGSIb3DQEJARYSY2gtYWRtaW5zQGdlbmkubmV0MIGfMA0G\\nCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC4LG9Xl2veo5+Zy1fDi47ajinYu+mv8QYDya2Hf8lPolQy\\nlnGFFQRMx/JsbG1BBQ86FqSeUWtvANhY1nRlrozutOBeg9EEfhX+JXvVdhEKQ4/ANliC0V1UR3GO\\nJHtQaj/6qoG/q01bWP7EJgf+ZPfTdCgCkJ89v8oth1m3UjCxcQIDAQABo4IBNzCCATMwHQYDVR0O\\nBBYEFHGlguYe8bTQK4umhY/oGl1ifTGuMEYGA1UdIwQ/MD2AFEU22V1Y/0L1KwlqbnkdPIMEy5hR\\noRqkGDAWMRQwEgYDVQQDEwtjaC5nZW5pLm5ldIIJAJvH3dZoB97bMEcGCCsGAQUFBwEBBDswOTA3\\nBhRpg8yTgKiYzKjHvbGngICqrteKG4YfaHR0cHM6Ly9jaC5nZW5pLm5ldC9jYWluZm8uaHRtbDBz\\nBgNVHREEbDBqgRJjaC1hZG1pbnNAZ2VuaS5uZXSGKXVybjpwdWJsaWNpZDpJRE4rY2guZ2VuaS5u\\nZXQrYXV0aG9yaXR5K21hhil1dWlkOjMxYzBmMDlmLTk1ZjctNDUxMC1hMzBiLWQ5M2RmMmJkMDJj\\nOTAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBAHgrtROjbfUT6HQCZCl1XuAEZQPse3/x\\nT2smC3LzAH4UUj3gEBq27VvxbqzazdBQCSeBEl2RUd+KoDzmhG5vBbAyHt8UE6s3P7Yx\\ngoNYTld0JHB5wq3XFRaaGbeVgo2AuK9S/Q3whzMTRW21a58tLP5zwKGzX3oyQQUT5J\\ncwv0z5NmJdAfk8Y=")
public String geniKey;
/**
* Key alias in key store
*/
@DocumentationExample("exogeni")
public String geniKeyAlias;
@XmlElement(name = "loginPubKey")
public List<LoginKey0> loginPubKey;
public String geniKeyPass;
@XmlElement(name = "loginPriKey")
public List<LoginKey0> loginPriKey;
}
/*
* 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.drip.commons.data.v0.external;
import javax.xml.bind.annotation.XmlRootElement;
/**
*
* @author S. Koulouzis
*/
@XmlRootElement
public class Deploy extends Execute {
}
/*
* 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.drip.commons.data.v0.external;
import com.webcohesion.enunciate.metadata.DocumentationExample;
import javax.xml.bind.annotation.XmlRootElement;
/**
*
* @author S. Koulouzis
*/
@XmlRootElement
public class Execute {
/**
* Not used. It's there for backwards compatibility.
*/
@DocumentationExample("user")
public String user;
/**
* Not used. It's there for backwards compatibility.
*/
@DocumentationExample("123")
public String pwd;
/**
* A referance id used from the servcie to do the provisioning
*/
@DocumentationExample("58c2c2f3a8d4b56889878d03")
public String action;
}
/*
* 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.drip.commons.data.v0.external;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlValue;
/**
*
* @author S. Koulouzis
*/
public class LoginKey0 {
@XmlAttribute(name="domain_name")
public String domain_name;
@XmlValue
public String content;
}
/*
* 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.drip.commons.data.v0.external;
import com.webcohesion.enunciate.metadata.DocumentationExample;
import java.io.Serializable;
import javax.xml.bind.annotation.XmlRootElement;
/**
*
* This class represents a plan to be provided to the planner.
*
* @author S. Koulouzis
*/
@XmlRootElement
public class Plan implements Serializable {
/**
* Not used. It's only there for backwords compatibility
*/
@DocumentationExample("user")
public String user;
/**
* Not used. It's only there for backwords compatibility
*/
@DocumentationExample("123")
public String pwd;
/**
* The contents of the TOSCA description
*/
@DocumentationExample("tosca_definitions_version: tosca_simple_yaml_1_0\\n\\n\\ndescription: example file for infrastructure planner\\n\\n\\nrepositories:\\n MOG_docker_hub: \\n description: MOG project’s code repository in GitHub\\n url: https://github.com/switch-project/mog\\n credential:\\n protocol: xauth\\n token_type: X-Auth-Token\\n # token encoded in Base64\\n token: 604bbe45ac7143a79e14f3158df67091\\n\\n\\nartifact_types:\\n tosca.artifacts.Deployment.Image.Container.Docker:\\n derived_from: tosca.artifacts.Deployment.Image\\n\\n\\ndata_types:\\n Switch.datatypes.QoS.AppComponent:\\n derived_from: tosca.datatypes.Root\\n properties:\\n response_time:\\n type: string\\n\\n Switch.datatypes.Application.Connection.EndPoint:\\n derived_from: tosca.datatypes.Root\\n properties:\\n address:\\n type: string\\n component_name:\\n type: string\\n netmask:\\n type: string\\n port_name:\\n type: string\\n\\n Switch.datatypes.Application.Connection.Multicast:\\n derived_from: tosca.datatypes.Root\\n properties:\\n multicastAddrIP:\\n type: string\\n multicastAddrPort:\\n type: integer\\n\\n Switch.datatypes.Network.EndPoint:\\n derived_from: tosca.datatypes.Root\\n properties:\\n address:\\n type: string\\n host_name:\\n type: string\\n netmask:\\n type: string\\n port_name:\\n type: string\\n\\n Switch.datatypes.Network.Multicast:\\n derived_from: tosca.datatypes.Root\\n properties:\\n multicastAddrIP:\\n type: string\\n multicastAddrPort:\\n type: integer\\n\\n\\nnode_types:\\n\\n Switch.nodes.Application.Container.Docker:\\n derived_from: tosca.nodes.Container.Application\\n properties:\\n QoS:\\n type: Switch.datatypes.QoS.AppComponent\\n artifacts:\\n docker_image:\\n type: tosca.artifacts.Deployment.Image.Container.Docker\\n interfaces:\\n Standard:\\n create:\\n inputs:\\n command:\\n type: string\\n exported_ports:\\n type: list\\n entry_schema:\\n type: string\\n port_bindings:\\n type: list\\n entry_schema:\\n type: string\\n\\n Switch.nodes.Application.Container.Docker.MOG.InputDistributor:\\n derived_from: Switch.nodes.Application.Container.Docker\\n artifacts:\\n docker_image:\\n type: tosca.artifacts.Deployment.Image.Container.Docker\\n file: \"mogswitch/InputDistributor:1.0\"\\n repository: MOG_docker_hub\\n properties:\\n inPort: \\n type: integer\\n waitingTime:\\n type: integer\\n multicastAddrIP:\\n type: string\\n multicastAddrPort:\\n type: integer\\n videoWidth:\\n type: integer\\n videoHeight:\\n type: integer\\n\\n Switch.nodes.Application.Container.Docker.MOG.ProxyTranscoder:\\n derived_from: Switch.nodes.Application.Container.Docker \\n artifacts:\\n docker_image:\\n type: tosca.artifacts.Deployment.Image.Container.Docker\\n file: \"mogswitch/ProxyTranscoder:1.0\"\\n repository: MOG_docker_hub\\n properties:\\n multicastAddrIP: \\n type: string\\n multicastAddrPort:\\n type: integer\\n videoWidth:\\n type: integer\\n videoHeight:\\n type: integer\\n\\n Switch.nodes.Application.Connection:\\n derived_from: tosca.nodes.Root \\n properties:\\n source:\\n type: Switch.datatypes.Application.Connection.EndPoint\\n target:\\n type: Switch.datatypes.Application.Connection.EndPoint\\n bandwidth:\\n type: string\\n latency: \\n type: string\\n jitter: \\n type: string\\n multicast:\\n type: Switch.datatypes.Application.Connection.Multicast\\n\\n Switch.nodes.Compute:\\n derived_from: tosca.nodes.Compute\\n properties:\\n OStype:\\n type: string\\n nodetype:\\n type: string\\n domain:\\n type: string\\n public_address:\\n type: string\\n \n"
+ " ethernet_port:\\n type: list\\n entry_schema:\\n type: tosca.datatypes.network.NetworkInfo\\n script:\\n type: string\\n installation:\\n type: string\\n ssh_credential:\\n type: tosca.datatypes.Credential\\n\\n Switch.nodes.Network:\\n derived_from: tosca.nodes.network.Network\\n properties:\\n bandwidth:\\n type: string\\n latency:\\n type: string\\n jitter:\\n type: string\\n source:\\n type: Switch.datatypes.Network.EndPoint\\n target:\\n type: Switch.datatypes.Network.EndPoint\\n multicast:\\n type: Switch.datatypes.Network.Multicast\\n\\n\\ntopology_template:\\n \\n node_templates:\\n 2d13d708e3a9441ab8336ce874e08dd1:\\n type: Switch.nodes.Application.Container.Docker.MOG.InputDistributor\\n artifacts:\\n docker_image:\\n file: \"mogswitch/InputDistributor:1.0\"\\n type: tosca.artifacts.Deployment.Image.Container.Docker\\n repository: MOG_docker_hub\\n properties:\\n QoS:\\n response_time: 30ms\\n inPort: 2000\\n waitingTime: 5\\n multicastAddrIP: 255.2.2.0\\n multicastAddrPort: 3000\\n videoWidth: 176\\n videoHeight: 100\\n interfaces:\\n Standard:\\n create:\\n implementation: docker_image\\n inputs:\\n command: InputDistributor\\n exported_ports:\\n - 2000\\n port_bindings:\\n - \"2000:2000\"\\n - \"3000:3000\"\\n\\n 8fcc1788d9ee462c826572c79fdb2a6a:\\n type: Switch.nodes.Application.Container.Docker.MOG.ProxyTranscoder\\n artifacts:\\n docker_image:\\n file: \"mogswitch/ProxyTranscoder:1.0\"\\n type: tosca.artifacts.Deployment.Image.Container.Docker\\n repository: MOG_docker_hub\\n properties:\\n QoS:\\n response_time: 30ms\\n multicastAddrIP: 255.2.2.0\\n multicastAddrPort: 3000\\n videoWidth: 176\\n videoHeight: 100\\n interfaces:\\n Standard:\\n create:\\n implementation: docker_image\\n inputs:\\n command: ProxyTranscoder\\n exported_ports:\\n - 80\\n port_bindings:\\n - \"8080:80\"\\n\\n 5e0add703c8a43938a39301f572e46c0:\\n type: Switch.nodes.Application.Connection\\n properties:\\n source:\\n address: 192.168.21.11\\n component_name: 2d13d708e3a9441ab8336ce874e08dd1\\n netmask: 255.255.255.0\\n port_name: \"inputDistributor_out\"\\n target:\\n address: 192.168.21.12\\n component_name: 8fcc1788d9ee462c826572c79fdb2a6a\\n netmask: 255.255.255.0\\n port_name: \"proxyTranscoder_in\"\\n latency: 30ms\\n bandwidth: 130MB/s\\n jitter: 500ms\\n multicast:\\n multicastAddrIP: 255.2.2.0\\n multicastAddrPort: 3000\\n")
public String file;
}
/*
* 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.drip.commons.data.v0.external;
import com.webcohesion.enunciate.metadata.DocumentationExample;
import javax.xml.bind.annotation.XmlRootElement;
/**
*
* @author S. Koulouzis
*/
@XmlRootElement
public class Register {
/**
* The user name
*/
@DocumentationExample("user")
public String user;
/**
* The user password
*/
@DocumentationExample("123abc")
public String pwd;
}
/*
* 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.drip.commons.data.v0.external;
import com.webcohesion.enunciate.metadata.DocumentationExample;
import java.util.List;
import javax.xml.bind.annotation.XmlRootElement;
/**
*
* @author S. Koulouzis
*/
@XmlRootElement
public class Result {
/**
* The status of the response
*/
@DocumentationExample("Success")
public String status;
/**
* Not used. Not used. It's there for backwards compatibility.
*/
@DocumentationExample("INFO")
public String info;
public List<Attribute> file;
}
/*
* 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.drip.commons.data.v0.external;
import java.util.List;
import javax.xml.bind.annotation.XmlRootElement;
/**
*
* @author S. Koulouzis
*/
@XmlRootElement
public class Upload {
public String user;
public String pwd;
public List<Attribute> file;
}
/*
* 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.drip.commons.data.v1.external;
import com.webcohesion.enunciate.metadata.DocumentationExample;
import java.util.List;
import org.springframework.data.mongodb.core.mapping.Document;
/**
* This class represents the cloud credentials. They are used by the provisoner
* to request for resources.
*
* @author S. Koulouzis
*/
@Document
public class CloudCredentials extends OwnedObject {
public static String ACCESS_KEY_NAME = "accessKeyId";
public static String SECRET_KEY_NAME = "secretKey";
private String secretKey;
private String accessKeyId;
private List<String> keyPairIDs;
private String cloudProviderName;
/**
* It is the secret key / password for accessing a cloud provider.
*
* @return the secret key
*/
@DocumentationExample("7A7vo19ffdfa4SAsA6gsF5Fgbfb5rtwY6hBxtYt12")
public String getSecretKey() {
return secretKey;
}
public void setSecretKey(String secretKey) {
this.secretKey = secretKey;
}
/**
* The name of the cloud provider
*
* @return the cloudProviderName
*/
@DocumentationExample("ec2")
public String getCloudProviderName() {
return cloudProviderName;
}
/**
* @param cloudProviderName the cloudProviderName to set
*/
public void setCloudProviderName(String cloudProviderName) {
this.cloudProviderName = cloudProviderName;
}
/**
* The access key ID for a cloud provider.
*
* @return the accessKeyId
*/
@DocumentationExample("AKIKIQY9K1ZUQ6M7YBSQ")
public String getAccessKeyId() {
return accessKeyId;
}
/**
* @param accessKeyId the accessKeyId to set
*/
public void setAccessKeyId(String accessKeyId) {
this.accessKeyId = accessKeyId;
}
/**
* The IDs of of the key pairs for accessing the VMs of that cloud provider.
*
* @return the keyPairIDs
*/
@DocumentationExample("AKIKIQY9K1ZUQ6M7YBSQ, LKJ2KIQY9K1F236M7YASD")
public List<String> getkeyPairIDs() {
return keyPairIDs;
}
/**
* @param keyIDs the keyPairIDs to set
*/
public void setKeyIDs(List<String> keyIDs) {
this.keyPairIDs = keyIDs;
}
}
/*
* 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.drip.commons.data.v1.external;
import com.webcohesion.enunciate.metadata.DocumentationExample;
/**
*
* This class is used by the deployer to deploy software
* (swarm,kubernetes,ansible). It is generated by the provisioner to contain VM
* information.
*
* @author S. Koulouzis
*/
public class DeployParameter {
private String cloudCertificateName;
private String IP;
private String user;
private String role;
/**
* The file name of the certificate used to log in as root to the
* provisioned VM.
* @return the cloudCertificateName
*/
@DocumentationExample("Virginia")
public String getCloudCertificateName() {
return cloudCertificateName;
}
/**
* @param cloudCertificateName the cloudCertificateName to set
*/
public void setCloudCertificateName(String cloudCertificateName) {
this.cloudCertificateName = cloudCertificateName;
}
/**
* The public IP of the provisioned VM
* @return the IP
*/
@DocumentationExample("52.73.245.157")
public String getIP() {
return IP;
}
/**
* @param IP the IP to set
*/
public void setIP(String IP) {
this.IP = IP;
}
/**
* The user name of the account created on the provisioned VM
* @return the user
*/
@DocumentationExample("vm_user")
public String getUser() {
return user;
}
/**
* @param user the user to set
*/
public void setUser(String user) {
this.user = user;
}
/**
* The role of the provisioned VM
* @return the role
*/
@DocumentationExample("slave")
public String getRole() {
return role;
}
/**
* @param role the role to set
*/
public void setRole(String role) {
this.role = role;
}
}
/*
* 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.drip.commons.data.v1.external;
import com.webcohesion.enunciate.metadata.DocumentationExample;
/**
* This class holds the necessary POJO IDs to request the deployment of a
* software
*
* @author S. Koulouzis
*/
public class DeployRequest extends OwnedObject {
private String provisionID;
private String managerType;
private String configurationID;
/**
* The ID of the provision resources description <code>ProvisionResponse</code>
* @return the provisionID
*/
@DocumentationExample("58e3946e0fb4f562d84ba1ad")
public String getProvisionID() {
return provisionID;
}
/**
* @param provisionID the provisionID to set
*/
public void setProvisionID(String provisionID) {
this.provisionID = provisionID;
}
/**
* The type of deployment manager to be used (swarm, ansile, kubernetes)
* @return the managerType
*/
@DocumentationExample("ansible")
public String getManagerType() {
return managerType;
}
/**
* @param managerType the managerType to set
*/
public void setManagerType(String managerType) {
this.managerType = managerType;
}
/**
* The ID of the configuration POJO that contains information used the
* chosen deployment manager (for now only ansible)
* <code>PlaybookRepresentation</code>
* @return the configurationID
*/
@DocumentationExample("58e3946e0fb4f562d84ba1ad")
public String getConfigurationID() {
return configurationID;
}
/**
* @param configurationID the configurationID to set
*/
public void setConfigurationID(String configurationID) {
this.configurationID = configurationID;
}
}
/*
* 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.drip.commons.data.v1.external;
import java.util.List;
import org.springframework.data.mongodb.core.mapping.Document;
/**
* This class represents the response of a deploy request. It may hold a key
* pair used for logging in and managing a docker cluster. Currently they key
* pair is only used by kubernetes
*
* @author S. Koulouzis
*/
@Document
public class DeployResponse extends DeployRequest {
private KeyPair key;
private List<String> ansibleOutputListIDs;
public void setAnsibleOutputList(List<String> outputListIDs) {
this.ansibleOutputListIDs = outputListIDs;
}
/**
* @return the ansibleOutputList
*/
public List<String> getAnsibleOutputList() {
return ansibleOutputListIDs;
}
public void setKey(KeyPair key) {
this.key = key;
}
/**
* The key pair to log in and manage a docker cluster
*
* @return
*/
public KeyPair getKeyPair() {
return key;
}
}
/*
* 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.drip.commons.data.v1.external;
import com.webcohesion.enunciate.metadata.DocumentationExample;
import java.util.Map;
/**
* This class represents a key. This key can be used to either login to a VM
* created by the provisiner or by the VM to allow the user to login to the VMs
* from the machine the keys correspond to.
*
* @author S. Koulouzis
*/
public class Key{
private Map<String, String> attributes;
private String key;
private KeyType type;
private String name;
/**
* The name of the key.
*
* @return
*/
@DocumentationExample("id_dsa.pub")
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
/**
* This enu specifies if a key is private or public
*/
public static enum KeyType {
/**
* For private keys
*/
PRIVATE,
/**
* For public keys
*/
PUBLIC
}
/**
* The type of key
*
* @return the type
*/
@DocumentationExample("PRIVATE")
public KeyType getType() {
return type;
}
/**
* @param type the type to set
*/
public void setType(KeyType type) {
this.type = type;
}
/**
* A general use key,value. In the case of the cloud credentials it's used
* to specify the domain name for ec2
*
* @return the attributes
*/
@DocumentationExample("domain_name:Virginia")
public Map<String, String> getAttributes() {
return attributes;
}
/**
* @param attributes the attributes to set
*/
public void setAttributes(Map<String, String> attributes) {
this.attributes = attributes;
}
/**
* The contents of the key.
*
* @return the key
*/
@DocumentationExample("-----BEGIN RSA PRIVATE KEY-----\\nMIIEogIBAAKCAQEAm6AALYxkJFNzD3bfVJ4+hMY5j0/kqM9CURLKXMlYuAysnvoG8wZKx9Bedefm\\neNSse4zTg798ZA2kDMZFIrwp1AseTwtj8DDu5fhG5DjyI3g6iJltS5zFQdMXneDlHXBX8cncSzNY\\nRx0NdjEMAe7YttvI8FNlxL0VnMFli/HB/ftzYMe5+AmkSROncVGHiwoiUpj+vtobCFOYtXsCf6ri\\nd4lgWA5wv6DZT/JKCYymiBqgSXu3ueFcEzw5SAukARWVjn1xccjZkokFfBbO/FpYY00TrUTBw9S6\\nD3iM+gj8RT6EKILOmhrt71D21S95WAWIT7h2YBsy1KAvMixhNf9VaQIDAQABAoIBAHhVYK3Xl3tr\\nN1Xm0ctJTQg3ijxhR2qsUBgGUokqezpdOoD2zbbOz7XvTYsX1GLr967U9pwxzUpELexexwiTvDgk\\nnLv8D7ui6qbRsmc4DSsWBRSophVIVFKQmftO8Xow6x+fuYJAYmsicM1KIYHBILtL+PSzV8anenWq\\nKQ3r0tfCiQhEzKEk4b1uT3SJWQyHE++JAhVkO7lIeb6S9Dg1jAaAeMnJ/NiMxTarpPRnxe6hsTsH\\ngG1iKWo+Skcl4SknOc+CMEfyDjG4FL7MGhKduahsO8vMUrgGsDD7EH3NiX/FweB8La6qpDYAwFpC\\nycrooyhiyzw8Wb5gGaYnmvr9l70CgYEAx74O8JleXaHpxEAmh4h7VbLmJ3mOylfBmOdzcHeedJQw\\nack2SAv65WBI9S9MEQ7J/vFuyw5HNk3C/mcWgzDQXSNIhHLvl/Z9sux/Qpm3SQWLzBxKV3dJ4r\\nwcAxzVA93+/L1Nee+VOKnlyRumvVa6+XLsLagpap2AVcTqlerMcCgYEAx3T2pXtqkCE9eU/ov22r\\npdaKjgHoGOUg1CMEfWi/Ch6sYIIRyrHz6dhy+yR1pXNgPbLWdrn8l88F3+IsmbaMupMgRmqwEC3G\\n9Y2FglGIVvRdZaagvRxLzRCcvcN4v6OYs9ST4o1xlv7Qxphld+0XDKv7VSCv/rASuK8BqlFL3E8C\\ngYArMXJRnRjG7qh6g9TRIjZphdI3XxX9s5Rt2D8iZvuhAhqmBZjzY4PR7kxYmO2+EpCjzNnEl0XW\\n/GHaWbiIjhnAykx4N9KP7gGom3O5lzwHUme1XnFKcO2wDjQwJbufRmba8iQF1srN577mF+Z7ha4V\\nJ1duCTzvWF1KFX6sk/uhKQKBgAcDFai7rgNjJ8YcCRKxyFcMM9LKPl6hr4XFtWKzTAQPEABUkkuN\\n9gVClsg9f+VRKRECOIf0Ae1UWeCFEwxUXp4wjfHrzkTDVztKvmbWdvSXorDwKrZ7SC7tZpVFSfly\\nxuuLjadpUZT9YFmbAfY1X5oSccOMYqORjRbxEB3svb4BAoGAGTgFuq9Zojh/KIqY8b4HpEfmh6CQ\\nhLVfD98Nqd6GDbxgvIM0v4mFXE92x2jn35Ia0JdFyh3B8Vkl7sqQZfxDFXI9O9pte2mxY9ICaY\\n55+X/SN1pd53BH+gaPZJy/R+Vpvs5MN48hoUKy5UKpoFeUWrS5QArjtvNCm4SGlXw=\\n-----END RSA PRIVATE KEY-----\\n")
public String getKey() {
return key;
}
/**
* @param key the key to set
*/
public void setKey(String key) {
this.key = key;
}
}
/*
* 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.drip.commons.data.v1.external;
import com.fasterxml.jackson.annotation.JsonInclude;
import org.springframework.data.mongodb.core.mapping.Document;
/**
* This class hold the pair of public private keys. The keys may be used for
* logging in VMs.
*
* @author S. Koulouzis
*/
@Document
@JsonInclude(JsonInclude.Include.NON_NULL)
public class KeyPair extends OwnedObject {
private Key privateKey;
private Key publicKey;
/**
* @return the privateKey
*/
public Key getPrivateKey() {
return privateKey;
}
/**
* @param privateKey the privateKey to set
* @throws nl.uva.sne.drip.api.exception.KeyException
*/
public void setPrivateKey(Key privateKey) throws Exception {
if (privateKey != null && privateKey.getType() != Key.KeyType.PRIVATE) {
throw new Exception("Trying to add public key to private");
}
this.privateKey = privateKey;
}
/**
* @return the publicKey
*/
public Key getPublicKey() {
return publicKey;
}
/**
* @param publicKey the publicKey to set
* @throws nl.uva.sne.drip.api.exception.KeyException
*/
public void setPublicKey(Key publicKey) throws Exception {
if (publicKey != null && publicKey.getType() != Key.KeyType.PUBLIC) {
throw new Exception("Trying to add private to public");
}
this.publicKey = publicKey;
}
}
/*
* 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.drip.commons.data.v1.external;
import com.webcohesion.enunciate.metadata.DocumentationExample;
import java.util.Map;
import org.springframework.data.mongodb.core.mapping.Document;
/**
* This is a generic class that hold key-value pairs. It's main usage is to hold
* abstract types such as TOSCA.
*
* @author S. Koulouzis
*/
@Document
public class KeyValueHolder extends OwnedObject{
private Map<String, Object> keyValue;
/**
* The key-value map
* @return the keyValue
*/
@DocumentationExample("\"artifact_types\":{\"tosca.artifacts.Deployment.Image.Container.Docker\":"
+ "{\"derived_from\": \"tosca.artifacts.Deployment.Image\"}}")
public Map<String, Object> getKeyValue() {
return keyValue;
}
/**
* @param keyValue the keyValue to set
*/
public void setKvMap(Map<String, Object> keyValue) {
this.keyValue = keyValue;
}
}
/*
* 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.drip.commons.data.v1.external;
import com.webcohesion.enunciate.metadata.DocumentationExample;
import javax.persistence.MappedSuperclass;
import javax.validation.constraints.NotNull;
import org.springframework.data.annotation.Id;
/**
* This is the base class for users to own resources. Many classes extend this
* class
*
* @author S. Koulouzis
*/
@MappedSuperclass
public class OwnedObject {
@Id
private String id;
private Long timestamp;
@NotNull
private String owner;
/**
* The owner (username) for the particular object. This value is set when
* the DAO saves the object based on the principal how made the call
*
* @return the owner
*/
@DocumentationExample("user1")
public String getOwner() {
return owner;
}
/**
* @param owner the ownerID to set
*/
public void setOwner(String owner) {
this.owner = owner;
}
/**
* The UID of this object. This value is auto generated by the DAO when the
* object is saved.
*
* @return the id
*/
@DocumentationExample("58e3946e0fb4f562d84ba1ad")
public String getId() {
return id;
}
/**
* @return the timestamp
*/
public Long getTimestamp() {
return timestamp;
}
public void setTimestamp(Long timestamp) {
this.timestamp = timestamp;
}
}
/*
* 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.drip.commons.data.v1.external;
import com.webcohesion.enunciate.metadata.DocumentationExample;
import java.util.Set;
import org.springframework.data.mongodb.core.mapping.Document;
/**
*
* This class represents a plan generated by the planner.
*
* @author S. Koulouzis
*/
@Document
public class PlanResponse extends KeyValueHolder {
private String toscaID;
private String name;
private Integer level;
private Set<String> loweLevelPlansIDs;
/**
* The name of the generated plan
*
* @return the name
*/
@DocumentationExample("planner_output_all.yml")
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* The id of the TOSCA <code>PlaybookRepresentation</code> description from
* which this plan was generated
*
* @return the toscaID
*/
@DocumentationExample("58e3946e0fb4f562d84ba1ad")
public String getToscaID() {
return toscaID;
}
/**
* @param toscaID the toscaID to set
*/
public void setToscaID(String toscaID) {
this.toscaID = toscaID;
}
/**
* The level of the plan. Some provisioners use levels to represent a plan.
* In these cases there are two levels of TOSCA descriptions.
*
* @return the level
*/
@DocumentationExample("0")
public Integer getLevel() {
return level;
}
/**
* @param level the level to set
*/
public void setLevel(Integer level) {
this.level = level;
}
/**
* The list of the lower level plans attached to this plan. Some
* provisioners use levels to represent a plan. In these cases there are two
* levels of TOSCA descriptions.
*
*
* @return the loweLevelPlansIDs
*/
@DocumentationExample("ew44Ae3946e0sdds4f562d84baA")
public Set<String> getLoweLevelPlanIDs() {
return loweLevelPlansIDs;
}
public void setLoweLevelPlansIDs(Set<String> loweLevelPlansIDs) {
this.loweLevelPlansIDs = loweLevelPlansIDs;
}
}
/*
* 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.drip.commons.data.v1.external;
import org.springframework.data.mongodb.core.mapping.Document;
/**
* This class represents a playbook used by ansible manager to deploy software.
*
* @author S. Koulouzis
*/
@Document
public class PlaybookRepresentation extends KeyValueHolder {
}
/*
* 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.drip.commons.data.v1.external;
import com.webcohesion.enunciate.metadata.DocumentationExample;
import java.util.List;
import org.springframework.data.mongodb.core.mapping.Document;
/**
* This class is a holder for the the object IDs that are required by the
* provisioner to request for cloud resources.
*
* @author S. Koulouzis
*/
@Document
public class ProvisionRequest extends KeyValueHolder {
private List<String> cloudCredentialsIDs;
private String planID;
private List<String> keyPairIDs;
/**
* The cloud credentials ids required to provision the cloud resources.
*
* @return the cloudCredentialsIDs
*/
@DocumentationExample("58e3946e0fb4f562d84ba1ad")
public List<String> getCloudCredentialsIDs() {
return cloudCredentialsIDs;
}
/**
* @param cloudCredentialsIDs the cloudCredentialsIDs to set
*/
public void setCloudCredentialsIDs(List<String> cloudCredentialsIDs) {
this.cloudCredentialsIDs = cloudCredentialsIDs;
}
/**
* The ID of the plan <code>PlanResponse</code> to provision for.
*
* @return the planID
*/
@DocumentationExample("ASedsfd46b4fDFd83ba1q")
public String getPlanID() {
return planID;
}
/**
* @param planID the planID to set
*/
public void setPlanID(String planID) {
this.planID = planID;
}
/**
* The key pair id for the keys to use to log in the provisioned VMs.
* @return the keyPairIDs
*/
@DocumentationExample("ASedsfd46b4fFd344a1A")
public List<String> getKeyPairIDs() {
return keyPairIDs;
}
/**
* @param userKeyID the keyPairIDs to set
*/
public void setKeyPairIDs(List<String> userKeyID) {
this.keyPairIDs = userKeyID;
}
}
/*
* 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.drip.commons.data.v1.external;
import java.util.List;
/**
* This class represents a description of provisioned resources
*
* @author S. Koulouzis
*/
public class ProvisionResponse extends ProvisionRequest {
private List<DeployParameter> deployParameters;
/**
* The deploy parameters.
*
* @return the deployParameters
*/
public List<DeployParameter> getDeployParameters() {
return deployParameters;
}
/**
* @param deployParameters the deployParameters to set
*/
public void setDeployParameters(List<DeployParameter> deployParameters) {
this.deployParameters = deployParameters;
}
}
/*
* 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.drip.commons.data.v1.external;
import com.webcohesion.enunciate.metadata.DocumentationExample;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
/**
* This class represents a simple script that can run on a provisioned VM.
*
* @author S. Koulouzis
*/
@Document
public class Script extends OwnedObject {
private String contents;
private String name;
/**
* The name of the script
*
* @return the name
*/
@DocumentationExample("config.sh")
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* The contents of the script
*
* @return the contents
*/
@DocumentationExample(" #!/bin/bash\n"
+ "echo \"Reading system-wide config....\" >&2\\n"
+ ". /etc/cool.cfg\n"
+ "if [ -r ~/.coolrc ]; then\n"
+ " echo \"Reading user config....\" >&2\\n"
+ " . ~/.coolrc\\n"
+ "fi")
public String getContents() {
return contents;
}
/**
* @param contents the contents to set
*/
public void setContents(String contents) {
this.contents = contents;
}
}
/*
* 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.drip.commons.data.v1.external;
import com.webcohesion.enunciate.metadata.DocumentationExample;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
/**
* This class is a representation of a TOSCA description.
*
* @author S. Koulouzis
*/
@Document
public class ToscaRepresentation extends KeyValueHolder {
private String name;
/**
* The name of the TOSCA description
*
* @return the name
*/
@DocumentationExample("input.yml")
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
}
/*
* 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.drip.commons.data.v1.external;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty.Access;
import com.webcohesion.enunciate.metadata.DocumentationExample;
import java.util.Collection;
import java.util.HashSet;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
/**
* This class represents a user.
*
* @author S. Koulouzis
*/
@Document
public class User implements UserDetails {
@Id
private String id;
private Collection<String> roles;
@JsonProperty(access = Access.WRITE_ONLY)
private String password;
@Indexed
private String username;
private boolean accountNonExpired;
private boolean accountNonLocked;
private boolean credentialsNonExpired;
private boolean enabled;
/**
* The unique id of this object. This value is auto-generated when the DAO
* saves this object
*
* @return the id
*/
@DocumentationExample("58e3946e0fb4f562d84ba1ad")
public String getId() {
return id;
}
@Override
@JsonIgnore
public Collection<? extends GrantedAuthority> getAuthorities() {
Collection<GrantedAuthority> athorities = new HashSet<>();
if (roles != null) {
for (String role : roles) {
String addedRole = role;
if (!role.startsWith("ROLE_")) {
addedRole = "ROLE_" + role;
}
athorities.add(new SimpleGrantedAuthority(addedRole));
}
}
return athorities;
}
@Override
public String getPassword() {
return this.password;
}
/**
* The username
*
* @return
*/
@Override
@DocumentationExample("user")
public String getUsername() {
return this.username;
}
/**
* If the account is not expired
*
* @return
*/
@Override
@DocumentationExample("true")
public boolean isAccountNonExpired() {
return this.accountNonExpired;
}
/**
* If the account is not locked
*
* @return
*/
@Override
@DocumentationExample("true")
public boolean isAccountNonLocked() {
return this.accountNonLocked;
}
/**
* If the credentials are not expired
*
* @return
*/
@Override
@DocumentationExample("true")
public boolean isCredentialsNonExpired() {
return this.credentialsNonExpired;
}
/**
* If the account is enabled
*
* @return
*/
@Override
@DocumentationExample("true")
public boolean isEnabled() {
return this.enabled;
}
/**
* @param password the password to set
*/
public void setPassword(String password) {
this.password = password;
}
/**
* @param username the username to set
*/
public void setUsername(String username) {
this.username = username;
}
/**
* @param accountNonExpired the accountNonExpired to set
*/
public void setAccountNonExpired(boolean accountNonExpired) {
this.accountNonExpired = accountNonExpired;
}
/**
* @param accountNonLocked the accountNonLocked to set
*/
public void setAccountNonLocked(boolean accountNonLocked) {
this.accountNonLocked = accountNonLocked;
}
/**
* @param credentialsNonExpired the credentialsNonExpired to set
*/
public void setCredentialsNonExpired(boolean credentialsNonExpired) {
this.credentialsNonExpired = credentialsNonExpired;
}
/**
* @param enabled the enabled to set
*/
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
/**
* The roles assigned to this user.
*
* @return the roles
*/
@DocumentationExample("[\"ADMIN\",\"USER\"]")
public Collection<String> getRoles() {
return roles;
}
/**
* @param roles the roles to set
*/
public void setRoles(Collection<String> roles) {
this.roles = roles;
}
/**
* @param id the id to set
*/
public void setId(String id) {
this.id = id;
}
}
/*
* 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.drip.commons.data.v1.external.ansible;
/**
*
* @author S. Koulouzis
*/
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import nl.uva.sne.drip.drip.commons.data.v1.external.OwnedObject;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
"host",
"result"
})
@Document
public class AnsibleOutput extends OwnedObject {
@Indexed
@JsonProperty("host")
private String host;
@Indexed
@JsonProperty("cloudDeploymentDomain")
private String cloudDeploymentDomain;
@Indexed
@JsonProperty("vmType")
private String vmType;
@JsonProperty("result")
private AnsibleResult result;
@JsonProperty("provisionID")
private String provisionID;
@JsonProperty("host")
public String getHost() {
return host;
}
@JsonProperty("host")
public void setHost(String host) {
this.host = host;
}
@JsonProperty("result")
public AnsibleResult getAnsibleResult() {
return result;
}
@JsonProperty("result")
public void setAnsiibleResult(AnsibleResult result) {
this.result = result;
}
@JsonProperty("cloudDeploymentDomain")
public String getCloudDeploymentDomain() {
return cloudDeploymentDomain;
}
@JsonProperty("cloudDeploymentDomain")
public void setCloudDeploymentDomain(String cloudDeploymentDomain) {
this.cloudDeploymentDomain = cloudDeploymentDomain;
}
@JsonProperty("vmType")
public String getVmType() {
return vmType;
}
@JsonProperty("vmType")
public void setVmType(String vmType) {
this.vmType = vmType;
}
@JsonProperty("provisionID")
public void setProvisionID(String provisionID) {
this.provisionID = provisionID;
}
@JsonProperty("provisionID")
public String getProvisionID() {
return provisionID;
}
}
/*
* 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.drip.commons.data.v1.external.ansible;
/**
*
* @author S. Koulouzis
*/
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Date;
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class AnsibleResult {
@JsonProperty("msg")
private String msg;
@JsonProperty("changed")
private Boolean changed;
@JsonProperty("end")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss.SSSSSS")
private Date end;
@JsonProperty("start")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss.SSSSSS")
private Date start;
@JsonProperty("delta")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm:ss.SSSSSS")
private Date delta;
@JsonProperty("stdout")
private String stdout;
@JsonProperty("stderr")
private String stderr;
@JsonProperty("cmd")
private List<String> cmd;
// @JsonProperty("stdout_lines")
// private List<String> stdout_lines;
// @JsonProperty("results")
// private List<AnsibleResult_> results = null;
@JsonProperty("msg")
public String getMsg() {
return msg;
}
@JsonProperty("msg")
public void setMsg(String msg) {
this.msg = msg;
}
@JsonProperty("changed")
public Boolean getChanged() {
return changed;
}
@JsonProperty("changed")
public void setChanged(Boolean changed) {
this.changed = changed;
}
// @JsonProperty("results")
// public List<AnsibleResult_> getAnsibleResults() {
// return results;
// }
//
// @JsonProperty("results")
// public void setAnsibleResults(List<AnsibleResult_> results) {
// this.results = results;
// }
@JsonProperty("end")
public Date getEnd() {
return end;
}
@JsonProperty("end")
public void setEnd(Date end) {
this.end = end;
}
@JsonProperty("stdout")
public String getStdout() {
return stdout;
}
@JsonProperty("stdout")
public void setStdout(String stdout) {
this.stdout = stdout;
}
@JsonProperty("cmd")
public List<String> getCmd() {
return cmd;
}
@JsonProperty("cmd")
public void setCmd(List<String> cmd) {
this.cmd = cmd;
}
@JsonProperty("start")
public Date getStart() {
return start;
}
@JsonProperty("start")
public void setStart(Date start) {
this.start = start;
}
@JsonProperty("stderr")
public String getStderr() {
return stderr;
}
@JsonProperty("stderr")
public void setStderr(String stderr) {
this.stderr = stderr;
}
@JsonProperty("delta")
public Date getDelta() {
return delta;
}
@JsonProperty("delta")
public void setDelta(Date delta) {
this.delta = delta;
}
// @JsonProperty("stdout_lines")
// public List<String> getStdout_lines() {
// return stdout_lines;
// }
//
// @JsonProperty("stdout_lines")
// public void setStdout_lines(List<String> stdout_lines) {
// this.stdout_lines = stdout_lines;
// }
}
/*
* 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.drip.commons.data.v1.external.ansible;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Date;
import nl.uva.sne.drip.drip.commons.data.v1.external.OwnedObject;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
/**
*
* @author S. Koulouzis
*/
@Document
public class BenchmarkResult extends OwnedObject {
@Indexed
private String host;
@Indexed
private String cloudDeploymentDomain;
@Indexed
@JsonProperty("vmType")
private String vmType;
@Indexed
@JsonProperty("end")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss.SSSSSS")
private Date end;
@Indexed
@JsonProperty("start")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss.SSSSSS")
private Date start;
@Indexed
@JsonProperty("delta")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm:ss.SSSSSS")
private Date delta;
/**
* @return the host
*/
public String getHost() {
return host;
}
/**
* @param host the host to set
*/
public void setHost(String host) {
this.host = host;
}
/**
* @return the cloudDeploymentDomain
*/
public String getCloudDeploymentDomain() {
return cloudDeploymentDomain;
}
/**
* @param cloudDeploymentDomain the cloudDeploymentDomain to set
*/
public void setCloudDeploymentDomain(String cloudDeploymentDomain) {
this.cloudDeploymentDomain = cloudDeploymentDomain;
}
/**
* @return the end
*/
public Date getEnd() {
return end;
}
/**
* @param end the end to set
*/
public void setEnd(Date end) {
this.end = end;
}
/**
* @return the start
*/
public Date getStart() {
return start;
}
/**
* @param start the start to set
*/
public void setStart(Date start) {
this.start = start;
}
/**
* @return the delta
*/
public Date getDelta() {
return delta;
}
/**
* @param delta the delta to set
*/
public void setDelta(Date delta) {
this.delta = delta;
}
/**
* @return the vmType
*/
public String getVmType() {
return vmType;
}
/**
* @param vmType the vmType to set
*/
public void setVmType(String vmType) {
this.vmType = vmType;
}
}
/*
* 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.drip.commons.data.v1.external.ansible;
/**
*
* @author S. Koulouzis
*/
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
"module_name",
"module_args"
})
public class Invocation {
@JsonProperty("module_name")
private String moduleName;
@JsonProperty("module_args")
private ModuleArgs moduleArgs;
@JsonProperty("module_name")
public String getModuleName() {
return moduleName;
}
@JsonProperty("module_name")
public void setModuleName(String moduleName) {
this.moduleName = moduleName;
}
@JsonProperty("module_args")
public ModuleArgs getModuleArgs() {
return moduleArgs;
}
@JsonProperty("module_args")
public void setModuleArgs(ModuleArgs moduleArgs) {
this.moduleArgs = moduleArgs;
}
}
/*
* 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.drip.commons.data.v1.external.ansible;
/**
*
* @author S. Koulouzis
*/
import java.util.HashMap;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import java.util.List;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
"dpkg_options",
"autoremove",
"force",
"name",
"install_recommends",
"package",
"purge",
"allow_unauthenticated",
"state",
"upgrade",
"update_cache",
"deb",
"only_upgrade",
"default_release",
"cache_valid_time"
})
public class ModuleArgs {
@JsonProperty("dpkg_options")
private String dpkgOptions;
@JsonProperty("autoremove")
private Boolean autoremove;
@JsonProperty("force")
private Boolean force;
@JsonProperty("name")
private List<String> name = null;
@JsonProperty("install_recommends")
private Object installRecommends;
@JsonProperty("package")
private List<String> _package = null;
@JsonProperty("purge")
private Boolean purge;
@JsonProperty("allow_unauthenticated")
private Boolean allowUnauthenticated;
@JsonProperty("state")
private String state;
@JsonProperty("upgrade")
private Object upgrade;
@JsonProperty("update_cache")
private Boolean updateCache;
@JsonProperty("deb")
private Object deb;
@JsonProperty("only_upgrade")
private Boolean onlyUpgrade;
@JsonProperty("default_release")
private Object defaultRelease;
@JsonProperty("cache_valid_time")
private Integer cacheValidTime;
@JsonProperty("dpkg_options")
public String getDpkgOptions() {
return dpkgOptions;
}
@JsonProperty("dpkg_options")
public void setDpkgOptions(String dpkgOptions) {
this.dpkgOptions = dpkgOptions;
}
@JsonProperty("autoremove")
public Boolean getAutoremove() {
return autoremove;
}
@JsonProperty("autoremove")
public void setAutoremove(Boolean autoremove) {
this.autoremove = autoremove;
}
@JsonProperty("force")
public Boolean getForce() {
return force;
}
@JsonProperty("force")
public void setForce(Boolean force) {
this.force = force;
}
@JsonProperty("name")
public List<String> getName() {
return name;
}
@JsonProperty("name")
public void setName(List<String> name) {
this.name = name;
}
@JsonProperty("install_recommends")
public Object getInstallRecommends() {
return installRecommends;
}
@JsonProperty("install_recommends")
public void setInstallRecommends(Object installRecommends) {
this.installRecommends = installRecommends;
}
@JsonProperty("package")
public List<String> getPackage() {
return _package;
}
@JsonProperty("package")
public void setPackage(List<String> _package) {
this._package = _package;
}
@JsonProperty("purge")
public Boolean getPurge() {
return purge;
}
@JsonProperty("purge")
public void setPurge(Boolean purge) {
this.purge = purge;
}
@JsonProperty("allow_unauthenticated")
public Boolean getAllowUnauthenticated() {
return allowUnauthenticated;
}
@JsonProperty("allow_unauthenticated")
public void setAllowUnauthenticated(Boolean allowUnauthenticated) {
this.allowUnauthenticated = allowUnauthenticated;
}
@JsonProperty("state")
public String getState() {
return state;
}
@JsonProperty("state")
public void setState(String state) {
this.state = state;
}
@JsonProperty("upgrade")
public Object getUpgrade() {
return upgrade;
}
@JsonProperty("upgrade")
public void setUpgrade(Object upgrade) {
this.upgrade = upgrade;
}
@JsonProperty("update_cache")
public Boolean getUpdateCache() {
return updateCache;
}
@JsonProperty("update_cache")
public void setUpdateCache(Boolean updateCache) {
this.updateCache = updateCache;
}
@JsonProperty("deb")
public Object getDeb() {
return deb;
}
@JsonProperty("deb")
public void setDeb(Object deb) {
this.deb = deb;
}
@JsonProperty("only_upgrade")
public Boolean getOnlyUpgrade() {
return onlyUpgrade;
}
@JsonProperty("only_upgrade")
public void setOnlyUpgrade(Boolean onlyUpgrade) {
this.onlyUpgrade = onlyUpgrade;
}
@JsonProperty("default_release")
public Object getDefaultRelease() {
return defaultRelease;
}
@JsonProperty("default_release")
public void setDefaultRelease(Object defaultRelease) {
this.defaultRelease = defaultRelease;
}
@JsonProperty("cache_valid_time")
public Integer getCacheValidTime() {
return cacheValidTime;
}
@JsonProperty("cache_valid_time")
public void setCacheValidTime(Integer cacheValidTime) {
this.cacheValidTime = cacheValidTime;
}
}
/*
* 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.drip.commons.data.v1.external.ansible;
import org.springframework.data.mongodb.core.mapping.Document;
/**
*
* @author S. Koulouzis
*/
@Document
public class SysbenchCPUBenchmark extends BenchmarkResult {
private String sysbenchVersion;
private int numberOfThreads;
private double executionTime;
private int totalNumberOfEvents;
private double avgEventsPerThread;
private double stddevEventsPerThread;
private double avgExecTimePerThread;
private double stddevExecTimePerThread;
private double minExecutionTimePerRequest;
private double avgExecutionTimePerRequest;
private double maxExecutionTimePerRequest;
private double approx95Percentile;
private String ansibleOutputID;
/**
* @return the sysbenchVersion
*/
public String getSysbenchVersion() {
return sysbenchVersion;
}
/**
* @param sysbenchVersion the sysbenchVersion to set
*/
public void setSysbenchVersion(String sysbenchVersion) {
this.sysbenchVersion = sysbenchVersion;
}
/**
* @return the numberOfThreads
*/
public int getNumberOfThreads() {
return numberOfThreads;
}
/**
* @param numberOfThreads the numberOfThreads to set
*/
public void setNumberOfThreads(int numberOfThreads) {
this.numberOfThreads = numberOfThreads;
}
/**
* @return the totalNumberOfEvents
*/
public int getTotalNumberOfEvents() {
return totalNumberOfEvents;
}
/**
* @param totalNumberOfEvents the totalNumberOfEvents to set
*/
public void setTotalNumberOfEvents(int totalNumberOfEvents) {
this.totalNumberOfEvents = totalNumberOfEvents;
}
/**
* @return the executionTime
*/
public double getExecutionTime() {
return executionTime;
}
/**
* @param executionTime the executionTime to set
*/
public void setExecutionTime(double executionTime) {
this.executionTime = executionTime;
}
/**
* @return the avgEventsPerThread
*/
public double getAvgEventsPerThread() {
return avgEventsPerThread;
}
/**
* @param avgEventsPerThread the avgEventsPerThread to set
*/
public void setAvgEventsPerThread(double avgEventsPerThread) {
this.avgEventsPerThread = avgEventsPerThread;
}
/**
* @return the stddevEventsPerThread
*/
public double getStddevEventsPerThread() {
return stddevEventsPerThread;
}
/**
* @param stddevEventsPerThread the stddevEventsPerThread to set
*/
public void setStddevEventsPerThread(double stddevEventsPerThread) {
this.stddevEventsPerThread = stddevEventsPerThread;
}
/**
* @return the avgExecTimePerThread
*/
public double getAvgExecTimePerThread() {
return avgExecTimePerThread;
}
/**
* @param avgExecTimePerThread the avgExecTimePerThread to set
*/
public void setAvgExecTimePerThread(double avgExecTimePerThread) {
this.avgExecTimePerThread = avgExecTimePerThread;
}
/**
* @return the stddevExecTimePerThread
*/
public double getStddevExecTimePerThread() {
return stddevExecTimePerThread;
}
/**
* @param stddevExecTimePerThread the stddevExecTimePerThread to set
*/
public void setStddevExecTimePerThread(double stddevExecTimePerThread) {
this.stddevExecTimePerThread = stddevExecTimePerThread;
}
/**
* @return the minExecutionTimePerRequest
*/
public double getMinExecutionTimePerRequest() {
return minExecutionTimePerRequest;
}
/**
* @param minExecutionTimePerRequest the minExecutionTimePerRequest to set
*/
public void setMinExecutionTimePerRequest(double minExecutionTimePerRequest) {
this.minExecutionTimePerRequest = minExecutionTimePerRequest;
}
/**
* @return the avgExecutionTimePerRequest
*/
public double getAvgExecutionTimePerRequest() {
return avgExecutionTimePerRequest;
}
/**
* @param avgExecutionTimePerRequest the avgExecutionTimePerRequest to set
*/
public void setAvgExecutionTimePerRequest(double avgExecutionTimePerRequest) {
this.avgExecutionTimePerRequest = avgExecutionTimePerRequest;
}
/**
* @return the maxExecutionTimePerRequest
*/
public double getMaxExecutionTimePerRequest() {
return maxExecutionTimePerRequest;
}
/**
* @param maxExecutionTimePerRequest the maxExecutionTimePerRequest to set
*/
public void setMaxExecutionTimePerRequest(double maxExecutionTimePerRequest) {
this.maxExecutionTimePerRequest = maxExecutionTimePerRequest;
}
/**
* @return the approx95Percentile
*/
public double getApprox95Percentile() {
return approx95Percentile;
}
/**
* @param approx95Percentile the approx95Percentile to set
*/
public void setApprox95Percentile(double approx95Percentile) {
this.approx95Percentile = approx95Percentile;
}
public void setAnsibleOutputID(String ansibleOutputID) {
this.ansibleOutputID = ansibleOutputID;
}
/**
* @return the ansibleOutputID
*/
public String getAnsibleOutputID() {
return ansibleOutputID;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>nl.uva.sne.drip</groupId>
<artifactId>drip</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>nl.uva.sne.drip</groupId>
<version>1.0-SNAPSHOT</version>
......@@ -14,6 +18,11 @@
</properties>
<dependencies>
<dependency>
<groupId>nl.uva.sne.drip</groupId>
<artifactId>drip-commons</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>nl.uva.sne.drip</groupId>
......@@ -21,7 +30,7 @@
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<dependency>
<groupId>nl.uva.sne.drip</groupId>
<artifactId>drip-provisioning-agent</artifactId>
<version>1.0-SNAPSHOT</version>
......
......@@ -15,13 +15,25 @@
*/
package nl.uva.sne.drip.drip.provisioner.utils;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.yaml.snakeyaml.Yaml;
import provisioning.credential.Credential;
import provisioning.credential.EC2Credential;
import provisioning.credential.EGICredential;
/**
*
......@@ -29,7 +41,10 @@ import org.json.JSONObject;
*/
public class MessageParsing {
public static File getTopology(JSONArray parameters, String tempInputDirPath, int level) throws JSONException, IOException {
private static ObjectMapper mapper;
public static List<File> getTopologies(JSONArray parameters, String tempInputDirPath, int level) throws JSONException, IOException {
List<File> topologyFiles = new ArrayList<>();
for (int i = 0; i < parameters.length(); i++) {
JSONObject param = (JSONObject) parameters.get(i);
String name = (String) param.get("name");
......@@ -38,28 +53,21 @@ public class MessageParsing {
int fileLevel = Integer.valueOf((String) attributes.get("level"));
if (fileLevel == level) {
String originalFilename = (String) attributes.get("filename");
String fileName = "";
// String[] parts = originalFilename.split("_");
// String prefix = "";
// //Clear date part form file name
// if (isNumeric(parts[0])) {
// for (int j = 1; j < parts.length; j++) {
// fileName += prefix + parts[j];
// prefix = "_";
// }
// } else {
fileName = originalFilename;
// }
String fileName = originalFilename;
File topologyFile = new File(tempInputDirPath + File.separator + fileName);
topologyFile.createNewFile();
String val = (String) param.get("value");
writeValueToFile(val, topologyFile);
return topologyFile;
topologyFiles.add(topologyFile);
//We should have only one top level topoloy
if (level == 0) {
return topologyFiles;
}
}
}
}
return null;
return topologyFiles;
}
public static void writeValueToFile(String value, File file) throws FileNotFoundException {
......@@ -71,4 +79,49 @@ public class MessageParsing {
}
}
public static List<File> getSSHKeys(JSONArray parameters, String tempInputDirPath, String filename) throws JSONException, IOException {
List<File> sshKeys = new ArrayList<>();
for (int i = 0; i < parameters.length(); i++) {
JSONObject param = (JSONObject) parameters.get(i);
String name = (String) param.get("name");
if (name.equals("sshkey")) {
String sshKeyContent = (String) param.get("value");
File sshKeyFile = new File(tempInputDirPath + File.separator + filename);
if (sshKeyFile.exists()) {
sshKeyFile = new File(tempInputDirPath + File.separator + i + "_" + filename);
}
if (sshKeyFile.createNewFile()) {
MessageParsing.writeValueToFile(sshKeyContent, sshKeyFile);
sshKeys.add(sshKeyFile);
}
}
}
return sshKeys;
}
public static Map<String, Object> ymlStream2Map(InputStream in) {
Yaml yaml = new Yaml();
Map<String, Object> map = (Map<String, Object>) yaml.load(in);
return map;
}
private static Map<String, String> getCloudRawCredentials(JSONArray parameters) throws JSONException, FileNotFoundException {
Map<String, String> map = new HashMap<>();
for (int i = 0; i < parameters.length(); i++) {
JSONObject param = (JSONObject) parameters.get(i);
String name = (String) param.get("name");
if (name.startsWith("cloud_credential")) {
map.put(name, (String) param.get("value"));
}
}
return map;
}
public static List<Credential> getCloudCredentials(JSONArray parameters, String tempInputDirPath) throws JSONException, FileNotFoundException {
mapper = new ObjectMapper();
mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
return null;
}
}
......@@ -161,12 +161,12 @@ public class Consumer extends DefaultConsumer {
geniConfFile = cloudConfFile;
}
File topologyFile = MessageParsing.getTopology(parameters, tempInputDirPath, 0);
File topologyFile = MessageParsing.getTopologies(parameters, tempInputDirPath, 0).get(0);
File mainTopologyFile = new File(tempInputDirPath + "topology_main");
FileUtils.moveFile(topologyFile, mainTopologyFile);
mainTopologyPath = mainTopologyFile.getAbsolutePath();
topologyFile = MessageParsing.getTopology(parameters, tempInputDirPath, 1);
topologyFile = MessageParsing.getTopologies(parameters, tempInputDirPath, 1).get(0);
File secondaryTopologyFile = new File(tempInputDirPath + File.separator + topologyFile.getName() + ".yml");
String outputFilePath = tempInputDirPath + File.separator + topologyFile.getName() + "_provisioned.yml";
TopologyElement x = new TopologyElement();
......@@ -180,7 +180,7 @@ public class Consumer extends DefaultConsumer {
logDir = getLogDirPath(parameters, tempInputDirPath);
File sshKey = getSSHKey(parameters, tempInputDirPath);
File sshKey = MessageParsing.getSSHKeys(parameters, tempInputDirPath, "user.pem").get(0);
if (sshKey != null) {
sshKeyFilePath = sshKey.getAbsolutePath();
}
......@@ -419,22 +419,6 @@ public class Consumer extends DefaultConsumer {
return System.getProperty("java.io.tmpdir");
}
private File getSSHKey(JSONArray parameters, String tempInputDirPath) throws JSONException, IOException {
for (int i = 0; i < parameters.length(); i++) {
JSONObject param = (JSONObject) parameters.get(i);
String name = (String) param.get("name");
if (name.equals("sshkey")) {
String sshKeyContent = (String) param.get("value");
File sshKeyFile = new File(tempInputDirPath + File.separator + "user.pem");
if (sshKeyFile.createNewFile()) {
MessageParsing.writeValueToFile(sshKeyContent, sshKeyFile);
return sshKeyFile;
}
}
}
return null;
}
private File getSciptFile(JSONArray parameters, String tempInputDirPath) throws JSONException, IOException {
for (int i = 0; i < parameters.length(); i++) {
JSONObject param = (JSONObject) parameters.get(i);
......
......@@ -21,9 +21,12 @@ import com.rabbitmq.client.DefaultConsumer;
import com.rabbitmq.client.Envelope;
import commonTool.CommonTool;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -31,11 +34,15 @@ import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import nl.uva.sne.drip.drip.provisioner.utils.MessageParsing;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import provisioning.credential.Credential;
import provisioning.credential.EC2Credential;
import provisioning.credential.EGICredential;
import provisioning.credential.SSHKeyPair;
......@@ -125,19 +132,21 @@ public class Consumer extends DefaultConsumer {
private void startTopology(JSONArray parameters, String tempInputDirPath) throws Exception {
String topTopologyLoadingPath = "ES/EGI/zh_all_test.yml";
File topologyFile = MessageParsing.getTopology(parameters, tempInputDirPath, 0);
File mainTopologyFile = new File(tempInputDirPath + "topology_main");
File topologyFile = MessageParsing.getTopologies(parameters, tempInputDirPath, 0).get(0);
File mainTopologyFile = new File(tempInputDirPath + "topology_main.yml");
FileUtils.moveFile(topologyFile, mainTopologyFile);
topTopologyLoadingPath = mainTopologyFile.getAbsolutePath();
//load 2nd level in same folder
topologyFile = MessageParsing.getTopology(parameters, tempInputDirPath, 1);
File secondaryTopologyFile = new File(tempInputDirPath + File.separator + topologyFile.getName() + ".yml");
String outputFilePath = tempInputDirPath + File.separator + topologyFile.getName() + "_provisioned.yml";
FileUtils.moveFile(topologyFile, secondaryTopologyFile);
String topTopologyLoadingPath = mainTopologyFile.getAbsolutePath();
System.exit(-1);
List<File> topologyFiles = MessageParsing.getTopologies(parameters, tempInputDirPath, 1);
for (File lowLevelTopologyFile : topologyFiles) {
File secondaryTopologyFile = new File(tempInputDirPath + File.separator + lowLevelTopologyFile.getName() + ".yml");
FileUtils.moveFile(lowLevelTopologyFile, secondaryTopologyFile);
}
Map<String, Object> map = MessageParsing.ymlStream2Map(new FileInputStream(topTopologyLoadingPath));
String publicKeyName = ((String) map.get("publicKeyPath")).split("@")[1].replaceAll("\"", "");
List<File> sshKeys = MessageParsing.getSSHKeys(parameters, tempInputDirPath, publicKeyName);
String currentDir = CommonTool.getPathDir(topTopologyLoadingPath);
......@@ -146,21 +155,30 @@ public class Consumer extends DefaultConsumer {
throw new Exception("sth wrong!");
}
////Initial credentials and ssh key pairs
List<Credential> credentials = MessageParsing.getCloudCredentials(parameters, tempInputDirPath);
UserCredential userCredential = new UserCredential();
for (Credential cred : credentials) {
////Initial credentials and ssh key pairs
if (userCredential.cloudAccess == null) {
userCredential.cloudAccess = new HashMap<>();
}
if (cred instanceof EC2Credential) {
userCredential.cloudAccess.put("ec2", cred);
}
if (cred instanceof EGICredential) {
userCredential.cloudAccess.put("egi", cred);
}
}
EC2Credential ec2Credential = new EC2Credential();
ec2Credential.accessKey = "23332323wer";
ec2Credential.secretKey = "fdfsdffdfsdf";
// EC2Credential ec2Credential = new EC2Credential();
// ec2Credential.accessKey = "23332323wer";
// ec2Credential.secretKey = "fdfsdffdfsdf";
//
// EGICredential egiCredential = new EGICredential();
// egiCredential.proxyFilePath = "/tmp/x509up_u0";
// egiCredential.trustedCertPath = "/etc/grid-security/certificates";
System.exit(-1);
EGICredential egiCredential = new EGICredential();
egiCredential.proxyFilePath = "/tmp/x509up_u0";
egiCredential.trustedCertPath = "/etc/grid-security/certificates";
if (userCredential.cloudAccess == null) {
userCredential.cloudAccess = new HashMap<>();
}
userCredential.cloudAccess.put("ec2", ec2Credential);
userCredential.cloudAccess.put("egi", egiCredential);
ArrayList<SSHKeyPair> sshKeyPairs = userCredential.loadSSHKeyPairFromFile(currentDir);
if (sshKeyPairs == null) {
throw new NullPointerException("ssh key pairs are null");
......
......@@ -13,5 +13,6 @@
<module>drip-api</module>
<module>drip-planner2provisioner</module>
<module>drip-tests</module>
<module>drip-commons</module>
</modules>
</project>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment