Commit 93f050a4 authored by Spiros Koulouzis's avatar Spiros Koulouzis

Parse input message correctly

parent 86b8f9db
...@@ -47,9 +47,6 @@ import org.springframework.web.bind.annotation.RequestParam; ...@@ -47,9 +47,6 @@ import org.springframework.web.bind.annotation.RequestParam;
@Component @Component
public class PlannerController { public class PlannerController {
@Autowired
private ToscaService toscaService;
@Autowired @Autowired
private SimplePlannerService simplePlannerService; private SimplePlannerService simplePlannerService;
...@@ -62,8 +59,8 @@ public class PlannerController { ...@@ -62,8 +59,8 @@ public class PlannerController {
String plan(@PathVariable("tosca_id") String toscaId) { String plan(@PathVariable("tosca_id") String toscaId) {
try { try {
Plan plan = simplePlannerService.getPlan(toscaId); // Plan plan = simplePlannerService.getPlan(toscaId);
// Plan plan = plannerService.getPlan(toscaId); Plan plan = plannerService.getPlan(toscaId);
if (plan == null) { if (plan == null) {
throw new NotFoundException("Could not make plan"); throw new NotFoundException("Could not make plan");
} }
......
...@@ -25,6 +25,7 @@ import nl.uva.sne.drip.api.exception.BadRequestException; ...@@ -25,6 +25,7 @@ import nl.uva.sne.drip.api.exception.BadRequestException;
import nl.uva.sne.drip.api.rpc.PlannerCaller; import nl.uva.sne.drip.api.rpc.PlannerCaller;
import nl.uva.sne.drip.commons.types.Message; import nl.uva.sne.drip.commons.types.Message;
import nl.uva.sne.drip.commons.types.MessageParameter; import nl.uva.sne.drip.commons.types.MessageParameter;
import nl.uva.sne.drip.commons.types.Plan;
import nl.uva.sne.drip.commons.types.ToscaRepresentation; import nl.uva.sne.drip.commons.types.ToscaRepresentation;
import nl.uva.sne.drip.commons.utils.Converter; import nl.uva.sne.drip.commons.utils.Converter;
import org.json.JSONException; import org.json.JSONException;
...@@ -45,7 +46,7 @@ public class PlannerService { ...@@ -45,7 +46,7 @@ public class PlannerService {
@Value("${message.broker.host}") @Value("${message.broker.host}")
private String messageBrokerHost; private String messageBrokerHost;
public ToscaRepresentation getPlan(String toscaId) throws JSONException, UnsupportedEncodingException, IOException, TimeoutException, InterruptedException { public Plan getPlan(String toscaId) throws JSONException, UnsupportedEncodingException, IOException, TimeoutException, InterruptedException {
try (PlannerCaller planner = new PlannerCaller(messageBrokerHost)) { try (PlannerCaller planner = new PlannerCaller(messageBrokerHost)) {
Message plannerInvokationMessage = buildPlannerMessage(toscaId); Message plannerInvokationMessage = buildPlannerMessage(toscaId);
......
No preview for this file type
...@@ -17,27 +17,24 @@ import json ...@@ -17,27 +17,24 @@ import json
connection = pika.BlockingConnection(pika.ConnectionParameters(host='172.17.0.2')) connection = pika.BlockingConnection(pika.ConnectionParameters(host='172.17.0.3'))
channel = connection.channel() channel = connection.channel()
channel.queue_declare(queue='planner_queue') channel.queue_declare(queue='planner_queue')
def handleDelivery(message): def handleDelivery(message):
parsed_json = json.loads(message) parsed_json_message = json.loads(message)
params = parsed_json["parameters"] params = parsed_json_message["parameters"]
for param in params: param = params[0]
name = param["name"] value = param["value"]
value = param["value"]
parsed_json_value = json.loads(value)
def on_request(ch, method, props, body): topology_template = parsed_json_value['topology_template']
handleDelivery(body) node_templates = topology_template["node_templates"]
print(" Message %s" % body)
response = "AAAAAAAAAAAAAAAAAAAAAA" json1 = node_templates
json1 = response.get('parameters')[0].get('value').get('topology_template').get('node_templates')
deadline = 0 deadline = 0
for j in json1: for j in json1:
...@@ -122,9 +119,13 @@ def on_request(ch, method, props, body): ...@@ -122,9 +119,13 @@ def on_request(ch, method, props, body):
par1["value"] = res1 par1["value"] = res1
par1["attributes"] = "null" par1["attributes"] = "null"
outcontent["parameters"].append(par1) outcontent["parameters"].append(par1)
return outcontent return outcontent
response = outcontent
def on_request(ch, method, props, body):
response = handleDelivery(body)
ch.basic_publish(exchange='', ch.basic_publish(exchange='',
routing_key=props.reply_to, routing_key=props.reply_to,
properties=pika.BasicProperties(correlation_id = \ properties=pika.BasicProperties(correlation_id = \
......
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