Commit e760ce9d authored by Spiros Koulouzis's avatar Spiros Koulouzis

Merge branch 'DRIP_0.1'

# Conflicts:
#	docs/apidocs/data.html
#	docs/apidocs/downloads.html
#	docs/apidocs/drip-api-gwt-json-overlay.jar
#	docs/apidocs/drip-api-js.zip
#	docs/apidocs/drip-api-json-client-json-sources.jar
#	docs/apidocs/drip-api-json-client.jar
#	docs/apidocs/drip-api-php.zip
#	docs/apidocs/drip-api-xml-client-xml-sources.jar
#	docs/apidocs/drip-api-xml-client.jar
#	docs/apidocs/drip-api.rb
#	docs/apidocs/index.html
#	docs/apidocs/json_AnsibleOutput.html
#	docs/apidocs/json_AnsibleResult.html
#	docs/apidocs/json_BenchmarkResult.html
#	docs/apidocs/json_CloudCredentials.html
#	docs/apidocs/json_DeployParameter.html
#	docs/apidocs/json_DeployRequest.html
#	docs/apidocs/json_DeployResponse.html
#	docs/apidocs/json_Key.html
#	docs/apidocs/json_KeyPair.html
#	docs/apidocs/json_KeyType.html
#	docs/apidocs/json_KeyValueHolder.html
#	docs/apidocs/json_OwnedObject.html
#	docs/apidocs/json_PlanResponse.html
#	docs/apidocs/json_PlaybookRepresentation.html
#	docs/apidocs/json_ProvisionRequest.html
#	docs/apidocs/json_ProvisionResponse.html
#	docs/apidocs/json_Script.html
#	docs/apidocs/json_SysbenchCPUBenchmark.html
#	docs/apidocs/json_ToscaRepresentation.html
#	docs/apidocs/json_User.html
#	docs/apidocs/ns0.xsd
#	docs/apidocs/resource_AnsibleOutputController.html
#	docs/apidocs/resource_BenchmarkController.html
#	docs/apidocs/resource_CloudConfigurationController0.html
#	docs/apidocs/resource_CloudCredentialsController.html
#	docs/apidocs/resource_DeployController.html
#	docs/apidocs/resource_DeployController0.html
#	docs/apidocs/resource_KeyPairController.html
#	docs/apidocs/resource_PlannerController.html
#	docs/apidocs/resource_PlannerController0.html
#	docs/apidocs/resource_ProvisionController.html
#	docs/apidocs/resource_ProvisionController0.html
#	docs/apidocs/resource_ScriptController.html
#	docs/apidocs/resource_UserController.html
#	docs/apidocs/resource_UserPublicKeysController0.html
#	docs/apidocs/resource_UserScriptController0.html
#	docs/apidocs/resources.html
#	docs/apidocs/syntax_json.html
#	docs/apidocs/syntax_xml.html
#	docs/apidocs/xml_ns0_ansibleOutput.html
#	docs/apidocs/xml_ns0_attribute.html
#	docs/apidocs/xml_ns0_benchmarkResult.html
#	docs/apidocs/xml_ns0_cloudCredentials.html
#	docs/apidocs/xml_ns0_confScript.html
#	docs/apidocs/xml_ns0_confUserKey.html
#	docs/apidocs/xml_ns0_configure.html
#	docs/apidocs/xml_ns0_deploy.html
#	docs/apidocs/xml_ns0_deployParameter.html
#	docs/apidocs/xml_ns0_deployRequest.html
#	docs/apidocs/xml_ns0_deployResponse.html
#	docs/apidocs/xml_ns0_execute.html
#	docs/apidocs/xml_ns0_key.html
#	docs/apidocs/xml_ns0_keyPair.html
#	docs/apidocs/xml_ns0_keyType.html
#	docs/apidocs/xml_ns0_keyValueHolder.html
#	docs/apidocs/xml_ns0_ownedObject.html
#	docs/apidocs/xml_ns0_plan.html
#	docs/apidocs/xml_ns0_planResponse.html
#	docs/apidocs/xml_ns0_playbookRepresentation.html
#	docs/apidocs/xml_ns0_provisionRequest.html
#	docs/apidocs/xml_ns0_provisionResponse.html
#	docs/apidocs/xml_ns0_register.html
#	docs/apidocs/xml_ns0_result.html
#	docs/apidocs/xml_ns0_script.html
#	docs/apidocs/xml_ns0_sysbenchCPUBenchmark.html
#	docs/apidocs/xml_ns0_toscaRepresentation.html
#	docs/apidocs/xml_ns0_user.html
parents 96cac04a 81676ee0
......@@ -9,10 +9,10 @@
<api-classes>
<include pattern="nl.uva.sne.drip.api.v1.rest.*" />
<include pattern="nl.uva.sne.drip.api.v0.rest.*" />
<include pattern="nl.uva.sne.drip.data.v1.external.*" />
<include pattern="nl.uva.sne.drip.data.v1.external.ansible.*" />
<include pattern="nl.uva.sne.drip.data.v0.external.*" />
<exclude pattern="nl.uva.sne.drip.data.internal.*"/>
<include pattern="nl.uva.sne.drip.drip.commons.data.v1.external.*" />
<include pattern="nl.uva.sne.drip.drip.commons.data.v1.external.ansible.*" />
<include pattern="nl.uva.sne.drip.drip.commons.data.v0.external.*" />
<exclude pattern="nl.uva.sne.drip.drip.commons.data.internal.*"/>
</api-classes>
......
......@@ -21,7 +21,12 @@
</properties>
<dependencies>
<dependency>
<groupId>nl.uva.sne.drip</groupId>
<artifactId>drip-commons</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
......
......@@ -16,7 +16,7 @@
package nl.uva.sne.drip.api.auth;
import java.io.Serializable;
import nl.uva.sne.drip.data.v1.external.User;
import nl.uva.sne.drip.drip.commons.data.v1.external.User;
import org.springframework.security.access.PermissionEvaluator;
import org.springframework.security.core.Authentication;
......
......@@ -15,7 +15,7 @@
*/
package nl.uva.sne.drip.api.dao;
import nl.uva.sne.drip.data.v1.external.ansible.AnsibleOutput;
import nl.uva.sne.drip.drip.commons.data.v1.external.ansible.AnsibleOutput;
import org.springframework.data.mongodb.repository.MongoRepository;
/**
......
......@@ -15,7 +15,7 @@
*/
package nl.uva.sne.drip.api.dao;
import nl.uva.sne.drip.data.v1.external.ansible.BenchmarkResult;
import nl.uva.sne.drip.drip.commons.data.v1.external.ansible.BenchmarkResult;
import org.springframework.data.mongodb.repository.MongoRepository;
/**
......
......@@ -15,7 +15,7 @@
*/
package nl.uva.sne.drip.api.dao;
import nl.uva.sne.drip.data.v1.external.CloudCredentials;
import nl.uva.sne.drip.drip.commons.data.v1.external.CloudCredentials;
import org.springframework.data.mongodb.repository.MongoRepository;
/**
......
......@@ -15,9 +15,9 @@
*/
package nl.uva.sne.drip.api.dao;
import nl.uva.sne.drip.data.v1.external.DeployResponse;
import nl.uva.sne.drip.data.v1.external.Key;
import nl.uva.sne.drip.data.v1.external.ansible.AnsibleResult;
import nl.uva.sne.drip.drip.commons.data.v1.external.DeployResponse;
import nl.uva.sne.drip.drip.commons.data.v1.external.Key;
import nl.uva.sne.drip.drip.commons.data.v1.external.ansible.AnsibleResult;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.mongodb.repository.Query;
......
......@@ -15,7 +15,7 @@
*/
package nl.uva.sne.drip.api.dao;
import nl.uva.sne.drip.data.v1.external.KeyPair;
import nl.uva.sne.drip.drip.commons.data.v1.external.KeyPair;
import org.springframework.data.mongodb.repository.MongoRepository;
/**
......
......@@ -15,7 +15,7 @@
*/
package nl.uva.sne.drip.api.dao;
import nl.uva.sne.drip.data.v1.external.PlanResponse;
import nl.uva.sne.drip.drip.commons.data.v1.external.PlanResponse;
import org.springframework.data.mongodb.repository.MongoRepository;
/**
......
......@@ -15,7 +15,7 @@
*/
package nl.uva.sne.drip.api.dao;
import nl.uva.sne.drip.data.v1.external.PlaybookRepresentation;
import nl.uva.sne.drip.drip.commons.data.v1.external.PlaybookRepresentation;
import org.springframework.data.mongodb.repository.MongoRepository;
/**
......
......@@ -15,7 +15,7 @@
*/
package nl.uva.sne.drip.api.dao;
import nl.uva.sne.drip.data.v1.external.ProvisionResponse;
import nl.uva.sne.drip.drip.commons.data.v1.external.ProvisionResponse;
import org.springframework.data.mongodb.repository.MongoRepository;
/**
......
......@@ -15,7 +15,7 @@
*/
package nl.uva.sne.drip.api.dao;
import nl.uva.sne.drip.data.v1.external.Script;
import nl.uva.sne.drip.drip.commons.data.v1.external.Script;
import org.springframework.data.mongodb.repository.MongoRepository;
/**
......
......@@ -15,7 +15,7 @@
*/
package nl.uva.sne.drip.api.dao;
import nl.uva.sne.drip.data.v1.external.ToscaRepresentation;
import nl.uva.sne.drip.drip.commons.data.v1.external.ToscaRepresentation;
import org.springframework.data.mongodb.repository.MongoRepository;
/**
......
......@@ -15,7 +15,7 @@
*/
package nl.uva.sne.drip.api.dao;
import nl.uva.sne.drip.data.v1.external.User;
import nl.uva.sne.drip.drip.commons.data.v1.external.User;
import org.springframework.data.mongodb.repository.MongoRepository;
/**
......
......@@ -15,7 +15,7 @@ import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
import java.util.logging.Logger;
import nl.uva.sne.drip.data.internal.Message;
import nl.uva.sne.drip.drip.commons.data.internal.Message;
import nl.uva.sne.drip.commons.utils.Converter;
import org.json.JSONException;
......
......@@ -22,11 +22,11 @@ import java.util.concurrent.TimeoutException;
*
* @author S. Koulouzis
*/
public class ProvisionerCaller extends DRIPCaller {
public class ProvisionerCaller0 extends DRIPCaller {
private static final String REQUEST_QUEUE_NAME = "provisioner_queue";
private static final String REQUEST_QUEUE_NAME = "provisioner_queue_v0";
public ProvisionerCaller(String messageBrokerHost) throws IOException, TimeoutException {
public ProvisionerCaller0(String messageBrokerHost) throws IOException, TimeoutException {
super(messageBrokerHost, REQUEST_QUEUE_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.api.rpc;
import java.io.IOException;
import java.util.concurrent.TimeoutException;
/**
*
* @author S. Koulouzis
*/
public class ProvisionerCaller1 extends DRIPCaller {
private static final String REQUEST_QUEUE_NAME = "provisioner_queue_v1";
public ProvisionerCaller1(String messageBrokerHost) throws IOException, TimeoutException {
super(messageBrokerHost, REQUEST_QUEUE_NAME);
}
}
......@@ -21,9 +21,9 @@ import java.util.List;
import java.util.Set;
import nl.uva.sne.drip.api.dao.AnsibleOutputDao;
import nl.uva.sne.drip.api.exception.NotFoundException;
import nl.uva.sne.drip.data.v1.external.User;
import nl.uva.sne.drip.data.v1.external.ansible.AnsibleOutput;
import nl.uva.sne.drip.data.v1.external.ansible.AnsibleResult;
import nl.uva.sne.drip.drip.commons.data.v1.external.User;
import nl.uva.sne.drip.drip.commons.data.v1.external.ansible.AnsibleOutput;
import nl.uva.sne.drip.drip.commons.data.v1.external.ansible.AnsibleResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.security.access.prepost.PostFilter;
......
......@@ -18,8 +18,8 @@ package nl.uva.sne.drip.api.service;
import java.util.List;
import nl.uva.sne.drip.api.dao.BenchmarkResultDao;
import nl.uva.sne.drip.api.exception.NotFoundException;
import nl.uva.sne.drip.data.v1.external.User;
import nl.uva.sne.drip.data.v1.external.ansible.BenchmarkResult;
import nl.uva.sne.drip.drip.commons.data.v1.external.User;
import nl.uva.sne.drip.drip.commons.data.v1.external.ansible.BenchmarkResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.security.access.prepost.PostFilter;
......
......@@ -18,8 +18,8 @@ package nl.uva.sne.drip.api.service;
import java.util.List;
import nl.uva.sne.drip.api.dao.CloudCredentialsDao;
import nl.uva.sne.drip.api.exception.NotFoundException;
import nl.uva.sne.drip.data.v1.external.CloudCredentials;
import nl.uva.sne.drip.data.v1.external.User;
import nl.uva.sne.drip.drip.commons.data.v1.external.CloudCredentials;
import nl.uva.sne.drip.drip.commons.data.v1.external.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.security.access.prepost.PostFilter;
......@@ -42,6 +42,7 @@ public class CloudCredentialsService {
User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
String owner = user.getUsername();
cloudCredentials.setOwner(owner);
cloudCredentials.setTimestamp(System.currentTimeMillis());
return dao.save(cloudCredentials);
}
......
......@@ -18,15 +18,15 @@ package nl.uva.sne.drip.api.service;
import java.util.ArrayList;
import java.util.List;
import nl.uva.sne.drip.api.exception.NotFoundException;
import nl.uva.sne.drip.data.v1.external.KeyPair;
import nl.uva.sne.drip.data.v1.external.User;
import nl.uva.sne.drip.drip.commons.data.v1.external.KeyPair;
import nl.uva.sne.drip.drip.commons.data.v1.external.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.security.access.prepost.PostFilter;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
import nl.uva.sne.drip.api.dao.KeyPairDao;
import nl.uva.sne.drip.data.v1.external.KeyPair;
import nl.uva.sne.drip.drip.commons.data.v1.external.KeyPair;
/**
*
......
......@@ -29,12 +29,13 @@ import nl.uva.sne.drip.api.dao.PlanDao;
import nl.uva.sne.drip.api.exception.BadRequestException;
import nl.uva.sne.drip.api.exception.NotFoundException;
import nl.uva.sne.drip.api.rpc.PlannerCaller;
import nl.uva.sne.drip.data.internal.Message;
import nl.uva.sne.drip.data.internal.MessageParameter;
import nl.uva.sne.drip.data.v1.external.PlanResponse;
import nl.uva.sne.drip.data.v1.external.ToscaRepresentation;
import nl.uva.sne.drip.commons.utils.Constants;
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;
import nl.uva.sne.drip.drip.commons.data.v1.external.ToscaRepresentation;
import nl.uva.sne.drip.commons.utils.Converter;
import nl.uva.sne.drip.data.v1.external.User;
import nl.uva.sne.drip.drip.commons.data.v1.external.User;
import nl.uva.sne.drip.drip.converter.P2PConverter;
import nl.uva.sne.drip.drip.converter.SimplePlanContainer;
import org.json.JSONException;
......@@ -63,7 +64,7 @@ public class PlannerService {
@Value("${message.broker.host}")
private String messageBrokerHost;
public PlanResponse getPlan(String toscaId) throws JSONException, UnsupportedEncodingException, IOException, TimeoutException, InterruptedException {
public PlanResponse getPlan(String toscaId, String clusterType) throws JSONException, UnsupportedEncodingException, IOException, TimeoutException, InterruptedException {
try (PlannerCaller planner = new PlannerCaller(messageBrokerHost)) {
Message plannerInvokationMessage = buildPlannerMessage(toscaId);
......@@ -84,7 +85,7 @@ public class PlannerService {
}
jsonArrayString.append("]");
SimplePlanContainer simplePlan = P2PConverter.convert(jsonArrayString.toString(), "vm_user", "Ubuntu 16.04", "swarm");
SimplePlanContainer simplePlan = P2PConverter.convert(jsonArrayString.toString(), "vm_user", "Ubuntu 16.04", clusterType);
PlanResponse topLevel = new PlanResponse();
topLevel.setTimestamp(System.currentTimeMillis());
topLevel.setLevel(0);
......@@ -117,7 +118,7 @@ public class PlannerService {
}
Map<String, Object> map = t2.getKeyValue();
String json = Converter.map2JsonString(map);
json = json.replaceAll("\\uff0E", "\\.");
json = json.replaceAll("\\uff0E", ".");
byte[] bytes = json.getBytes();
Message invokationMessage = new Message();
......@@ -143,24 +144,25 @@ public class PlannerService {
Map<String, Object> map = plan.getKeyValue();
Set<String> ids = plan.getLoweLevelPlanIDs();
for (String lowID : ids) {
Map<String, Object> lowLevelMap = findOne(lowID).getKeyValue();
PlanResponse ll = findOne(lowID);
Map<String, Object> lowLevelMap = ll.getKeyValue();
if (lowLevelMap != null) {
map.putAll(lowLevelMap);
map.put(ll.getName(), lowLevelMap);
}
}
if (fromat != null && fromat.equals("yml")) {
String ymlStr = Converter.map2YmlString(map);
ymlStr = ymlStr.replaceAll("\\uff0E", "\\.");
ymlStr = ymlStr.replaceAll("\\uff0E", ".");
return ymlStr;
}
if (fromat != null && fromat.equals("json")) {
String jsonStr = Converter.map2JsonString(map);
jsonStr = jsonStr.replaceAll("\\uff0E", "\\.");
jsonStr = jsonStr.replaceAll("\\uff0E", ".");
return jsonStr;
}
String ymlStr = Converter.map2YmlString(map);
ymlStr = ymlStr.replaceAll("\\uff0E", "\\.");
ymlStr = ymlStr.replaceAll("\\uff0E", ".");
return ymlStr;
}
......@@ -188,12 +190,11 @@ public class PlannerService {
}
@PostAuthorize("(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
public PlanResponse findOne(String lowiID) {
PlanResponse plan = planDao.findOne(lowiID);
public PlanResponse findOne(String id) {
PlanResponse plan = planDao.findOne(id);
if (plan == null) {
throw new NotFoundException();
}
return plan;
}
......@@ -203,6 +204,12 @@ public class PlannerService {
if (plan == null) {
throw new NotFoundException();
}
Set<String> lowIds = plan.getLoweLevelPlanIDs();
if (lowIds != null) {
for (String lId : lowIds) {
planDao.delete(lId);
}
}
planDao.delete(plan);
return plan;
}
......@@ -212,4 +219,38 @@ public class PlannerService {
planDao.deleteAll();
}
public String saveStringContents(String ymlContents, Integer level, String name) {
//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");
// ymlContents = ymlContents.replaceAll("\uff0E", ".");
Map<String, Object> map = Converter.ymlString2Map(ymlContents);
PlanResponse pr = new PlanResponse();
pr.setKvMap(map);
pr.setLevel(level);
pr.setName(name);
save(pr);
return pr.getId();
}
}
......@@ -20,9 +20,9 @@ import java.util.List;
import java.util.Map;
import nl.uva.sne.drip.api.exception.NotFoundException;
import nl.uva.sne.drip.commons.utils.Constants;
import nl.uva.sne.drip.data.v1.external.PlaybookRepresentation;
import nl.uva.sne.drip.drip.commons.data.v1.external.PlaybookRepresentation;
import nl.uva.sne.drip.commons.utils.Converter;
import nl.uva.sne.drip.data.v1.external.User;
import nl.uva.sne.drip.drip.commons.data.v1.external.User;
import org.json.JSONException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PostAuthorize;
......@@ -54,17 +54,17 @@ public class PlaybookService {
if (fromat != null && fromat.toLowerCase().equals("yml")) {
String ymlStr = Converter.map2YmlString(map);
ymlStr = ymlStr.replaceAll("\\uff0E", "\\.");
ymlStr = ymlStr.replaceAll("\\uff0E", ".");
ymlStr = ymlStr.replaceAll("\'---':", "---");
return ymlStr;
}
if (fromat != null && fromat.toLowerCase().equals("json")) {
String jsonStr = Converter.map2JsonString(map);
jsonStr = jsonStr.replaceAll("\\uff0E", "\\.");
jsonStr = jsonStr.replaceAll("\\uff0E", ".");
return jsonStr;
}
String ymlStr = Converter.map2YmlString(map);
ymlStr = ymlStr.replaceAll("\\uff0E", "\\.");
ymlStr = ymlStr.replaceAll("\\uff0E", ".");
ymlStr = ymlStr.replaceAll("\'---':", "---");
return ymlStr;
......
......@@ -21,8 +21,8 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Service;
import nl.uva.sne.drip.api.dao.ScriptDao;
import nl.uva.sne.drip.api.exception.NotFoundException;
import nl.uva.sne.drip.data.v1.external.Script;
import nl.uva.sne.drip.data.v1.external.User;
import nl.uva.sne.drip.drip.commons.data.v1.external.Script;
import nl.uva.sne.drip.drip.commons.data.v1.external.User;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.security.access.prepost.PostFilter;
import org.springframework.security.core.context.SecurityContextHolder;
......
......@@ -29,10 +29,10 @@ import java.util.concurrent.TimeoutException;
import nl.uva.sne.drip.api.dao.PlanDao;
import nl.uva.sne.drip.api.exception.NotFoundException;
import nl.uva.sne.drip.api.rpc.PlannerCaller;
import nl.uva.sne.drip.data.internal.Message;
import nl.uva.sne.drip.data.internal.MessageParameter;
import nl.uva.sne.drip.data.v1.external.PlanResponse;
import nl.uva.sne.drip.data.v1.external.ToscaRepresentation;
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;
import nl.uva.sne.drip.drip.commons.data.v1.external.ToscaRepresentation;
import nl.uva.sne.drip.commons.utils.Converter;
import org.json.JSONException;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -105,7 +105,7 @@ public class SimplePlannerService {
}
Map<String, Object> map = t2.getKeyValue();
String ymlStr = Converter.map2YmlString(map);
ymlStr = ymlStr.replaceAll("\\uff0E", "\\.");
ymlStr = ymlStr.replaceAll("\\uff0E", ".");
byte[] bytes = ymlStr.getBytes();
Message invokationMessage = new Message();
......@@ -145,16 +145,16 @@ public class SimplePlannerService {
if (fromat != null && fromat.equals("yml")) {
String ymlStr = Converter.map2YmlString(map);
ymlStr = ymlStr.replaceAll("\\uff0E", "\\.");
ymlStr = ymlStr.replaceAll("\\uff0E", ".");
return ymlStr;
}
if (fromat != null && fromat.equals("json")) {
String jsonStr = Converter.map2JsonString(map);
jsonStr = jsonStr.replaceAll("\\uff0E", "\\.");
jsonStr = jsonStr.replaceAll("\\uff0E", ".");
return jsonStr;
}
String ymlStr = Converter.map2YmlString(map);
ymlStr = ymlStr.replaceAll("\\uff0E", "\\.");
ymlStr = ymlStr.replaceAll("\\uff0E", ".");
return ymlStr;
}
......
......@@ -21,9 +21,9 @@ import java.util.Map;
import nl.uva.sne.drip.api.dao.ToscaDao;
import nl.uva.sne.drip.api.exception.NotFoundException;
import nl.uva.sne.drip.commons.utils.Constants;
import nl.uva.sne.drip.data.v1.external.ToscaRepresentation;
import nl.uva.sne.drip.drip.commons.data.v1.external.ToscaRepresentation;
import nl.uva.sne.drip.commons.utils.Converter;
import nl.uva.sne.drip.data.v1.external.User;
import nl.uva.sne.drip.drip.commons.data.v1.external.User;
import org.json.JSONException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PostAuthorize;
......@@ -54,16 +54,16 @@ public class ToscaService {
if (fromat != null && fromat.equals("yml")) {
String ymlStr = Converter.map2YmlString(map);
ymlStr = ymlStr.replaceAll("\\uff0E", "\\.");
ymlStr = ymlStr.replaceAll("\\uff0E", ".");
return ymlStr;
}
if (fromat != null && fromat.equals("json")) {
String jsonStr = Converter.map2JsonString(map);
jsonStr = jsonStr.replaceAll("\\uff0E", "\\.");
jsonStr = jsonStr.replaceAll("\\uff0E", ".");
return jsonStr;
}
String ymlStr = Converter.map2YmlString(map);
ymlStr = ymlStr.replaceAll("\\uff0E", "\\.");
ymlStr = ymlStr.replaceAll("\\uff0E", ".");
return ymlStr;
}
......
......@@ -19,7 +19,7 @@ import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import nl.uva.sne.drip.api.dao.UserDao;
import nl.uva.sne.drip.data.v1.external.User;
import nl.uva.sne.drip.drip.commons.data.v1.external.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
......
......@@ -23,7 +23,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.security.RolesAllowed;
import nl.uva.sne.drip.api.exception.KeyException;
import nl.uva.sne.drip.data.v1.external.CloudCredentials;
import nl.uva.sne.drip.drip.commons.data.v1.external.CloudCredentials;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -35,9 +35,9 @@ import nl.uva.sne.drip.api.exception.NullKeyIDException;
import nl.uva.sne.drip.api.service.CloudCredentialsService;
import nl.uva.sne.drip.api.service.KeyPairService;
import nl.uva.sne.drip.api.service.UserService;
import nl.uva.sne.drip.data.v0.external.Configure;
import nl.uva.sne.drip.data.v1.external.Key;
import nl.uva.sne.drip.data.v1.external.KeyPair;
import nl.uva.sne.drip.drip.commons.data.v0.external.Configure;
import nl.uva.sne.drip.drip.commons.data.v1.external.Key;
import nl.uva.sne.drip.drip.commons.data.v1.external.KeyPair;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
......@@ -62,7 +62,7 @@ public class CloudConfigurationController0 {
@RequestMapping(value = "/ec2", method = RequestMethod.POST, consumes = MediaType.TEXT_XML_VALUE)
@RolesAllowed({UserService.USER, UserService.ADMIN})
public @ResponseBody
String postEC2Conf(@RequestBody Configure configure) {
String postEC2Conf(@RequestBody Configure configure) throws Exception {
if (configure.key == null) {
throw new NullKeyException();
}
......@@ -76,9 +76,9 @@ public class CloudConfigurationController0 {
List<String> loginKeyIDs = new ArrayList<>();
for (nl.uva.sne.drip.data.v0.external.LoginKey0 key0 : configure.loginKey) {
for (nl.uva.sne.drip.drip.commons.data.v0.external.LoginKey0 key0 : configure.loginKey) {
try {
nl.uva.sne.drip.data.v1.external.Key key1 = new nl.uva.sne.drip.data.v1.external.Key();
nl.uva.sne.drip.drip.commons.data.v1.external.Key key1 = new nl.uva.sne.drip.drip.commons.data.v1.external.Key();
KeyPair pair = new KeyPair();
pair.setTimestamp(System.currentTimeMillis());
key1.setKey(key0.content);
......@@ -102,7 +102,7 @@ public class CloudConfigurationController0 {
@RequestMapping(value = "/geni", method = RequestMethod.POST, consumes = MediaType.TEXT_XML_VALUE)
@RolesAllowed({UserService.USER, UserService.ADMIN})
public @ResponseBody
String postGeniConf(@RequestBody Configure configure) {
String postGeniConf(@RequestBody Configure configure) throws Exception {
if (configure.geniKey == null) {
throw new NullKeyException();
}
......@@ -117,9 +117,9 @@ public class CloudConfigurationController0 {
List<String> loginKeyIDs = new ArrayList<>();
for (nl.uva.sne.drip.data.v0.external.LoginKey0 key0 : configure.loginPubKey) {
for (nl.uva.sne.drip.drip.commons.data.v0.external.LoginKey0 key0 : configure.loginPubKey) {
try {
nl.uva.sne.drip.data.v1.external.Key key1 = new nl.uva.sne.drip.data.v1.external.Key();
nl.uva.sne.drip.drip.commons.data.v1.external.Key key1 = new nl.uva.sne.drip.drip.commons.data.v1.external.Key();
key1.setKey(key0.content);
key1.setType(Key.KeyType.PUBLIC);
KeyPair pair = new KeyPair();
......@@ -132,9 +132,9 @@ public class CloudConfigurationController0 {
}
}
for (nl.uva.sne.drip.data.v0.external.LoginKey0 key0 : configure.loginPriKey) {
for (nl.uva.sne.drip.drip.commons.data.v0.external.LoginKey0 key0 : configure.loginPriKey) {
try {
nl.uva.sne.drip.data.v1.external.Key key1 = new nl.uva.sne.drip.data.v1.external.Key();
nl.uva.sne.drip.drip.commons.data.v1.external.Key key1 = new nl.uva.sne.drip.drip.commons.data.v1.external.Key();
key1.setKey(key0.content);
key1.setType(Key.KeyType.PRIVATE);
KeyPair pair = new KeyPair();
......
......@@ -17,6 +17,8 @@ package nl.uva.sne.drip.api.v0.rest;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.security.RolesAllowed;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -25,12 +27,12 @@ import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import nl.uva.sne.drip.api.service.DeployService;
import nl.uva.sne.drip.api.service.UserService;
import nl.uva.sne.drip.data.v0.external.Deploy;
import nl.uva.sne.drip.data.v0.external.Attribute;
import nl.uva.sne.drip.data.v0.external.Result;
import nl.uva.sne.drip.data.v1.external.DeployRequest;
import nl.uva.sne.drip.data.v1.external.DeployResponse;
import nl.uva.sne.drip.data.v1.external.Key;
import nl.uva.sne.drip.drip.commons.data.v0.external.Deploy;
import nl.uva.sne.drip.drip.commons.data.v0.external.Attribute;
import nl.uva.sne.drip.drip.commons.data.v0.external.Result;
import nl.uva.sne.drip.drip.commons.data.v1.external.DeployRequest;
import nl.uva.sne.drip.drip.commons.data.v1.external.DeployResponse;
import nl.uva.sne.drip.drip.commons.data.v1.external.Key;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Component;
......@@ -55,23 +57,33 @@ public class DeployController0 {
@RolesAllowed({UserService.USER, UserService.ADMIN})
public @ResponseBody
Result deployKubernetes(@RequestBody Deploy deploy) {
DeployRequest deployReq = new DeployRequest();
deployReq.setManagerType("kubernetes");
deployReq.setProvisionID(deploy.action);
return deploy(deployReq);
try {
DeployRequest deployReq = new DeployRequest();
deployReq.setManagerType("kubernetes");
deployReq.setProvisionID(deploy.action);
return deploy(deployReq);
} catch (Exception ex) {
Logger.getLogger(DeployController0.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
@RequestMapping(value = "/swarm", method = RequestMethod.POST, consumes = MediaType.TEXT_XML_VALUE, produces = MediaType.TEXT_XML_VALUE)
@RolesAllowed({UserService.USER, UserService.ADMIN})
public @ResponseBody
Result deploySwarm(@RequestBody Deploy deploy) {
DeployRequest deployReq = new DeployRequest();
deployReq.setManagerType("swarm");
deployReq.setProvisionID(deploy.action);
return deploy(deployReq);
try {
DeployRequest deployReq = new DeployRequest();
deployReq.setManagerType("swarm");
deployReq.setProvisionID(deploy.action);
return deploy(deployReq);
} catch (Exception ex) {
Logger.getLogger(DeployController0.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
private Result deploy(DeployRequest deployReq) {
private Result deploy(DeployRequest deployReq) throws Exception {
DeployResponse key = deployService.deploySoftware(deployReq);
......
......@@ -21,7 +21,7 @@ import java.util.List;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
import java.util.logging.Logger;
import nl.uva.sne.drip.data.v0.external.Result;
import nl.uva.sne.drip.drip.commons.data.v0.external.Result;
import javax.annotation.security.RolesAllowed;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -33,8 +33,8 @@ import nl.uva.sne.drip.api.service.PlannerService;
import nl.uva.sne.drip.api.service.ToscaService;
import nl.uva.sne.drip.api.service.UserService;
import nl.uva.sne.drip.commons.utils.Converter;
import nl.uva.sne.drip.data.v0.external.Attribute;
import nl.uva.sne.drip.data.v0.external.Plan;
import nl.uva.sne.drip.drip.commons.data.v0.external.Attribute;
import nl.uva.sne.drip.drip.commons.data.v0.external.Plan;
import org.json.JSONException;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
......@@ -65,7 +65,7 @@ public class PlannerController0 {
String yaml = plan0.file;
yaml = yaml.replaceAll("\\\\n", "\n");
String id = toscaService.saveYamlString(yaml, null);
nl.uva.sne.drip.data.v1.external.PlanResponse plan1 = plannerService.getPlan(id);
nl.uva.sne.drip.drip.commons.data.v1.external.PlanResponse plan1 = plannerService.getPlan(id,"swarm");
Result r = new Result();
r.info = ("INFO");
......@@ -76,7 +76,7 @@ public class PlannerController0 {
files.add(e);
for (String lowiID : plan1.getLoweLevelPlanIDs()) {
nl.uva.sne.drip.data.v1.external.PlanResponse lowPlan1 = plannerService.findOne(lowiID);
nl.uva.sne.drip.drip.commons.data.v1.external.PlanResponse lowPlan1 = plannerService.findOne(lowiID);
e = Converter.plan1toFile(lowPlan1);
files.add(e);
//Don't save them cause they will be re-uploaded in the provision step
......
......@@ -16,7 +16,7 @@
package nl.uva.sne.drip.api.v0.rest;
import java.io.IOException;
import nl.uva.sne.drip.data.v1.external.ProvisionRequest;
import nl.uva.sne.drip.drip.commons.data.v1.external.ProvisionRequest;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
......@@ -39,13 +39,13 @@ import nl.uva.sne.drip.api.service.ProvisionService;
import nl.uva.sne.drip.api.service.KeyPairService;
import nl.uva.sne.drip.api.service.ScriptService;
import nl.uva.sne.drip.api.service.UserService;
import nl.uva.sne.drip.data.v0.external.Execute;
import nl.uva.sne.drip.data.v0.external.Attribute;
import nl.uva.sne.drip.data.v0.external.Result;
import nl.uva.sne.drip.data.v0.external.Upload;
import nl.uva.sne.drip.data.v1.external.CloudCredentials;
import nl.uva.sne.drip.data.v1.external.KeyPair;
import nl.uva.sne.drip.data.v1.external.ProvisionResponse;
import nl.uva.sne.drip.drip.commons.data.v0.external.Execute;
import nl.uva.sne.drip.drip.commons.data.v0.external.Attribute;
import nl.uva.sne.drip.drip.commons.data.v0.external.Result;
import nl.uva.sne.drip.drip.commons.data.v0.external.Upload;
import nl.uva.sne.drip.drip.commons.data.v1.external.CloudCredentials;
import nl.uva.sne.drip.drip.commons.data.v1.external.KeyPair;
import nl.uva.sne.drip.drip.commons.data.v1.external.ProvisionResponse;
import org.json.JSONException;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
......@@ -90,12 +90,12 @@ public class ProvisionController0 {
List<String> idList = new ArrayList<>();
idList.add(cloudCredID);
resp.setCloudCredentialsIDs(idList);
List<nl.uva.sne.drip.data.v0.external.Attribute> plans = upload.file;
nl.uva.sne.drip.data.v1.external.PlanResponse topLevelPlan = null;
List<nl.uva.sne.drip.drip.commons.data.v0.external.Attribute> plans = upload.file;
nl.uva.sne.drip.drip.commons.data.v1.external.PlanResponse topLevelPlan = null;
Set<String> loweLevelPlansIDs = new HashSet<>();
for (nl.uva.sne.drip.data.v0.external.Attribute p : plans) {
nl.uva.sne.drip.data.v1.external.PlanResponse plan1 = Converter.File2Plan1(p);
for (nl.uva.sne.drip.drip.commons.data.v0.external.Attribute p : plans) {
nl.uva.sne.drip.drip.commons.data.v1.external.PlanResponse plan1 = Converter.File2Plan1(p);
if (plan1.getLevel() == 0) {
topLevelPlan = plan1;
} else {
......@@ -114,7 +114,7 @@ public class ProvisionController0 {
String userKeyID = keyPair.getId();
keyPairIDs.add(userKeyID);
}
resp.setKeyPairIDs(keyPairIDs);
resp.setUserKeyPairIDs(keyPairIDs);
}
resp = provisionService.save(resp);
return "Success: Infrastructure files are uploaded! Action number: "
......@@ -128,7 +128,7 @@ public class ProvisionController0 {
try {
ProvisionRequest req = provisionService.findOne(exc.action);
req = provisionService.provisionResources(req);
req = provisionService.provisionResources(req,0);
Map<String, Object> map = req.getKeyValue();
String yaml = Converter.map2YmlString(map);
yaml = yaml.replaceAll("\n", "\\\\n");
......@@ -146,6 +146,8 @@ public class ProvisionController0 {
return res;
} catch (IOException | TimeoutException | JSONException | InterruptedException ex) {
Logger.getLogger(ProvisionController0.class.getName()).log(Level.SEVERE, null, ex);
} catch (Exception ex) {
Logger.getLogger(ProvisionController0.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
......
......@@ -21,7 +21,7 @@ import javax.annotation.security.RolesAllowed;
import nl.uva.sne.drip.api.exception.PasswordNullException;
import nl.uva.sne.drip.api.exception.UserExistsException;
import nl.uva.sne.drip.api.exception.UserNullException;
import nl.uva.sne.drip.data.v1.external.User;
import nl.uva.sne.drip.drip.commons.data.v1.external.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -29,7 +29,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import nl.uva.sne.drip.api.service.UserService;
import nl.uva.sne.drip.data.v0.external.Register;
import nl.uva.sne.drip.drip.commons.data.v0.external.Register;
import org.springframework.http.MediaType;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
......
......@@ -30,11 +30,11 @@ import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import nl.uva.sne.drip.api.service.KeyPairService;
import nl.uva.sne.drip.api.service.UserService;
import nl.uva.sne.drip.data.v0.external.ConfUserKey;
import nl.uva.sne.drip.data.v1.external.Key;
import nl.uva.sne.drip.data.v1.external.KeyPair;
import nl.uva.sne.drip.data.v1.external.ProvisionRequest;
import nl.uva.sne.drip.data.v1.external.ProvisionResponse;
import nl.uva.sne.drip.drip.commons.data.v0.external.ConfUserKey;
import nl.uva.sne.drip.drip.commons.data.v1.external.Key;
import nl.uva.sne.drip.drip.commons.data.v1.external.KeyPair;
import nl.uva.sne.drip.drip.commons.data.v1.external.ProvisionRequest;
import nl.uva.sne.drip.drip.commons.data.v1.external.ProvisionResponse;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
......@@ -59,7 +59,7 @@ public class UserPublicKeysController0 {
@RequestMapping(value = "/confuserkey", method = RequestMethod.POST, consumes = MediaType.TEXT_XML_VALUE)
@RolesAllowed({UserService.USER, UserService.ADMIN})
public @ResponseBody
String uploadUserPublicKeys(@RequestBody ConfUserKey confUserKey) {
String uploadUserPublicKeys(@RequestBody ConfUserKey confUserKey) throws Exception {
try {
KeyPair pair = new KeyPair();
Key upk = new Key();
......@@ -72,7 +72,7 @@ public class UserPublicKeysController0 {
ProvisionResponse provPlan = provisionService.findOne(confUserKey.action);
List<String> keyPairIDs = new ArrayList<>();
keyPairIDs.add(pair.getId());
provPlan.setKeyPairIDs(keyPairIDs);
provPlan.setUserKeyPairIDs(keyPairIDs);
provisionService.save(provPlan);
return "Success: " + pair.getId();
......
......@@ -23,9 +23,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import nl.uva.sne.drip.api.service.ScriptService;
import nl.uva.sne.drip.api.service.UserService;
import nl.uva.sne.drip.data.v0.external.ConfScript;
import nl.uva.sne.drip.data.v1.external.ProvisionResponse;
import nl.uva.sne.drip.data.v1.external.Script;
import nl.uva.sne.drip.drip.commons.data.v0.external.ConfScript;
import nl.uva.sne.drip.drip.commons.data.v1.external.ProvisionResponse;
import nl.uva.sne.drip.drip.commons.data.v1.external.Script;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMethod;
......
......@@ -28,7 +28,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import nl.uva.sne.drip.api.service.UserService;
import nl.uva.sne.drip.data.v1.external.ansible.AnsibleOutput;
import nl.uva.sne.drip.drip.commons.data.v1.external.ansible.AnsibleOutput;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
......
......@@ -23,15 +23,13 @@ import javax.annotation.security.RolesAllowed;
import nl.uva.sne.drip.api.exception.NotFoundException;
import nl.uva.sne.drip.api.service.BenchmarkResultService;
import nl.uva.sne.drip.api.service.UserService;
import nl.uva.sne.drip.data.v1.external.ansible.BenchmarkResult;
import nl.uva.sne.drip.data.v1.external.ansible.BenchmarkResult;
import nl.uva.sne.drip.drip.commons.data.v1.external.ansible.BenchmarkResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
/**
......
......@@ -26,7 +26,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.security.RolesAllowed;
import javax.ws.rs.core.MediaType;
import nl.uva.sne.drip.data.v1.external.CloudCredentials;
import nl.uva.sne.drip.drip.commons.data.v1.external.CloudCredentials;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -40,8 +40,8 @@ import nl.uva.sne.drip.api.exception.NullKeyException;
import nl.uva.sne.drip.api.service.CloudCredentialsService;
import nl.uva.sne.drip.api.service.KeyPairService;
import nl.uva.sne.drip.api.service.UserService;
import nl.uva.sne.drip.data.v1.external.Key;
import nl.uva.sne.drip.data.v1.external.KeyPair;
import nl.uva.sne.drip.drip.commons.data.v1.external.Key;
import nl.uva.sne.drip.drip.commons.data.v1.external.KeyPair;
import org.apache.commons.io.FilenameUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
......@@ -105,11 +105,12 @@ public class CloudCredentialsController {
* @param file
* @param id
* @return the CloudCredentials id
* @throws java.lang.Exception
*/
@RequestMapping(value = "/upload/{id}", method = RequestMethod.POST)
@RolesAllowed({UserService.USER, UserService.ADMIN})
public @ResponseBody
String addLogineKey(@RequestParam("file") MultipartFile file, @PathVariable("id") String id) {
String addLogineKey(@RequestParam("file") MultipartFile file, @PathVariable("id") String id) throws Exception {
try {
CloudCredentials cloudCredentials = cloudCredentialsService.findOne(id);
......@@ -206,16 +207,19 @@ public class CloudCredentialsController {
@RequestMapping(value = "/sample", method = RequestMethod.GET)
@RolesAllowed({UserService.USER, UserService.ADMIN})
public @ResponseBody
CloudCredentials geta() {
CloudCredentials getSample() {
CloudCredentials cloudCredentials = new CloudCredentials();
cloudCredentials.setTimestamp(System.currentTimeMillis());
cloudCredentials.setAccessKeyId("AKIAITY3KHZUQ6M7YBSQ");
cloudCredentials.setCloudProviderName("ec2");
cloudCredentials.setSecretKey("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");
cloudCredentials.setAccessKeyId("AKIAITWERHZUQ6M7YBSQ");
cloudCredentials.setCloudProviderName("egi");
cloudCredentials.setSecretKey("6J7uo99ifrff45sa6Gsy5vgb3b3ewdsdtwY6hBxtYt9y");
List<String> keyIDs = new ArrayList<>();
keyIDs.add("58da4c91f7b43a3282cacdbb");
keyIDs.add("58da4d2af7b43a3282cacdbd");
cloudCredentials.setKeyIDs(keyIDs);
Map<String, Object> attributes = new HashMap<>();
attributes.put("myProxyEndpoint", "myproxy.egee.host.com");
attributes.put("trustedCertificatesURL", "https://dist.eugridpma.info/distribution/igtf/current/accredited/igtf-preinstalled-bundle-classic.tar.gz");
cloudCredentials.setAttributes(attributes);
return cloudCredentials;
}
......
......@@ -17,7 +17,7 @@ package nl.uva.sne.drip.api.v1.rest;
import com.webcohesion.enunciate.metadata.rs.ResponseCode;
import com.webcohesion.enunciate.metadata.rs.StatusCodes;
import nl.uva.sne.drip.data.v1.external.PlaybookRepresentation;
import nl.uva.sne.drip.drip.commons.data.v1.external.PlaybookRepresentation;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
......
......@@ -19,6 +19,8 @@ import com.webcohesion.enunciate.metadata.rs.ResponseCode;
import com.webcohesion.enunciate.metadata.rs.StatusCodes;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.security.RolesAllowed;
import nl.uva.sne.drip.api.exception.BadRequestException;
import nl.uva.sne.drip.api.exception.NotFoundException;
......@@ -29,8 +31,8 @@ import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import nl.uva.sne.drip.api.service.DeployService;
import nl.uva.sne.drip.api.service.UserService;
import nl.uva.sne.drip.data.v1.external.DeployRequest;
import nl.uva.sne.drip.data.v1.external.DeployResponse;
import nl.uva.sne.drip.drip.commons.data.v1.external.DeployRequest;
import nl.uva.sne.drip.drip.commons.data.v1.external.DeployResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
......@@ -56,14 +58,19 @@ public class DeployController {
@RolesAllowed({UserService.USER, UserService.ADMIN})
public @ResponseBody
String deploy(@RequestBody DeployRequest deployRequest) {
if (deployRequest.getManagerType() == null) {
throw new BadRequestException("Must provide manager type. Aveliable: ansible, swarm ,kubernetes");
try {
if (deployRequest.getManagerType() == null) {
throw new BadRequestException("Must provide manager type. Aveliable: ansible, swarm ,kubernetes");
}
if (deployRequest.getProvisionID() == null) {
throw new BadRequestException("Must provide provision ID");
}
DeployResponse deploy = deployService.deploySoftware(deployRequest);
return deploy.getId();
} catch (Exception ex) {
Logger.getLogger(DeployController.class.getName()).log(Level.SEVERE, null, ex);
}
if (deployRequest.getProvisionID() == null) {
throw new BadRequestException("Must provide provision ID");
}
DeployResponse deploy = deployService.deploySoftware(deployRequest);
return deploy.getId();
return null;
}
@RequestMapping(value = "/sample", method = RequestMethod.GET)
......
......@@ -17,7 +17,7 @@ package nl.uva.sne.drip.api.v1.rest;
import com.webcohesion.enunciate.metadata.rs.ResponseCode;
import com.webcohesion.enunciate.metadata.rs.StatusCodes;
import nl.uva.sne.drip.data.v1.external.Key;
import nl.uva.sne.drip.drip.commons.data.v1.external.Key;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -36,7 +36,7 @@ import nl.uva.sne.drip.api.exception.NotFoundException;
import nl.uva.sne.drip.api.exception.NullKeyException;
import nl.uva.sne.drip.api.service.KeyPairService;
import nl.uva.sne.drip.api.service.UserService;
import nl.uva.sne.drip.data.v1.external.KeyPair;
import nl.uva.sne.drip.drip.commons.data.v1.external.KeyPair;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
......@@ -136,7 +136,7 @@ public class KeyPairController {
@RequestMapping(value = "/sample", method = RequestMethod.GET)
@RolesAllowed({UserService.USER, UserService.ADMIN})
public @ResponseBody
KeyPair geta() {
KeyPair geta() throws Exception {
try {
KeyPair pair = new KeyPair();
pair.setTimestamp(System.currentTimeMillis());
......
......@@ -19,7 +19,9 @@ import com.webcohesion.enunciate.metadata.rs.ResponseCode;
import com.webcohesion.enunciate.metadata.rs.StatusCodes;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
import java.util.logging.Logger;
......@@ -34,8 +36,9 @@ import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import nl.uva.sne.drip.api.service.PlannerService;
import nl.uva.sne.drip.api.service.UserService;
import nl.uva.sne.drip.data.v1.external.PlanResponse;
import nl.uva.sne.drip.drip.commons.data.v1.external.PlanResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
/**
......@@ -51,7 +54,7 @@ import org.springframework.web.bind.annotation.RequestParam;
@ResponseCode(code = 401, condition = "Bad credentials")
})
public class PlannerController {
@Autowired
private PlannerService plannerService;
......@@ -67,7 +70,7 @@ public class PlannerController {
String plan(@PathVariable("tosca_id") String toscaId) {
try {
PlanResponse plan = plannerService.getPlan(toscaId);
PlanResponse plan = plannerService.getPlan(toscaId, "swarm");
if (plan == null) {
throw new NotFoundException("Could not make plan");
}
......@@ -145,9 +148,39 @@ public class PlannerController {
List<PlanResponse> all = plannerService.findAll();
List<String> ids = new ArrayList<>();
for (PlanResponse tr : all) {
ids.add(tr.getId());
if (tr.getLevel() == 0) {
ids.add(tr.getId());
}
}
return ids;
}
@RequestMapping(value = "/post/{name}", method = RequestMethod.POST)
@RolesAllowed({UserService.USER, UserService.ADMIN})
public @ResponseBody
String postTop(@RequestBody String toscaContents, @PathVariable("name") String name) {
return plannerService.saveStringContents(toscaContents, 0, name);
}
@RequestMapping(value = "/post/{level}/{name}/{id}", method = RequestMethod.POST)
@RolesAllowed({UserService.USER, UserService.ADMIN})
public @ResponseBody
String postLow(@RequestBody String toscaContents, @PathVariable("level") String level, @PathVariable("name") String name, @PathVariable("id") String id) {
int intLevel = Integer.valueOf(level);
if (intLevel == 0) {
return plannerService.saveStringContents(toscaContents, 0, name);
}
PlanResponse topPlan = plannerService.findOne(id);
Set<String> lowIDs = topPlan.getLoweLevelPlanIDs();
if (lowIDs == null) {
lowIDs = new HashSet<>();
}
String lowPlanID = plannerService.saveStringContents(toscaContents, intLevel, name);
lowIDs.add(lowPlanID);
topPlan.setLoweLevelPlansIDs(lowIDs);
topPlan = plannerService.save(topPlan);
return topPlan.getId();
}
}
......@@ -17,7 +17,7 @@ package nl.uva.sne.drip.api.v1.rest;
import com.webcohesion.enunciate.metadata.rs.ResponseCode;
import com.webcohesion.enunciate.metadata.rs.StatusCodes;
import nl.uva.sne.drip.data.v1.external.ProvisionRequest;
import nl.uva.sne.drip.drip.commons.data.v1.external.ProvisionRequest;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
......@@ -35,7 +35,7 @@ import org.springframework.web.bind.annotation.RestController;
import nl.uva.sne.drip.api.exception.NotFoundException;
import nl.uva.sne.drip.api.service.ProvisionService;
import nl.uva.sne.drip.api.service.UserService;
import nl.uva.sne.drip.data.v1.external.ProvisionResponse;
import nl.uva.sne.drip.drip.commons.data.v1.external.ProvisionResponse;
import org.json.JSONException;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
......@@ -72,6 +72,10 @@ public class ProvisionController {
@RolesAllowed({UserService.USER, UserService.ADMIN})
public @ResponseBody
ProvisionResponse get(@PathVariable("id") String id) {
ProvisionResponse pro = provisionService.findOne(id);
if (pro == null) {
throw new NotFoundException();
}
return provisionService.findOne(id);
}
......@@ -85,10 +89,15 @@ public class ProvisionController {
@RolesAllowed({UserService.USER, UserService.ADMIN})
public @ResponseBody
String delete(@PathVariable("id") String id) {
ProvisionRequest provPlan = provisionService.findOne(id);
ProvisionResponse provPlan = provisionService.findOne(id);
if (provPlan != null) {
provisionService.delete(id);
return "Deleted : " + id;
try {
provisionService.deleteProvisionedResources(provPlan);
ProvisionResponse provisionInfo = provisionService.delete(id);
return "Deleted : " + id;
} catch (IOException | TimeoutException | InterruptedException | JSONException ex) {
Logger.getLogger(ProvisionController.class.getName()).log(Level.SEVERE, null, ex);
}
}
throw new NotFoundException();
}
......@@ -99,7 +108,6 @@ public class ProvisionController {
String deleteAll() {
provisionService.deleteAll();
return "Done";
}
/**
......@@ -137,12 +145,14 @@ public class ProvisionController {
throw new BadRequestException();
}
try {
req = provisionService.provisionResources(req);
req = provisionService.provisionResources(req, 1);
return req.getId();
} catch (IOException | TimeoutException | JSONException | InterruptedException ex) {
Logger.getLogger(ProvisionController.class.getName()).log(Level.SEVERE, null, ex);
} catch (Exception ex) {
Logger.getLogger(ProvisionController.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
......@@ -158,7 +168,7 @@ public class ProvisionController {
req.setCloudCredentialsIDs(cloudCredentialsIDs);
List<String> keyPairIDs = new ArrayList<>();
keyPairIDs.add("58f8da042af45d6621813c4e");
req.setKeyPairIDs(keyPairIDs);
req.setUserKeyPairIDs(keyPairIDs);
req.setPlanID("58da51f7f7b42e7d967752a1");
return req;
}
......
......@@ -32,7 +32,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import nl.uva.sne.drip.api.exception.NotFoundException;
import nl.uva.sne.drip.data.v1.external.Script;
import nl.uva.sne.drip.drip.commons.data.v1.external.Script;
import org.springframework.web.bind.annotation.PathVariable;
import nl.uva.sne.drip.api.service.ScriptService;
import nl.uva.sne.drip.api.service.UserService;
......
......@@ -17,7 +17,7 @@ package nl.uva.sne.drip.api.v1.rest;
import com.webcohesion.enunciate.metadata.rs.ResponseCode;
import com.webcohesion.enunciate.metadata.rs.StatusCodes;
import nl.uva.sne.drip.data.v1.external.ToscaRepresentation;
import nl.uva.sne.drip.drip.commons.data.v1.external.ToscaRepresentation;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
......
......@@ -26,7 +26,7 @@ import nl.uva.sne.drip.api.exception.PasswordNullException;
import nl.uva.sne.drip.api.exception.UserExistsException;
import nl.uva.sne.drip.api.exception.UserNotFoundException;
import nl.uva.sne.drip.api.exception.UserNullException;
import nl.uva.sne.drip.data.v1.external.User;
import nl.uva.sne.drip.drip.commons.data.v1.external.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
......
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>nl.uva.sne.drip</groupId>
<artifactId>drip</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>drip-commons</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.8.6</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>1.8.0.RELEASE</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-rest-core</artifactId>
<version>2.5.6.RELEASE</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>com.webcohesion.enunciate</groupId>
<artifactId>enunciate-core-annotations</artifactId>
<version>2.8.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.17</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>4.2.1.RELEASE</version>
<type>jar</type>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project>
\ No newline at end of file
......@@ -26,17 +26,18 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import nl.uva.sne.drip.data.v0.external.Attribute;
import nl.uva.sne.drip.data.v1.external.CloudCredentials;
import nl.uva.sne.drip.data.internal.Message;
import nl.uva.sne.drip.data.internal.MessageParameter;
import nl.uva.sne.drip.data.v1.external.PlanResponse;
import nl.uva.sne.drip.drip.commons.data.v1.external.CloudCredentials;
import org.apache.commons.io.FilenameUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.yaml.snakeyaml.Yaml;
import nl.uva.sne.drip.drip.commons.data.internal.Message;
import nl.uva.sne.drip.drip.commons.data.internal.MessageParameter;
import nl.uva.sne.drip.drip.commons.data.v0.external.Attribute;
import nl.uva.sne.drip.drip.commons.data.v1.external.PlanResponse;
/**
*
* @author S. Koulouzis
......@@ -61,7 +62,7 @@ public class Converter {
return (Map<String, Object>) object;
}
public static Map<String, Object> ymlString2Map(InputStream in) {
public static Map<String, Object> ymlStream2Map(InputStream in) {
Yaml yaml = new Yaml();
Map<String, Object> map = (Map<String, Object>) yaml.load(in);
return map;
......
......@@ -20,9 +20,10 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.TimeoutException;
import nl.uva.sne.drip.data.internal.Message;
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;
/**
*
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.data.internal;
package nl.uva.sne.drip.drip.commons.data.internal;
import java.io.Serializable;
import java.util.List;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.data.internal;
package nl.uva.sne.drip.drip.commons.data.internal;
import java.io.Serializable;
import java.util.Map;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.data.v0.external;
package nl.uva.sne.drip.drip.commons.data.v0.external;
import com.webcohesion.enunciate.metadata.DocumentationExample;
import javax.xml.bind.annotation.XmlAttribute;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.data.v0.external;
package nl.uva.sne.drip.drip.commons.data.v0.external;
import com.webcohesion.enunciate.metadata.DocumentationExample;
import javax.xml.bind.annotation.XmlRootElement;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.data.v0.external;
package nl.uva.sne.drip.drip.commons.data.v0.external;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.data.v0.external;
package nl.uva.sne.drip.drip.commons.data.v0.external;
import com.webcohesion.enunciate.metadata.DocumentationExample;
import java.util.List;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.data.v0.external;
package nl.uva.sne.drip.drip.commons.data.v0.external;
import javax.xml.bind.annotation.XmlRootElement;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.data.v0.external;
package nl.uva.sne.drip.drip.commons.data.v0.external;
import com.webcohesion.enunciate.metadata.DocumentationExample;
import javax.xml.bind.annotation.XmlRootElement;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.data.v0.external;
package nl.uva.sne.drip.drip.commons.data.v0.external;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlValue;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.data.v0.external;
package nl.uva.sne.drip.drip.commons.data.v0.external;
import com.webcohesion.enunciate.metadata.DocumentationExample;
import java.io.Serializable;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.data.v0.external;
package nl.uva.sne.drip.drip.commons.data.v0.external;
import com.webcohesion.enunciate.metadata.DocumentationExample;
import javax.xml.bind.annotation.XmlRootElement;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.data.v0.external;
package nl.uva.sne.drip.drip.commons.data.v0.external;
import com.webcohesion.enunciate.metadata.DocumentationExample;
import java.util.List;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.data.v0.external;
package nl.uva.sne.drip.drip.commons.data.v0.external;
import java.util.List;
import javax.xml.bind.annotation.XmlRootElement;
......
......@@ -13,10 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.data.v1.external;
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;
/**
......@@ -26,19 +28,23 @@ import org.springframework.data.mongodb.core.mapping.Document;
* @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.
*
......@@ -71,7 +77,7 @@ public class CloudCredentials extends OwnedObject {
}
/**
* The access key ID for a cloud provider.
* The access key ID / user name for a cloud provider.
*
* @return the accessKeyId
*/
......@@ -103,4 +109,32 @@ public class CloudCredentials extends OwnedObject {
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;
}
}
......@@ -13,8 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.data.v1.external;
package nl.uva.sne.drip.drip.commons.data.v1.external;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.webcohesion.enunciate.metadata.DocumentationExample;
/**
......@@ -25,31 +26,32 @@ import com.webcohesion.enunciate.metadata.DocumentationExample;
*
* @author S. Koulouzis
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DeployParameter {
private String cloudCertificateName;
// private String cloudCertificateName;
private String IP;
private String user;
private String role;
/**
* The file name of the certificate used to log in as root to the
* provisioned VM.
* @return the cloudCertificateName
*/
@DocumentationExample("Virginia")
public String getCloudCertificateName() {
return cloudCertificateName;
}
/**
* @param cloudCertificateName the cloudCertificateName to set
*/
public void setCloudCertificateName(String cloudCertificateName) {
this.cloudCertificateName = cloudCertificateName;
}
// /**
// * The file name of the certificate used to log in as root to the
// * provisioned VM.
// * @return the cloudCertificateName
// */
// @DocumentationExample("Virginia")
// public String getCloudCertificateName() {
// return cloudCertificateName;
// }
//
// /**
// * @param cloudCertificateName the cloudCertificateName to set
// */
// public void setCloudCertificateName(String cloudCertificateName) {
// this.cloudCertificateName = cloudCertificateName;
// }
/**
* The public IP of the provisioned VM
......
......@@ -13,8 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.data.v1.external;
package nl.uva.sne.drip.drip.commons.data.v1.external;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.webcohesion.enunciate.metadata.DocumentationExample;
/**
......@@ -23,6 +24,7 @@ import com.webcohesion.enunciate.metadata.DocumentationExample;
*
* @author S. Koulouzis
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DeployRequest extends OwnedObject {
private String provisionID;
......
......@@ -13,8 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.data.v1.external;
package nl.uva.sne.drip.drip.commons.data.v1.external;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.List;
import nl.uva.sne.drip.data.v1.external.ansible.AnsibleOutput;
import org.springframework.data.mongodb.core.mapping.Document;
......@@ -27,6 +28,7 @@ import org.springframework.data.mongodb.core.mapping.Document;
* @author S. Koulouzis
*/
@Document
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DeployResponse extends DeployRequest {
private KeyPair key;
......
......@@ -13,8 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.data.v1.external;
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;
......@@ -25,6 +26,7 @@ import java.util.Map;
*
* @author S. Koulouzis
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Key{
private Map<String, String> attributes;
......
......@@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.data.v1.external;
package nl.uva.sne.drip.drip.commons.data.v1.external;
import com.fasterxml.jackson.annotation.JsonInclude;
import nl.uva.sne.drip.api.exception.KeyException;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
/**
......@@ -31,6 +31,8 @@ public class KeyPair extends OwnedObject {
private Key privateKey;
private Key publicKey;
@Indexed
private String keyPairId;
/**
* @return the privateKey
......@@ -41,11 +43,11 @@ public class KeyPair extends OwnedObject {
/**
* @param privateKey the privateKey to set
* @throws nl.uva.sne.drip.api.exception.KeyException
* @throws java.lang.Exception
*/
public void setPrivateKey(Key privateKey) throws KeyException {
public void setPrivateKey(Key privateKey) throws Exception {
if (privateKey != null && privateKey.getType() != Key.KeyType.PRIVATE) {
throw new KeyException("Trying to add public key to private");
throw new Exception("Trying to add public key to private");
}
this.privateKey = privateKey;
}
......@@ -59,13 +61,27 @@ public class KeyPair extends OwnedObject {
/**
* @param publicKey the publicKey to set
* @throws nl.uva.sne.drip.api.exception.KeyException
* @throws java.lang.Exception
*/
public void setPublicKey(Key publicKey) throws KeyException {
public void setPublicKey(Key publicKey) throws Exception {
if (publicKey != null && publicKey.getType() != Key.KeyType.PUBLIC) {
throw new KeyException("Trying to add private to 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;
}
}
......@@ -13,8 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.data.v1.external;
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;
......@@ -26,6 +27,7 @@ import org.springframework.data.mongodb.core.mapping.Document;
* @author S. Koulouzis
*/
@Document
@JsonInclude(JsonInclude.Include.NON_NULL)
public class KeyValueHolder extends OwnedObject{
private Map<String, Object> keyValue;
......
......@@ -13,8 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.data.v1.external;
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;
......@@ -27,6 +28,7 @@ import org.springframework.data.annotation.Id;
* @author S. Koulouzis
*/
@MappedSuperclass
@JsonInclude(JsonInclude.Include.NON_NULL)
public class OwnedObject {
@Id
......
......@@ -13,8 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.data.v1.external;
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;
......@@ -26,6 +27,7 @@ import org.springframework.data.mongodb.core.mapping.Document;
* @author S. Koulouzis
*/
@Document
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PlanResponse extends KeyValueHolder {
private String toscaID;
......
......@@ -13,8 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.data.v1.external;
package nl.uva.sne.drip.drip.commons.data.v1.external;
import com.fasterxml.jackson.annotation.JsonInclude;
import org.springframework.data.mongodb.core.mapping.Document;
/**
......@@ -23,5 +24,6 @@ import org.springframework.data.mongodb.core.mapping.Document;
* @author S. Koulouzis
*/
@Document
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PlaybookRepresentation extends KeyValueHolder {
}
......@@ -13,8 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.data.v1.external;
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;
......@@ -26,13 +27,16 @@ import org.springframework.data.mongodb.core.mapping.Document;
* @author S. Koulouzis
*/
@Document
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ProvisionRequest extends KeyValueHolder {
private List<String> cloudCredentialsIDs;
private String planID;
private List<String> keyPairIDs;
private List<String> userKeyPairIDs;
private List<String> deployerKeyPairIDs;
/**
* The cloud credentials ids required to provision the cloud resources.
......@@ -70,18 +74,33 @@ public class ProvisionRequest extends KeyValueHolder {
/**
* The key pair id for the keys to use to log in the provisioned VMs.
* @return the keyPairIDs
*
* @return the userKeyPairIDs
*/
@DocumentationExample("ASedsfd46b4fFd344a1A")
public List<String> getUserKeyPairIDs() {
return userKeyPairIDs;
}
/**
* @param userKeyID the userKeyPairIDs to set
*/
@DocumentationExample("ASedsfd46b4fFd344a1A")
public List<String> getKeyPairIDs() {
return keyPairIDs;
public void setUserKeyPairIDs(List<String> userKeyID) {
this.userKeyPairIDs = userKeyID;
}
/**
* @param userKeyID the keyPairIDs to set
* @return the deployerKeyPairIDs
*/
public void setKeyPairIDs(List<String> userKeyID) {
this.keyPairIDs = userKeyID;
public List<String> getDeployerKeyPairIDs() {
return deployerKeyPairIDs;
}
/**
* @param deployerKeyPairIDs the deployerKeyPairIDs to set
*/
public void setDeployerKeyPairIDs(List<String> deployerKeyPairIDs) {
this.deployerKeyPairIDs = deployerKeyPairIDs;
}
}
......@@ -13,8 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.data.v1.external;
package nl.uva.sne.drip.drip.commons.data.v1.external;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.ArrayList;
import java.util.List;
/**
......@@ -22,9 +24,11 @@ import java.util.List;
*
* @author S. Koulouzis
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ProvisionResponse extends ProvisionRequest {
private List<DeployParameter> deployParameters;
private ArrayList<String> cloudKeyPairIDs;
/**
* The deploy parameters.
......@@ -42,4 +46,15 @@ public class ProvisionResponse extends ProvisionRequest {
this.deployParameters = deployParameters;
}
public void setCloudKeyPairIDs(ArrayList<String> cloudKeyPairIDs) {
this.cloudKeyPairIDs = cloudKeyPairIDs;
}
/**
* @return the cloudKeyPairIDs
*/
public ArrayList<String> getCloudKeyPairIDs() {
return cloudKeyPairIDs;
}
}
......@@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.data.v1.external;
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.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
/**
......@@ -25,6 +25,7 @@ import org.springframework.data.mongodb.core.mapping.Document;
* @author S. Koulouzis
*/
@Document
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Script extends OwnedObject {
private String contents;
......
......@@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.data.v1.external;
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.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
/**
......@@ -25,6 +25,7 @@ import org.springframework.data.mongodb.core.mapping.Document;
* @author S. Koulouzis
*/
@Document
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ToscaRepresentation extends KeyValueHolder {
private String name;
......
......@@ -13,9 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.data.v1.external;
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;
......@@ -34,6 +35,7 @@ import org.springframework.security.core.userdetails.UserDetails;
* @author S. Koulouzis
*/
@Document
@JsonInclude(JsonInclude.Include.NON_NULL)
public class User implements UserDetails {
@Id
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.data.v1.external.ansible;
package nl.uva.sne.drip.drip.commons.data.v1.external.ansible;
/**
*
......@@ -22,7 +22,7 @@ package nl.uva.sne.drip.data.v1.external.ansible;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import nl.uva.sne.drip.data.v1.external.OwnedObject;
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;
......@@ -52,6 +52,10 @@ public class AnsibleOutput extends OwnedObject {
@JsonProperty("provisionID")
private String provisionID;
@Indexed
@JsonProperty("cloudProvider")
private String cloudProvider;
@JsonProperty("host")
public String getHost() {
return host;
......@@ -101,4 +105,22 @@ public class AnsibleOutput extends OwnedObject {
public String getProvisionID() {
return provisionID;
}
public void setCloudProviderName(String cloudProvider) {
this.setCloudProvider(cloudProvider);
}
/**
* @return the cloudProvider
*/
public String getCloudProvider() {
return cloudProvider;
}
/**
* @param cloudProvider the cloudProvider to set
*/
public void setCloudProvider(String cloudProvider) {
this.cloudProvider = cloudProvider;
}
}
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.data.v1.external.ansible;
package nl.uva.sne.drip.drip.commons.data.v1.external.ansible;
/**
*
......
/*
/*
* Copyright 2017 S. Koulouzis, Wang Junchao, Huan Zhou, Yang Hu
*
* Licensed under the Apache License, Version 2.0 (the "License");
......@@ -13,12 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.data.v1.external.ansible;
package nl.uva.sne.drip.drip.commons.data.v1.external.ansible;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Date;
import nl.uva.sne.drip.data.v1.external.OwnedObject;
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;
......@@ -33,8 +33,8 @@ public class BenchmarkResult extends OwnedObject {
private String host;
@Indexed
private String cloudDeploymentDomain;
@Indexed
@Indexed
@JsonProperty("vmType")
private String vmType;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.data.v1.external.ansible;
package nl.uva.sne.drip.drip.commons.data.v1.external.ansible;
/**
*
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.data.v1.external.ansible;
package nl.uva.sne.drip.drip.commons.data.v1.external.ansible;
/**
*
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.data.v1.external.ansible;
package nl.uva.sne.drip.drip.commons.data.v1.external.ansible;
import org.springframework.data.mongodb.core.mapping.Document;
......
-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQDAI5hMEdqCIf12SDh9N9hOTOX+yhTAxvF8YKwz9rD3N3F49e/e
aG6IzsixYPNrf8Aos0ANFnJDQK3wsC1PrfNLrEMz6/Kalj/D4GotCaVCFZBxvwjn
OotwYSyJF6bqnv5bun37xY9nrMcr1JmrxRtkhB4QDbW1vu0uzeezkbM1TQIDAQAB
AoGARlzCqRjgrEdGSsqn5TNOQ15l26ilcPNp++JrLZxpsh7brzBhZ1FXKUKQvGSE
wBlIhZ8fFavirD5DdKEP9t38+lZ0gE1Ky4Xz77J92RctIgSgReZ8niZGjDTiuS9o
QBEyfPcJXekVlEGDvyH4BkRocarGnaJfNBqu1+LSL+tDmQECQQDvK4py989ts1nt
O+fV2XH7sb1MeYVlWw8SgfUaHTQLCONpUSo+PIfdbCwYbxGTObWZmZs1Z/naVNU7
0FI8mronAkEAzajTx14yvr2tH8A8yTvXwyWXBU56uCAj6n8UI2kfGIoj5/oT5EzC
NX/bJsG5orS7roZqKvCmy6V2vKaKUdDBawJBAN5gJoeFABmoo9lfVMzSNBfpB/A+
IRi/VMFJkiJousXzyrZWoCdj0pO/CzTguH+iLcaWOuiqN3aYX/cQWBY/awsCQD8H
L6hZKSolzUn+y2JM0co/2fHJZHjLeNZkDdLwY5RMucZdcP01vQtSXOKa2n6P7zkE
fsMcL7IXyrT0QU3jsXMCQA5bQiZ7W4SlE5r1Odz8we+3r/6BbUeAT3WIY/bwAcWn
yEYfOy9GXmX97kTX92m1RjKylNv1B41RoEGGz3yuUtk=
-----END RSA PRIVATE KEY-----
-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQCrID6iv0ObjfT0EKTN/3YgWZUMGNo/IETu2nzRnKLU8W5YKp9N
9Zwl+rhHjyE+GOadx+brzThcGKawXkgNxu0KO7E+pKpnB3cuFdtfIqW9jFLrNopM
WuX7tquZPc8l49JPe+2Z5z6WitJ9XJWgpDqdE8Jba9B3o0GuwqYE36I0HwIDAQAB
AoGAFFE2vpHg0AYxsAyN1JthBgQ8yvvkZZxKMuWj7isfthKYHEWrNlFT4bp7yJs4
wiuordD/HL331A9lMwlumpwkpmEfpTJcN5ndw5wwt0XReXdp0Icu4/t7FufalcVb
eGEJQOMAPkfgGU6AciyHMKjzTa5ZWQhU4YpZ2JSlVmZNUUECQQDzHHrP3go77IRq
gSI8ytCOnm3tBL+Wo5yQfJv2PlQdD/v5TWIZTQoqgBsgpQZ70ylRiF/y9rAqebNx
8bTQGIf/AkEAtDLGufAPm36ja3LdgFUCvfeb0a8IOwc8ih6eAEuBpYqgwKwV+ota
WPXP3Cdw/patP2Ev9YwKBa6Vqz/oogVT4QJAU+2UFGkCPXfEqwQTrssRvvrA1l+a
SMYJCfSK3zLbVQEsqv9lC3kGNm/tbZKrL1pR3FzpSvaREMjdA0w/cMvXPwJBAIez
CTZy0r4NUvGSkb2XxzXZpmz0e6VAINX+kou0UNCiIcaWkQKZOJNvoXWv+gau346w
GJa4O7/lpm5M9Vo12uECQDJbvjums0EE0xPRe37uAqmYr9Aborex7RBO+kIs0eNE
RDbzuUMMs7pJbUeQ5bFaDMZKwoSIEJMWuJMSsZ1Jd1s=
-----END RSA PRIVATE KEY-----
......@@ -74,16 +74,17 @@ def execute_playbook(hosts, playbook_path,user,ssh_key_file,extra_vars,passwords
print '[ERROR] The playbook does not exist'
return '[ERROR] The playbook does not exist'
os.environ['ANSIBLE_HOST_KEY_CHECKING'] = 'False'
os.environ['ANSIBLE_HOST_KEY_CHECKING'] = 'false'
ansible.constants.HOST_KEY_CHECKING = False
variable_manager = VariableManager()
loader = DataLoader()
inventory = Inventory(loader=loader, variable_manager=variable_manager, host_list=hosts)
Options = namedtuple('Options', ['listtags', 'listtasks', 'listhosts', 'syntax', 'connection','module_path', 'forks', 'remote_user', 'private_key_file', 'ssh_common_args', 'ssh_extra_args', 'sftp_extra_args', 'scp_extra_args', 'become', 'become_method', 'become_user', 'verbosity', 'check'])
Options = namedtuple('Options', ['listtags', 'listtasks', 'listhosts', 'syntax', 'connection','module_path', 'forks', 'remote_user', 'private_key_file', 'ssh_common_args', 'ssh_extra_args', 'sftp_extra_args', 'scp_extra_args', 'become', 'become_method', 'become_user', 'verbosity', 'check','host_key_checking'])
options = Options(listtags=False, listtasks=False, listhosts=False, syntax=False, connection='smart', module_path=None, forks=None, remote_user=user, private_key_file=ssh_key_file, ssh_common_args=None, ssh_extra_args=None, sftp_extra_args=None, scp_extra_args=None, become=True, become_method='sudo', become_user='root', verbosity=None, check=False )
options = Options(listtags=False, listtasks=False, listhosts=False, syntax=False, connection='smart', module_path=None, forks=None, remote_user=user, private_key_file=ssh_key_file, ssh_common_args=None, ssh_extra_args=None, sftp_extra_args=None, scp_extra_args=None, become=True, become_method='sudo', become_user='root', verbosity=None, check=False , host_key_checking=False)
variable_manager.extra_vars = extra_vars
......
......@@ -105,11 +105,7 @@ def on_request(ch, method, props, body):
res_name = "ansible_output"
else:
res_name = "credential"
print manager_type
print res_name
response = {}
outcontent = {}
current_milli_time = lambda: int(round(time.time() * 1000))
......
CESNET&&https://carach5.ics.muni.cz:11443&&ubuntu 14.04&&medium&&http://fedcloud.egi.eu/occi/compute/flavour/1.0#medium&&http://occi.carach5.ics.muni.cz/occi/infrastructure/os_tpl#uuid_egi_ubuntu_server_14_04_lts_fedcloud_warg_131&&ubuntu
CESNET&&https://carach5.ics.muni.cz:11443&&ubuntu 14.04&&extra_large&&http://schemas.fedcloud.egi.eu/occi/infrastructure/resource_tpl#extra_large&& http://occi.carach5.ics.muni.cz/occi/infrastructure/os_tpl#uuid_egi_ubuntu_server_14_04_lts_fedcloud_warg_131&&ubuntu
\ No newline at end of file
Ubuntu 14.04&&Virginia&&ami-2d39803a
Ubuntu 14.04&&California&&ami-48db9d28
Ubuntu 16.04&&Virginia&&ami-40d28157
Ubuntu 16.04&&California&&ami-6e165d0e
Ubuntu 16.04&&Ohio&&ami-fcc19b99
Ubuntu 14.04&&Ohio&&ami-41d48e24
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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