Commit 7184ee84 authored by Spiros Koulouzis's avatar Spiros Koulouzis

added more properties to topology and VM to better match cloudStorm.

updated project structure 
refactor manager to use one service and RPC caller 
parent 163e531e
...@@ -98,16 +98,30 @@ node_types: ...@@ -98,16 +98,30 @@ node_types:
type: string type: string
required: true required: true
default: "ExoGeni" default: "ExoGeni"
description: The name of the provider e.g. EC2, ExoGeni etc.
name: name:
type: string type: string
required: false required: false
description: the name of this topology
domain: domain:
type: string type: string
required: true required: true
default: "UvA (Amsterdam, The Netherlands) XO Rack" default: "UvA (Amsterdam, The Netherlands) XO Rack"
description: the domain of this topology e.g. California, UvA, etc
credential: credential:
type: tosca.datatypes.Credential type: tosca.datatypes.Credential
required: false required: false
status:
type: string
required: true
default: "fresh"
description: The state of this topology
constraints:
- valid_values: [ "fresh" , "running" "deleted" "failed" "stopped" ]
subnet:
type: string
required: false
description: The subnet of the VMs this topology e.g. 192.168.10.10/24
interfaces: interfaces:
Standard: Standard:
create: dumy.yaml create: dumy.yaml
...@@ -160,7 +174,16 @@ node_types: ...@@ -160,7 +174,16 @@ node_types:
description: the role of the VM in the topology description: the role of the VM in the topology
default: "master" default: "master"
constraints: constraints:
- valid_values: [ "master","worker" ] - valid_values: [ "master","worker" ]
private_ip:
type: string
required: false
description: The private IP of the VM e.g. 192.168.10.10
node_type:
type: string
required: false
description: the type of VM depending on the provider. e.g. XOSmall, t.medium etc. It has to match the mem_size, num_cores etc.
interfaces: interfaces:
Standard: Standard:
create: dumy.yaml create: dumy.yaml
......
...@@ -25,7 +25,7 @@ import java.util.concurrent.TimeoutException; ...@@ -25,7 +25,7 @@ import java.util.concurrent.TimeoutException;
*/ */
public class PlannerCaller extends DRIPCaller { public class PlannerCaller extends DRIPCaller {
private static final String REQUEST_QUEUE_NAME = "planner_queue"; private static final String REQUEST_QUEUE_NAME = "planner";
public PlannerCaller(String messageBrokerHost) throws IOException, TimeoutException { public PlannerCaller(String messageBrokerHost) throws IOException, TimeoutException {
super(messageBrokerHost, REQUEST_QUEUE_NAME); super(messageBrokerHost, REQUEST_QUEUE_NAME);
......
<?xml version="1.0" encoding="UTF-8"?> <?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"> <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> <modelVersion>4.0.0</modelVersion>
<groupId>nl.uva.sne.drip</groupId>
<artifactId>drip-commons</artifactId>
<packaging>jar</packaging>
<name>drip-commons</name>
<version>3.0.0</version>
<properties>
<java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<springfox-version>2.9.2</springfox-version>
</properties>
<parent> <parent>
<groupId>nl.uva.sne.drip</groupId> <groupId>nl.uva.sne.drip</groupId>
<artifactId>drip</artifactId> <artifactId>drip</artifactId>
<version>1.0-SNAPSHOT</version> <version>3.0.0</version>
</parent> </parent>
<artifactId>drip-commons</artifactId>
<packaging>jar</packaging>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>javax</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>javaee-web-api</artifactId> <artifactId>spring-boot-starter-web</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>jackson-databind</artifactId> <artifactId>spring-boot-starter-tomcat</artifactId>
<version>2.8.6</version>
</dependency> </dependency>
<!--SpringFox dependencies -->
<dependency> <dependency>
<groupId>org.springframework.data</groupId> <groupId>io.springfox</groupId>
<artifactId>spring-data-mongodb</artifactId> <artifactId>springfox-swagger2</artifactId>
<version>1.8.0.RELEASE</version> <version>${springfox-version}</version>
<type>jar</type>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-fileupload</groupId> <groupId>io.springfox</groupId>
<artifactId>commons-fileupload</artifactId> <artifactId>springfox-swagger-ui</artifactId>
<version>1.3.2</version> <version>${springfox-version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.data</groupId> <groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>spring-data-rest-core</artifactId> <artifactId>jackson-dataformat-yaml</artifactId>
<version>2.5.6.RELEASE</version>
<type>jar</type>
</dependency> </dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
<type>jar</type>
</dependency>
<dependency> <dependency>
<groupId>org.hamcrest</groupId> <groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>hamcrest-core</artifactId> <artifactId>jackson-datatype-jsr310</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency> </dependency>
<!-- Bean Validation API support -->
<dependency> <dependency>
<groupId>org.yaml</groupId> <groupId>javax.validation</groupId>
<artifactId>snakeyaml</artifactId> <artifactId>validation-api</artifactId>
<version>1.17</version>
<type>jar</type>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.security</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-security-core</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<version>4.2.1.RELEASE</version> <scope>test</scope>
<type>jar</type>
</dependency> </dependency>
<!-- <dependency> <dependency>
<groupId>org.jglobus</groupId> <groupId>com.github.joschi.jackson</groupId>
<artifactId>ssl-proxies</artifactId> <artifactId>jackson-datatype-threetenbp</artifactId>
<version>2.1.0</version> <version>2.6.4</version>
<type>jar</type> <type>jar</type>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.jglobus</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>myproxy</artifactId> <artifactId>spring-boot-starter-amqp</artifactId>
<version>2.1.0</version> </dependency>
<type>jar</type>
</dependency> -->
<dependency> <dependency>
<groupId>com.webcohesion.enunciate</groupId> <groupId>de.flapdoodle.embed</groupId>
<artifactId>enunciate-core-annotations</artifactId> <artifactId>de.flapdoodle.embed.mongo</artifactId>
<version>2.9.1</version> <scope>test</scope>
<type>jar</type> </dependency>
</dependency>
<dependency> <dependency>
<groupId>com.rabbitmq</groupId> <groupId>org.springframework.data</groupId>
<artifactId>amqp-client</artifactId> <artifactId>spring-data-commons</artifactId>
<version>4.0.2</version> <version>2.1.10.RELEASE</version>
<type>jar</type>
</dependency> </dependency>
</dependencies> </dependencies>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build> <build>
...@@ -118,5 +104,4 @@ ...@@ -118,5 +104,4 @@
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
</project> </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;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.attribute.PosixFilePermission;
import java.security.cert.CertificateEncodingException;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import static nl.uva.sne.drip.commons.utils.FileUtils.untar;
//import org.globus.common.CoGProperties;
//import org.globus.myproxy.GetParams;
//import org.globus.myproxy.MyProxyException;
//import org.globus.util.Util;
//import org.gridforum.jgss.ExtendedGSSCredential;
//import org.gridforum.jgss.ExtendedGSSManager;
//import org.ietf.jgss.GSSCredential;
//import org.ietf.jgss.GSSException;
//import org.ietf.jgss.GSSManager;
/**
*
* @author S. Koulouzis
*/
public class AAUtils {
private static int retry = 0;
public enum SOURCE {
MY_PROXY,
CERTIFICATE, PROXY_FILE
}
public static String generateProxy(String accessKeyId, String secretKey, SOURCE source, String myProxyEndpoint, List voname) throws IOException, CertificateEncodingException {
File proxy_file = null;
switch (source) {
case MY_PROXY:
// GetParams getRequest = new GetParams();
// getRequest.setUserName(accessKeyId);
// getRequest.setCredentialName(null);
// getRequest.setLifetime(43200);
// getRequest.setWantTrustroots(false);
// getRequest.setPassphrase(secretKey);
// getRequest.setVoname(voname);
// GSSManager manager = ExtendedGSSManager.getInstance();
// GSSCredential credential = manager.createCredential(GSSCredential.INITIATE_ONLY);
// org.globus.myproxy.MyProxy myProxy = new org.globus.myproxy.MyProxy(myProxyEndpoint, 7512);
// GSSCredential newCred = myProxy.get(credential, getRequest);
// CoGProperties properties = CoGProperties.getDefault();
// String outputFile = properties.getProxyFile();
// proxy_file = new File(outputFile);
// String path = proxy_file.getPath();
// byte[] data
// = ((ExtendedGSSCredential) newCred).export(ExtendedGSSCredential.IMPEXP_OPAQUE);
// Util.setOwnerAccessOnly(path);
// Files.write(Paths.get(path), data);
//// try (FileOutputStream out = new FileOutputStream(path);) {
//// Util.setOwnerAccessOnly(path);
//// byte[] data
//// = ((ExtendedGSSCredential) newCred).export(ExtendedGSSCredential.IMPEXP_OPAQUE);
//// out.write(data);
//// }
break;
case PROXY_FILE:
secretKey += "\n";
proxy_file = new File("/tmp/x509up_u1000");
if (proxy_file.exists()) {
Set<PosixFilePermission> perm = new HashSet<>();
perm.add(PosixFilePermission.OWNER_WRITE);
Files.setPosixFilePermissions(proxy_file.toPath(), perm);
}
Files.write(proxy_file.toPath(), secretKey.getBytes());
break;
case CERTIFICATE:
break;
default:
break;
}
Set<PosixFilePermission> perm = new HashSet<>();
perm.add(PosixFilePermission.OWNER_READ);
Files.setPosixFilePermissions(proxy_file.toPath(), perm);
return proxy_file.getAbsolutePath();
}
public static void downloadCACertificates(URL url, String folder) throws IOException {
String[] parts = url.getFile().split("/");
String fileName = parts[parts.length - 1];
File bundle = new File(folder + File.separator + fileName);
if (!bundle.getParentFile().exists()) {
if (!bundle.getParentFile().mkdirs()) {
throw new IOException(bundle + " could not be created");
}
}
if (!bundle.exists()) {
try {
URL website = new URL(url.toString());
ReadableByteChannel rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(bundle);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
untar(new File(folder), bundle);
retry = 0;
} catch (MalformedURLException ex) {
Logger.getLogger(AAUtils.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
if (retry < 3) {
retry++;
downloadCACertificates(url, folder);
}else{
throw ex;
}
}
}
}
}
/*
* 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,0x99};
}
/*
* 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.List;
import java.util.Map;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
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.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, IOException {
// JSONObject jsonObject = new JSONObject(jsonString);
// return jsonObject2Map(jsonObject);
Map<String, Object> result
= new ObjectMapper().readValue(jsonString, HashMap.class);
return result;
}
public static List<Object> jsonString2List(String jsonString) throws JSONException, IOException {
JSONArray jSONArray = new JSONArray(jsonString);
return jsonArray2List(jSONArray);
}
public static Map<String, Object> jsonObject2Map(JSONObject object) throws JSONException, IOException {
return new ObjectMapper().readValue(object.toString(), HashMap.class);
// 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 = new ObjectMapper().readValue(((JSONObject) value).toString(), HashMap.class);
// } else if (value.equals("[]")) {
// value = new ArrayList();
// } else if (value.getClass().getName().equals("org.json.JSONObject$Null")) {
// value = new String();
// }
// map.put(key, value);
// }
// return map;
}
public static List<Object> jsonArray2List(JSONArray array) throws JSONException, IOException {
List<Object> list = new ArrayList();
if (array != null) {
for (int i = 0; i < array.length(); i++) {
list.add(array.getString(i));
}
}
// 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);
// }
// if (value instanceof String) {
// System.err.println(value);
// }
// list.add(value);
// }
return list;
}
public static String json2Yml2(String jsonString) throws JSONException {
// DumperOptions options = new DumperOptions();
// options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
// options.setPrettyFlow(true);
// options.setDefaultScalarStyle(DumperOptions.ScalarStyle.SINGLE_QUOTED);
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 Map<String, Object> cleanStringContents(String ymlContents, boolean removeNewLine) {
if (removeNewLine) {
//Remove '\' and 'n' if they are together and replace them with '\n'
char[] array = ymlContents.toCharArray();
StringBuilder sb = new StringBuilder();
int prevChar = -1;
for (int i = 0; i < array.length; i++) {
int currentChar = (int) array[i];
if (prevChar > 0 && prevChar == 92 && currentChar == 110) {
sb.delete(sb.length() - 1, sb.length());
sb.append('\n');
} else {
sb.append((char) currentChar);
}
prevChar = (int) array[i];
}
ymlContents = sb.toString();
}
ymlContents = ymlContents.replaceAll("(?m)^[ \t]*\r?\n", "");
for (int i = 0; i < Constants.BAD_CHARS.length; i++) {
int hex = Constants.BAD_CHARS[i];
ymlContents = ymlContents.replaceAll(String.valueOf((char) hex), "");
}
ymlContents = ymlContents.replaceAll("\\.", "\uff0E");
Map<String, Object> map = null;
map = ymlString2Map(ymlContents);
return map;
}
public static String jsonObject2String(String msg) {
msg = msg.replaceAll("\"", Matcher.quoteReplacement("\\\""));
msg = "\"" + msg + "\"";
return msg;
}
public static Number castToNumber(Object value) {
if (value instanceof Number) {
return (Number) value;
}
if (value instanceof String) {
Pattern p = Pattern.compile("-?\\d+");
Matcher m = p.matcher((CharSequence) value);
while (m.find()) {
return Integer.valueOf(m.group());
}
}
return null;
}
}
/*
* 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.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.MessageProperties;
import java.io.IOException;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import java.util.logging.StreamHandler;
import nl.uva.sne.drip.commons.utils.DRIPLogRecordFactory;
import nl.uva.sne.drip.drip.commons.data.v1.external.DRIPLogRecord;
import nl.uva.sne.drip.drip.commons.data.v1.external.User;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
/**
*
* @author S. Koulouzis
*/
public class DRIPLogHandler extends StreamHandler {
private final String qeueName;
private final ObjectMapper mapper;
private final ConnectionFactory factory;
private String owner;
public DRIPLogHandler(String messageBrokerHost) throws IOException, TimeoutException {
factory = new ConnectionFactory();
factory.setHost(messageBrokerHost);
factory.setPort(AMQP.PROTOCOL.PORT);
//factory.setUsername("guest");
//factory.setPassword("pass");
this.qeueName = "log_qeue";
this.mapper = new ObjectMapper();
mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
}
@Override
public void publish(LogRecord record) {
try (Connection connection = factory.newConnection()) {
Channel channel = connection.createChannel();
SecurityContext ctx = SecurityContextHolder.getContext();
Authentication auth = ctx.getAuthentication();
if (auth != null) {
User user = (User) auth.getPrincipal();
setOwner(user.getUsername());
}
DRIPLogRecord dripLog = DRIPLogRecordFactory.create(record);
dripLog.setOwner(getOwner());
String jsonInString = mapper.writeValueAsString(dripLog);
// channel.basicPublish(qeueName, owner, null, jsonInString.getBytes());
// channel.basicPublish(qeueName, owner, MessageProperties.PERSISTENT_TEXT_PLAIN, jsonInString.getBytes("UTF-8"));
String qeueNameUser = qeueName + "_" + getOwner();
channel.queueDeclare(qeueNameUser, true, false, false, null);
channel.basicPublish("", qeueNameUser, MessageProperties.PERSISTENT_TEXT_PLAIN, jsonInString.getBytes("UTF-8"));
} catch (JsonProcessingException ex) {
Logger.getLogger(DRIPLogHandler.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException | TimeoutException ex) {
Logger.getLogger(DRIPLogHandler.class.getName()).log(Level.SEVERE, null, ex);
}
}
// @Override
// public void close() {
// if (channel != null && channel.isOpen()) {
// try {
// channel.close();
// if (connection != null && connection.isOpen()) {
// connection.close();
// }
// } catch (IOException | TimeoutException ex) {
// Logger.getLogger(DRIPLogHandler.class.getName()).log(Level.SEVERE, null, ex);
// }
// }
// super.close();
// }
/**
* @return the owner
*/
public String getOwner() {
return owner;
}
/**
* @param owner the owner to set
*/
public void setOwner(String owner) {
this.owner = owner;
}
}
/*
* 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.util.logging.LogRecord;
import nl.uva.sne.drip.drip.commons.data.v1.external.DRIPLogRecord;
/**
*
* @author S. Koulouzis
*/
public class DRIPLogRecordFactory {
public static DRIPLogRecord create(LogRecord rec) {
DRIPLogRecord dRec = new DRIPLogRecord();
dRec.setLevel(rec.getLevel().getName());
dRec.setLoggerName(rec.getLoggerName());
dRec.setMessage(rec.getMessage());
dRec.setMillis(dRec.getTimestamp());
dRec.setSequenceNumber(rec.getSequenceNumber());
dRec.setSourceClassName(rec.getSourceClassName());
dRec.setSourceMethodName(rec.getSourceMethodName());
return dRec;
}
}
/*
* 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.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
/**
*
* @author S. Koulouzis
*/
public class FileUtils {
/**
* 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();
}
public static void untar(File dest, File tarFile) throws IOException {
Process p = Runtime.getRuntime().exec(" tar -xzvf " + tarFile.getAbsolutePath() + " -C " + dest.getAbsolutePath());
BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));
String s = null;
StringBuilder error = new StringBuilder();
while ((s = stdError.readLine()) != null) {
error.append(s);
}
if (s != null) {
throw new IOException(error.toString());
}
// dest.mkdir();
// TarArchiveInputStream tarIn;
//
// tarIn = new TarArchiveInputStream(
// new GzipCompressorInputStream(
// new BufferedInputStream(
// new FileInputStream(
// tarFile
// )
// )
// )
// );
//
// org.apache.commons.compress.archivers.tar.TarArchiveEntry tarEntry = tarIn.getNextTarEntry();
//
// while (tarEntry != null) {
// File destPath = new File(dest, tarEntry.getName());
// if (tarEntry.isDirectory()) {
// destPath.mkdirs();
// } else {
// destPath.createNewFile();
// byte[] btoRead = new byte[1024];
// try (BufferedOutputStream bout = new BufferedOutputStream(new FileOutputStream(destPath))) {
// int len;
//
// while ((len = tarIn.read(btoRead)) != -1) {
// bout.write(btoRead, 0, len);
// }
// }
//// Set<PosixFilePermission> perms = new HashSet<>();
//// perms.add(PosixFilePermission.OWNER_READ);
//// perms.add(PosixFilePermission.OWNER_WRITE);
//// perms.add(PosixFilePermission.OWNER_EXECUTE);
////
//// perms.add(PosixFilePermission.GROUP_READ);
//// perms.add(PosixFilePermission.GROUP_WRITE);
//// perms.add(PosixFilePermission.GROUP_EXECUTE);
////
//// perms.add(PosixFilePermission.OTHERS_READ);
//// perms.add(PosixFilePermission.OTHERS_EXECUTE);
//// perms.add(PosixFilePermission.OTHERS_EXECUTE);
//// Files.setPosixFilePermissions(Paths.get(destPath.getAbsolutePath()), perms);
// }
// tarEntry = tarIn.getNextTarEntry();
// }
// tarIn.close();
}
}
/*
* 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;
}
}
...@@ -22,9 +22,6 @@ import java.util.Iterator; ...@@ -22,9 +22,6 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.json.JSONException;
/** /**
* *
......
/*
* 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;
/**
*
*
*
* @author S. Koulouzis.
*/
public class Message implements Serializable {
private String owner;
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;
}
/**
* @return the owner
*/
public String getOwner() {
return owner;
}
/**
* @param owner the owner to set
*/
public void setOwner(String owner) {
this.owner = owner;
}
}
/*
* 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.v1.external;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.webcohesion.enunciate.metadata.DocumentationExample;
import java.util.Map;
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
@JsonInclude(JsonInclude.Include.NON_NULL)
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 List<KeyPair> keyPairs;
private String cloudProviderName;
private Map<String, Object> attributes;
/**
* 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 / user name 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;
// }
//
// /**
// * @return the keyPairs
// */
// public List<KeyPair> getKeyPairs() {
// return keyPairs;
// }
//
// /**
// * @param keyPairs the keyPairs to set
// */
// public void setKeyPairs(List<KeyPair> keyPairs) {
// this.keyPairs = keyPairs;
// }
/**
* @return the attributes
*/
public Map<String, Object> getAttributes() {
return attributes;
}
/**
* @param attributes the attributes to set
*/
public void setAttributes(Map<String, Object> 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.v1.external;
import com.fasterxml.jackson.annotation.JsonInclude;
import org.springframework.data.mongodb.core.mapping.Document;
/**
* This class represents a configuration ( playbook used by ansible manager or
* composer for docker-composer) to deploy software.
*
* @author S. Koulouzis
*/
@Document
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ConfigurationRepresentation 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.fasterxml.jackson.annotation.JsonInclude;
import org.springframework.data.mongodb.core.mapping.Document;
/**
* @author S. Koulouzis
*/
@Document
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DRIPLogRecord extends OwnedObject {
private String level;
private String loggerName;
private String message;
private long millis;
private long sequenceNumber;
private String sourceClassName;
private String sourceMethodName;
/**
* @return the level
*/
public String getLevel() {
return level;
}
/**
* @param level the level to set
*/
public void setLevel(String level) {
this.level = level;
}
/**
* @return the loggerName
*/
public String getLoggerName() {
return loggerName;
}
/**
* @param loggerName the loggerName to set
*/
public void setLoggerName(String loggerName) {
this.loggerName = loggerName;
}
/**
* @return the message
*/
public String getMessage() {
return message;
}
/**
* @param message the message to set
*/
public void setMessage(String message) {
this.message = message;
}
/**
* @return the millis
*/
public long getMillis() {
return millis;
}
/**
* @param millis the millis to set
*/
public void setMillis(long millis) {
this.millis = millis;
}
/**
* @return the sequenceNumber
*/
public long getSequenceNumber() {
return sequenceNumber;
}
/**
* @param sequenceNumber the sequenceNumber to set
*/
public void setSequenceNumber(long sequenceNumber) {
this.sequenceNumber = sequenceNumber;
}
/**
* @return the sourceClassName
*/
public String getSourceClassName() {
return sourceClassName;
}
/**
* @param sourceClassName the sourceClassName to set
*/
public void setSourceClassName(String sourceClassName) {
this.sourceClassName = sourceClassName;
}
/**
* @return the sourceMethodName
*/
public String getSourceMethodName() {
return sourceMethodName;
}
/**
* @param sourceMethodName the sourceMethodName to set
*/
public void setSourceMethodName(String sourceMethodName) {
this.sourceMethodName = sourceMethodName;
}
}
/*
* 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 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
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DeployParameter {
// private String cloudCertificateName;
private String IP;
private String user;
private String role;
/**
* 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.fasterxml.jackson.annotation.JsonInclude;
import com.webcohesion.enunciate.metadata.DocumentationExample;
/**
* This class holds the necessary POJO IDs to request the deployment of a
* software
*
* @author S. Koulouzis
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
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;
}
}
/*
* 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 com.webcohesion.enunciate.metadata.DocumentationExample;
import java.util.List;
import java.util.Map;
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
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DeployResponse extends KeyValueHolder {
/**
* @return the provisionID
*/
public String getProvisionID() {
return provisionID;
}
/**
* @param provisionID the provisionID to set
*/
public void setProvisionID(String provisionID) {
this.provisionID = provisionID;
}
private String 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;
/**
*
* @author S. Koulouzis
*/
public class GrafanaMonitorringMessage {
}
/*
* 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 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
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
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.index.Indexed;
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;
@Indexed
private String keyPairId;
/**
* @return the privateKey
*/
public Key getPrivateKey() {
return privateKey;
}
/**
* @param privateKey the privateKey to set
* @throws java.lang.Exception
*/
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 java.lang.Exception
*/
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;
}
/**
* @return the keyPairId
*/
public String getKeyPairId() {
return keyPairId;
}
/**
* @param keyPairId the keyPairId to set
*/
public void setKeyPairId(String keyPairId) {
this.keyPairId = keyPairId;
}
}
/*
* 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 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
@JsonInclude(JsonInclude.Include.NON_NULL)
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.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.webcohesion.enunciate.metadata.DocumentationExample;
import java.util.Date;
import org.springframework.data.mongodb.core.mapping.Document;
@Document
@JsonInclude(JsonInclude.Include.NON_NULL)
public class MonitorringMessage extends OwnedObject {
private Date date;
private Date time;
private String metricMame;
private String subid;
private double value;
private String messageType;
/**
* @return the metricMame
*/
@DocumentationExample("cpuTotal")
public String getMetricMame() {
return metricMame;
}
/**
* @param metricMame the metricMame to set
*/
public void setMetricMame(String metricMame) {
this.metricMame = metricMame;
}
/**
* @return the subid
*/
@DocumentationExample("1ccba0cc92174ce788695cfc0a027b57")
public String getSubid() {
return subid;
}
/**
* @param subid the subid to set
*/
public void setSubid(String subid) {
this.subid = subid;
}
/**
* @return the value
*/
@DocumentationExample("91.0500021021063106")
public double getValue() {
return value;
}
/**
* @param value the value to set
*/
public void setValue(double value) {
this.value = value;
}
/**
* @return the messageType
*/
@DocumentationExample("critical")
public String getMessageType() {
return messageType;
}
/**
* @param messageType the messageType to set
*/
public void setMessageType(String messageType) {
this.messageType = messageType;
}
/**
* @return the date
*/
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
@DocumentationExample("2017-08-25")
public Date getDate() {
return date;
}
/**
* @param date the date to set
*/
public void setDate(Date date) {
this.date = date;
}
/**
* @return the time
*/
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "hh:mm:ss")
@DocumentationExample("11:30:00")
public Date getTime() {
return time;
}
/**
* @param time the time to set
*/
public void setTime(Date time) {
this.time = time;
}
}
/*
* 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 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
@JsonInclude(JsonInclude.Include.NON_NULL)
public class OwnedObject {
@Id
private String id;
private Long timestamp = System.currentTimeMillis();
@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 who made the call.
* It is created automatically. No need to set during a POST
*
* @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;
}
/**
* The object's creation date in unix time stamp. It is created automatically.
* No need to set during a POST
* @return the timestamp
*/
@DocumentationExample("1499793079011")
public Long getTimestamp() {
return 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.fasterxml.jackson.annotation.JsonInclude;
import com.webcohesion.enunciate.metadata.DocumentationExample;
import org.springframework.data.mongodb.core.mapping.Document;
/**
* This class represents a plan request sent to the planner.
*
* @author S. Koulouzis
*/
@Document
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PlanRequest {
private String toscaID;
private String managerType;
private String vmUserName;
private String cloudProvider;
private String osType;
private String domain;
/**
* The ID of the tosca file the generated this plan
*
* @return the toscaID
*/
@DocumentationExample("592d5884e452f1b9b666a657")
public String getToscaID() {
return toscaID;
}
/**
* @param toscaID the toscaID to set
*/
public void setToscaID(String toscaID) {
this.toscaID = toscaID;
}
/**
* The type of cluster manager
*
* @return the managerType
*/
@DocumentationExample("swarm")
public String getManagerType() {
return managerType;
}
/**
* @param managerType the managerType to set
*/
public void setManagerType(String managerType) {
this.managerType = managerType;
}
/**
* The default username to be set to all VMs
*
* @return the vmUserName
*/
@DocumentationExample("vm_user")
public String getVmUserName() {
return vmUserName;
}
/**
* @param vmUserName the vmUserName to set
*/
public void setVmUserName(String vmUserName) {
this.vmUserName = vmUserName;
}
/**
* The cloud provider
*
* @return the cloudProvider
*/
@DocumentationExample("egi")
public String getCloudProvider() {
return cloudProvider;
}
/**
* @param cloudProvider the cloudProvider to set
*/
public void setCloudProvider(String cloudProvider) {
this.cloudProvider = cloudProvider;
}
/**
* The type of OS for the VMs
*
* @return the osType
*/
@DocumentationExample("Ubuntu16.04")
public String getOsType() {
return osType;
}
/**
* @param osType the osType to set
*/
public void setOsType(String osType) {
this.osType = osType;
}
/**
* The domain to request the VMs
* @return the domain
*/
@DocumentationExample("us-east-1")
public String getDomain() {
return domain;
}
/**
* @param domain the domain to set
*/
public void setDomain(String domain) {
this.domain = domain;
}
}
/*
* 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 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
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PlanResponse extends KeyValueHolder {
private String toscaID;
// private Set<String> loweLevelPlansIDs;
/**
* 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 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 com.fasterxml.jackson.annotation.JsonInclude;
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
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ProvisionRequest extends KeyValueHolder {
private List<String> cloudCredentialsIDs;
private String planID;
private List<String> userKeyPairIDs;
private List<String> deployerKeyPairIDs;
/**
* 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 userKeyPairIDs
*/
@DocumentationExample("ASedsfd46b4fFd344a1A")
public List<String> getUserKeyPairIDs() {
return userKeyPairIDs;
}
/**
* @param userKeyID the userKeyPairIDs to set
*/
public void setUserKeyPairIDs(List<String> userKeyID) {
this.userKeyPairIDs = userKeyID;
}
/**
* @return the deployerKeyPairIDs
*/
public List<String> getDeployerKeyPairIDs() {
return deployerKeyPairIDs;
}
/**
* @param deployerKeyPairIDs the deployerKeyPairIDs to set
*/
public void setDeployerKeyPairIDs(List<String> deployerKeyPairIDs) {
this.deployerKeyPairIDs = deployerKeyPairIDs;
}
}
/*
* 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 com.webcohesion.enunciate.metadata.DocumentationExample;
import java.util.ArrayList;
import java.util.List;
/**
* This class represents a description of provisioned resources
*
* @author S. Koulouzis
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ProvisionResponse extends KeyValueHolder {
private String planID;
/**
* 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;
}
}
/*
* 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;
/**
*
* This class represents a scale response for a deployment. At the moment we
* only support swarm.
*
*
* @author S. Koulouzis
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ScaleDeploymetResponse extends ScaleRequest {
}
/*
* 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 com.webcohesion.enunciate.metadata.DocumentationExample;
/**
*
* This class represents a scale request for a deployment. At the moment we only
* support swarm.
*
*
* @author S. Koulouzis
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ScaleRequest extends OwnedObject {
private String scaleTargetID;
private String scaleTargetName;
private int numOfInstances;
/**
* The ID of the deployment or provisioned resources to scale. For
* deployment scale only swarm deployments are supported.
*
* @return the scaleTargetID
*/
@DocumentationExample("58e3946e0fb4f562d84ba1ad")
public String getScaleTargetID() {
return scaleTargetID;
}
/**
*
* @param deployID the scaleTargetID to set
*/
public void setScaleTargetID(String deployID) {
this.scaleTargetID = deployID;
}
/**
* The name of the service or topology to scale.
*
* @return the scaleTargetName
*/
@DocumentationExample("telegreen_db")
public String getScaleTargetName() {
return scaleTargetName;
}
/**
* @param serviceName the scaleTargetName to set
*/
public void setScaleTargetName(String serviceName) {
this.scaleTargetName = serviceName;
}
/**
* The number of instances to start. This number is absolute not cumulative.
* If we have 2 instances running and we request for 3 we'll have 3 if we
* request 1 we'll have 1
*
* @return the numOfInstances
*/
@DocumentationExample("5")
public int getNumOfInstances() {
return numOfInstances;
}
/**
* @param numOfInstances the numOfInstances to set
*/
public void setNumOfInstances(int numOfInstances) {
this.numOfInstances = numOfInstances;
}
}
/*
* 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 com.webcohesion.enunciate.metadata.DocumentationExample;
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
@JsonInclude(JsonInclude.Include.NON_NULL)
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.fasterxml.jackson.annotation.JsonInclude;
import com.webcohesion.enunciate.metadata.DocumentationExample;
import org.springframework.data.mongodb.core.mapping.Document;
/**
* This class is a representation of a TOSCA description.
*
* @author S. Koulouzis
*/
@Document
@JsonInclude(JsonInclude.Include.NON_NULL)
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.JsonInclude;
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
@JsonInclude(JsonInclude.Include.NON_NULL)
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;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.webcohesion.enunciate.metadata.DocumentationExample;
import nl.uva.sne.drip.drip.commons.data.v1.external.KeyValueHolder;
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;
/**
* This class represents the the ansible out put for a specific VM. This can be
* used as a archive / log of ansible executions
*
* @author S. Koulouzis
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
@Document
public class AnsibleOutput extends OwnedObject {
@Indexed
private String host;
@Indexed
private String cloudDeploymentDomain;
@Indexed
private String vmType;
private KeyValueHolder result;
private String provisionID;
@Indexed
private String cloudProvider;
/**
* The host (IP) of the VM that executed the playbook
*
* @return the host
*/
@JsonProperty("host")
@DocumentationExample("147.228.242.58")
public String getHost() {
return host;
}
@JsonProperty("host")
public void setHost(String host) {
this.host = host;
}
/**
* The output of the playbook execution
*
* @return the result
*/
@JsonProperty("result")
public KeyValueHolder getAnsibleResult() {
return result;
}
@JsonProperty("result")
public void setAnsiibleResult(KeyValueHolder result) {
this.result = result;
}
/**
* The cloud domain where the VM that run the playbook
*
* @return the domain
*/
@DocumentationExample("https://carach5.ics.muni.cz:11443")
@JsonProperty("cloudDeploymentDomain")
public String getCloudDeploymentDomain() {
return cloudDeploymentDomain;
}
@JsonProperty("cloudDeploymentDomain")
public void setCloudDeploymentDomain(String cloudDeploymentDomain) {
this.cloudDeploymentDomain = cloudDeploymentDomain;
}
/**
* The type of VM that run the playbook
*
* @return
*/
@DocumentationExample("medium")
@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;
}
/**
* The provision used to spawn the VM for this playbook execution
*
* @return the provision ID
*/
@DocumentationExample("59172db6e452f1b9b666a621")
@JsonProperty("provisionID")
public String getProvisionID() {
return provisionID;
}
/**
* The cloud provider
*
* @return the cloudProvider
*/
@DocumentationExample("ec2")
@JsonProperty("cloudProvider")
public String getCloudProvider() {
return cloudProvider;
}
/**
* @param cloudProvider the cloudProvider to set
*/
public void setCloudProvider(String cloudProvider) {
this.cloudProvider = cloudProvider;
}
}
/*
* 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.webcohesion.enunciate.metadata.DocumentationExample;
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;
/**
* This class represents an benchmark result for a specific VM.
*
* @author S. Koulouzis
*/
@Document
public class BenchmarkResult extends OwnedObject {
@Indexed
private String host;
@Indexed
private String cloudDeploymentDomain;
@Indexed
private String vmType;
@Indexed
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss.SSSSSS")
private Date end;
@Indexed
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss.SSSSSS")
private Date start;
@Indexed
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm:ss.SSSSSS")
private Date delta;
/**
* @return the host
*/
@DocumentationExample("147.228.242.58")
public String getHost() {
return host;
}
/**
* @param host the host to set
*/
public void setHost(String host) {
this.host = host;
}
/**
* @return the cloudDeploymentDomain
*/
@DocumentationExample("us-east-1")
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;
import org.springframework.data.mongodb.core.mapping.Document;
/**
*This class represents a sysbench CPU Benchmark for a specific VM.
* @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;
/**
* The sysbench version
* @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;
}
}
...@@ -12,9 +12,9 @@ ...@@ -12,9 +12,9 @@
<springfox-version>2.9.2</springfox-version> <springfox-version>2.9.2</springfox-version>
</properties> </properties>
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>nl.uva.sne.drip</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>drip</artifactId>
<version>2.1.8.RELEASE</version> <version>3.0.0</version>
</parent> </parent>
<build> <build>
<sourceDirectory>src/main/java</sourceDirectory> <sourceDirectory>src/main/java</sourceDirectory>
...@@ -95,6 +95,11 @@ ...@@ -95,6 +95,11 @@
<artifactId>de.flapdoodle.embed.mongo</artifactId> <artifactId>de.flapdoodle.embed.mongo</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>nl.uva.sne.drip</groupId>
<artifactId>drip-commons</artifactId>
<version>3.0.0</version>
<type>jar</type>
</dependency>
</dependencies> </dependencies>
</project> </project>
...@@ -9,9 +9,9 @@ import org.springframework.http.ResponseEntity; ...@@ -9,9 +9,9 @@ import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import nl.uva.sne.drip.service.PlannerService; import nl.uva.sne.drip.service.DRIPService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@Controller @Controller
public class PlannerApiController implements PlannerApi { public class PlannerApiController implements PlannerApi {
...@@ -21,11 +21,11 @@ public class PlannerApiController implements PlannerApi { ...@@ -21,11 +21,11 @@ public class PlannerApiController implements PlannerApi {
private final ObjectMapper objectMapper; private final ObjectMapper objectMapper;
private final HttpServletRequest request; private final HttpServletRequest request;
@Value("${message.broker.queue.planner}")
private String queueName;
@Autowired @Autowired
private PlannerService plannerService; private DRIPService dripService;
@org.springframework.beans.factory.annotation.Autowired @org.springframework.beans.factory.annotation.Autowired
public PlannerApiController(ObjectMapper objectMapper, HttpServletRequest request) { public PlannerApiController(ObjectMapper objectMapper, HttpServletRequest request) {
...@@ -33,15 +33,14 @@ public class PlannerApiController implements PlannerApi { ...@@ -33,15 +33,14 @@ public class PlannerApiController implements PlannerApi {
this.request = request; this.request = request;
} }
@Override @Override
public ResponseEntity<String> planToscaTemplateByID(@ApiParam( public ResponseEntity<String> planToscaTemplateByID(@ApiParam(
value = "ID of topolog template to plan",required=true) value = "ID of topolog template to plan", required = true)
@PathVariable("id") String id) { @PathVariable("id") String id) {
String accept = request.getHeader("Accept"); String accept = request.getHeader("Accept");
if (accept != null && accept.contains("text/plain")) { if (accept != null && accept.contains("text/plain")) {
String planedYemplateId = plannerService.plan(id); dripService.setRequestQeueName(queueName);
String planedYemplateId = dripService.execute(id);
return new ResponseEntity<>(planedYemplateId, HttpStatus.OK); return new ResponseEntity<>(planedYemplateId, HttpStatus.OK);
} }
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
......
...@@ -11,6 +11,9 @@ import org.springframework.web.bind.annotation.PathVariable; ...@@ -11,6 +11,9 @@ import org.springframework.web.bind.annotation.PathVariable;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import nl.uva.sne.drip.service.DRIPService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-10T17:15:46.465Z") @javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-10T17:15:46.465Z")
...@@ -23,29 +26,29 @@ public class ProvisionerApiController implements ProvisionerApi { ...@@ -23,29 +26,29 @@ public class ProvisionerApiController implements ProvisionerApi {
private final HttpServletRequest request; private final HttpServletRequest request;
@Value("${message.broker.queue.provisioner}")
private String queueName;
@Autowired
private DRIPService dripService;
@org.springframework.beans.factory.annotation.Autowired @org.springframework.beans.factory.annotation.Autowired
public ProvisionerApiController(ObjectMapper objectMapper, HttpServletRequest request) { public ProvisionerApiController(ObjectMapper objectMapper, HttpServletRequest request) {
this.objectMapper = objectMapper; this.objectMapper = objectMapper;
this.request = request; this.request = request;
} }
@Override @Override
public ResponseEntity<String> provisionPlanToscaTemplateByID( public ResponseEntity<String> provisionPlanToscaTemplateByID(
@ApiParam(value = "ID of topolog template to plan", required = true) @ApiParam(value = "ID of topolog template to plan", required = true)
@PathVariable("id") String id) { @PathVariable("id") String id) {
String accept = request.getHeader("Accept"); String accept = request.getHeader("Accept");
if (accept != null && accept.contains("")) { if (accept != null && accept.contains("text/plain")) {
try { dripService.setRequestQeueName(queueName);
return new ResponseEntity<>(objectMapper.readValue("", String.class), HttpStatus.NOT_IMPLEMENTED); String planedYemplateId = dripService.execute(id);
} catch (IOException e) { return new ResponseEntity<>(planedYemplateId, HttpStatus.NOT_IMPLEMENTED);
log.error("Couldn't serialize response for content type ", e);
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
} }
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
} }
} }
...@@ -6,12 +6,7 @@ ...@@ -6,12 +6,7 @@
package nl.uva.sne.drip.configuration; package nl.uva.sne.drip.configuration;
import com.rabbitmq.client.ConnectionFactory; import com.rabbitmq.client.ConnectionFactory;
import java.io.IOException;
import java.util.concurrent.TimeoutException;
import nl.uva.sne.drip.rpc.PlannerCaller;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
/** /**
......
...@@ -18,9 +18,10 @@ import java.util.logging.Logger; ...@@ -18,9 +18,10 @@ import java.util.logging.Logger;
import nl.uva.sne.drip.model.Message; import nl.uva.sne.drip.model.Message;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
/* /*
* Copyright 2017 S. Koulouzis, Wang Junchao, Huan Zhou, Yang Hu * Copyright 2019 S. Koulouzis
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -38,15 +39,16 @@ import org.springframework.stereotype.Component; ...@@ -38,15 +39,16 @@ import org.springframework.stereotype.Component;
* *
* @author S. Koulouzis * @author S. Koulouzis
*/ */
public abstract class DRIPCaller implements AutoCloseable { @Service
public class DRIPCaller implements AutoCloseable {
private final Connection connection; private final Connection connection;
private final Channel channel; private final Channel channel;
private final String replyQueueName; private final String replyQueueName;
private final String requestQeueName; private String requestQeueName;
private final ObjectMapper mapper; private final ObjectMapper mapper;
public DRIPCaller(String requestQeueName, ConnectionFactory factory) throws IOException, TimeoutException { public DRIPCaller(ConnectionFactory factory) throws IOException, TimeoutException {
// factory.setHost(messageBrokerHost); // factory.setHost(messageBrokerHost);
// factory.setPort(AMQP.PROTOCOL.PORT); // factory.setPort(AMQP.PROTOCOL.PORT);
...@@ -56,7 +58,6 @@ public abstract class DRIPCaller implements AutoCloseable { ...@@ -56,7 +58,6 @@ public abstract class DRIPCaller implements AutoCloseable {
channel = connection.createChannel(); channel = connection.createChannel();
// create a single callback queue per client not per requests. // create a single callback queue per client not per requests.
replyQueueName = channel.queueDeclare().getQueue(); replyQueueName = channel.queueDeclare().getQueue();
this.requestQeueName = requestQeueName;
this.mapper = new ObjectMapper(); this.mapper = new ObjectMapper();
mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true); mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
} }
...@@ -102,8 +103,8 @@ public abstract class DRIPCaller implements AutoCloseable { ...@@ -102,8 +103,8 @@ public abstract class DRIPCaller implements AutoCloseable {
.correlationId(corrId) .correlationId(corrId)
.replyTo(getReplyQueueName()) .replyTo(getReplyQueueName())
.build(); .build();
Logger.getLogger(DRIPCaller.class.getName()).log(Level.INFO, "Sending: {0} to queue: {1}", new Object[]{jsonInString, requestQeueName}); Logger.getLogger(DRIPCaller.class.getName()).log(Level.INFO, "Sending: {0} to queue: {1}", new Object[]{jsonInString, getRequestQeueName()});
getChannel().basicPublish("", requestQeueName, props, jsonInString.getBytes("UTF-8")); getChannel().basicPublish("", getRequestQeueName(), props, jsonInString.getBytes("UTF-8"));
final BlockingQueue<String> response = new ArrayBlockingQueue(1); final BlockingQueue<String> response = new ArrayBlockingQueue(1);
...@@ -120,4 +121,18 @@ public abstract class DRIPCaller implements AutoCloseable { ...@@ -120,4 +121,18 @@ public abstract class DRIPCaller implements AutoCloseable {
return mapper.readValue(resp, Message.class); return mapper.readValue(resp, Message.class);
} }
/**
* @return the requestQeueName
*/
public String getRequestQeueName() {
return requestQeueName;
}
/**
* @param requestQeueName the requestQeueName to set
*/
public void setRequestQeueName(String requestQeueName) {
this.requestQeueName = requestQeueName;
}
} }
/*
* 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.rpc;
import com.rabbitmq.client.ConnectionFactory;
import java.io.IOException;
import java.util.concurrent.TimeoutException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
*
* @author S. Koulouzis.
*/
@Component
public class PlannerCaller extends DRIPCaller {
private static final String REQUEST_QUEUE_NAME = "planner_queue";
@Autowired
ConnectionFactory factory;
@Autowired
public PlannerCaller(ConnectionFactory factory) throws IOException, TimeoutException {
super(REQUEST_QUEUE_NAME, factory);
}
}
...@@ -11,7 +11,7 @@ import java.util.logging.Level; ...@@ -11,7 +11,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import nl.uva.sne.drip.model.Message; import nl.uva.sne.drip.model.Message;
import nl.uva.sne.drip.model.ToscaTemplate; import nl.uva.sne.drip.model.ToscaTemplate;
import nl.uva.sne.drip.rpc.PlannerCaller; import nl.uva.sne.drip.rpc.DRIPCaller;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -20,15 +20,17 @@ import org.springframework.stereotype.Service; ...@@ -20,15 +20,17 @@ import org.springframework.stereotype.Service;
* @author S. Koulouzis * @author S. Koulouzis
*/ */
@Service @Service
public class PlannerService { public class DRIPService {
@Autowired @Autowired
private ToscaTemplateService toscaTemplateService; private ToscaTemplateService toscaTemplateService;
@Autowired @Autowired
PlannerCaller plannerCaller; DRIPCaller caller;
public String plan(String id) { private String requestQeueName;
public String execute(String id) {
try { try {
String ymlToscaTemplate = toscaTemplateService.findByID(id); String ymlToscaTemplate = toscaTemplateService.findByID(id);
...@@ -38,19 +40,34 @@ public class PlannerService { ...@@ -38,19 +40,34 @@ public class PlannerService {
message.setCreationDate(System.currentTimeMillis()); message.setCreationDate(System.currentTimeMillis());
message.setToscaTemplate(toscaTemplate); message.setToscaTemplate(toscaTemplate);
Message plannerResponse = plannerCaller.call(message); caller.setRequestQeueName(requestQeueName);
Message plannerResponse = caller.call(message);
ToscaTemplate plannedToscaTemplate = plannerResponse.getToscaTemplate(); ToscaTemplate plannedToscaTemplate = plannerResponse.getToscaTemplate();
return toscaTemplateService.save(plannedToscaTemplate); return toscaTemplateService.save(plannedToscaTemplate);
} catch (IOException | TimeoutException | InterruptedException ex) { } catch (IOException | TimeoutException | InterruptedException ex) {
Logger.getLogger(PlannerService.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(DRIPService.class.getName()).log(Level.SEVERE, null, ex);
} finally { } finally {
try { try {
plannerCaller.close(); caller.close();
} catch (IOException | TimeoutException ex) { } catch (IOException | TimeoutException ex) {
Logger.getLogger(PlannerService.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(DRIPService.class.getName()).log(Level.SEVERE, null, ex);
} }
} }
return null; return null;
} }
/**
* @return the requestQeueName
*/
public String getRequestQeueName() {
return requestQeueName;
}
/**
* @param requestQeueName the requestQeueName to set
*/
public void setRequestQeueName(String requestQeueName) {
this.requestQeueName = requestQeueName;
}
} }
...@@ -7,6 +7,9 @@ spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false ...@@ -7,6 +7,9 @@ spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false
message.broker.host=127.0.0.1 message.broker.host=127.0.0.1
message.broker.username=guest message.broker.username=guest
message.broker.password=guest message.broker.password=guest
message.broker.queue.provisioner=provisioner
message.broker.queue.planner=planner
message.broker.queue.deployer=deployer
db.host=127.0.0.1 db.host=127.0.0.1
db.name=drip db.name=drip
......
<?xml version="1.0" encoding="UTF-8"?>
<project-shared-configuration>
<!--
This file contains additional configuration written by modules in the NetBeans IDE.
The configuration is intended to be shared among all the users of project and
therefore it is assumed to be part of version control checkout.
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
-->
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
<!--
Properties that influence various parts of the IDE, especially code formatting and the like.
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
That way multiple projects can share the same settings (useful for formatting rules for example).
Any value defined here will override the pom.xml file value but is only applicable to the current project.
-->
<netbeans.hint.licensePath>${project.basedir}/../licenseheader.txt</netbeans.hint.licensePath>
<org-netbeans-modules-whitelist.whitelist-oracle>false</org-netbeans-modules-whitelist.whitelist-oracle>
</properties>
</project-shared-configuration>
<?xml version="1.0" encoding="UTF-8"?>
<actions>
<action>
<actionName>run</actionName>
<packagings>
<packaging>jar</packaging>
</packagings>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
</goals>
<properties>
<exec.args>-classpath %classpath nl.uva.sne.drip.drip.provisioner.RPCServer /home/alogo/workspace/DRIP/drip-provisioner/etc/provisioner.properties</exec.args>
<exec.executable>java</exec.executable>
</properties>
</action>
<action>
<actionName>debug</actionName>
<packagings>
<packaging>jar</packaging>
</packagings>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
</goals>
<properties>
<exec.args>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath nl.uva.sne.drip.drip.provisioner.RPCServer /home/alogo/workspace/DRIP/drip-provisioner/etc/provisioner.properties</exec.args>
<exec.executable>java</exec.executable>
<jpda.listen>true</jpda.listen>
</properties>
</action>
<action>
<actionName>profile</actionName>
<packagings>
<packaging>jar</packaging>
</packagings>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
</goals>
<properties>
<exec.args>-classpath %classpath nl.uva.sne.drip.drip.provisioner.RPCServer /home/alogo/workspace/DRIP/drip-provisioner/etc/provisioner.properties</exec.args>
<exec.executable>java</exec.executable>
</properties>
</action>
</actions>
...@@ -4,111 +4,29 @@ ...@@ -4,111 +4,29 @@
<parent> <parent>
<groupId>nl.uva.sne.drip</groupId> <groupId>nl.uva.sne.drip</groupId>
<artifactId>drip</artifactId> <artifactId>drip</artifactId>
<version>1.0-SNAPSHOT</version> <version>3.0.0</version>
</parent> </parent>
<groupId>nl.uva.sne.drip</groupId> <groupId>nl.uva.sne.drip</groupId>
<version>1.0-SNAPSHOT</version> <version>3.0.0</version>
<artifactId>drip-provisioner</artifactId> <artifactId>drip-provisioner</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<properties> <properties>
<maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.target>1.8</maven.compiler.target>
<ch.qos.logback.version>1.2.3</ch.qos.logback.version>
</properties> </properties>
<dependencies> <dependencies>
<dependency>
<groupId>nl.uva.sne.drip</groupId>
<artifactId>drip-commons</artifactId>
<version>1.0-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>nl.uva.sne.drip</groupId>
<artifactId>drip-provisioning-agent</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency> <dependency>
<groupId>com.rabbitmq</groupId> <groupId>com.rabbitmq</groupId>
<artifactId>amqp-client</artifactId> <artifactId>amqp-client</artifactId>
<version>4.0.2</version>
</dependency> </dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.8.6</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
<type>jar</type>
</dependency>
<!--bcprov-jdk16-1.46-->
<!-- <dependency>
<groupId>org.jglobus</groupId>
<artifactId>myproxy</artifactId>
<version>2.0.6</version>
</dependency>
-->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.5</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-archiver</artifactId>
<version>2.4.4</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${ch.qos.logback.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${ch.qos.logback.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-access</artifactId>
<version>${ch.qos.logback.version}</version>
</dependency>
<dependency>
<groupId>nl.uva.sne.drip</groupId>
<artifactId>drip-planner2provisioner</artifactId>
<version>1.0-SNAPSHOT</version>
<type>jar</type>
</dependency>
</dependencies> </dependencies>
......
/*
* 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.provisioner;
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DefaultConsumer;
import com.rabbitmq.client.Envelope;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* This is a provision Message consumer
*
*
* @author S. Koulouzis
*/
public class Consumer extends DefaultConsumer {
private final Channel channel;
// Map<String, String> em = new HashMap<>();
private final Logger logger;
private final String messageBrokerHost;
public Consumer(Channel channel, String messageBrokerHost) throws IOException, TimeoutException {
super(channel);
this.channel = channel;
this.messageBrokerHost = messageBrokerHost;
logger = Logger.getLogger(Consumer.class.getName());
}
@Override
public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {
//Create the reply properties which tells us where to reply, and which id to use.
//No need to change anything here
AMQP.BasicProperties replyProps = new AMQP.BasicProperties.Builder()
.correlationId(properties.getCorrelationId())
.build();
String response = "";
//The queue only moves bytes so we need to convert them to string
String message = new String(body, "UTF-8");
String tempInputDirPath = System.getProperty("java.io.tmpdir") + File.separator + "Input-" + Long.toString(System.nanoTime()) + File.separator;
File tempInputDir = new File(tempInputDirPath);
if (!(tempInputDir.mkdirs())) {
throw new FileNotFoundException("Could not create input directory: " + tempInputDir.getAbsolutePath());
}
response = "response";
logger.log(Level.INFO, "Sending Response: '{'0'}'{0}", response);
// Logger.getLogger(Consumer.class.getName()).log(Level.INFO, "Sending Response: {0}", response);
//We send the response back. No need to change anything here
channel.basicPublish("", properties.getReplyTo(), replyProps, response.getBytes("UTF-8"));
channel.basicAck(envelope.getDeliveryTag(), false);
}
}
...@@ -28,16 +28,17 @@ import java.util.Properties; ...@@ -28,16 +28,17 @@ import java.util.Properties;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import nl.uva.sne.drip.drip.provisioner.utils.PropertyValues;
/** /**
* *
* @author H. Zhou * @author S. Koulouzis
*/ */
public class RPCServer { public class RPCServer {
private static Properties prop;
public static void main(String[] argv) throws MalformedURLException { public static void main(String[] argv) throws MalformedURLException {
Properties prop = new Properties(); prop = new Properties();
if (argv.length >= 1) { if (argv.length >= 1) {
try { try {
prop.load(new FileInputStream(argv[0])); prop.load(new FileInputStream(argv[0]));
...@@ -45,7 +46,7 @@ public class RPCServer { ...@@ -45,7 +46,7 @@ public class RPCServer {
Logger.getLogger(RPCServer.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(RPCServer.class.getName()).log(Level.SEVERE, null, ex);
} }
} else { } else {
String resourceName = "provisioner.properies"; String resourceName = "application.properies";
ClassLoader loader = Thread.currentThread().getContextClassLoader(); ClassLoader loader = Thread.currentThread().getContextClassLoader();
try (InputStream resourceStream = loader.getResourceAsStream(resourceName)) { try (InputStream resourceStream = loader.getResourceAsStream(resourceName)) {
prop.load(resourceStream); prop.load(resourceStream);
...@@ -53,38 +54,36 @@ public class RPCServer { ...@@ -53,38 +54,36 @@ public class RPCServer {
Logger.getLogger(RPCServer.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(RPCServer.class.getName()).log(Level.SEVERE, null, ex);
} }
} }
PropertyValues.setPropertyValues(prop);
start(); start();
} }
private static void start() { private static void start() {
ConnectionFactory factory = new ConnectionFactory(); ConnectionFactory factory = new ConnectionFactory();
factory.setHost(PropertyValues.HOST); factory.setHost(prop.getProperty("message.broker.host"));
factory.setPassword("guest"); factory.setPassword(prop.getProperty("message.broker.username"));
factory.setUsername("guest"); factory.setUsername(prop.getProperty("message.broker.password"));
factory.setPort(AMQP.PROTOCOL.PORT); factory.setPort(AMQP.PROTOCOL.PORT);
Logger.getLogger(RPCServer.class.getName()).log(Level.INFO, "Connected to: {0}", PropertyValues.HOST); Logger.getLogger(RPCServer.class.getName()).log(Level.INFO, "Connected to: {0}", prop.getProperty("message.broker.host"));
try (Connection connection = factory.newConnection()) { try (Connection connection = factory.newConnection()) {
Channel channel = connection.createChannel(); Channel channel = connection.createChannel();
//We define the queue name //We define the queue name
channel.queueDeclare(PropertyValues.RPC_QUEUE_NAME, false, false, false, null); channel.queueDeclare(prop.getProperty("message.broker.queue.provisioner", "provisioner"), false, false, false, null);
DefaultConsumer c; DefaultConsumer c;
// if (PropertyValues.RPC_QUEUE_NAME.endsWith("v0")) { c = new nl.uva.sne.drip.drip.provisioner.Consumer(channel, prop.getProperty("message.broker.host"));
// c = new nl.uva.sne.drip.drip.provisioner.v0.Consumer(channel);
// } else {
c = new nl.uva.sne.drip.drip.provisioner.v1.Consumer(channel, PropertyValues.HOST);
// }
//Start listening for messages //Start listening for messages
channel.basicConsume(PropertyValues.RPC_QUEUE_NAME, false, c); channel.basicConsume(prop.getProperty("message.broker.queue.provisioner", "provisioner"), false, c);
//Block so we don't close the channel //Block so we don't close the channel
while (true) { while (true) {
try { try {
Thread.sleep(100); Thread.sleep(100);
} catch (InterruptedException _ignore) { } catch (InterruptedException ex) {
Logger.getLogger(RPCServer.class.getName()).log(Level.SEVERE, null, ex);
} }
} }
} catch (IOException | TimeoutException ex) { } catch (IOException | TimeoutException ex) {
......
/*
* 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.provisioner.utils;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.MessageFormat;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import nl.uva.sne.drip.drip.provisioner.RPCServer;
/**
*
* @author S. Koulouzis
*/
public class PropertyValues {
public static String RPC_QUEUE_NAME = "provisioner_queue_v1";
public static String HOST = "127.0.0.1";
public static String TRUSTED_CERTIFICATE_FOLDER;
public static URL CA_BUNDLE_URL;
// public static String MY_PROXY_ENDPOINT;
public static String DOMAIN_INFO_PATH = "etc";
public static void setPropertyValues(Properties prop) throws MalformedURLException {
PropertyValues.HOST = prop.getProperty("rabbitmq.host", "127.0.0.1");
PropertyValues.RPC_QUEUE_NAME = prop.getProperty("rpc.queue.name",
"provisioner_queue_v1");
PropertyValues.TRUSTED_CERTIFICATE_FOLDER = prop.getProperty("trusted.certificates.folder", System.getProperty("user.home") + File.separator + ".globus" + File.separator + "certificates");
CA_BUNDLE_URL = new URL(prop.getProperty("ca.bundle.url",
"https://dist.eugridpma.info/distribution/igtf/current/accredited/igtf-preinstalled-bundle-classic.tar.gz"));
// MY_PROXY_ENDPOINT = prop.getProperty("my.proxy.endpoint");
DOMAIN_INFO_PATH = prop.getProperty("domain.info.path",
"etc");
Logger.getLogger(RPCServer.class.getName()).log(Level.INFO,
MessageFormat.format("rabbitmq.host: {0}", PropertyValues.HOST));
Logger.getLogger(RPCServer.class.getName()).log(Level.INFO,
MessageFormat.format("rpc.queue.name: {0}", PropertyValues.RPC_QUEUE_NAME));
}
}
message.broker.host=127.0.0.1
message.broker.username=guest
message.broker.password=guest
message.broker.queue.provisioner=provisioner
\ No newline at end of file
# LOG4J Configuration
# ===================
# Set root logger level to DEBUG and its only appender to A1.
log4j.rootLogger=FINE, A1
# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender
# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d{HH:mm:ss,SSS} (%t) %-5p [%c] - %m%n
\ No newline at end of file
handlers = java.util.logging.ConsoleHandler
nl.uva.cs.level = FINE
############################################################
# Handler specific properties.
# Describes specific configuration info for Handlers.
############################################################
java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
\ No newline at end of file
rabbitmq.host=127.0.0.1
rpc.queue.name=provisioner_queue_v1
...@@ -35,7 +35,7 @@ public class RPCServer { ...@@ -35,7 +35,7 @@ public class RPCServer {
/** /**
*The name of the queue to send and receive massages *The name of the queue to send and receive massages
*/ */
private static final String RPC_QUEUE_NAME = "planner_queue"; private static final String RPC_QUEUE_NAME = "planner";
/** /**
* The IP or host name of the RabbitMQ server * The IP or host name of the RabbitMQ server
*/ */
......
...@@ -2,13 +2,26 @@ ...@@ -2,13 +2,26 @@
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="462ede19-adfe-472b-975e-fefefa973fe0" name="Default Changelist" comment=""> <list default="true" id="462ede19-adfe-472b-975e-fefefa973fe0" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/../TOSCA/application_example_output.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/../TOSCA/application_example_output.yaml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/../drip-api/src/main/java/nl/uva/sne/drip/api/rpc/PlannerCaller.java" beforeDir="false" afterPath="$PROJECT_DIR$/../drip-api/src/main/java/nl/uva/sne/drip/api/rpc/PlannerCaller.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-manager/src/main/java/nl/uva/sne/drip/api/PlannerApiController.java" beforeDir="false" afterPath="$PROJECT_DIR$/../drip-manager/src/main/java/nl/uva/sne/drip/api/PlannerApiController.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-manager/src/main/java/nl/uva/sne/drip/configuration/RPCCallersConfig.java" beforeDir="false" afterPath="$PROJECT_DIR$/../drip-manager/src/main/java/nl/uva/sne/drip/configuration/RPCCallersConfig.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-manager/src/main/java/nl/uva/sne/drip/rpc/DRIPCaller.java" beforeDir="false" afterPath="$PROJECT_DIR$/../drip-manager/src/main/java/nl/uva/sne/drip/rpc/DRIPCaller.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-manager/src/main/java/nl/uva/sne/drip/rpc/PlannerCaller.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-manager/src/main/java/nl/uva/sne/drip/service/PlannerService.java" beforeDir="false" afterPath="$PROJECT_DIR$/../drip-manager/src/main/java/nl/uva/sne/drip/service/DRIPService.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-manager/src/main/resources/application.properties" beforeDir="false" afterPath="$PROJECT_DIR$/../drip-manager/src/main/resources/application.properties" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-provisioner/nb-configuration.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-provisioner/nbactions.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-provisioner/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../drip-provisioner/pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-provisioner/src/main/java/nl/uva/sne/drip/drip/provisioner/RPCServer.java" beforeDir="false" afterPath="$PROJECT_DIR$/../drip-provisioner/src/main/java/nl/uva/sne/drip/drip/provisioner/RPCServer.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-provisioner/src/main/java/nl/uva/sne/drip/drip/provisioner/utils/MessageParsing.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-provisioner/src/main/java/nl/uva/sne/drip/drip/provisioner/utils/PropertyValues.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-provisioner/src/main/java/nl/uva/sne/drip/drip/provisioner/v1/Consumer.java" beforeDir="false" afterPath="$PROJECT_DIR$/../drip-provisioner/src/main/java/nl/uva/sne/drip/drip/provisioner/Consumer.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-provisioner/src/main/resources/log4j.properties" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-provisioner/src/main/resources/logging.properties" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-provisioner/src/main/resources/provisioner.properies" beforeDir="false" afterPath="$PROJECT_DIR$/../drip-provisioner/src/main/resources/application.properies" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-simple_planner/src/main/java/nl/uva/sne/drip/drip/planner/RPCServer.java" beforeDir="false" afterPath="$PROJECT_DIR$/../drip-simple_planner/src/main/java/nl/uva/sne/drip/drip/planner/RPCServer.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/planner/planner.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/planner/planner.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/planner/simple_spec_alayzer.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/planner/simple_spec_alayzer.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/rpc_server.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/rpc_server.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/rpc_server.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/rpc_server.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/test_planner.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/tests/test_planner.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/utils/tosca.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/utils/tosca.py" afterDir="false" />
</list> </list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
...@@ -98,7 +111,7 @@ ...@@ -98,7 +111,7 @@
<option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/src/rpc_server.py" /> <option name="SCRIPT_NAME" value="$PROJECT_DIR$/src/rpc_server.py" />
<option name="PARAMETERS" value="localhost planner_queue" /> <option name="PARAMETERS" value="localhost planner" />
<option name="SHOW_COMMAND_LINE" value="false" /> <option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" /> <option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" /> <option name="MODULE_MODE" value="false" />
......
...@@ -31,7 +31,7 @@ def init_chanel(args): ...@@ -31,7 +31,7 @@ def init_chanel(args):
global rabbitmq_host global rabbitmq_host
if len(args) > 1: if len(args) > 1:
rabbitmq_host = args[1] rabbitmq_host = args[1]
queue_name = args[2] # planner_queue queue_name = args[2] # planner
else: else:
rabbitmq_host = '127.0.0.1' rabbitmq_host = '127.0.0.1'
......
...@@ -4,14 +4,17 @@ ...@@ -4,14 +4,17 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>nl.uva.sne.drip</groupId> <groupId>nl.uva.sne.drip</groupId>
<artifactId>drip</artifactId> <artifactId>drip</artifactId>
<version>1.0-SNAPSHOT</version> <version>3.0.0</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.8.RELEASE</version>
</parent>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
<modules> <modules>
<module>drip-api</module>
<module>drip-planner2provisioner</module>
<module>drip-commons</module> <module>drip-commons</module>
<module>drip-provisioner</module> <module>drip-provisioner</module>
<module>drip-manager</module> <module>drip-manager</module>
......
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