Commit 779bc2e5 authored by Spiros Koulouzis's avatar Spiros Koulouzis

move interfaces

added SURE Simple qUeRy sErvice TOSCA swagger
implementing cloudstorm service for provisioner
parent 56b5187a
...@@ -38,7 +38,7 @@ public class ProvisionerService { ...@@ -38,7 +38,7 @@ public class ProvisionerService {
String ymlToscaTemplate = toscaTemplateService.findByID(id); String ymlToscaTemplate = toscaTemplateService.findByID(id);
ToscaTemplate toscaTemplate = toscaTemplateService.getYaml2ToscaTemplate(ymlToscaTemplate); ToscaTemplate toscaTemplate = toscaTemplateService.getYaml2ToscaTemplate(ymlToscaTemplate);
TOSCAUtils.getNodesByType(toscaTemplate);
return null; return null;
} }
......
...@@ -17,6 +17,7 @@ package nl.uva.sne.drip.provisioner; ...@@ -17,6 +17,7 @@ package nl.uva.sne.drip.provisioner;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.SerializationFeature;
import com.jcraft.jsch.JSchException;
import com.rabbitmq.client.AMQP; import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel; import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DefaultConsumer; import com.rabbitmq.client.DefaultConsumer;
...@@ -52,35 +53,39 @@ public class Consumer extends DefaultConsumer { ...@@ -52,35 +53,39 @@ public class Consumer extends DefaultConsumer {
} }
@Override @Override
public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException { public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException, FileNotFoundException {
//Create the reply properties which tells us where to reply, and which id to use. try {
//No need to change anything here //Create the reply properties which tells us where to reply, and which id to use.
AMQP.BasicProperties replyProps = new AMQP.BasicProperties.Builder() //No need to change anything here
.correlationId(properties.getCorrelationId()) AMQP.BasicProperties replyProps = new AMQP.BasicProperties.Builder()
.build(); .correlationId(properties.getCorrelationId())
.build();
Message message = objectMapper.readValue(new String(body, "UTF-8"), Message.class); Message message = objectMapper.readValue(new String(body, "UTF-8"), Message.class);
String tempInputDirPath = System.getProperty("java.io.tmpdir") + File.separator + "Input-" + Long.toString(System.nanoTime()) + File.separator; String tempInputDirPath = System.getProperty("java.io.tmpdir") + File.separator + "Input-" + Long.toString(System.nanoTime()) + File.separator;
File tempInputDir = new File(tempInputDirPath); File tempInputDir = new File(tempInputDirPath);
if (!(tempInputDir.mkdirs())) { if (!(tempInputDir.mkdirs())) {
throw new FileNotFoundException("Could not create input directory: " + tempInputDir.getAbsolutePath()); throw new FileNotFoundException("Could not create input directory: " + tempInputDir.getAbsolutePath());
} }
ProvisionerRPCService service = new ProvisionerRPCService(); ProvisionerRPCService service = new ProvisionerRPCService();
ToscaTemplate toscaTemplate = service.execute(message.getToscaTemplate()); ToscaTemplate toscaTemplate = service.execute(message.getToscaTemplate());
Message responceMessage = new Message();
responceMessage.setCreationDate(System.currentTimeMillis());
responceMessage.setToscaTemplate(toscaTemplate);
String response = objectMapper.writeValueAsString(responceMessage);
logger.log(Level.INFO, "Sending Response: '{'0'}'{0}", response); Message responceMessage = new Message();
responceMessage.setCreationDate(System.currentTimeMillis());
responceMessage.setToscaTemplate(toscaTemplate);
String response = objectMapper.writeValueAsString(responceMessage);
logger.log(Level.INFO, "Sending Response: '{'0'}'{0}", response);
// Logger.getLogger(Consumer.class.getName()).log(Level.INFO, "Sending Response: {0}", response); // Logger.getLogger(Consumer.class.getName()).log(Level.INFO, "Sending Response: {0}", response);
//We send the response back. No need to change anything here //We send the response back. No need to change anything here
channel.basicPublish("", properties.getReplyTo(), replyProps, response.getBytes("UTF-8")); channel.basicPublish("", properties.getReplyTo(), replyProps, response.getBytes("UTF-8"));
channel.basicAck(envelope.getDeliveryTag(), false); channel.basicAck(envelope.getDeliveryTag(), false);
} catch (JSchException ex) {
Logger.getLogger(Consumer.class.getName()).log(Level.SEVERE, null, ex);
}
} }
......
...@@ -55,6 +55,7 @@ class ProvisionerRPCService { ...@@ -55,6 +55,7 @@ class ProvisionerRPCService {
subnetMap.put("name", "subnet" + counter++); subnetMap.put("name", "subnet" + counter++);
subnetMap.put("subnet", subnetValue.split("/")[0]); subnetMap.put("subnet", subnetValue.split("/")[0]);
subnetMap.put("netmask", subnetValue.split("/")[1]); subnetMap.put("netmask", subnetValue.split("/")[1]);
Object members = null;
subnetMap.put("members", members); subnetMap.put("members", members);
subnets.add(subnetMap); subnets.add(subnetMap);
} }
......
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