Commit 698454ae authored by Spiros Koulouzis's avatar Spiros Koulouzis

fixed msg bug.

parent 724dcf64
...@@ -11,3 +11,4 @@ ...@@ -11,3 +11,4 @@
/drip-api/nbproject/ /drip-api/nbproject/
/drip-tests/nbproject/ /drip-tests/nbproject/
/drip-tests/target/ /drip-tests/target/
/docs/playbooks/euroArgo_conf_playbook2.yml
\ No newline at end of file
---
publicKeyPath: "name@id_rsa.pub"
userName: "vm_user"
topologies:
- topology: "egi-level-1"
cloudProvider: "EGI"
domain: "CESNET"
status: "fresh"
tag: "fixed"
statusInfo: null
copyOf: null
sshKeyPairId: null
connections: null
---
subnets: null
components:
- name: "nodeA"
type: "switch/compute"
nodeType: "medium"
OStype: "Ubuntu 14.04"
script: null
role: null
dockers: null
publicAddress: null
ethernetPort: null
VMResourceID: null
\ No newline at end of file
...@@ -12,14 +12,17 @@ ...@@ -12,14 +12,17 @@
- {name: Copy scripts, copy: src=/tmp/scripts/ArgoDiffusion/scripts dest=/tmp/scripts owner=vm_user group=vm_user mode=755} - {name: Copy scripts, copy: src=/tmp/scripts/ArgoDiffusion/scripts dest=/tmp/scripts owner=vm_user group=vm_user mode=755}
- {name: create dir, file: path=/home/vm_user/.irods/ state=directory owner=vm_user group=vm_user} - {name: create dir, file: path=/home/vm_user/.irods/ state=directory owner=vm_user group=vm_user}
- {name: Copy irods_environment, copy: src=/tmp/conf/irods_environment.json dest=/home/vm_user/.irods/ owner=vm_user group=vm_user mode=755} - {name: Copy irods_environment, copy: src=/tmp/conf/irods_environment.json dest=/home/vm_user/.irods/ owner=vm_user group=vm_user mode=755}
- {name: Run iinit, command: expect -c "spawn iinit; expect \"Enter your current iRODS password\"; send \"PASSWORD\n\";interact;", register: streamoutput, become: yes, become_user: vm_user} - {name: Copy iint, copy: src=/tmp/conf/iint_euroargo.exp dest=/tmp/iint_euroargo.exp owner=vm_user group=vm_user mode=755}
- {name: Run iinit, command: expect /tmp/iint_euroargo.exp, register: streamoutput, become: yes, become_user: vm_user}
- debug: msg="{{ streamoutput.stdout }}" - debug: msg="{{ streamoutput.stdout }}"
- debug: msg="{{ streamoutput.stderr }}"
- {name: create dir, file: path=/mnt/data/ state=directory owner=vm_user group=vm_user} - {name: create dir, file: path=/mnt/data/ state=directory owner=vm_user group=vm_user}
- {name: create dir, file: path=/mnt/data/source/ state=directory owner=vm_user group=vm_user} - {name: create dir, file: path=/mnt/data/source/ state=directory owner=vm_user group=vm_user}
- {name: create dir, file: path=/mnt/data/source/output state=directory owner=vm_user group=vm_user} - {name: create dir, file: path=/mnt/data/source/output state=directory owner=vm_user group=vm_user}
- {name: create dir, file: path=/mnt/data/irods/ state=directory owner=vm_user group=vm_user} - {name: create dir, file: path=/mnt/data/irods/ state=directory owner=vm_user group=vm_user}
- {name: Run irodsFs, command: irodsFs /mnt/data/irods/, register: streamoutput, become: yes, become_user: vm_user} - {name: Run irodsFs, command: irodsFs /mnt/data/irods/, register: streamoutput, become: yes, become_user: vm_user}
- debug: msg="{{ streamoutput.stdout }}" - debug: msg="{{ streamoutput.stdout }}"
- debug: msg="{{ streamoutput.stderr }}"
- {name: Copy from tmp, command: cp /tmp/scripts/scripts/ar_bigmetadata.json /mnt/data/source/, become: yes, become_user: vm_user} - {name: Copy from tmp, command: cp /tmp/scripts/scripts/ar_bigmetadata.json /mnt/data/source/, become: yes, become_user: vm_user}
- {name: Copy from irods, command: ln -s /mnt/data/irods/monthly /mnt/data/source/input, become: yes, become_user: vm_user} - {name: Copy from irods, command: ln -s /mnt/data/irods/monthly /mnt/data/source/input, become: yes, become_user: vm_user}
- {name: Copy from irods, command: cp /mnt/data/irods/action/argo_model.py /mnt/data/source/, become: yes, become_user: vm_user} - {name: Copy from irods, command: cp /mnt/data/irods/action/argo_model.py /mnt/data/source/, become: yes, become_user: vm_user}
......
...@@ -3,3 +3,5 @@ ...@@ -3,3 +3,5 @@
tasks: tasks:
- {name: Run generation_argo_big_data, command: /usr/bin/python /mnt/data/source/generation_argo_big_data.py /mnt/data/source/configuration.json, register: streamoutput, become: yes, become_user: vm_user} - {name: Run generation_argo_big_data, command: /usr/bin/python /mnt/data/source/generation_argo_big_data.py /mnt/data/source/configuration.json, register: streamoutput, become: yes, become_user: vm_user}
- debug: msg="{{ streamoutput.stdout }}" - debug: msg="{{ streamoutput.stdout }}"
- {name: Copy output to irods, command: cp /mnt/data/source/output/data_argo.txt /mnt/data/irods/result, become: yes, become_user: vm_user}
\ No newline at end of file
...@@ -26,6 +26,7 @@ import java.util.Map; ...@@ -26,6 +26,7 @@ import java.util.Map;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.regex.Matcher;
import nl.uva.sne.drip.api.dao.DeployDao; import nl.uva.sne.drip.api.dao.DeployDao;
import nl.uva.sne.drip.api.exception.NotFoundException; import nl.uva.sne.drip.api.exception.NotFoundException;
import nl.uva.sne.drip.api.rpc.DRIPCaller; import nl.uva.sne.drip.api.rpc.DRIPCaller;
...@@ -50,11 +51,14 @@ import org.springframework.security.core.context.SecurityContextHolder; ...@@ -50,11 +51,14 @@ import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import nl.uva.sne.drip.api.dao.KeyPairDao; import nl.uva.sne.drip.api.dao.KeyPairDao;
import nl.uva.sne.drip.api.exception.KeyException; import nl.uva.sne.drip.api.exception.KeyException;
import nl.uva.sne.drip.commons.utils.Converter;
import nl.uva.sne.drip.drip.commons.data.v1.external.KeyPair; import nl.uva.sne.drip.drip.commons.data.v1.external.KeyPair;
import nl.uva.sne.drip.drip.commons.data.v1.external.ansible.AnsibleOutput; 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.AnsibleResult;
import nl.uva.sne.drip.drip.commons.data.v1.external.ansible.BenchmarkResult; 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 nl.uva.sne.drip.drip.commons.data.v1.external.ansible.SysbenchCPUBenchmark;
import org.json.JSONArray;
import org.json.JSONObject;
/** /**
* *
...@@ -162,7 +166,6 @@ public class DeployService { ...@@ -162,7 +166,6 @@ public class DeployService {
// CloudCredentials cCred = cloudCredentialsService.findOne(cloudConfIDs.get(0)); // CloudCredentials cCred = cloudCredentialsService.findOne(cloudConfIDs.get(0));
// loginKeysIDs = cCred.getkeyPairIDs(); // loginKeysIDs = cCred.getkeyPairIDs();
// } // }
List<KeyPair> loginKeys = new ArrayList<>(); List<KeyPair> loginKeys = new ArrayList<>();
for (String keyID : loginKeysIDs) { for (String keyID : loginKeysIDs) {
KeyPair key = keyDao.findOne(keyID); KeyPair key = keyDao.findOne(keyID);
...@@ -258,6 +261,9 @@ public class DeployService { ...@@ -258,6 +261,9 @@ public class DeployService {
String value = p.getValue(); String value = p.getValue();
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
value = parseValue(value);
List<AnsibleOutput> outputList = mapper.readValue(value, new TypeReference<List<AnsibleOutput>>() { List<AnsibleOutput> outputList = mapper.readValue(value, new TypeReference<List<AnsibleOutput>>() {
}); });
...@@ -444,4 +450,55 @@ public class DeployService { ...@@ -444,4 +450,55 @@ public class DeployService {
return Double.valueOf(string.replaceAll("approx. 95 percentile:", "").replaceAll("ms", "").trim()); return Double.valueOf(string.replaceAll("approx. 95 percentile:", "").replaceAll("ms", "").trim());
} }
private String parseValue(String value) throws JSONException {
JSONArray ja = new JSONArray(value);
JSONArray newJa = new JSONArray();
for (int i = 0; i < ja.length(); i++) {
JSONObject jo = ja.getJSONObject(i);
JSONObject result = ((JSONObject) jo.get("result"));
if (result.has("msg")) {
String msg;
try {
msg = (String) result.get("msg");
} catch (java.lang.ClassCastException ex) {
JSONObject message = (JSONObject) result.get("msg");
msg = Converter.jsonObject2String(message.toString());
result.put("msg", msg);
jo.put("result", result);
}
}
JSONObject invocation = ((JSONObject) (result).get("invocation"));
if (invocation.has("module_args")) {
JSONObject module_args = (JSONObject) invocation.get("module_args");
if (module_args.has("msg")) {
String msg;
try {
msg = (String) module_args.get("msg");
} catch (java.lang.ClassCastException ex) {
JSONObject message = (JSONObject) module_args.get("msg");
msg = Converter.jsonObject2String(message.toString());
module_args.put("msg", msg);
invocation.put("module_args", module_args);
}
}
}
if (invocation.has("msg")) {
String msg;
try {
msg = (String) invocation.get("msg");
} catch (java.lang.ClassCastException ex) {
JSONObject message = (JSONObject) invocation.get("msg");
msg = Converter.jsonObject2String(message.toString());
invocation.put("msg", msg);
result.put("invocation", invocation);
}
}
newJa.put(jo);
}
return newJa.toString();
}
} }
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<html>
<head>
<title>Crunchify - Spring MVC Upload Multiple Files Example</title>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script>
$(document)
.ready(
function () {
//add more file components if Add is clicked
$('#addFile')
.click(
function () {
var fileIndex = $('#fileTable tr')
.children().length - 1;
$('#fileTable')
.append(
'<tr><td>'
+ ' <input type="file" name="files[' + fileIndex + ']" />'
+ '</td></tr>');
});
});
</script>
<style type="text/css">
body {
background-image:
url('https://cdn.crunchify.com/wp-content/uploads/2013/03/Crunchify.bg_.300.png');
}
</style>
</head>
<body>
<br>
<br>
<div align="center">
<h1>Crunchify - Spring MVC Upload Multiple Files Example</h1>
<form:form method="post" action="savefiles.html"
modelAttribute="uploadForm" enctype="multipart/form-data">
<p>Select files to upload. Press Add button to add more file
inputs.</p>
<table id="fileTable">
<tr>
<td><input name="files[0]" type="file" /></td>
</tr>
<tr>
<td><input name="files[1]" type="file" /></td>
</tr>
</table>
<br />
<input type="submit" value="Upload" />
<input id="addFile" type="button" value="Add File" />
</form:form>
<br />
</div>
</body>
</html>
\ No newline at end of file
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
<title>Crunchify - Upload Multiple Files Example</title>
<style type="text/css">
body {
background-image:
url('https://cdn.crunchify.com/wp-content/uploads/2013/03/Crunchify.bg_.300.png');
}
</style>
</head>
<body>
<br>
<br>
<div align="center">
<h1>Crunchify - Spring MVC Upload Multiple Files Example</h1>
<p>Awesome.. Following files are uploaded successfully.</p>
<ol>
<c:forEach items="${files}" var="file">
- ${file} <br>
</c:forEach>
</ol>
<a href="http://localhost:8080/CrunchifySpringMVC3.2.1/upload.html"><input
type="button" value="Go Back" /></a> <br />
<br />
<br />
<div
style="font-family: verdana; line-height: 25px; padding: 5px 10px; border-radius: 10px; border: 1px dotted #A4A4A4; width: 50%; font-size: 12px;">
Spring MVC Upload Multiple Files Example by <a
href='https://crunchify.com'>Crunchify</a>. Click <a
href='https://crunchify.com/category/java-web-development-tutorial/'>here</a>
for all Java, Spring MVC, Web Development examples.<br>
</div>
</div>
</body>
</html>
\ No newline at end of file
...@@ -26,6 +26,7 @@ import java.util.Iterator; ...@@ -26,6 +26,7 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.regex.Matcher;
import nl.uva.sne.drip.drip.commons.data.v1.external.CloudCredentials; import nl.uva.sne.drip.drip.commons.data.v1.external.CloudCredentials;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.json.JSONArray; import org.json.JSONArray;
...@@ -241,4 +242,10 @@ public class Converter { ...@@ -241,4 +242,10 @@ public class Converter {
return map; return map;
} }
public static String jsonObject2String(String msg) {
msg = msg.replaceAll("\"", Matcher.quoteReplacement("\\\""));
msg = "\"" + msg + "\"";
return msg;
}
} }
...@@ -163,7 +163,6 @@ public class Consumer extends DefaultConsumer { ...@@ -163,7 +163,6 @@ public class Consumer extends DefaultConsumer {
File mainTopologyFile = new File(tempInputDirPath + "topology_main.yml"); File mainTopologyFile = new File(tempInputDirPath + "topology_main.yml");
FileUtils.moveFile(topologyFile, mainTopologyFile); FileUtils.moveFile(topologyFile, mainTopologyFile);
String topTopologyLoadingPath = mainTopologyFile.getAbsolutePath(); String topTopologyLoadingPath = mainTopologyFile.getAbsolutePath();
List<File> topologyFiles = MessageParsing.getTopologies(parameters, tempInputDirPath, 1); List<File> topologyFiles = MessageParsing.getTopologies(parameters, tempInputDirPath, 1);
// for (File lowLevelTopologyFile : topologyFiles) { // for (File lowLevelTopologyFile : topologyFiles) {
// File secondaryTopologyFile = new File(tempInputDirPath + File.separator + lowLevelTopologyFile.getName() + ".yml"); // File secondaryTopologyFile = new File(tempInputDirPath + File.separator + lowLevelTopologyFile.getName() + ".yml");
......
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