summaryrefslogtreecommitdiffstats
path: root/tosca2heat/heat-translator/translator/osc/v1
diff options
context:
space:
mode:
Diffstat (limited to 'tosca2heat/heat-translator/translator/osc/v1')
-rw-r--r--tosca2heat/heat-translator/translator/osc/v1/tests/fakes.py5
-rw-r--r--tosca2heat/heat-translator/translator/osc/v1/translate.py10
2 files changed, 13 insertions, 2 deletions
diff --git a/tosca2heat/heat-translator/translator/osc/v1/tests/fakes.py b/tosca2heat/heat-translator/translator/osc/v1/tests/fakes.py
index a08c3ac..3bab0b7 100644
--- a/tosca2heat/heat-translator/translator/osc/v1/tests/fakes.py
+++ b/tosca2heat/heat-translator/translator/osc/v1/tests/fakes.py
@@ -12,6 +12,8 @@
import sys
+import mock
+
class FakeApp(object):
def __init__(self):
@@ -20,6 +22,9 @@ class FakeApp(object):
self.stdout = sys.stdout
self.stderr = sys.stderr
+ self.cloud = mock.Mock()
+ self.cloud.get_session.return_value = None
+
class FakeClientManager(object):
def __init__(self):
diff --git a/tosca2heat/heat-translator/translator/osc/v1/translate.py b/tosca2heat/heat-translator/translator/osc/v1/translate.py
index ef005e2..afe3ba2 100644
--- a/tosca2heat/heat-translator/translator/osc/v1/translate.py
+++ b/tosca2heat/heat-translator/translator/osc/v1/translate.py
@@ -21,6 +21,8 @@ from cliff import command
from toscaparser.tosca_template import ToscaTemplate
from toscaparser.utils.gettextutils import _
+from translator.common import flavors
+from translator.common import images
from translator.common.utils import UrlUtils
from translator.conf.config import ConfigProvider
from translator.hot.tosca_translator import TOSCATranslator
@@ -35,7 +37,7 @@ class TranslateTemplate(command.Command):
"""Translate a template"""
- auth_required = False
+ auth_required = True
def get_parser(self, prog_name):
parser = super(TranslateTemplate, self).get_parser(prog_name)
@@ -73,6 +75,10 @@ class TranslateTemplate(command.Command):
'(%s).'), parsed_args)
output = None
+ session = self.app.cloud.get_session()
+ flavors.SESSION = session
+ images.SESSION = session
+
if parsed_args.parameter:
parsed_params = parsed_args.parameter
else:
@@ -94,7 +100,7 @@ class TranslateTemplate(command.Command):
translator = TOSCATranslator(tosca, parsed_params)
output = translator.translate()
else:
- msg = _('Could not find template file.')
+ msg = _('Could not find template file.\n')
log.error(msg)
sys.stdout.write(msg)
raise SystemExit