[CORD-1492] Adding tosca related functions in xosgenx jinja functions
Change-Id: I1ba1f5874a984a30645aa31a190dcd64d99b0938
diff --git a/lib/xos-genx/xosgenx/jinja2_extensions.py b/lib/xos-genx/xosgenx/jinja2_extensions.py
index 8377d5a..f07aa14 100644
--- a/lib/xos-genx/xosgenx/jinja2_extensions.py
+++ b/lib/xos-genx/xosgenx/jinja2_extensions.py
@@ -429,8 +429,18 @@
return options_str
-def xproto_tosca_required(blank):
- if blank == "False":
- return "true"
- return "false"
+def xproto_tosca_required(null, blank, default=None):
+
+ if null == 'True' or blank == 'True' or default != 'False':
+ return "false"
+ return "true"
+
+def xproto_tosca_field_type(type):
+ """
+ TOSCA requires fields of type 'bool' to be 'boolean'
+ """
+ if type == "bool":
+ return "boolean"
+ else:
+ return type
diff --git a/lib/xos-genx/xosgenx/targets/tosca.xtarget b/lib/xos-genx/xosgenx/targets/tosca.xtarget
deleted file mode 100644
index b5e51ae..0000000
--- a/lib/xos-genx/xosgenx/targets/tosca.xtarget
+++ /dev/null
@@ -1,31 +0,0 @@
-tosca_definitions_version: tosca_simple_yaml_1_0
-
-node_types:
-{% for m in proto.messages %}
- tosca.nodes.{{ m.name }}:
- derived_from: tosca.nodes.Root
- description: {{ m.name }}
- properties:
- no-delete:
- 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
- {%- for f in m.fields %}
- {{ f.name }}:
- type: {{ f.type }}
- required: {{ xproto_tosca_required(f.options.blank) }}
- description: {{ f.options.help_text }}
- {%- endfor %}
-{%- endfor %}
\ No newline at end of file