aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlas Kozat <ulas.kozat@gmail.com>2016-06-10 21:38:16 -0700
committerUlas Kozat <ulas.kozat@gmail.com>2016-06-10 21:38:16 -0700
commit069277d5ac5cbd1b8e84bb15ed766825aa8059d3 (patch)
tree34958ab6eddc752a0d7a5531f7adb202222bb118
parent54ceb4a7a213805811c92583d519dce4d4ef6e3f (diff)
Added heat translation support
Change-Id: I9d2462e34eda9e052774be280984dd571ff14650 Signed-off-by: Ulas Kozat <ulas.kozat@gmail.com>
-rwxr-xr-xDominoServer.py19
-rw-r--r--lib/partitioner/partitioner.py4
2 files changed, 17 insertions, 6 deletions
diff --git a/DominoServer.py b/DominoServer.py
index 98a67e3..fc9f0ad 100755
--- a/DominoServer.py
+++ b/DominoServer.py
@@ -33,6 +33,8 @@ from thrift.server import TServer
from toscaparser.tosca_template import ToscaTemplate
#from toscaparser.utils.gettextutils import _
#import toscaparser.utils.urlutils
+from translator.hot.tosca_translator import TOSCATranslator
+
from mapper import *
from partitioner import *
@@ -279,13 +281,13 @@ class CommunicationHandler:
logging.debug('Selected Sites: %s', node_site)
# Create per-domain Tosca files
- file_paths = partitioner.partition_tosca('./toscafiles/template1.yaml',node_site,tosca.tpl)
+ file_paths = partitioner.partition_tosca('./toscafiles/template',node_site,tosca.tpl)
logging.debug('Per domain file paths: %s', file_paths)
- # Create list of translated template files
-
# Create work-flow
+
+
# Send domain templates to each domain agent/client
# FOR NOW: send untranslated but partitioned tosca files to scheduled sites
# TBD: read from work-flow
@@ -293,10 +295,19 @@ class CommunicationHandler:
domino_client_ip = self.dominoServer.registration_record[site].ipaddr
domino_client_port = self.dominoServer.registration_record[site].tcpport
try:
- template_lines = miscutil.read_templatefile(file_paths[site])
+ if 'hot' in self.dominoServer.subscribed_templateformats[site]:
+ tosca = ToscaTemplate(file_paths[site])
+ translator = TOSCATranslator(tosca, {}, False)
+ output = translator.translate()
+ logging.debug('HOT translation: \n %s', output)
+ template_lines = [ output ]
+ else:
+ template_lines = miscutil.read_templatefile(file_paths[site])
self.push_template(template_lines, domino_client_ip, domino_client_port)
except IOError as e:
logging.error('I/O error(%d): %s' , e.errno, e.strerror)
+ except:
+ logging.error('Error: %s', sys.exc_info()[0])
#Fill in the details
pub_r = PublishResponseMessage()
diff --git a/lib/partitioner/partitioner.py b/lib/partitioner/partitioner.py
index a098aca..f5b1546 100644
--- a/lib/partitioner/partitioner.py
+++ b/lib/partitioner/partitioner.py
@@ -45,8 +45,8 @@ def partition_tosca(filepath, nodesite, tpl):
for site in sitenodes:
tpl_l = tpl_local[site]
print tpl_l , '\n'
- file_paths[site] = filepath + '_part' + str(site)
- fout = open(filepath + '_part' + str(site),'w')
+ file_paths[site] = filepath + '_part' + str(site) + '.yaml'
+ fout = open(file_paths[site],'w')
if tpl_l.has_key('tosca_definitions_version'):
fout.write('tosca_definitions_version: ')