[CORD-1528] Allow to reference models already created
Change-Id: Icf1cab69e0939d84f7f9c01d774f4399df51a7a4
diff --git a/src/tosca/parser.py b/src/tosca/parser.py
index 029b6ed..7c4f429 100644
--- a/src/tosca/parser.py
+++ b/src/tosca/parser.py
@@ -1,4 +1,4 @@
-from toscaparser.tosca_template import ToscaTemplate
+from toscaparser.tosca_template import ToscaTemplate, ValidationError
from default import TOSCA_RECIPES_DIR
from grpc_client.resources import RESOURCES
from grpc_client.models_accessor import GRPCModelsAccessor
@@ -89,6 +89,8 @@
for line in msg.splitlines():
if line.strip().startswith('MissingRequiredFieldError'):
readable.append(line)
+ if line.strip().startswith('UnknownFieldError'):
+ readable.append(line)
if len(readable) > 0:
return '/n'.join(readable)
@@ -162,7 +164,7 @@
if class_name not in RESOURCES:
raise Exception("Nodetemplate %s's type %s is not a known resource" % (recipe.name, class_name))
model = GRPCModelsAccessor.get_model_from_classname(class_name, data)
- # [] populate model with data[[
+ # [] populate model with data
model = self.populate_model(model, data)
# [] check if the model has requirements
# [] if it has populate them
@@ -172,12 +174,11 @@
self.saved_model_by_name[recipe.name] = model
- except Exception as e:
- print e
+ except ValidationError as e:
if e.message:
- exception_msg = e.message
+ exception_msg = TOSCA_Parser._translate_exception(e.message)
else:
- exception_msg = str(e)
+ exception_msg = TOSCA_Parser._translate_exception(str(e))
raise Exception(exception_msg)
diff --git a/src/tosca/xtarget/tosca.xtarget b/src/tosca/xtarget/tosca.xtarget
index 313874b..2cdec9c 100644
--- a/src/tosca/xtarget/tosca.xtarget
+++ b/src/tosca/xtarget/tosca.xtarget
@@ -9,22 +9,10 @@
{{ m.name|lower }}:
type: tosca.capabilities.xos.{{ m.name }}
properties:
- no-delete:
+ must-exist:
type: boolean
default: false
- description: Do not allow Tosca to delete this object
- no-create:
- type: boolean
- default: false
- description: Do not allow Tosca to create this object
- no-update:
- type: boolean
- default: false
- description: Do not allow Tosca to update this object
- replaces:
- type: string
- required: false
- descrption: Replaces/renames this object
+ description: Allow to reference existing models in TOSCA recipes
{% for f in m.fields %}
{%- if not f.link -%}
{{ f.name }}: