Commit a9d4ea29 authored by Spiros Koulouzis's avatar Spiros Koulouzis

started new planner. This is a simple planner where for each container asignes on medium VM

parent c0c06b7d
...@@ -13,3 +13,5 @@ ...@@ -13,3 +13,5 @@
/drip-tests/target/ /drip-tests/target/
/docs/playbooks/euroArgo_conf_playbook2.yml /docs/playbooks/euroArgo_conf_playbook2.yml
/Dockerfiles/env_file /Dockerfiles/env_file
/argo_optimizer/nbproject/private/
/drip_planner2/nbproject/private/
\ No newline at end of file
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
<h1 class="page-header">Files and Libraries</h1> <h1 class="page-header">Files and Libraries</h1>
<h3 id="artifact_gwt_json_overlay">GWT JSON Overlay</h3> <h3 id="artifact_gwt_json_overlay">GWT JSON Overlay</h3>
<p class="lead">Created October 3, 2017</p> <p class="lead">Created October 4, 2017</p>
<p> <p> <p> <p>
The <a href="http://code.google.com/webtoolkit/">Google Web Toolkit</a> JSON Overlay library provides the JSON Overlays that The <a href="http://code.google.com/webtoolkit/">Google Web Toolkit</a> JSON Overlay library provides the JSON Overlays that
can be used to access the Web service API for this application. can be used to access the Web service API for this application.
...@@ -97,7 +97,7 @@ ...@@ -97,7 +97,7 @@
</tbody> </tbody>
</table> </table>
<h3 id="artifact_java_json_client_library">Java JSON Client Library</h3> <h3 id="artifact_java_json_client_library">Java JSON Client Library</h3>
<p class="lead">Created October 3, 2017</p> <p class="lead">Created October 4, 2017</p>
<p><p> <p><p>
The Java client-side library is used to provide the set of Java objects that can be serialized The Java client-side library is used to provide the set of Java objects that can be serialized
to/from JSON using <a href="http://jackson.codehaus.org/">Jackson</a>. This is useful for accessing the to/from JSON using <a href="http://jackson.codehaus.org/">Jackson</a>. This is useful for accessing the
...@@ -127,7 +127,7 @@ ...@@ -127,7 +127,7 @@
</tbody> </tbody>
</table> </table>
<h3 id="artifact_java_xml_client_library">Java XML Client Library</h3> <h3 id="artifact_java_xml_client_library">Java XML Client Library</h3>
<p class="lead">Created October 3, 2017</p> <p class="lead">Created October 4, 2017</p>
<p><p> <p><p>
The Java client-side library is used to access the Web service API for this application using Java. The Java client-side library is used to access the Web service API for this application using Java.
</p> </p>
...@@ -155,7 +155,7 @@ ...@@ -155,7 +155,7 @@
</tbody> </tbody>
</table> </table>
<h3 id="artifact_js_client_library">JavaScript Client Library</h3> <h3 id="artifact_js_client_library">JavaScript Client Library</h3>
<p class="lead">Created October 3, 2017</p> <p class="lead">Created October 4, 2017</p>
<p><p> <p><p>
The JavaScript client-side library defines classes that can be (de)serialized to/from JSON. The JavaScript client-side library defines classes that can be (de)serialized to/from JSON.
This is useful for accessing the resources that are published by this application, but only This is useful for accessing the resources that are published by this application, but only
...@@ -190,7 +190,7 @@ ...@@ -190,7 +190,7 @@
</tbody> </tbody>
</table> </table>
<h3 id="artifact_php_json_client_library">PHP JSON Client Library</h3> <h3 id="artifact_php_json_client_library">PHP JSON Client Library</h3>
<p class="lead">Created October 3, 2017</p> <p class="lead">Created October 4, 2017</p>
<p><p> <p><p>
The PHP JSON client-side library defines the PHP classes that can be (de)serialized to/from JSON. The PHP JSON client-side library defines the PHP classes that can be (de)serialized to/from JSON.
This is useful for accessing the resources that are published by this application, but only This is useful for accessing the resources that are published by this application, but only
...@@ -219,7 +219,7 @@ ...@@ -219,7 +219,7 @@
</tbody> </tbody>
</table> </table>
<h3 id="artifact_php_xml_client_library">PHP XML Client Library</h3> <h3 id="artifact_php_xml_client_library">PHP XML Client Library</h3>
<p class="lead">Created October 3, 2017</p> <p class="lead">Created October 4, 2017</p>
<p><p> <p><p>
The PHP client-side library defines the PHP classes that can be (de)serialized to/from XML. The PHP client-side library defines the PHP classes that can be (de)serialized to/from XML.
This is useful for accessing the resources that are published by this application, but only This is useful for accessing the resources that are published by this application, but only
...@@ -251,7 +251,7 @@ ...@@ -251,7 +251,7 @@
</tbody> </tbody>
</table> </table>
<h3 id="artifact_ruby_json_client_library">Ruby JSON Client Library</h3> <h3 id="artifact_ruby_json_client_library">Ruby JSON Client Library</h3>
<p class="lead">Created October 3, 2017</p> <p class="lead">Created October 4, 2017</p>
<p><p> <p><p>
The Ruby JSON client-side library defines the Ruby classes that can be (de)serialized to/from JSON. The Ruby JSON client-side library defines the Ruby classes that can be (de)serialized to/from JSON.
This is useful for accessing the REST endpoints that are published by this application, but only This is useful for accessing the REST endpoints that are published by this application, but only
......
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
<h1 class="page-header">Files and Libraries</h1> <h1 class="page-header">Files and Libraries</h1>
<h3 id="artifact_gwt_json_overlay">GWT JSON Overlay</h3> <h3 id="artifact_gwt_json_overlay">GWT JSON Overlay</h3>
<p class="lead">Created October 3, 2017</p> <p class="lead">Created October 4, 2017</p>
<p> <p> <p> <p>
The <a href="http://code.google.com/webtoolkit/">Google Web Toolkit</a> JSON Overlay library provides the JSON Overlays that The <a href="http://code.google.com/webtoolkit/">Google Web Toolkit</a> JSON Overlay library provides the JSON Overlays that
can be used to access the Web service API for this application. can be used to access the Web service API for this application.
...@@ -97,7 +97,7 @@ ...@@ -97,7 +97,7 @@
</tbody> </tbody>
</table> </table>
<h3 id="artifact_java_json_client_library">Java JSON Client Library</h3> <h3 id="artifact_java_json_client_library">Java JSON Client Library</h3>
<p class="lead">Created October 3, 2017</p> <p class="lead">Created October 4, 2017</p>
<p><p> <p><p>
The Java client-side library is used to provide the set of Java objects that can be serialized The Java client-side library is used to provide the set of Java objects that can be serialized
to/from JSON using <a href="http://jackson.codehaus.org/">Jackson</a>. This is useful for accessing the to/from JSON using <a href="http://jackson.codehaus.org/">Jackson</a>. This is useful for accessing the
...@@ -127,7 +127,7 @@ ...@@ -127,7 +127,7 @@
</tbody> </tbody>
</table> </table>
<h3 id="artifact_java_xml_client_library">Java XML Client Library</h3> <h3 id="artifact_java_xml_client_library">Java XML Client Library</h3>
<p class="lead">Created October 3, 2017</p> <p class="lead">Created October 4, 2017</p>
<p><p> <p><p>
The Java client-side library is used to access the Web service API for this application using Java. The Java client-side library is used to access the Web service API for this application using Java.
</p> </p>
...@@ -155,7 +155,7 @@ ...@@ -155,7 +155,7 @@
</tbody> </tbody>
</table> </table>
<h3 id="artifact_js_client_library">JavaScript Client Library</h3> <h3 id="artifact_js_client_library">JavaScript Client Library</h3>
<p class="lead">Created October 3, 2017</p> <p class="lead">Created October 4, 2017</p>
<p><p> <p><p>
The JavaScript client-side library defines classes that can be (de)serialized to/from JSON. The JavaScript client-side library defines classes that can be (de)serialized to/from JSON.
This is useful for accessing the resources that are published by this application, but only This is useful for accessing the resources that are published by this application, but only
...@@ -190,7 +190,7 @@ ...@@ -190,7 +190,7 @@
</tbody> </tbody>
</table> </table>
<h3 id="artifact_php_json_client_library">PHP JSON Client Library</h3> <h3 id="artifact_php_json_client_library">PHP JSON Client Library</h3>
<p class="lead">Created October 3, 2017</p> <p class="lead">Created October 4, 2017</p>
<p><p> <p><p>
The PHP JSON client-side library defines the PHP classes that can be (de)serialized to/from JSON. The PHP JSON client-side library defines the PHP classes that can be (de)serialized to/from JSON.
This is useful for accessing the resources that are published by this application, but only This is useful for accessing the resources that are published by this application, but only
...@@ -219,7 +219,7 @@ ...@@ -219,7 +219,7 @@
</tbody> </tbody>
</table> </table>
<h3 id="artifact_php_xml_client_library">PHP XML Client Library</h3> <h3 id="artifact_php_xml_client_library">PHP XML Client Library</h3>
<p class="lead">Created October 3, 2017</p> <p class="lead">Created October 4, 2017</p>
<p><p> <p><p>
The PHP client-side library defines the PHP classes that can be (de)serialized to/from XML. The PHP client-side library defines the PHP classes that can be (de)serialized to/from XML.
This is useful for accessing the resources that are published by this application, but only This is useful for accessing the resources that are published by this application, but only
...@@ -251,7 +251,7 @@ ...@@ -251,7 +251,7 @@
</tbody> </tbody>
</table> </table>
<h3 id="artifact_ruby_json_client_library">Ruby JSON Client Library</h3> <h3 id="artifact_ruby_json_client_library">Ruby JSON Client Library</h3>
<p class="lead">Created October 3, 2017</p> <p class="lead">Created October 4, 2017</p>
<p><p> <p><p>
The Ruby JSON client-side library defines the Ruby classes that can be (de)serialized to/from JSON. The Ruby JSON client-side library defines the Ruby classes that can be (de)serialized to/from JSON.
This is useful for accessing the REST endpoints that are published by this application, but only This is useful for accessing the REST endpoints that are published by this application, but only
......
...@@ -128,7 +128,7 @@ public abstract class DRIPCaller implements AutoCloseable { ...@@ -128,7 +128,7 @@ public abstract class DRIPCaller implements AutoCloseable {
clean = clean.replaceAll("\"null\"", "null"); clean = clean.replaceAll("\"null\"", "null");
} }
Logger.getLogger(DRIPCaller.class.getName()).log(Level.INFO, "Got: {0}", clean); Logger.getLogger(DRIPCaller.class.getName()).log(Level.INFO, "Got: {0}", clean);
return mapper.readValue(clean, Message.class); return mapper.readValue(clean, Message.class);
} }
} }
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>drip_planner2</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.python.pydev.PyDevBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.python.pydev.pythonNature</nature>
</natures>
</projectDescription>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse-pydev version="1.0"?><pydev_project>
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
<path>/${PROJECT_DIR_NAME}</path>
</pydev_pathproperty>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
</pydev_project>
java.lib.path=
main.file=rpc_server.py
platform.active=Python_2.7.12
python.lib.path=
src.dir=src
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.python.project</type>
<configuration>
<data xmlns="http://nbpython.dev.java.net/ns/php-project/1">
<name>drip_planner2</name>
<sources>
<root id="src.dir"/>
</sources>
<tests/>
</data>
</configuration>
</project>
# To change this license header, choose License Headers in Project Properties.
# To change this template file, choose Tools | Templates
# and open the template in the editor.
import argparse
import getopt
import json
import networkx as nx
import numpy as np
import operator
import os
import pika
import random
import re
import sys
import time
from toscaparser import *
from toscaparser.tosca_template import ToscaTemplate
def init_chanel(args):
if len(args) > 1:
rabbitmq_host = args[1]#sys.argv[1]
else:
rabbitmq_host = '127.0.0.1'
connection = pika.BlockingConnection(pika.ConnectionParameters(host=rabbitmq_host))
channel = connection.channel()
channel.queue_declare(queue='planner_queue')
return channel
def start(channel):
channel.basic_qos(prefetch_count=1)
channel.basic_consume(on_request, queue='planner_queue')
print(" [x] Awaiting RPC requests")
channel.start_consuming()
def on_request(ch, method, props, body):
response = handle_delivery(body)
ch.basic_publish(exchange='',
routing_key=props.reply_to,
properties=pika.BasicProperties(correlation_id=\
props.correlation_id),
body=str(response))
ch.basic_ack(delivery_tag=method.delivery_tag)
def handle_delivery(message):
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"]
response = {}
current_milli_time = lambda: int(round(time.time() * 1000))
response["creationDate"] = current_milli_time()
response["parameters"] = []
for nodes in node_templates:
if "Switch.nodes.Application.Container.Docker." in node_templates[nodes]['type']:
node_keys = node_templates[nodes].keys()
if 'artifacts' in node_keys:
artifact_key = next(iter(node_templates[nodes]['artifacts']))
artifact_keys = node_templates[nodes]['artifacts'][artifact_key].keys()
if 'file' in artifact_keys:
docker = node_templates[nodes]['artifacts'][artifact_key]['file']
elif 'docker_image' in artifact_keys:
docker = node_templates[nodes]['artifacts']['docker_image']['file']
result = {}
parameter = {}
result['name'] = nodes
result['size'] = 'Medium'
result['docker'] = docker
parameter['value'] = str(json.dumps(result))
parameter['attributes'] = 'null'
parameter["url"] = "null"
parameter["encoding"] = "UTF-8"
response["parameters"].append(parameter)
print ("Output message: %s" % json.dumps(response))
return json.dumps(response)
if __name__ == "__main__":
print sys.argv
channel = init_chanel(sys.argv)
start(channel)
from setuptools import setup, find_packages
setup (
name='drip_planner2',
version='0.1',
packages=find_packages(),
# Declare your packages' dependencies here, for eg:
install_requires=['foo>=3'],
# Fill in these to make your Egg ready for upload to
# PyPI
author='S. Koulouzis',
author_email='',
#summary = 'Just another Python package for the cheese shop',
url='',
license='',
long_description='Long description of the package',
# could also include long_description, download_url, classifiers, etc.
)
\ No newline at end of file
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