Commit 21bbe89f authored by Spiros Koulouzis's avatar Spiros Koulouzis

Added maven dependency for provisoner core

Make sure we write input files correctly 
parent fbd089e7
...@@ -109,7 +109,7 @@ public abstract class DRIPCaller { ...@@ -109,7 +109,7 @@ public abstract class DRIPCaller {
} }
}); });
String strResponse = response.take(); String strResponse = response.take();
System.err.println(strResponse); // System.err.println(strResponse);
return mapper.readValue(strResponse, Message.class); return mapper.readValue(strResponse, Message.class);
} }
......
input.tosca.folder.path=/tmp/ message.broker.host=172.17.0.2
message.broker.host=172.17.0.3
db.name=drip db.name=drip
db.username=drip-user db.username=drip-user
db.password=drip-pass db.password=drip-pass
...@@ -55,7 +55,7 @@ public class Consumer extends DefaultConsumer { ...@@ -55,7 +55,7 @@ public class Consumer extends DefaultConsumer {
private final Channel channel; private final Channel channel;
private final String propertiesPath = "etc/consumer.properties"; private final String propertiesPath = "etc/consumer.properties";
private String jarFilePath; // private String jarFilePath;
public class topologyElement { public class topologyElement {
...@@ -70,13 +70,13 @@ public class Consumer extends DefaultConsumer { ...@@ -70,13 +70,13 @@ public class Consumer extends DefaultConsumer {
try (InputStream in = new FileInputStream(propertiesPath)) { try (InputStream in = new FileInputStream(propertiesPath)) {
prop.load(in); prop.load(in);
} }
jarFilePath = prop.getProperty("jar.file.path", "/root/SWITCH/bin/ProvisioningCore.jar"); // jarFilePath = prop.getProperty("jar.file.path", "/root/SWITCH/bin/ProvisioningCore.jar");
File jarFile = new File(jarFilePath); // File jarFile = new File(jarFilePath);
if (!jarFile.exists()) { // if (!jarFile.exists()) {
throw new IOException(jarFile.getAbsolutePath() + " not found!"); // throw new IOException(jarFile.getAbsolutePath() + " not found!");
} else { // } else {
jarFilePath = jarFile.getAbsolutePath(); // jarFilePath = jarFile.getAbsolutePath();
} // }
} }
@Override @Override
...@@ -135,8 +135,7 @@ public class Consumer extends DefaultConsumer { ...@@ -135,8 +135,7 @@ public class Consumer extends DefaultConsumer {
try { try {
ec2ConfFile = new File(tempInputDirPath + "ec2.Conf"); ec2ConfFile = new File(tempInputDirPath + "ec2.Conf");
if (ec2ConfFile.createNewFile()) { if (ec2ConfFile.createNewFile()) {
PrintWriter out = new PrintWriter(ec2ConfFile); writeValueToFile((String) param.get(Parameter.VALUE), ec2ConfFile);
out.print(param.get(Parameter.VALUE));
} else { } else {
return null; return null;
} }
...@@ -148,8 +147,7 @@ public class Consumer extends DefaultConsumer { ...@@ -148,8 +147,7 @@ public class Consumer extends DefaultConsumer {
try { try {
geniConfFile = new File(tempInputDirPath + "geni.Conf"); geniConfFile = new File(tempInputDirPath + "geni.Conf");
if (geniConfFile.createNewFile()) { if (geniConfFile.createNewFile()) {
PrintWriter out = new PrintWriter(geniConfFile); writeValueToFile((String) param.get(Parameter.VALUE), geniConfFile);
out.print(param.get(Parameter.VALUE));
} else { } else {
return null; return null;
} }
...@@ -165,8 +163,8 @@ public class Consumer extends DefaultConsumer { ...@@ -165,8 +163,8 @@ public class Consumer extends DefaultConsumer {
File topologyFile = new File(tempInputDirPath + "topology_main"); File topologyFile = new File(tempInputDirPath + "topology_main");
if (topologyFile.createNewFile()) { if (topologyFile.createNewFile()) {
PrintWriter out = new PrintWriter(topologyFile); writeValueToFile((String) param.get(Parameter.VALUE), topologyFile);
out.print(param.get(Parameter.VALUE));
mainTopologyPath = topologyFile.getAbsolutePath(); mainTopologyPath = topologyFile.getAbsolutePath();
} else { } else {
return null; return null;
...@@ -177,8 +175,8 @@ public class Consumer extends DefaultConsumer { ...@@ -177,8 +175,8 @@ public class Consumer extends DefaultConsumer {
File topologyFile = new File(tempInputDirPath + fileName + ".yml"); File topologyFile = new File(tempInputDirPath + fileName + ".yml");
String outputFilePath = tempInputDirPath + fileName + "_provisioned.yml"; String outputFilePath = tempInputDirPath + fileName + "_provisioned.yml";
if (topologyFile.createNewFile()) { if (topologyFile.createNewFile()) {
PrintWriter out = new PrintWriter(outputFilePath); writeValueToFile((String) param.get(Parameter.VALUE), topologyFile);
out.print(param.get(Parameter.VALUE));
topologyElement x = new topologyElement(); topologyElement x = new topologyElement();
x.topologyName = fileName; x.topologyName = fileName;
x.outputFilePath = outputFilePath; x.outputFilePath = outputFilePath;
...@@ -240,8 +238,9 @@ public class Consumer extends DefaultConsumer { ...@@ -240,8 +238,9 @@ public class Consumer extends DefaultConsumer {
logDir = System.getProperty("java.io.tmpdir"); logDir = System.getProperty("java.io.tmpdir");
} }
String cmd = "java -jar " + jarFilePath + " ec2=" + ec2ConfFilePath + " exogeni=" + geniConfFilePath + " logDir=" + logDir + " topology=" + mainTopologyPath; String cmd = "ec2=" + ec2ConfFilePath + " exogeni=" + geniConfFilePath + " logDir=" + logDir + " topology=" + mainTopologyPath;
Provisioning.ProvisioningCore.main(cmd.split(" ")); Provisioning.ProvisioningCore.main(cmd.split(" "));
// String cmd = "java -jar " + jarFilePath + " ec2=" + ec2ConfFilePath + " exogeni=" + geniConfFilePath + " logDir=" + logDir + " topology=" + mainTopologyPath;
// try { // try {
// Logger.getLogger(Consumer.class.getName()).log(Level.INFO, "Executing: " + cmd); // Logger.getLogger(Consumer.class.getName()).log(Level.INFO, "Executing: " + cmd);
// Process p = Runtime.getRuntime().exec(cmd); // Process p = Runtime.getRuntime().exec(cmd);
...@@ -352,4 +351,13 @@ public class Consumer extends DefaultConsumer { ...@@ -352,4 +351,13 @@ public class Consumer extends DefaultConsumer {
return jo.toString(); return jo.toString();
} }
private void writeValueToFile(String value, File file) throws FileNotFoundException {
try (PrintWriter out = new PrintWriter(file)) {
out.print(value);
}
if (!file.exists() || file.length() < value.getBytes().length) {
throw new FileNotFoundException("File " + file.getAbsolutePath() + " doesn't exist or contents are missing ");
}
}
} }
...@@ -31,7 +31,7 @@ import java.util.logging.Logger; ...@@ -31,7 +31,7 @@ import java.util.logging.Logger;
public class RPCServer { public class RPCServer {
private static final String RPC_QUEUE_NAME = "provisioner_queue"; private static final String RPC_QUEUE_NAME = "provisioner_queue";
private static final String HOST = "172.17.0.3"; private static final String HOST = "172.17.0.2";
public static void main(String[] argv) { public static void main(String[] argv) {
start(); start();
......
...@@ -31,7 +31,7 @@ import java.util.logging.Logger; ...@@ -31,7 +31,7 @@ import java.util.logging.Logger;
public class RPCServer { public class RPCServer {
private static final String RPC_QUEUE_NAME = "planner_queue"; private static final String RPC_QUEUE_NAME = "planner_queue";
private static final String HOST = "172.17.0.3"; private static final String HOST = "172.17.0.2";
public static void main(String[] argv) { public static void main(String[] argv) {
start(); start();
......
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