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

Merge commit 'cff8a3c0' into ansible

Conflicts:
	drip-api/src/main/java/nl/uva/sne/drip/api/service/DeployService.java
	drip-api/src/main/java/nl/uva/sne/drip/data/v1/external/ansible/AnsibleOutput.java
	drip-api/src/main/java/nl/uva/sne/drip/data/v1/external/ansible/AnsibleResult.java
	drip-api/src/main/java/nl/uva/sne/drip/data/v1/external/ansible/Invocation.java
parents ece0b4bf cff8a3c0
......@@ -10,6 +10,7 @@
<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.*"/>
</api-classes>
......
......@@ -9,8 +9,6 @@ import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.DefaultConsumer;
import com.rabbitmq.client.Envelope;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
......@@ -18,11 +16,8 @@ import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
import java.util.logging.Logger;
import nl.uva.sne.drip.data.v1.external.Message;
import nl.uva.sne.drip.data.v1.external.MessageParameter;
import nl.uva.sne.drip.commons.utils.Converter;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
/*
* Copyright 2017 S. Koulouzis, Wang Junchao, Huan Zhou, Yang Hu
......
......@@ -15,6 +15,8 @@
*/
package nl.uva.sne.drip.api.service;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
......@@ -48,6 +50,7 @@ import nl.uva.sne.drip.api.dao.DeployDao;
import nl.uva.sne.drip.api.dao.KeyPairDao;
import nl.uva.sne.drip.api.exception.KeyException;
import nl.uva.sne.drip.data.v1.external.KeyPair;
import nl.uva.sne.drip.data.v1.external.ansible.AnsibleOutput;
/**
*
......@@ -210,12 +213,12 @@ public class DeployService {
return ansibleParameter;
}
private DeployResponse handleResponse(List<MessageParameter> params) throws KeyException {
private DeployResponse handleResponse(List<MessageParameter> params) throws KeyException, IOException {
DeployResponse deployResponse = new DeployResponse();
for (MessageParameter p : params) {
String name = p.getName();
System.err.println(name + " : " + p.getValue());
if (name.equals("credential")) {
String value = p.getValue();
Key k = new Key();
......@@ -224,10 +227,16 @@ public class DeployService {
KeyPair pair = new KeyPair();
pair.setPrivateKey(k);
deployResponse.setKey(pair);
save(deployResponse);
return deployResponse;
}
if (name.equals("ansible_output")) {
String value = p.getValue();
ObjectMapper mapper = new ObjectMapper();
System.err.println(value);
List<AnsibleOutput> outputList = mapper.readValue(value, new TypeReference<List<AnsibleOutput>>() {
});
deployResponse.setAnsibleOutputList(outputList);
}
}
save(deployResponse);
......
......@@ -15,8 +15,8 @@
*/
package nl.uva.sne.drip.data.v1.external;
import com.webcohesion.enunciate.metadata.DocumentationExample;
import org.springframework.data.annotation.Id;
import java.util.List;
import nl.uva.sne.drip.data.v1.external.ansible.AnsibleOutput;
import org.springframework.data.mongodb.core.mapping.Document;
/**
......@@ -31,15 +31,28 @@ public class DeployResponse extends DeployRequest {
private KeyPair key;
private List<AnsibleOutput> ansibleOutputList;
public void setAnsibleOutputList(List<AnsibleOutput> outputList) {
this.ansibleOutputList = outputList;
}
/**
* @return the ansibleOutputList
*/
public List<AnsibleOutput> getAnsibleOutputList() {
return ansibleOutputList;
}
public void setKey(KeyPair key) {
this.key = key;
}
/**
* The key pair to log in and manage a docker cluster
*
* @return
*/
public KeyPair getKeyPair() {
return key;
}
......
......@@ -15,16 +15,18 @@
*/
package nl.uva.sne.drip.data.v1.external;
import com.fasterxml.jackson.annotation.JsonInclude;
import nl.uva.sne.drip.api.exception.KeyException;
import org.springframework.data.mongodb.core.mapping.Document;
/**
* This class hold the pair of public private keys. The kyes may be used for
* This class hold the pair of public private keys. The keys may be used for
* logging in VMs.
*
* @author S. Koulouzis
*/
@Document
@JsonInclude(JsonInclude.Include.NON_NULL)
public class KeyPair extends OwnedObject {
private Key privateKey;
......
/*
* 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.data.v1.external.ansible;
/**
*
* @author S. Koulouzis
*/
import java.util.List;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
"_ansible_parsed",
"changed",
"_ansible_no_log",
"cache_updated",
"_ansible_item_result",
"item",
"invocation",
"cache_update_time"
})
public class Result_ {
@JsonProperty("_ansible_parsed")
private Boolean ansibleParsed;
@JsonProperty("changed")
private Boolean changed;
@JsonProperty("_ansible_no_log")
private Boolean ansibleNoLog;
@JsonProperty("cache_updated")
private Boolean cacheUpdated;
@JsonProperty("_ansible_item_result")
private Boolean ansibleItemResult;
@JsonProperty("item")
private List<String> item = null;
@JsonProperty("invocation")
private Invocation invocation;
@JsonProperty("cache_update_time")
private Integer cacheUpdateTime;
@JsonProperty("_ansible_parsed")
public Boolean getAnsibleParsed() {
return ansibleParsed;
}
@JsonProperty("_ansible_parsed")
public void setAnsibleParsed(Boolean ansibleParsed) {
this.ansibleParsed = ansibleParsed;
}
@JsonProperty("changed")
public Boolean getChanged() {
return changed;
}
@JsonProperty("changed")
public void setChanged(Boolean changed) {
this.changed = changed;
}
@JsonProperty("_ansible_no_log")
public Boolean getAnsibleNoLog() {
return ansibleNoLog;
}
@JsonProperty("_ansible_no_log")
public void setAnsibleNoLog(Boolean ansibleNoLog) {
this.ansibleNoLog = ansibleNoLog;
}
@JsonProperty("cache_updated")
public Boolean getCacheUpdated() {
return cacheUpdated;
}
@JsonProperty("cache_updated")
public void setCacheUpdated(Boolean cacheUpdated) {
this.cacheUpdated = cacheUpdated;
}
@JsonProperty("_ansible_item_result")
public Boolean getAnsibleItemResult() {
return ansibleItemResult;
}
@JsonProperty("_ansible_item_result")
public void setAnsibleItemResult(Boolean ansibleItemResult) {
this.ansibleItemResult = ansibleItemResult;
}
@JsonProperty("item")
public List<String> getItem() {
return item;
}
@JsonProperty("item")
public void setItem(List<String> item) {
this.item = item;
}
@JsonProperty("invocation")
public Invocation getInvocation() {
return invocation;
}
@JsonProperty("invocation")
public void setInvocation(Invocation invocation) {
this.invocation = invocation;
}
@JsonProperty("cache_update_time")
public Integer getCacheUpdateTime() {
return cacheUpdateTime;
}
@JsonProperty("cache_update_time")
public void setCacheUpdateTime(Integer cacheUpdateTime) {
this.cacheUpdateTime = cacheUpdateTime;
}
}
......@@ -81,9 +81,9 @@ def execute_playbook(hosts, playbook_path,user,ssh_key_file,extra_vars,passwords
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', 'aaaaaaaaaaa'])
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 = 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 , aaaaaaaaaaa=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 )
variable_manager.extra_vars = extra_vars
......
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