Commit dd0fedf3 authored by WorkflowPlanning's avatar WorkflowPlanning Committed by GitHub

Add files via upload

parent 1f8ca025
...@@ -17,19 +17,27 @@ import json ...@@ -17,19 +17,27 @@ import json
connection = pika.BlockingConnection(pika.ConnectionParameters(host='172.17.0.3')) connection = pika.BlockingConnection(pika.ConnectionParameters(host='172.17.0.2'))
channel = connection.channel() channel = connection.channel()
channel.queue_declare(queue='planner_queue') channel.queue_declare(queue='planner_queue')
def on_request(ch, method, props, body):
def handleDelivery(message):
parsed_message = json.loads(body) parsed_json = json.loads(message)
value = parsed_message.get('parameters')[0].get('value') params = parsed_json["parameters"]
parsed_value = json.loads(value) for param in params:
name = param["name"]
json1 = parsed_value.get('topology_template').get('node_templates') value = param["value"]
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')
deadline = 0 deadline = 0
for j in json1: for j in json1:
...@@ -93,24 +101,29 @@ def on_request(ch, method, props, body): ...@@ -93,24 +101,29 @@ def on_request(ch, method, props, body):
#print content['workflow'] #print content['workflow']
#return #return
res = wf.generateJSON() res = wf.generateJSON()
end = time.time() end = time.time()
print (end - start) print (end - start)
# convert the json to the file required
res1 = {}
for key, value in sorted_nodeDic:
print value, res[str(value)]
res1[nodeDic1[value]] = res[str(value)]
print res1
# generate the json files in the corresponding format as the # generate the json files in the corresponding format as the
outcontent = {} outcontent = {}
current_milli_time = lambda: int(round(time.time() * 1000)) outcontent["creationDate"] = 1487002029722
outcontent["creationDate"] = current_milli_time()
outcontent["parameters"] = [] outcontent["parameters"] = []
par1 = {} par1 = {}
par1["url"] = 'null' par1["url"] = "null"
par1["encoding"] = "UTF-8" par1["encoding"] = "UTF-8"
par1["name"] = "plan" par1["value"] = res1
par1["value"] = res par1["attributes"] = "null"
par1["attributes"] = 'null'
outcontent["parameters"].append(par1) outcontent["parameters"].append(par1)
return outcontent
response = outcontent response = outcontent
print(response)
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 = \
......
...@@ -114,7 +114,12 @@ def main(argv): ...@@ -114,7 +114,12 @@ def main(argv):
end = time.time() end = time.time()
print (end - start) print (end - start)
# convert the json to the file required
res1 = {}
for key, value in sorted_nodeDic:
print value, res[str(value)]
res1[nodeDic1[value]] = res[str(value)]
print res1
# generate the json files in the corresponding format as the # generate the json files in the corresponding format as the
outcontent = {} outcontent = {}
outcontent["creationDate"] = 1487002029722 outcontent["creationDate"] = 1487002029722
...@@ -122,7 +127,7 @@ def main(argv): ...@@ -122,7 +127,7 @@ def main(argv):
par1 = {} par1 = {}
par1["url"] = "null" par1["url"] = "null"
par1["encoding"] = "UTF-8" par1["encoding"] = "UTF-8"
par1["value"] = res par1["value"] = res1
par1["attributes"] = "null" par1["attributes"] = "null"
outcontent["parameters"].append(par1) outcontent["parameters"].append(par1)
return outcontent return outcontent
......
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