thor.xsl 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. ################################################################################
  4. # HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
  5. #
  6. # Licensed under the Apache License, Version 2.0 (the "License");
  7. # you may not use this file except in compliance with the License.
  8. # You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. ################################################################################
  18. -->
  19. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  20. xmlns:fo="http://www.w3.org/1999/XSL/Format" xml:space="default">
  21. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"/>
  22. <xsl:param name="process" select="'thor'"/>
  23. <xsl:param name="isLinuxInstance" select="0"/>
  24. <xsl:param name="tempPath" select="'c:\temp\'"/>
  25. <xsl:param name="outputFilePath"/>
  26. <xsl:variable name="oldPathSeparator">
  27. <xsl:choose>
  28. <xsl:when test="$isLinuxInstance = 1">'\:'</xsl:when>
  29. <xsl:otherwise>'/$'</xsl:otherwise>
  30. </xsl:choose>
  31. </xsl:variable>
  32. <xsl:variable name="newPathSeparator">
  33. <xsl:choose>
  34. <xsl:when test="$isLinuxInstance = 1">'/$'</xsl:when>
  35. <xsl:otherwise>'\:'</xsl:otherwise>
  36. </xsl:choose>
  37. </xsl:variable>
  38. <xsl:template match="/">
  39. <xsl:apply-templates select="/Environment/Software/ThorCluster[@name=$process]"/>
  40. </xsl:template>
  41. <!-- directories -->
  42. <xsl:template match="@externalProgDir">
  43. <xsl:attribute name="{name()}">
  44. <xsl:variable name="tempdirvar" select="translate(., $oldPathSeparator, $newPathSeparator)"/>
  45. <xsl:if test="$isLinuxInstance=1 and not(starts-with($tempdirvar, '/'))">/</xsl:if>
  46. <xsl:value-of select="$tempdirvar"/>
  47. </xsl:attribute>
  48. </xsl:template>
  49. <!-- pluginsPath is a relative path handled differently from above directories -->
  50. <xsl:template match="@pluginsPath">
  51. <xsl:attribute name="pluginsPath">
  52. <xsl:variable name="path" select="translate(., '/$', '\:')"/>
  53. <xsl:variable name="path2">
  54. <xsl:choose>
  55. <xsl:when test="starts-with($path, '.\')">
  56. <!--skip .\ prefix -->
  57. <xsl:value-of select="substring($path, 3)"/>
  58. </xsl:when>
  59. <xsl:otherwise>
  60. <xsl:value-of select="$path"/>
  61. </xsl:otherwise>
  62. </xsl:choose>
  63. </xsl:variable>
  64. <xsl:variable name="len" select="string-length($path2)"/>
  65. <xsl:variable name="path3">
  66. <xsl:choose>
  67. <xsl:when test="$len > 0">
  68. <xsl:value-of select="$path2"/>
  69. <xsl:if test="not(substring($path2, number($len)-1, 1) = '\')">\</xsl:if>
  70. </xsl:when>
  71. <xsl:otherwise>plugins\</xsl:otherwise>
  72. </xsl:choose>
  73. </xsl:variable>
  74. <xsl:value-of select="translate($path3, $oldPathSeparator, $newPathSeparator)"/>
  75. </xsl:attribute>
  76. </xsl:template>
  77. <xsl:template match="@daliServers">
  78. <xsl:attribute name="{name()}">
  79. <xsl:variable name="dali" select="."/>
  80. <xsl:for-each select="/Environment/Software/DaliServerProcess[@name=$dali]/Instance">
  81. <xsl:call-template name="getNetAddress">
  82. <xsl:with-param name="computer" select="@computer"/>
  83. </xsl:call-template>
  84. <xsl:if test="string(@port) != ''">:<xsl:value-of select="@port"/>
  85. </xsl:if>
  86. <xsl:if test="position() != last()">, </xsl:if>
  87. </xsl:for-each>
  88. </xsl:attribute>
  89. </xsl:template>
  90. <!--eat attributes not needed to be generated or those which would be processed somewhere else -->
  91. <xsl:template match="@build|@buildSet|@computer|@description|@directory"/>
  92. <xsl:template match="@*">
  93. <xsl:copy-of select="."/>
  94. </xsl:template>
  95. <xsl:template match="ThorCluster">
  96. <xsl:variable name="masterport" select="@masterport"/>
  97. <xsl:variable name="slaveport" select="@slaveport"/>
  98. <xsl:variable name="masternode" select="ThorMasterProcess/@computer"/>
  99. <xsl:for-each select="/Environment/Software/ThorCluster[@name!=string($process)]">
  100. <xsl:variable name="thismasterport" select="@masterport"/>
  101. <xsl:variable name="thisthor" select="@name"/>
  102. <xsl:for-each select="ThorMasterProcess[@computer=$masternode]">
  103. <xsl:if test="string($thismasterport)=string($masterport)">
  104. <xsl:message terminate="yes">
  105. There cannot be more than one ThorCluster ('<xsl:value-of select="$process"/>' and '<xsl:value-of select="$thisthor"/>') with the same thor master '"<xsl:value-of select="$masternode"/>' and same thor master port '<xsl:value-of select="$masterport"/>!
  106. </xsl:message>
  107. </xsl:if>
  108. </xsl:for-each>
  109. </xsl:for-each>
  110. <xsl:for-each select="ThorSlaveProcess">
  111. <xsl:variable name="slavenode" select="@computer"/>
  112. <xsl:if test=" count(/Environment/Software/DafilesrvProcess/Instance[@computer=$slavenode]) = 0">
  113. <xsl:message terminate="yes">
  114. '<xsl:value-of select="$slavenode"/>' slave is not assigned to a Dafilesrv process.
  115. </xsl:message>
  116. </xsl:if>
  117. <xsl:if test=" count(/Environment/Software/FTSlaveProcess/Instance[@computer=$slavenode]) = 0">
  118. <xsl:message terminate="yes">
  119. '<xsl:value-of select="$slavenode"/>' slave is not assigned to a FT Slave process.
  120. </xsl:message>
  121. </xsl:if>
  122. <xsl:for-each select="/Environment/Software/ThorCluster[@name!=string($process)]">
  123. <xsl:variable name="thisslaveport" select="@slaveport"/>
  124. <xsl:if test="string($thisslaveport)=string($slaveport)">
  125. <xsl:if test="count(ThorSlaveProcess[@computer=$slavenode]) > 0">
  126. <xsl:message terminate="yes">
  127. There cannot be more than one ThorCluster ('<xsl:value-of select="$process"/>' and '<xsl:value-of select="@name"/>') with the same thor slave '"<xsl:value-of select="$slavenode"/>' and thor slave port '<xsl:value-of select="$slaveport"/>'!
  128. </xsl:message>
  129. </xsl:if>
  130. </xsl:if>
  131. </xsl:for-each>
  132. </xsl:for-each>
  133. <xsl:for-each select="ThorSpareProcess">
  134. <xsl:variable name="thorSpareNode" select="@computer"/>
  135. <xsl:if test=" count(/Environment/Software/DafilesrvProcess/Instance[@computer=$thorSpareNode]) = 0">
  136. <xsl:message terminate="yes">
  137. '<xsl:value-of select="$thorSpareNode"/>' spare is not assigned to a Dafilesrv process.
  138. </xsl:message>
  139. </xsl:if>
  140. <xsl:if test=" count(/Environment/Software/FTSlaveProcess/Instance[@computer=$thorSpareNode]) = 0">
  141. <xsl:message terminate="yes">
  142. '<xsl:value-of select="$thorSpareNode"/>' spare is not assigned to a FT Slave process.
  143. </xsl:message>
  144. </xsl:if>
  145. </xsl:for-each>
  146. <Thor>
  147. <xsl:attribute name="name">
  148. <xsl:value-of select="@name"/>
  149. </xsl:attribute>
  150. <xsl:attribute name="nodeGroup">
  151. <xsl:choose>
  152. <xsl:when test="string(@nodeGroup) = ''">
  153. <xsl:value-of select="@name"/>
  154. </xsl:when>
  155. <xsl:otherwise>
  156. <xsl:value-of select="@nodeGroup"/>
  157. </xsl:otherwise>
  158. </xsl:choose>
  159. </xsl:attribute>
  160. <xsl:attribute name="outputNodeGroup">
  161. <xsl:choose>
  162. <xsl:when test="string(@outputNodeGroup) = ''">
  163. <xsl:choose>
  164. <xsl:when test="string(@nodeGroup) = ''">
  165. <xsl:value-of select="@name"/>
  166. </xsl:when>
  167. <xsl:otherwise>
  168. <xsl:value-of select="@nodeGroup"/>
  169. </xsl:otherwise>
  170. </xsl:choose>
  171. </xsl:when>
  172. <xsl:otherwise>
  173. <xsl:value-of select="@outputNodeGroup"/>
  174. </xsl:otherwise>
  175. </xsl:choose>
  176. </xsl:attribute>
  177. <xsl:apply-templates select="@*[string(.) != '']"/>
  178. <xsl:copy-of select="/Environment/Software/Directories"/>
  179. <xsl:copy-of select="/Environment/Hardware/cost"/>
  180. @XSL_PLUGIN_DEFINITION@
  181. <Debug>
  182. <xsl:for-each select="Debug/@*">
  183. <xsl:if test="string(.) != ''">
  184. <xsl:copy-of select="."/>
  185. </xsl:if>
  186. </xsl:for-each>
  187. </Debug>
  188. <SSH>
  189. <xsl:for-each select="SSH/@*">
  190. <xsl:if test="string(.) != ''">
  191. <xsl:copy-of select="."/>
  192. </xsl:if>
  193. </xsl:for-each>
  194. </SSH>
  195. </Thor>
  196. </xsl:template>
  197. <xsl:template name="getNetAddress">
  198. <xsl:param name="computer"/>
  199. <xsl:value-of select="/Environment/Hardware/Computer[@name=$computer]/@netAddress"/>
  200. </xsl:template>
  201. <xsl:template name="GetPathName">
  202. <xsl:param name="path"/>
  203. <xsl:if test="contains($path, '\')">
  204. <xsl:variable name="prefix" select="substring-before($path, '\')"/>
  205. <xsl:value-of select="concat($prefix, '\')"/>
  206. <xsl:call-template name="GetPathName">
  207. <xsl:with-param name="path" select="substring-after($path, '\')"/>
  208. </xsl:call-template>
  209. </xsl:if>
  210. </xsl:template>
  211. </xsl:stylesheet>