1 <!-- Licensed under the Apache License, Version 2.0 (the "License");
2 you may not use this file except in compliance with the License.
3 You may obtain a copy of the License at
4 http://www.apache.org/licenses/LICENSE-2.0
6 Unless required by applicable law or agreed to in writing, software
7 distributed under the License is distributed on an "AS IS" BASIS,
8 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9 See the License for the specific language governing permissions and limitations under the License.
11 <xsl:stylesheet version="1.0" xmlns:ns="urn:ietf:params:xml:ns:yang:yin:1" xmlns:y="urn:ietf:params:xml:ns:yang:ietf-vdus" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="t">
12 <xsl:output indent="no" method ="text"/>
14 <xsl:variable name="tosca_general">
15 <entry key="tosca_definitions_version">tosca_definitions_version:tosca_simple_yaml_1_0_0</entry>
16 <entry key="tosca_default_namespace">tosca_default_namespace:tosca_simple_yaml_1_0_0</entry>
17 <entry key="template_name">template_name:</entry>
18 <entry key="description">description:</entry>
19 <entry key="template_author">template_author:</entry>
20 <entry key="template_version">template_version:</entry>
21 <entry key="derived">derived_from:tosca.nodes.Root</entry>
22 <entry key="import">import:</entry>
24 <xsl:variable name="nodeTypes">
25 <entry key="generalvdus">type:tosca.nodes.general.vdus</entry>
26 <entry key="compute">type:tosca.nodes.compute</entry>
27 <entry key="storage">type:tosca.nodes.block.Storage</entry>
28 <entry key="network">type:tosca.nodes.network</entry>
29 <entry key="security">type:tosca.nodes.security</entry>
30 <entry key="policy">type:tosca.nodes.policy</entry>
33 <xsl:template match="ns:module">
34 <xsl:value-of select="concat(document('')//xsl:variable[@name='tosca_general']/entry[@key='tosca_definitions_version'] ,'
')" />
35 <xsl:value-of select="concat(document('')//xsl:variable[@name='tosca_general']/entry[@key='description'],'
	',ns:description/node()/text(),'
')" />
36 <xsl:value-of select="concat(document('')//xsl:variable[@name='tosca_general']/entry[@key='import'],'
	',ns:import/@module,'
')" />
38 ID: <xsl:value-of select="@name"/>
39 Vendor: <xsl:value-of select="ns:organization/node()/text()"/>
41 <xsl:for-each select="ns:container">
42 dsl_definitions:<xsl:for-each select="ns:list">
43 compute_props_host_<xsl:value-of select="@name"/>: <text disable-output-escaping="yes"><![CDATA[&]]>compute_props_host_</text><xsl:value-of select="@name"/>
44 <xsl:for-each select="ns:container"><xsl:if test="@name = 'resource'"><xsl:for-each select="ns:container"><xsl:if test="@name = 'cpu'"><xsl:variable name="num_cpu" select="ns:leaf/ns:type/ns:range/@value"/>
45 num_cpu: <xsl:value-of select="$num_cpu"/>
47 <xsl:if test="@name='memory'">
48 <xsl:variable name="memory" select="ns:leaf/ns:type/ns:range/@value"/>
49 mem_size: <xsl:value-of select="$memory"></xsl:value-of>
55 node_types:<xsl:for-each select="ns:list">
56 tosca.nodes.compute.<xsl:value-of select="@name"/>:
57 derived_from: tosca.nodes.compute
60 # A description of the topology template
62 <xsl:value-of select="ns:description/node()/text()"/>
65 type: scalar-unit.size<xsl:for-each select="ns:list"><xsl:if test="(@name != 'connection-points') and (@name != 'internal-virtual-link')">
66 <xsl:for-each select="ns:container"><xsl:if test="@name = 'resource'"><xsl:for-each select="ns:container"><xsl:if test="@name = 'disk'">
67 default: <xsl:value-of select="ns:leaf/ns:type/ns:range/@value"/>
68 description: <xsl:value-of select="ns:description/node()/text()"/>
69 </xsl:if></xsl:for-each></xsl:if></xsl:for-each>
70 </xsl:if></xsl:for-each>
74 Block storage mount point (filesystem path).
75 node_templates:<xsl:for-each select="ns:list"><xsl:if test="(@name != 'connection-points') and (@name != 'internal-virtual-link')">
76 <xsl:text>
		</xsl:text>
77 <xsl:value-of select="@name"/>:
78 type: tosca.nodes.Compute
87 properties: *compute_props_host_<xsl:value-of select="@name"/>
90 min_instances: <xsl:for-each select="ns:leaf"><xsl:if test="@name = 'instance-num'">
91 <xsl:value-of select="ns:default/@value"/>
92 </xsl:if></xsl:for-each>
93 default_instances: <xsl:for-each select="ns:leaf"><xsl:if test="@name = 'instance-num'">
94 <xsl:value-of select="ns:default/@value"/>
95 </xsl:if></xsl:for-each>
98 node: <xsl:value-of select="@name"/>_BlockStorage
102 location: { get_input:storage_location }
104 Standard:<xsl:for-each select="ns:container">
105 <xsl:if test="@name = 'workflow-script'">
106 <xsl:for-each select="ns:leaf">
108 <xsl:when test="@name = 'init'">
110 implementation: <xsl:value-of select="ns:default/@value"/>
112 <xsl:when test="@name='terminate'">
114 implementaion: <xsl:value-of select="ns:default/@value"/>
116 <xsl:when test="@name='graceful-shutdown'">
118 implementaion: <xsl:value-of select="ns:default/@value"/>
124 <xsl:for-each select="ns:container">
125 <xsl:if test="@name = 'auto-scale-policies'">
126 monitoring_policy:<xsl:for-each select="ns:list">
127 name: <xsl:value-of select="ns:key/@value"/>
128 parameters:<xsl:for-each select="../../ns:container"> <xsl:if test="@name = 'monitor-paras'">
129 <xsl:text>
				</xsl:text>
130 <xsl:for-each select="ns:leaf-list">
131 <xsl:for-each select="ns:type">
132 <xsl:for-each select="ns:enum">
133 <xsl:value-of select="@name"/>:
137 </xsl:if></xsl:for-each>
138 actions:<xsl:for-each select="ns:container"> <xsl:if test="@name = 'actions'">
139 <xsl:text>
				</xsl:text>
140 <xsl:for-each select="ns:list"> <xsl:value-of select="ns:key/@value"/>: <xsl:value-of select="ns:leaf/ns:type/ns:enum/@name"/> </xsl:for-each>
141 </xsl:if> </xsl:for-each>
142 </xsl:for-each></xsl:if></xsl:for-each>
143 <xsl:text>
		</xsl:text>
144 <xsl:variable name="vdu" select = "@name"/>
145 <xsl:value-of select="$vdu"/>_BlockStorage:
146 type: tosca.nodes.BlockStorage
148 size: { get_input:storage_size }</xsl:if></xsl:for-each><xsl:for-each select="ns:list"><xsl:for-each select="ns:container"><xsl:if test="@name = 'resource'"><xsl:for-each select="ns:container">
149 <xsl:if test="@name='vnic'">
150 <xsl:variable name="vnic" select="ns:leaf/ns:type/ns:range/@value"/>
151 <xsl:call-template name="nic.loop">
152 <xsl:with-param name="from" select="1"/>
153 <xsl:with-param name="to" select="$vnic"/>
160 <xsl:for-each select="ns:list">
161 <xsl:if test="@name='connection-points'">
162 <xsl:variable name="vnic" select="count(ns:leaf)"/>
163 <xsl:call-template name="cp.loop">
164 <xsl:with-param name="from" select="1"/>
165 <xsl:with-param name="to" select="$vnic"/>
169 <xsl:for-each select="ns:list">
170 <xsl:for-each select="ns:container"><xsl:if test="@name = 'resource'"><xsl:for-each select="ns:list"><xsl:if test="@name = 'network-interfaces'">
172 <xsl:variable name="vnic" select="count(ns:choice/ns:case)"/>
173 <xsl:call-template name="internalCP.loop">
174 <xsl:with-param name="from" select="1"/>
175 <xsl:with-param name="to" select="$vnic"/>
177 </xsl:if></xsl:for-each></xsl:if>
180 <xsl:for-each select="ns:list">
181 <xsl:if test="@name='internal-virtual-link'">
182 <xsl:variable name="vnic" select="count(ns:leaf-list)"/>
183 <xsl:call-template name="VL.loop">
184 <xsl:with-param name="from" select="1"/>
185 <xsl:with-param name="to" select="$vnic"/>
191 <xsl:template name="nic.loop">
192 <xsl:param name="from"/>
193 <xsl:param name="to"/>
194 <xsl:if test="$from <= $to">
195 <xsl:text>
	</xsl:text>
196 <xsl:value-of select="../../../@name"/>_network<xsl:value-of select="$from"/>:
197 type:tosca.nodes.network.Network
200 <xsl:value-of select="../../@name"/>_port<xsl:value-of select="$from"/>:
201 type:tosca.nodes.network.Port
204 node:<xsl:value-of select="../../@name"/>
206 node:<xsl:value-of select="../../../@name"/>_network<xsl:value-of select="$from"/>
207 <xsl:call-template name="nic.loop">
208 <xsl:with-param name="from" select="$from + 1"/>
209 <xsl:with-param name="to" select="$to"/>
213 <xsl:template name="cp.loop">
214 <xsl:param name="from"/>
215 <xsl:param name="to"/>
216 <xsl:if test="$from <= $to">
217 <xsl:text>
	</xsl:text>
218 <xsl:value-of select="ns:key/@value"/>:
219 #Endpoint for the VNF
220 type: tosca.nodes.nfv.CP
224 <xsl:call-template name="cp.loop">
225 <xsl:with-param name="from" select="$from + 1"/>
226 <xsl:with-param name="to" select="$to"/>
231 <xsl:template name="internalCP.loop">
232 <xsl:param name="from"/>
233 <xsl:param name="to"/>
234 <xsl:if test="$from <= $to">
235 <xsl:text>
	</xsl:text>
236 CP<xsl:value-of select="$from"/>:
237 type: tosca.nodes.nfv.CP
239 type:<xsl:value-of select="ns:choice/ns:case/ns:leaf/ns:type/@name"></xsl:value-of>
242 node: <xsl:value-of select="ns:choice/ns:case/ns:leaf/ns:type/ns:path/@value"/>
244 node: <xsl:value-of select="ns:choice/ns:case/ns:leaf/ns:type/ns:path/@value"/>
245 <xsl:call-template name="internalCP.loop">
246 <xsl:with-param name="from" select="$from + 1"/>
247 <xsl:with-param name="to" select="$to"/>
252 <xsl:template name="VL.loop">
253 <xsl:param name="from"/>
254 <xsl:param name="to"/>
255 <xsl:if test="$from <= $to">
256 <xsl:text>
	</xsl:text>
257 VL<xsl:value-of select="$from"/>:
258 type: tosca.nodes.nfv.VL
265 <xsl:call-template name="VL.loop">
266 <xsl:with-param name="from" select="$from + 1"/>
267 <xsl:with-param name="to" select="$to"/>