Commit d81db714 authored by Spiros Koulouzis's avatar Spiros Koulouzis

format TOSCA output

parent 03233112
...@@ -2,9 +2,32 @@ ...@@ -2,9 +2,32 @@
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="462ede19-adfe-472b-975e-fefefa973fe0" name="Default Changelist" comment="slolved cap error"> <list default="true" id="462ede19-adfe-472b-975e-fefefa973fe0" name="Default Changelist" comment="slolved cap error">
<change beforePath="$PROJECT_DIR$/../TOSCA/types/capabilities.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/../TOSCA/types/capabilities.yaml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/../TOSCA/application_example.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/../TOSCA/application_example.yaml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../TOSCA/types/nodes.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/../TOSCA/types/nodes.yaml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/../drip-api/src/main/java/nl/uva/sne/drip/api/rpc/DRIPCaller.java" beforeDir="false" afterPath="$PROJECT_DIR$/../drip-api/src/main/java/nl/uva/sne/drip/api/rpc/DRIPCaller.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-api/src/main/java/nl/uva/sne/drip/controller/PlannerController.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-api/src/main/java/nl/uva/sne/drip/controller/ProvisionController.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-api/src/main/java/nl/uva/sne/drip/service/CloudStormService.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-api/src/main/java/nl/uva/sne/drip/service/PlannerService.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-commons/src/main/java/nl/uva/sne/drip/drip/commons/model/tosca/Artifact.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-commons/src/main/java/nl/uva/sne/drip/drip/commons/model/tosca/Attribute.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-commons/src/main/java/nl/uva/sne/drip/drip/commons/model/tosca/Constraint.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-commons/src/main/java/nl/uva/sne/drip/drip/commons/model/tosca/EntrySchema.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-commons/src/main/java/nl/uva/sne/drip/drip/commons/model/tosca/Interface.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-commons/src/main/java/nl/uva/sne/drip/drip/commons/model/tosca/Property.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-commons/src/main/java/nl/uva/sne/drip/drip/commons/model/tosca/PropertyStatus.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-commons/src/main/java/nl/uva/sne/drip/drip/commons/model/tosca/Requirement.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-commons/src/main/java/nl/uva/sne/drip/drip/commons/model/tosca/capabilities/Capabilities.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-commons/src/main/java/nl/uva/sne/drip/drip/commons/model/tosca/nodes/NodeState.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-commons/src/main/java/nl/uva/sne/drip/drip/commons/model/tosca/nodes/RootNode.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/planner/basic_planner.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/planner/basic_planner.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/rpc_server.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/rpc_server.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/venv/lib/python3.6/site-packages/easy-install.pth" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/venv/lib/python3.6/site-packages/prettytable.py" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/venv/lib/python3.6/site-packages/pyparsing.py" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/venv/lib/python3.6/site-packages/setuptools-40.8.0-py3.6.egg" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/venv/lib/python3.6/site-packages/setuptools.pth" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/venv/lib/python3.6/site-packages/six.py" beforeDir="false" />
</list> </list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
...@@ -78,7 +101,7 @@ ...@@ -78,7 +101,7 @@
<option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/src/rpc_server.py" /> <option name="SCRIPT_NAME" value="$PROJECT_DIR$/src/rpc_server.py" />
<option name="PARAMETERS" value="" /> <option name="PARAMETERS" value="test_local" />
<option name="SHOW_COMMAND_LINE" value="false" /> <option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" /> <option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" /> <option name="MODULE_MODE" value="false" />
...@@ -145,11 +168,6 @@ ...@@ -145,11 +168,6 @@
<line>95</line> <line>95</line>
<option name="timeStamp" value="2" /> <option name="timeStamp" value="2" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/src/rpc_server.py</url>
<line>98</line>
<option name="timeStamp" value="3" />
</line-breakpoint>
</breakpoints> </breakpoints>
<default-breakpoints> <default-breakpoints>
<breakpoint type="python-exception"> <breakpoint type="python-exception">
......
...@@ -115,10 +115,14 @@ class BasicPlanner: ...@@ -115,10 +115,14 @@ class BasicPlanner:
logging.info('The TOSCA template in: ' + path + ' has no requirements') logging.info('The TOSCA template in: ' + path + ' has no requirements')
tp = TOSCAParser() tp = TOSCAParser()
yaml_str = tp.tosca_template2_yaml(self.template) yaml_str = tp.tosca_template2_yaml(self.template)
yaml_str = yaml_str.replace('tosca_definitions_version: tosca_simple_yaml_1_0', '')
logging.info('TOSCA template: \n' + yaml_str) yaml_str = yaml_str.replace('description: TOSCA example', '')
yaml_str = yaml_str.replace('tosca_template', 'topology_template')
# print(yaml_str) self.formatted_yaml_str = 'tosca_definitions_version: tosca_simple_yaml_1_0\nrepositories:\n docker_hub: https://hub.docker.com/\n'+yaml_str
# logging.info('TOSCA template: \n' + formatted_yaml_str)
def get_plan(self):
return self.formatted_yaml_str
def get_missing_requirements(self, node): def get_missing_requirements(self, node):
logging.info('Looking for requirements for node: ' + node.name) logging.info('Looking for requirements for node: ' + node.name)
......
...@@ -6,14 +6,14 @@ import json ...@@ -6,14 +6,14 @@ import json
import logging import logging
import os import os
import os.path import os.path
from os.path import expanduser from builtins import print
import pika
from planner.winery_planner import *
from planner.basic_planner import * from planner.basic_planner import *
import pika
import sys import sys
import tempfile import tempfile
import time import time
import logging import logging
import base64
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
if not getattr(logger, 'handler_set', None): if not getattr(logger, 'handler_set', None):
...@@ -76,8 +76,8 @@ def handle_delivery(message): ...@@ -76,8 +76,8 @@ def handle_delivery(message):
current_milli_time = lambda: int(round(time.time() * 1000)) current_milli_time = lambda: int(round(time.time() * 1000))
rabbit = DRIPLoggingHandler(host=rabbitmq_host, port=5672, user=owner) #rabbit = DRIPLoggingHandler(host=rabbitmq_host, port=5672, user=owner)
logger.addHandler(rabbit) #logger.addHandler(rabbit)
try: try:
tosca_file_path = tempfile.gettempdir() + "/planner_files/" + str(current_milli_time()) + "/" tosca_file_path = tempfile.gettempdir() + "/planner_files/" + str(current_milli_time()) + "/"
...@@ -96,15 +96,15 @@ def handle_delivery(message): ...@@ -96,15 +96,15 @@ def handle_delivery(message):
response["creationDate"] = current_milli_time() response["creationDate"] = current_milli_time()
response["parameters"] = [] response["parameters"] = []
if queue_name == "planner_queue": if queue_name == "planner_queue":
planner = DumpPlanner(tosca_file_path + "/" + tosca_file_name + ".yml"); planner = BasicPlanner(tosca_file_path + "/" + tosca_file_name + ".yml")
vm_nodes = planner.plan(max_vms) plan = planner.get_plan()
for vm in vm_nodes:
parameter = {} parameter = {}
parameter['value'] = str(json.dumps(vm)) encodedBytes = base64.b64encode(plan.encode("utf-8"))
parameter['name'] = 'vm' encodedStr = str(encodedBytes, "utf-8")
parameter['value'] = encodedStr
parameter['name'] = 'tosca_plan'
parameter['encoding'] = 'UTF-8' parameter['encoding'] = 'UTF-8'
response["parameters"].append(parameter) response["parameters"].append(parameter)
logger.info("Returning plan") logger.info("Returning plan")
logger.info("Output message:" + json.dumps(response)) logger.info("Output message:" + json.dumps(response))
return json.dumps(response) return json.dumps(response)
...@@ -118,8 +118,9 @@ if __name__ == "__main__": ...@@ -118,8 +118,9 @@ if __name__ == "__main__":
# namespace = "http%253A%252F%252Fsne.uva.nl%252Fservicetemplates" # namespace = "http%253A%252F%252Fsne.uva.nl%252Fservicetemplates"
# servicetemplate_id = "wordpress_w1-wip1" # servicetemplate_id = "wordpress_w1-wip1"
# planner = WineryPlanner(tosca_reposetory_api_base_url,namespace,servicetemplate_id) # planner = WineryPlanner(tosca_reposetory_api_base_url,namespace,servicetemplate_id)
tosca_file_path = "../../TOSCA/application_example_output.yaml" tosca_file_path = "../../TOSCA/application_example.yaml"
planner = BasicPlanner(tosca_file_path) planner = BasicPlanner(tosca_file_path)
print(planner.get_plan())
else: else:
logger.info("Input args: " + sys.argv[0] + ' ' + sys.argv[1] + ' ' + sys.argv[2]) logger.info("Input args: " + sys.argv[0] + ' ' + sys.argv[1] + ' ' + sys.argv[2])
channel = init_chanel(sys.argv) channel = init_chanel(sys.argv)
......
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