1 | <?xml version="1.0" encoding="UTF-8"?> |
---|
2 | |
---|
3 | <!-- |
---|
4 | TO_DO: |
---|
5 | --> |
---|
6 | |
---|
7 | |
---|
8 | <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
---|
9 | xmlns:rtg="http://www.QosCosGrid.org/resourceDescription" |
---|
10 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
---|
11 | |
---|
12 | <xsl:strip-space elements="*"/> |
---|
13 | |
---|
14 | <xsl:output method="xml" version="1.0" encoding="UTF-8" omit-xml-declaration="yes" indent="yes"/> |
---|
15 | |
---|
16 | <!-- ===================================================== ====================================================== --> |
---|
17 | <xsl:variable name="AD_IDENTIFIER">AD_ID</xsl:variable> |
---|
18 | <xsl:variable name="RES_IDENTIFIER">RES_ID</xsl:variable> |
---|
19 | <xsl:variable name="GROUP_IDENTIFIER">GROUP_ID</xsl:variable> |
---|
20 | <xsl:variable name="GATEWAY">GATEWAY</xsl:variable> |
---|
21 | <!-- ===================================================== ====================================================== --> |
---|
22 | <xsl:template match="/"> |
---|
23 | <xsl:apply-templates select="/rtg:rtg"/> |
---|
24 | </xsl:template> |
---|
25 | <!-- ===================================================== ====================================================== --> |
---|
26 | <xsl:template match="rtg:rtg"> |
---|
27 | <xsl:element name="hostParameters"> |
---|
28 | |
---|
29 | <xsl:if test="rtg:context/rtg:defaultTimeInterval"> |
---|
30 | <xsl:element name="validity"> |
---|
31 | <xsl:call-template name="TIME_STATUS_TEMPLATE"> |
---|
32 | <xsl:with-param name="TIME_INTERVAL" select="rtg:context/rtg:defaultTimeInterval"/> |
---|
33 | </xsl:call-template> |
---|
34 | </xsl:element> |
---|
35 | </xsl:if> |
---|
36 | |
---|
37 | <xsl:if test="rtg:intraADInfo/rtg:compResource"> |
---|
38 | <xsl:element name="resources"> |
---|
39 | <xsl:apply-templates select="rtg:intraADInfo/rtg:compResource"/> |
---|
40 | </xsl:element> |
---|
41 | </xsl:if> |
---|
42 | |
---|
43 | <xsl:if test="rtg:intraADInfo/rtg:resourcesCommunicationGroup"> |
---|
44 | <xsl:element name="topology"> |
---|
45 | <xsl:apply-templates select="rtg:intraADInfo/rtg:resourcesCommunicationGroup"/> |
---|
46 | </xsl:element> |
---|
47 | </xsl:if> |
---|
48 | </xsl:element> |
---|
49 | </xsl:template> |
---|
50 | <!-- ===================================================== ====================================================== --> |
---|
51 | <xsl:template match="rtg:compResource"> |
---|
52 | <xsl:element name="computingResource"> |
---|
53 | <xsl:attribute name="resourceId"> |
---|
54 | <xsl:call-template name="IDENTIFIER_TEMPLATE"> |
---|
55 | <xsl:with-param name="AD_ID" select="../@adId"/> |
---|
56 | <xsl:with-param name="ID" select="@id"/> |
---|
57 | </xsl:call-template> |
---|
58 | </xsl:attribute> |
---|
59 | |
---|
60 | <xsl:element name="machineParameters"> |
---|
61 | <xsl:apply-templates select="rtg:resourceSpecificMetric" mode="METRIC_MODE"/> |
---|
62 | |
---|
63 | <xsl:variable name="TEMPLATE_ID" select="@templateIdRef"/> |
---|
64 | <xsl:apply-templates select="../rtg:compResourceTemplate[@id=$TEMPLATE_ID]/rtg:metric" mode="METRIC_MODE"> |
---|
65 | <xsl:with-param name="RES_ID"> |
---|
66 | <xsl:value-of select="@id"/> |
---|
67 | </xsl:with-param> |
---|
68 | </xsl:apply-templates> |
---|
69 | </xsl:element> |
---|
70 | |
---|
71 | <xsl:variable name="RES_ID" select="@id"/> |
---|
72 | |
---|
73 | <xsl:if test="../rtg:resourceAvailability[@resourceIdRef=$RES_ID]/rtg:resourceState[rtg:resourceState]"> |
---|
74 | <xsl:element name="availability"> |
---|
75 | <xsl:apply-templates select="../rtg:resourceAvailability[@resourceIdRef=$RES_ID]/rtg:resourceState[rtg:resourceState]"/> |
---|
76 | </xsl:element> |
---|
77 | </xsl:if> |
---|
78 | |
---|
79 | <xsl:element name="additionalProperties"> |
---|
80 | <xsl:element name="property"> |
---|
81 | <xsl:attribute name="name"> |
---|
82 | <xsl:value-of select="$AD_IDENTIFIER"/> |
---|
83 | </xsl:attribute> |
---|
84 | <xsl:value-of select="../@adId"/> |
---|
85 | </xsl:element> |
---|
86 | |
---|
87 | <xsl:element name="property"> |
---|
88 | <xsl:attribute name="name"> |
---|
89 | <xsl:value-of select="$RES_IDENTIFIER"/> |
---|
90 | </xsl:attribute> |
---|
91 | <xsl:value-of select="@id"/> |
---|
92 | </xsl:element> |
---|
93 | |
---|
94 | <xsl:element name="property"> |
---|
95 | <xsl:attribute name="name"> |
---|
96 | <xsl:value-of select="$GATEWAY"/> |
---|
97 | </xsl:attribute> |
---|
98 | <xsl:value-of select="@isGateway"/> |
---|
99 | </xsl:element> |
---|
100 | </xsl:element> |
---|
101 | |
---|
102 | </xsl:element> |
---|
103 | </xsl:template> |
---|
104 | <!-- ===================================================== ====================================================== --> |
---|
105 | <xsl:template match="*" mode="METRIC_MODE"> |
---|
106 | <xsl:param name="RES_ID"/> |
---|
107 | |
---|
108 | <xsl:choose> |
---|
109 | <xsl:when test="@xsi:type='cpuCount'"> |
---|
110 | <xsl:call-template name="PARAMETER_TEMPLATE"> |
---|
111 | <xsl:with-param name="TYPE">hostParameter</xsl:with-param> |
---|
112 | <xsl:with-param name="NAME">cpucount</xsl:with-param> |
---|
113 | <xsl:with-param name="RES_ID"><xsl:value-of select="$RES_ID"/></xsl:with-param> |
---|
114 | <xsl:with-param name="METRIC">cpuCount</xsl:with-param> |
---|
115 | </xsl:call-template> |
---|
116 | </xsl:when> |
---|
117 | <xsl:when test="@xsi:type='cpuSpeed'"> |
---|
118 | <xsl:call-template name="PARAMETER_TEMPLATE"> |
---|
119 | <xsl:with-param name="TYPE">hostParameter</xsl:with-param> |
---|
120 | <xsl:with-param name="NAME">cpuspeed</xsl:with-param> |
---|
121 | </xsl:call-template> |
---|
122 | </xsl:when> |
---|
123 | <xsl:when test="@xsi:type='memoryTotal'"> |
---|
124 | <xsl:call-template name="PARAMETER_TEMPLATE"> |
---|
125 | <xsl:with-param name="TYPE">hostParameter</xsl:with-param> |
---|
126 | <xsl:with-param name="NAME">memory</xsl:with-param> |
---|
127 | </xsl:call-template> |
---|
128 | </xsl:when> |
---|
129 | <xsl:when test="@xsi:type='diskTotal'"> |
---|
130 | <xsl:call-template name="PARAMETER_TEMPLATE"> |
---|
131 | <xsl:with-param name="TYPE">hostParameter</xsl:with-param> |
---|
132 | <xsl:with-param name="NAME">diskspace</xsl:with-param> |
---|
133 | </xsl:call-template> |
---|
134 | </xsl:when> |
---|
135 | <xsl:when test="@xsi:type='swapTotal'"> |
---|
136 | <xsl:call-template name="PARAMETER_TEMPLATE"> |
---|
137 | <xsl:with-param name="TYPE">otherParameter</xsl:with-param> |
---|
138 | <xsl:with-param name="NAME">swap</xsl:with-param> |
---|
139 | </xsl:call-template> |
---|
140 | </xsl:when> |
---|
141 | |
---|
142 | <xsl:when test="@xsi:type='cpuType'"> |
---|
143 | <xsl:call-template name="PARAMETER_TEMPLATE"> |
---|
144 | <xsl:with-param name="TYPE">hostParameter</xsl:with-param> |
---|
145 | <xsl:with-param name="NAME">cpuarch</xsl:with-param> |
---|
146 | </xsl:call-template> |
---|
147 | </xsl:when> |
---|
148 | <xsl:when test="@xsi:type='osName'"> |
---|
149 | <xsl:call-template name="PARAMETER_TEMPLATE"> |
---|
150 | <xsl:with-param name="TYPE">hostParameter</xsl:with-param> |
---|
151 | <xsl:with-param name="NAME">osname</xsl:with-param> |
---|
152 | </xsl:call-template> |
---|
153 | </xsl:when> |
---|
154 | <xsl:when test="@xsi:type='osVersion'"> |
---|
155 | <xsl:call-template name="PARAMETER_TEMPLATE"> |
---|
156 | <xsl:with-param name="TYPE">hostParameter</xsl:with-param> |
---|
157 | <xsl:with-param name="NAME">osversion</xsl:with-param> |
---|
158 | </xsl:call-template> |
---|
159 | </xsl:when> |
---|
160 | <xsl:when test="@xsi:type='hostName'"> |
---|
161 | <xsl:call-template name="PARAMETER_TEMPLATE"> |
---|
162 | <xsl:with-param name="TYPE">hostParameter</xsl:with-param> |
---|
163 | <xsl:with-param name="NAME">hostname</xsl:with-param> |
---|
164 | </xsl:call-template> |
---|
165 | </xsl:when> |
---|
166 | <xsl:when test="@xsi:type='ip'"> |
---|
167 | <xsl:call-template name="PARAMETER_TEMPLATE"> |
---|
168 | <xsl:with-param name="TYPE">otherParameter</xsl:with-param> |
---|
169 | <xsl:with-param name="NAME">ip</xsl:with-param> |
---|
170 | </xsl:call-template> |
---|
171 | </xsl:when> |
---|
172 | |
---|
173 | <xsl:when test="@xsi:type='bandwidth'"> |
---|
174 | <xsl:call-template name="PARAMETER_TEMPLATE"> |
---|
175 | <xsl:with-param name="TYPE">networkParameter</xsl:with-param> |
---|
176 | <xsl:with-param name="NAME">bandwidth</xsl:with-param> |
---|
177 | </xsl:call-template> |
---|
178 | </xsl:when> |
---|
179 | <xsl:when test="@xsi:type='latency'"> |
---|
180 | <xsl:call-template name="PARAMETER_TEMPLATE"> |
---|
181 | <xsl:with-param name="TYPE">networkParameter</xsl:with-param> |
---|
182 | <xsl:with-param name="NAME">latency</xsl:with-param> |
---|
183 | </xsl:call-template> |
---|
184 | </xsl:when> |
---|
185 | |
---|
186 | <xsl:otherwise> |
---|
187 | <xsl:call-template name="PARAMETER_TEMPLATE"> |
---|
188 | <xsl:with-param name="TYPE">otherParameter</xsl:with-param> |
---|
189 | <xsl:with-param name="NAME"><xsl:value-of select="@xsi:type"/></xsl:with-param> |
---|
190 | </xsl:call-template> |
---|
191 | </xsl:otherwise> |
---|
192 | |
---|
193 | </xsl:choose> |
---|
194 | </xsl:template> |
---|
195 | <!-- ===================================================== ====================================================== --> |
---|
196 | <xsl:template name="PARAMETER_TEMPLATE"> |
---|
197 | <xsl:param name="TYPE"/> |
---|
198 | <xsl:param name="NAME"/> |
---|
199 | <xsl:param name="RES_ID" select="FALSE"/> |
---|
200 | <xsl:param name="METRIC" select="FALSE"/> |
---|
201 | |
---|
202 | <xsl:element name="{$TYPE}"> |
---|
203 | <xsl:attribute name="name"> |
---|
204 | <xsl:value-of select="$NAME"/> |
---|
205 | </xsl:attribute> |
---|
206 | |
---|
207 | <xsl:apply-templates mode="PARAMETER_VALUE_MODE"/> |
---|
208 | |
---|
209 | <xsl:if test="$RES_ID"> |
---|
210 | <xsl:apply-templates select="../../rtg:resourceAvailability[@resourceIdRef=$RES_ID]/rtg:resourceState/rtg:metricAvailability[rtg:metric/@xsi:type=$METRIC]"/> |
---|
211 | </xsl:if> |
---|
212 | |
---|
213 | </xsl:element> |
---|
214 | </xsl:template> |
---|
215 | <!-- ===================================================== ====================================================== --> |
---|
216 | <xsl:template match="rtg:rangeValue" mode="PARAMETER_VALUE_MODE"> |
---|
217 | <xsl:element name="paramValue"> |
---|
218 | <xsl:value-of select="rtg:value"/> |
---|
219 | </xsl:element> |
---|
220 | </xsl:template> |
---|
221 | <!-- ===================================================== ====================================================== --> |
---|
222 | <xsl:template match="rtg:value" mode="PARAMETER_VALUE_MODE"> |
---|
223 | <xsl:element name="paramValue"> |
---|
224 | <xsl:value-of select="."/> |
---|
225 | </xsl:element> |
---|
226 | </xsl:template> |
---|
227 | <!-- ===================================================== ====================================================== --> |
---|
228 | <xsl:template match="rtg:resourceState"> |
---|
229 | <xsl:call-template name="TIME_STATUS_TEMPLATE"> |
---|
230 | <xsl:with-param name="STATUS" select="rtg:resourceState"/> |
---|
231 | <xsl:with-param name="TIME_INTERVAL" select="rtg:timeInterval"/> |
---|
232 | </xsl:call-template> |
---|
233 | </xsl:template> |
---|
234 | <!-- ===================================================== ====================================================== --> |
---|
235 | <xsl:template name="TIME_STATUS_TEMPLATE"> |
---|
236 | <xsl:param name="STATUS" select="FALSE"/> |
---|
237 | <xsl:param name="TIME_INTERVAL"/> |
---|
238 | |
---|
239 | <xsl:if test="$TIME_INTERVAL"> |
---|
240 | <xsl:element name="timeSlot"> |
---|
241 | <xsl:if test="$STATUS"> |
---|
242 | <xsl:attribute name="state"> |
---|
243 | <xsl:value-of select="$STATUS"/> |
---|
244 | </xsl:attribute> |
---|
245 | </xsl:if> |
---|
246 | <xsl:apply-templates select="$TIME_INTERVAL" mode="TIME_INTERVAL_MODE"/> |
---|
247 | </xsl:element> |
---|
248 | </xsl:if> |
---|
249 | </xsl:template> |
---|
250 | <!-- ===================================================== ====================================================== --> |
---|
251 | <xsl:template match="*" mode="TIME_INTERVAL_MODE"> |
---|
252 | <xsl:element name="slotStart"> |
---|
253 | <xsl:value-of select="rtg:lowerBoundedRange"/> |
---|
254 | </xsl:element> |
---|
255 | <xsl:choose> |
---|
256 | <xsl:when test="rtg:upperBoundedRange"> |
---|
257 | <xsl:element name="slotEnd"> |
---|
258 | <xsl:value-of select="rtg:upperBoundedRange"/> |
---|
259 | </xsl:element> |
---|
260 | </xsl:when> |
---|
261 | <xsl:when test="rtg:duration"> |
---|
262 | <xsl:element name="slotDuration"> |
---|
263 | <xsl:value-of select="rtg:duration"/> |
---|
264 | </xsl:element> |
---|
265 | </xsl:when> |
---|
266 | </xsl:choose> |
---|
267 | </xsl:template> |
---|
268 | <!-- ===================================================== ====================================================== --> |
---|
269 | <xsl:template match="rtg:metricAvailability"> |
---|
270 | <xsl:element name="availability"> |
---|
271 | <xsl:call-template name="TIME_STATUS_TEMPLATE"> |
---|
272 | <xsl:with-param name="STATUS" select="rtg:state"/> |
---|
273 | <xsl:with-param name="TIME_INTERVAL" select="../rtg:timeInterval"/> |
---|
274 | </xsl:call-template> |
---|
275 | </xsl:element> |
---|
276 | </xsl:template> |
---|
277 | <!-- ===================================================== ====================================================== --> |
---|
278 | <!-- ===================================================== ====================================================== --> |
---|
279 | <xsl:template match="rtg:resourcesCommunicationGroup"> |
---|
280 | <xsl:element name="resourcesGroup"> |
---|
281 | <xsl:attribute name="groupId"> |
---|
282 | <xsl:call-template name="IDENTIFIER_TEMPLATE"> |
---|
283 | <xsl:with-param name="AD_ID" select="../@adId"/> |
---|
284 | <xsl:with-param name="ID" select="@groupId"/> |
---|
285 | </xsl:call-template> |
---|
286 | </xsl:attribute> |
---|
287 | |
---|
288 | <xsl:element name="resources"> |
---|
289 | <xsl:apply-templates select="rtg:resourceIdRef"> |
---|
290 | </xsl:apply-templates> |
---|
291 | </xsl:element> |
---|
292 | |
---|
293 | <xsl:element name="networkParamsInsideGroup"> |
---|
294 | <xsl:variable name="NET_ID" select="@netResourceIdRef"/> |
---|
295 | <xsl:apply-templates select="../rtg:netResource[@id=$NET_ID]"/> |
---|
296 | </xsl:element> |
---|
297 | |
---|
298 | <xsl:variable name="AD_ID" select="../@adId"/> |
---|
299 | <xsl:variable name="GROUP_ID" select="@groupId"/> |
---|
300 | <xsl:apply-templates select="/rtg:rtg/rtg:interADInfo/rtg:link[@fromAdId=$AD_ID and @fromGroupId=$GROUP_ID]"/> |
---|
301 | |
---|
302 | <xsl:element name="additionalProperties"> |
---|
303 | <xsl:element name="property"> |
---|
304 | <xsl:attribute name="name"> |
---|
305 | <xsl:value-of select="$AD_IDENTIFIER"/> |
---|
306 | </xsl:attribute> |
---|
307 | <xsl:value-of select="$AD_ID"/> |
---|
308 | </xsl:element> |
---|
309 | <xsl:element name="property"> |
---|
310 | <xsl:attribute name="name"> |
---|
311 | <xsl:value-of select="$GROUP_IDENTIFIER"/> |
---|
312 | </xsl:attribute> |
---|
313 | <xsl:value-of select="$GROUP_ID"/> |
---|
314 | </xsl:element> |
---|
315 | <xsl:element name="property"> |
---|
316 | <xsl:attribute name="name"> |
---|
317 | <xsl:value-of select="$GATEWAY"/> |
---|
318 | </xsl:attribute> |
---|
319 | <xsl:value-of select="@isGateway"/> |
---|
320 | </xsl:element> |
---|
321 | |
---|
322 | |
---|
323 | </xsl:element> |
---|
324 | |
---|
325 | </xsl:element> |
---|
326 | </xsl:template> |
---|
327 | <!-- ===================================================== ====================================================== --> |
---|
328 | <xsl:template match="rtg:resourceIdRef"> |
---|
329 | |
---|
330 | <xsl:element name="computingResourceIdRef"> |
---|
331 | <xsl:value-of select="."/> |
---|
332 | </xsl:element> |
---|
333 | </xsl:template> |
---|
334 | <!-- ===================================================== ====================================================== --> |
---|
335 | <xsl:template match="rtg:netResource"> |
---|
336 | <xsl:variable name="TEMPLATE_ID" select="@templateIdRef"/> |
---|
337 | <xsl:apply-templates select="../rtg:netResourceTemplate[@id=$TEMPLATE_ID]/rtg:metric" mode="METRIC_MODE"/> |
---|
338 | </xsl:template> |
---|
339 | <!-- ===================================================== ====================================================== --> |
---|
340 | <xsl:template match="rtg:link"> |
---|
341 | <xsl:element name="networkParamsToGroup"> |
---|
342 | <xsl:attribute name="groupId"> |
---|
343 | <xsl:call-template name="IDENTIFIER_TEMPLATE"> |
---|
344 | <xsl:with-param name="AD_ID" select="@toAdId"/> |
---|
345 | <xsl:with-param name="ID" select="@toGroupId"/> |
---|
346 | </xsl:call-template> |
---|
347 | </xsl:attribute> |
---|
348 | <xsl:attribute name="isSymmetric"> |
---|
349 | <xsl:value-of select="../@isSymmetric"/> |
---|
350 | </xsl:attribute> |
---|
351 | |
---|
352 | <xsl:variable name="NET_AD_ID" select="@adIdRef"/> |
---|
353 | <xsl:variable name="NET_ID" select="@netResourceIdRef"/> |
---|
354 | <xsl:apply-templates select="/rtg:rtg/rtg:intraADInfo[@adId=$NET_AD_ID]/rtg:netResource[@id=$NET_ID]"/> |
---|
355 | |
---|
356 | <xsl:element name="additionalProperties"> |
---|
357 | <xsl:element name="property"> |
---|
358 | <xsl:attribute name="name"> |
---|
359 | <xsl:value-of select="$AD_IDENTIFIER"/> |
---|
360 | </xsl:attribute> |
---|
361 | <xsl:value-of select="@toAdId"/> |
---|
362 | </xsl:element> |
---|
363 | <xsl:element name="property"> |
---|
364 | <xsl:attribute name="name"> |
---|
365 | <xsl:value-of select="$GROUP_IDENTIFIER"/> |
---|
366 | </xsl:attribute> |
---|
367 | <xsl:value-of select="@toGroupId"/> |
---|
368 | </xsl:element> |
---|
369 | </xsl:element> |
---|
370 | |
---|
371 | </xsl:element> |
---|
372 | </xsl:template> |
---|
373 | <!-- ===================================================== ====================================================== --> |
---|
374 | <!-- ===================================================== ====================================================== --> |
---|
375 | <xsl:template name="IDENTIFIER_TEMPLATE"> |
---|
376 | <xsl:param name="AD_ID"/> |
---|
377 | <xsl:param name="ID"/> |
---|
378 | |
---|
379 | <xsl:value-of select="$AD_ID"/> |
---|
380 | <xsl:value-of select="'-'"/> |
---|
381 | <xsl:value-of select="$ID"/> |
---|
382 | </xsl:template> |
---|
383 | <!-- ===================================================== ====================================================== --> |
---|
384 | <xsl:template match="*"> |
---|
385 | BRAK OBSLUGI DLA = <xsl:value-of select="name()"/> |
---|
386 | </xsl:template> |
---|
387 | <!-- ===================================================== ====================================================== --> |
---|
388 | </xsl:transform> |
---|