Unverified Commit 49776fb6 authored by skoulouzis's avatar skoulouzis Committed by GitHub

Merge pull request #139 from skoulouzis/DRIP_2.0

Drip 2.0
parents f73d43d5 02c5d3a9
......@@ -2,105 +2,94 @@ version: '3'
services:
graphite:
restart: always
image: vladwing/graphite
volumes:
- graphite_data:/opt/graphite/storage
environment:
- VIRTUAL_HOST=graphite.beia.switch
networks:
- web
- graphite
deploy:
labels:
- "traefik.backend=graphite"
- "traefik.frontend.rule=Host:graphite.beia.switch"
- "traefik.port=80"
grafana:
restart: always
image: grafana/grafana
environment:
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD:-secret}
- VIRTUAL_HOST=grafana.beia.switch
volumes:
- grafana_data:/var/lib/grafana
depends_on:
- graphite
networks:
- web
#monitoring_server:
#image: salmant/ul_monitoring_server_container_image
#ports:
#- "8080:8080"
#- "4242:4242"
#- "4245:4245"
#- "7199:7199"
#- "7000:7000"
#- "7001:7001"
#- "9160:9160"
#- "9042:9042"
#- "8012:8012"
#- "61621:61621"
#environment:
#- MONITORING_SERVER=monitoring_server
#- VIRTUAL_HOST=jcatascopia.beia.switch
#- VIRTUAL_PORT=8080
#networks:
#- asap
#- web
deploy:
labels:
- "traefik.backend=grafana"
- "traefik.frontend.rule=Host:grafana.beia.switch"
- "traefik.port=3000"
monitoring_server:
image: salmant/ul_monitoring_server_container_image
environment:
- MONITORING_SERVER=monitoring_server
networks:
- web
deploy:
labels:
- "traefik.backend=monitoring_server"
- "traefik.frontend.rule=Host:jcatascopia.beia.switch"
- "traefik.port=8080"
monitoring_adapter:
restart: always
image: beia/monitoring_adapter
environment:
- GRAPHITE_SERVER=graphite
- MONITORING_PREFIX=eu.beia.switch
- MONITORING_SERVER=${MONITORING_SERVER:-194.249.1.175}
- MONITORING_SERVER=monitoring_server
- LOGGING_LEVEL=${LOGGING_LEVEL:-info}
depends_on:
- graphite
#- monitoring_server
- monitoring_server
networks:
- graphite
- data
- asap
- web
data_collector:
image: beia/data_collector
environment:
# - CONFIG=config
- STATSD_HOST=monitoring_adapter
depends_on:
# - config
- monitoring_adapter
networks:
# - config
- data
- web
alerter:
image: beia/alerter
environment:
# - CONFIG=config
- STATSD_HOST=monitoring_adapter
- VIRTUAL_HOST=alerter.beia.switch
- NOTIFICATION_SERVICE=notify
depends_on:
- notify
# - config
networks:
# - config
- web
- data
# config:
# image: beia/config_manager
# environment:
# - TOSCA_URL=${TOSCA_URL:-http://www.google.com}
# networks:
# - config
deploy:
labels:
- "traefik.backend=alerter"
- "traefik.frontend.rule=Host:alerter.beia.switch"
- "traefik.port=80"
web:
image: jwilder/nginx-proxy
image: traefik
command: --web --docker.swarmmode --docker.watch --logLevel=INFO
ports:
- "80:80/tcp"
- "80:80"
- "8081:8080"
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- /var/run/docker.sock:/var/run/docker.sock
deploy:
placement:
constraints: [node.role == manager]
networks:
- web
notify_asterisk:
# TODO: Add shared storage/volume for sounds
restart: always
image: dorinelfilip/ast13
image: beia/asterisk
environment:
- SIP_USERNAME=55025
- SIP_HOST=sip.clickphone.ro
......@@ -110,20 +99,22 @@ services:
- SIP_PEERNAME=clickphone
- ARI_USERNAME=${ARI_USERNAME:-admin}
- ARI_SECRET=${ARI_SECRET:-changeme}
deploy:
labels:
- "traefik.docker.network=beia_web"
networks:
- notify_asterisk
- web
notify:
restart: always
image: dorinelfilip/notify
image: beia/notify
depends_on:
- notify_asterisk
- notify_redis
networks:
- notify_asterisk
- notify_redis
- notify
- asap
- web
# - data
# - sip
# - asap
environment:
- ARI_URL=${ARI_URL:-http://notify_asterisk:8088}
- ARI_USERNAME=${ARI_USERNAME:-admin}
......@@ -134,12 +125,15 @@ services:
- REDIS_PORT=${REDIS_PORT:-6379}
- REDIS_PASSWORD=${REDIS_PASSWORD:-changeme}
- DEFAULT_SIP=${DEFAULT_SIP:-${SIP_PEERNAME}}
ports:
- "8001:80/tcp"
deploy:
labels:
- "traefik.backend=notify"
- "traefik.frontend.rule=Host:notify.beia.switch"
- "traefik.port=80"
notify_redis:
restart: always
image: redis:alpine
networks:
- web
entrypoint:
- redis-server
- "--requirepass"
......@@ -147,20 +141,14 @@ services:
# of the container image is needed
- ${REDIS_PASSWORD:-changeme}
networks:
- notify_redis
- web
volumes:
- redis_data:/data
networks:
notify_redis:
notify_asterisk:
notify:
data:
web:
graphite:
asap:
volumes:
graphite_data:
grafana_data:
redis_data:
networks:
web:
......@@ -154,6 +154,11 @@
<artifactId>wadl-client-plugin</artifactId>
<version>1.1.6</version>
</dependency>
<!-- <dependency>
<groupId>net.bull.javamelody</groupId>
<artifactId>javamelody-core</artifactId>
<version>1.71.0</version>
</dependency> -->
</dependencies>
......@@ -208,7 +213,7 @@
</plugin>
<!-- <plugin>
<!-- <plugin>
<groupId>com.webcohesion.enunciate</groupId>
<artifactId>enunciate-maven-plugin</artifactId>
<version>2.9.1</version>
......
......@@ -61,6 +61,9 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
.authorizeRequests()
.antMatchers("/manager/*").hasRole("ADMIN")
.and()
.authorizeRequests()
.antMatchers("/monitoring/*").hasRole("ADMIN")
.and()
.formLogin()
.and()
.httpBasic()
......
......@@ -16,7 +16,7 @@
package nl.uva.sne.drip.api.dao;
import nl.uva.sne.drip.drip.commons.data.v1.external.DeployResponse;
import nl.uva.sne.drip.drip.commons.data.v1.external.ansible.AnsibleResult;
import nl.uva.sne.drip.drip.commons.data.v1.external.KeyValueHolder;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.mongodb.repository.Query;
......@@ -27,5 +27,5 @@ import org.springframework.data.mongodb.repository.Query;
public interface DeployDao extends MongoRepository<DeployResponse, String> {
@Query(value = "{'statusHistories':{$elemMatch:{'status':{$in:['PROCESSABLE']}}},'created' : { '$gt' : { '$date' : ':?0' } , '$lt' : { '$date' : ':?1'}}}", count = true)
public Iterable<AnsibleResult> findByCommand(String cmd);
public Iterable<KeyValueHolder> findByCommand(String cmd);
}
......@@ -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.drip.commons.data.v1.external.KeyValueHolder;
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;
......@@ -79,35 +79,4 @@ public class AnsibleOutputService {
ansibleOutputDao.deleteAll();
}
public List<String> findAllCommands() {
List<AnsibleOutput> all = findAll();
Set<String> hashset = new HashSet<>();
for (AnsibleOutput ans : all) {
AnsibleResult res = ans.getAnsibleResult();
if (res != null) {
List<String> commandList = res.getCmd();
if (commandList != null) {
hashset.add(commandList.get(0));
}
}
}
return new ArrayList<>(hashset);
}
public List<AnsibleOutput> findByCommand(String command) {
List<AnsibleOutput> all = findAll();
List<AnsibleOutput> filtered = new ArrayList<>();
for (AnsibleOutput ans : all) {
AnsibleResult res = ans.getAnsibleResult();
if (res != null) {
List<String> commandList = res.getCmd();
if (commandList != null && commandList.get(0).equals(command)) {
filtered.add(ans);
}
}
}
return filtered;
}
}
......@@ -54,11 +54,11 @@ import nl.uva.sne.drip.commons.utils.Converter;
import nl.uva.sne.drip.commons.utils.DRIPLogHandler;
import nl.uva.sne.drip.drip.commons.data.v1.external.ConfigurationRepresentation;
import nl.uva.sne.drip.drip.commons.data.v1.external.KeyPair;
import nl.uva.sne.drip.drip.commons.data.v1.external.KeyValueHolder;
import nl.uva.sne.drip.drip.commons.data.v1.external.PlanResponse;
import nl.uva.sne.drip.drip.commons.data.v1.external.ScaleRequest;
import nl.uva.sne.drip.drip.commons.data.v1.external.ToscaRepresentation;
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 nl.uva.sne.drip.drip.commons.data.v1.external.ansible.BenchmarkResult;
import nl.uva.sne.drip.drip.commons.data.v1.external.ansible.SysbenchCPUBenchmark;
import org.json.JSONArray;
......@@ -476,66 +476,63 @@ public class DeployService {
}
private BenchmarkResult parseSaveBenchmarkResult(AnsibleOutput ansOut) {
AnsibleResult res = ansOut.getAnsibleResult();
if (res != null) {
List<String> cmdList = res.getCmd();
if (cmdList != null) {
switch (cmdList.get(0)) {
case "sysbench":
String[] out = res.getStdout().split("\n");
String version = getSysbeanchVersion(out[0]);
int numOfThreads = getNumberOfThreads(out[3]);
Double executionTime = getExecutionTime(out[14]);
int totalNumberOfEvents = getTotalNumberOfEvents(out[15]);
double minExecutionTimePerRequest = getMinExecutionTimePerRequest(out[18]);
double avgExecutionTimePerRequest = getAvgExecutionTimePerRequest(out[19]);
double maxExecutionTimePerRequest = getMaxExecutionTimePerRequest(out[20]);
double approx95Percentile = getApprox95Percentile(out[21]);
double avgEventsPerThread = getAvgEventsPerThread(out[24]);
double stddevEventsPerThread = getStddevEventsPerThread(out[24]);
double avgExecTimePerThread = getAvgExecTimePerThread(out[25]);
double stddevExecTimePerThread = getStddevExecTimePerThread(out[25]);
SysbenchCPUBenchmark b = new SysbenchCPUBenchmark();
b.setSysbenchVersion(version);
b.setNumberOfThreads(numOfThreads);
b.setExecutionTime(executionTime * 1000);
b.setTotalNumberOfEvents(totalNumberOfEvents);
b.setAvgEventsPerThread(avgEventsPerThread);
b.setStddevEventsPerThread(stddevEventsPerThread);
b.setAvgExecTimePerThread(avgExecTimePerThread * 1000);
b.setStddevExecTimePerThread(stddevExecTimePerThread);
b.setApprox95Percentile(approx95Percentile);
b.setMinExecutionTimePerRequest(minExecutionTimePerRequest);
b.setAvgExecutionTimePerRequest(avgExecutionTimePerRequest);
b.setMaxExecutionTimePerRequest(maxExecutionTimePerRequest);
b.setAnsibleOutputID(ansOut.getId());
b.setCloudDeploymentDomain(ansOut.getCloudDeploymentDomain());
b.setDelta(ansOut.getAnsibleResult().getDelta());
b.setStart(ansOut.getAnsibleResult().getStart());
b.setEnd(ansOut.getAnsibleResult().getEnd());
b.setHost(ansOut.getHost());
b.setVmType(ansOut.getVmType());
b = (SysbenchCPUBenchmark) benchmarkResultService.save(b);
return b;
default:
return null;
}
}
}
// KeyValueHolder res = ansOut.getAnsibleResult();
// if (res != null) {
// List<String> cmdList = res.getCmd();
// if (cmdList != null) {
//
// switch (cmdList.get(0)) {
// case "sysbench":
// String[] out = res.getStdout().split("\n");
// String version = getSysbeanchVersion(out[0]);
// int numOfThreads = getNumberOfThreads(out[3]);
// Double executionTime = getExecutionTime(out[14]);
// int totalNumberOfEvents = getTotalNumberOfEvents(out[15]);
//
// double minExecutionTimePerRequest = getMinExecutionTimePerRequest(out[18]);
// double avgExecutionTimePerRequest = getAvgExecutionTimePerRequest(out[19]);
// double maxExecutionTimePerRequest = getMaxExecutionTimePerRequest(out[20]);
// double approx95Percentile = getApprox95Percentile(out[21]);
//
// double avgEventsPerThread = getAvgEventsPerThread(out[24]);
// double stddevEventsPerThread = getStddevEventsPerThread(out[24]);
//
// double avgExecTimePerThread = getAvgExecTimePerThread(out[25]);
// double stddevExecTimePerThread = getStddevExecTimePerThread(out[25]);
//
// SysbenchCPUBenchmark b = new SysbenchCPUBenchmark();
// b.setSysbenchVersion(version);
//
// b.setNumberOfThreads(numOfThreads);
// b.setExecutionTime(executionTime * 1000);
//
// b.setTotalNumberOfEvents(totalNumberOfEvents);
//
// b.setAvgEventsPerThread(avgEventsPerThread);
// b.setStddevEventsPerThread(stddevEventsPerThread);
//
// b.setAvgExecTimePerThread(avgExecTimePerThread * 1000);
// b.setStddevExecTimePerThread(stddevExecTimePerThread);
// b.setApprox95Percentile(approx95Percentile);
//
// b.setMinExecutionTimePerRequest(minExecutionTimePerRequest);
// b.setAvgExecutionTimePerRequest(avgExecutionTimePerRequest);
// b.setMaxExecutionTimePerRequest(maxExecutionTimePerRequest);
//
// b.setAnsibleOutputID(ansOut.getId());
//
// b.setCloudDeploymentDomain(ansOut.getCloudDeploymentDomain());
// b.setHost(ansOut.getHost());
// b.setVmType(ansOut.getVmType());
// b = (SysbenchCPUBenchmark) benchmarkResultService.save(b);
// return b;
//
// default:
// return null;
//
// }
// }
// }
return null;
}
......@@ -643,7 +640,6 @@ public class DeployService {
Map<String, Object> info = new HashMap();
for (MessageParameter param : params) {
String jsonResp = param.getValue().replaceAll("^\"|\"$", "");
System.err.println(jsonResp);
Map<String, Object> kv = Converter.jsonString2Map(jsonResp);
info.putAll(kv);
......
......@@ -292,7 +292,7 @@ public class PlannerService {
private String getBestDomain(String cloudProvider) {
switch (cloudProvider.trim().toLowerCase()) {
case "ec2":
return "Virginia";
return "Frankfurt";
case "egi":
return "CESNET";
}
......
......@@ -455,7 +455,6 @@ public class ProvisionService {
logger.info("Got provisioner response");
return parseCreateResourcesResponse(response.getParameters(), provisionRequest, null, true, true);
}
}
private ProvisionResponse callProvisioner1(ProvisionRequest provisionRequest) throws IOException, TimeoutException, JSONException, InterruptedException, Exception {
......@@ -830,8 +829,5 @@ public class ProvisionService {
}
private void parseDeleteResourcesResponse(List<MessageParameter> parameters, ProvisionResponse provisionInfo) {
// for (MessageParameter p : parameters) {
// System.err.println(p.getName() + " : " + p.getValue());
// }
}
}
......@@ -51,6 +51,7 @@ import org.springframework.web.bind.annotation.RequestBody;
@RestController
@RequestMapping("/user/v0.0/switch/account/configure")
@Component
@Deprecated
public class CloudConfigurationController0 {
@Autowired
......
......@@ -39,7 +39,7 @@ import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
/**
* This controller is responsible for deploying a cluster on provisoned
* This controller is responsible for deploying a cluster on provisioned
* resources.
*
* @author S. Koulouzis
......@@ -48,6 +48,7 @@ import org.springframework.web.bind.annotation.RequestBody;
@RequestMapping("/user/v0.0/switch/deploy")
@Component
@PreAuthorize("isAuthenticated()")
@Deprecated
public class DeployController0 {
@Autowired
......
......@@ -41,14 +41,15 @@ import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
/**
* This controller is responsible for planing the type of resources to be
* provisopned based on a TOSCA description.
* This controller is responsible for planning the type of resources to be
* provisioned based on a TOSCA description.
*
* @author S. Koulouzis
*/
@RestController
@RequestMapping("/user/v0.0/switch/plan")
@Component
@Deprecated
public class PlannerController0 {
@Autowired
......
......@@ -61,6 +61,7 @@ import org.springframework.web.bind.annotation.RequestBody;
@RequestMapping("/user/v0.0/switch/provision")
@Component
@PreAuthorize("isAuthenticated()")
@Deprecated
public class ProvisionController0 {
@Autowired
......
......@@ -43,6 +43,7 @@ import org.springframework.web.bind.annotation.RequestBody;
@RestController
@RequestMapping("/manager/v0.0/switch/account")
@Component
@Deprecated
public class UserController0 {
@Autowired
......
......@@ -48,6 +48,7 @@ import org.springframework.web.bind.annotation.RequestBody;
@RestController
@RequestMapping("/user/v0.0/switch/provision")
@Component
@Deprecated
public class UserPublicKeysController0 {
@Autowired
......
......@@ -33,13 +33,14 @@ import org.springframework.web.bind.annotation.ResponseBody;
/**
* This controller is responsible for handling user scripts. These user can be
* used by the provisoner to run on the created VMs.
* used by the provisioner to run on the created VMs.
*
* @author S. Koulouzis
*/
@RestController
@RequestMapping("/user/v0.0/switch/provision")
@Component
@Deprecated
public class UserScriptController0 {
@Autowired
......
......@@ -70,22 +70,6 @@ public class AnsibleOutputController {
return resp;
}
/**
* Query AnsibleOutput by executing command.
*
* @param command
* @return
*/
@RequestMapping(method = RequestMethod.GET, params = {"command"})
@RolesAllowed({UserService.USER, UserService.ADMIN})
@StatusCodes({
@ResponseCode(code = 200, condition = "Successful query")
})
public @ResponseBody
List<AnsibleOutput> getByCommand(@RequestParam(value = "command") String command) {
return ansibleOutputService.findByCommand(command);
}
/**
* Returns the ids of stored objects. Empty list if non stored
*
......@@ -106,20 +90,6 @@ public class AnsibleOutputController {
return ids;
}
/**
* Query for used (unique) commands
*
* @return
*/
@RequestMapping(value = "/commands", method = RequestMethod.GET)
@RolesAllowed({UserService.USER, UserService.ADMIN})
@StatusCodes({
@ResponseCode(code = 200, condition = "Successful query")
})
public @ResponseBody
List<String> getCommands() {
return ansibleOutputService.findAllCommands();
}
/**
* Deletes object
......
......@@ -45,7 +45,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
/**
* This controller is responsible for deploying a cluster on provisoned
* This controller is responsible for deploying a cluster on provisioned
* resources.
*
* @author S. Koulouzis
......
......@@ -35,7 +35,6 @@ 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.PlannerService;
import nl.uva.sne.drip.api.service.ToscaService;
import nl.uva.sne.drip.api.service.UserService;
import nl.uva.sne.drip.drip.commons.data.v1.external.PlanResponse;
import org.springframework.stereotype.Controller;
......@@ -43,8 +42,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
/**
* This controller is responsible for planing the type of resources to be
* provisopned based on a TOSCA description.
* This controller is responsible for planning the type of resources to be
* provisioned based on a TOSCA description.
*
* @author S. Koulouzis
*/
......@@ -54,6 +53,7 @@ import org.springframework.web.bind.annotation.RequestParam;
@StatusCodes({
@ResponseCode(code = 401, condition = "Bad credentials")
})
//@MonitoredWithSpring
public class PlannerController {
@Autowired
......
......@@ -56,8 +56,8 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandl
* @author S. Koulouzis
*/
@Controller
@RequestMapping("/user/v1.0/?wadl")
public class WADLController {
@RequestMapping("/")
public class RootController {
String xs_namespace = "http://www.w3.org/2001/XMLSchema";
@Autowired
......@@ -67,15 +67,15 @@ public class WADLController {
@RequestMapping(method = RequestMethod.GET,
// consumes = MediaType.APPLICATION_XML_VALUE,
produces = MediaType.APPLICATION_XML_VALUE)
public @ResponseBody
Application generateWadl(HttpServletRequest request) {
Application generateWadl(HttpServletRequest request, @RequestParam("wadl") String wadl) {
Enumeration headerNames = request.getHeaderNames();
while (headerNames.hasMoreElements()) {
String key = (String) headerNames.nextElement();
String value = request.getHeader(key);
System.err.println(key + " : " + value);
}
Application result = new Application();
......@@ -91,12 +91,8 @@ public class WADLController {
HandlerMethod handlerMethod = entry.getValue();
Object object = handlerMethod.getBean();
// System.err.println(object);
// System.err.println(object.getClass().getName());
// System.err.println(object.toString());
Object bean = webApplicationContext.getBean(object.toString());
// System.err.println(bean.getClass().getName());
boolean isRestContoller = bean.getClass().isAnnotationPresent(RestController.class);
if (bean.getClass().getName().contains("nl.uva.sne.drip.api.v1.rest")) {
isRestContoller = true;
......
var app = angular.module('flapperNews', []);
app.controller('MainCtrl', [
'$scope',
function ($scope) {
$scope.test = 'Hello world!';
}]);
<html>
<head>
<title>My Angular App!</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js"></script>
<script src="app.js"></script>
</head>
<body ng-app="flapperNews" ng-controller="MainCtrl">
<div>
{{test}}
</div>
</body>
</html>
\ No newline at end of file
<html>
</html>
\ No newline at end of file
<html>
</html>
\ No newline at end of file
......@@ -68,21 +68,4 @@ public class TestCloudCredentialsController {
public void testPostCredentials() throws IOException {
}
// @Test
// public void testUpload() throws IOException {
// HttpClient client = HttpClientBuilder.create().build();
// HttpPost post = new HttpPost(url);
// MultipartEntityBuilder builder = MultipartEntityBuilder.create();
// builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
//
// FileBody fileBody = new FileBody(toscaFile);
// builder.addPart("file", fileBody);
// HttpEntity entity = builder.build();
// post.setEntity(entity);
//
// HttpResponse status = client.execute(post);
// System.err.println(status.getStatusLine());
// assertEquals(200, status.getStatusLine().getStatusCode());
////
// }
}
......@@ -19,6 +19,7 @@ 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;
......@@ -42,7 +43,7 @@ public class AnsibleOutput extends OwnedObject {
@Indexed
private String vmType;
private AnsibleResult result;
private KeyValueHolder result;
private String provisionID;
......@@ -72,12 +73,12 @@ public class AnsibleOutput extends OwnedObject {
* @return the result
*/
@JsonProperty("result")
public AnsibleResult getAnsibleResult() {
public KeyValueHolder getAnsibleResult() {
return result;
}
@JsonProperty("result")
public void setAnsiibleResult(AnsibleResult result) {
public void setAnsiibleResult(KeyValueHolder result) {
this.result = result;
}
......
/*
* Copyright 2017 S. Koulouzis, Wang Junchao, Huan Zhou, Yang Hu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.drip.commons.data.v1.external.ansible;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Date;
/**
* This class represents an ansible execution result. This can be used as a
* archive / log of ansible executions for example how much time it took for
* execution, errors etc.
*
* @author S. Koulouzis
*/
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class AnsibleResult {
private String msg;
private Boolean changed;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss.SSSSSS")
private Date end;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss.SSSSSS")
private Date start;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm:ss.SSSSSS")
private Date delta;
private String stdout;
private String stderr;
private List<String> cmd;
// @JsonProperty("stdout_lines")
// private List<String> stdout_lines;
// @JsonProperty("results")
// private List<AnsibleResult_> results = null;
@JsonProperty("msg")
public String getMsg() {
return msg;
}
@JsonProperty("msg")
public void setMsg(String msg) {
this.msg = msg;
}
@JsonProperty("changed")
public Boolean getChanged() {
return changed;
}
@JsonProperty("changed")
public void setChanged(Boolean changed) {
this.changed = changed;
}
// @JsonProperty("results")
// public List<AnsibleResult_> getAnsibleResults() {
// return results;
// }
//
// @JsonProperty("results")
// public void setAnsibleResults(List<AnsibleResult_> results) {
// this.results = results;
// }
@JsonProperty("end")
public Date getEnd() {
return end;
}
@JsonProperty("end")
public void setEnd(Date end) {
this.end = end;
}
@JsonProperty("stdout")
public String getStdout() {
return stdout;
}
@JsonProperty("stdout")
public void setStdout(String stdout) {
this.stdout = stdout;
}
@JsonProperty("cmd")
public List<String> getCmd() {
return cmd;
}
@JsonProperty("cmd")
public void setCmd(List<String> cmd) {
this.cmd = cmd;
}
@JsonProperty("start")
public Date getStart() {
return start;
}
@JsonProperty("start")
public void setStart(Date start) {
this.start = start;
}
@JsonProperty("stderr")
public String getStderr() {
return stderr;
}
@JsonProperty("stderr")
public void setStderr(String stderr) {
this.stderr = stderr;
}
@JsonProperty("delta")
public Date getDelta() {
return delta;
}
@JsonProperty("delta")
public void setDelta(Date delta) {
this.delta = delta;
}
// @JsonProperty("stdout_lines")
// public List<String> getStdout_lines() {
// return stdout_lines;
// }
//
// @JsonProperty("stdout_lines")
// public void setStdout_lines(List<String> stdout_lines) {
// this.stdout_lines = stdout_lines;
// }
}
......@@ -72,12 +72,14 @@ def install_prerequisites(vm,return_dict):
sftp.chdir('/tmp/')
install_script = file_path + "/" + "ansible_setup.sh"
sftp.put(install_script, "ansible_setup.sh")
stdin, stdout, stderr = ssh.exec_command("sudo hostname ip-%s" % (vm.ip.replace('.','-')))
sshout = stdout.read()
logger.info("stdout: " + sshout)
logger.info("stderr: " + stderr.read())
stdin, stdout, stderr = ssh.exec_command("sudo sh /tmp/ansible_setup.sh")
stdout.read()
logger.info("stdout: " + stdout.read())
logger.info("stderr: " + stderr.read())
logger.info("Ansible prerequisites installed on: " + (vm.ip))
except Exception as e:
......
#! /bin/bash
killall apt
rm /var/lib/dpkg/lock
dpkg --configure -a
apt-get update
apt-get -y upgrade
export DEBIAN_FRONTEND=noninteractive
apt-get -o Dpkg::Options::="--force-confold" upgrade -q -y --force-yes
apt-get -y install software-properties-common python openssh-server sudo
service ssh restart
\ No newline at end of file
......@@ -74,6 +74,7 @@ def docker_check(vm, compose_name):
cmd = 'sudo docker stack ps '+ compose_name +' --format ' + services_format
logger.info("Sending :"+cmd)
stdin, stdout, stderr = ssh.exec_command(cmd)
stack_ps_resp = stdout.readlines()
services_info = []
......@@ -90,6 +91,8 @@ def docker_check(vm, compose_name):
json_dict = json.loads(json_dict)
except Exception as e:
json_dict = json_dict.replace('\"ports\":\"\"', '\"ports\":null').replace('\"\"', '\"')
json_dict = json_dict.replace('\"node\":\",\"', '\"node\":null,\"').replace('\"\"', '\"')
json_dict = json_dict.replace("\\", "").replace("Noxe2x80xa6", "No...")
json_dict = json.loads(json_dict)
nodes_hostname.add(json_dict['node'])
......@@ -116,6 +119,7 @@ def docker_check(vm, compose_name):
cmd = 'sudo docker node inspect '
for hostname in nodes_hostname:
if hostname:
cmd += ' '+hostname
logger.info("Sending :"+cmd)
stdin, stdout, stderr = ssh.exec_command(cmd)
......
......@@ -4,3 +4,6 @@ Ubuntu 16.04&&Virginia&&ami-41e0b93b
Ubuntu 16.04&&California&&ami-79aeae19
Ubuntu 16.04&&Ohio&&ami-2581aa40
Ubuntu 14.04&&Ohio&&ami-f0f8d695
Ubuntu 16.04&&Frankfurt&&ami-af79ebc0
......@@ -15,8 +15,11 @@
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<ch.qos.logback.version>1.2.3</ch.qos.logback.version>
</properties>
<dependencies>
<dependency>
<groupId>nl.uva.sne.drip</groupId>
......@@ -89,6 +92,23 @@
<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>
</dependencies>
......
......@@ -638,7 +638,7 @@ public class Consumer extends DefaultConsumer {
// paramValue += tempInputDirPath + File.separator + sub.subTopology.accessKeyPair.SSHKeyPairId + File.separator + "id_rsa";
paramValue += vm.role + "\n";
}
//else if (vm == null || !sub.status.equals("running")) {
// else if (vm == null || !sub.status.equals("running")) {
// throw new Exception("A VM failed to start. Deleteing all topology");
// }
}
......
File added
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