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;
@Component
public class PlannerController {
@Autowired
private ToscaService toscaService;
@Autowired
private SimplePlannerService simplePlannerService;
......@@ -62,8 +59,8 @@ public class PlannerController {
String plan(@PathVariable("tosca_id") String toscaId) {
try {
Plan plan = simplePlannerService.getPlan(toscaId);
// Plan plan = plannerService.getPlan(toscaId);
// Plan plan = simplePlannerService.getPlan(toscaId);
Plan plan = plannerService.getPlan(toscaId);
if (plan == null) {
throw new NotFoundException("Could not make plan");
}
......
......@@ -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.commons.types.Message;
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.utils.Converter;
import org.json.JSONException;
......@@ -45,7 +46,7 @@ public class PlannerService {
@Value("${message.broker.host}")
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)) {
Message plannerInvokationMessage = buildPlannerMessage(toscaId);
......
No preview for this file type
......@@ -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.queue_declare(queue='planner_queue')
def handleDelivery(message):
parsed_json = json.loads(message)
params = parsed_json["parameters"]
for param in params:
name = param["name"]
parsed_json_message = json.loads(message)
params = parsed_json_message["parameters"]
param = params[0]
value = param["value"]
parsed_json_value = json.loads(value)
topology_template = parsed_json_value['topology_template']
node_templates = topology_template["node_templates"]
def on_request(ch, method, props, body):
handleDelivery(body)
print(" Message %s" % body)
response = "AAAAAAAAAAAAAAAAAAAAAA"
json1 = response.get('parameters')[0].get('value').get('topology_template').get('node_templates')
json1 = node_templates
deadline = 0
for j in json1:
......@@ -122,9 +119,13 @@ def on_request(ch, method, props, body):
par1["value"] = res1
par1["attributes"] = "null"
outcontent["parameters"].append(par1)
return outcontent
response = outcontent
def on_request(ch, method, props, body):
response = handleDelivery(body)
ch.basic_publish(exchange='',
routing_key=props.reply_to,
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