backupnode_vars.xsl 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. ################################################################################
  4. # HPCC SYSTEMS software Copyright (C) 2017 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" xmlns:fo="http://www.w3.org/1999/XSL/Format" xml:space="default">
  20. <xsl:output method="text" indent="no" omit-xml-declaration="yes"/>
  21. <xsl:strip-space elements="*"/>
  22. <xsl:param name="process" select="'unknown'"/>
  23. <xsl:template match="/">
  24. <xsl:apply-templates select="/Environment/Software"/>
  25. </xsl:template>
  26. <xsl:template match="BackupNodeProcess">
  27. <xsl:if test="@name = $process">
  28. <xsl:call-template name="printHeader">
  29. <xsl:with-param name="header" select="'default'"/>
  30. </xsl:call-template>
  31. <xsl:call-template name="printVariable">
  32. <xsl:with-param name="var" select="'thorlist'"/>
  33. <xsl:with-param name="val">
  34. <xsl:call-template name="getNodeList"/>
  35. </xsl:with-param>
  36. </xsl:call-template>
  37. <xsl:call-template name="printClusterDetails"/>
  38. </xsl:if>
  39. </xsl:template>
  40. <!-- getNodeList
  41. return NodeGroups in csv list
  42. -->
  43. <xsl:template name="getNodeList">
  44. <xsl:choose>
  45. <xsl:when test="NodeGroup">
  46. <xsl:for-each select="NodeGroup">
  47. <xsl:variable name="nodeName" select="@name"/>
  48. <xsl:for-each select="/Environment/Software/ThorCluster">
  49. <xsl:if test="($nodeName = @name) and (((@localThor = 'false' or not(@localThor)) and not(@nodeGroup)) or (@nodeGroup = @name))">
  50. <xsl:value-of select="@name"/><xsl:text>,</xsl:text>
  51. </xsl:if>
  52. </xsl:for-each>
  53. </xsl:for-each>
  54. </xsl:when>
  55. <xsl:otherwise>
  56. <xsl:for-each select="/Environment/Software/ThorCluster">
  57. <xsl:if test="((@localThor = 'false' or not(@localThor)) and not(@nodeGroup)) or (@nodeGroup = @name)">
  58. <xsl:value-of select="@name"/><xsl:text>,</xsl:text>
  59. </xsl:if>
  60. </xsl:for-each>
  61. </xsl:otherwise>
  62. </xsl:choose>
  63. </xsl:template>
  64. <!-- getNodeList -->
  65. <xsl:template name="printClusterDetails">
  66. <xsl:choose>
  67. <xsl:when test="NodeGroup">
  68. <xsl:for-each select="NodeGroup">
  69. <xsl:variable name="nodeName" select="@name"/>
  70. <xsl:variable name="interval" select="@interval"/>
  71. <xsl:for-each select="/Environment/Software/ThorCluster[@name=$nodeName]">
  72. <xsl:if test="((@localThor = 'false' or not(@localThor)) and not(@nodeGroup)) or (@nodeGroup = @name)">
  73. <xsl:call-template name="getThorClusterDetails">
  74. <xsl:with-param name="interval" select="$interval"/>
  75. </xsl:call-template>
  76. </xsl:if>
  77. </xsl:for-each>
  78. </xsl:for-each>
  79. </xsl:when>
  80. <xsl:otherwise>
  81. <xsl:for-each select="/Environment/Software/ThorCluster">
  82. <xsl:if test="((@localThor = 'false' or not(@localThor)) and not(@nodeGroup)) or (@nodeGroup = @name)">
  83. <xsl:call-template name="getThorClusterDetails">
  84. </xsl:call-template>
  85. </xsl:if>
  86. </xsl:for-each>
  87. </xsl:otherwise>
  88. </xsl:choose>
  89. </xsl:template>
  90. <!--getThorClusterDetails-->
  91. <!--
  92. [header]
  93. interval
  94. daliserver
  95. localthor
  96. thormaster
  97. thorprimary
  98. thorname
  99. SSHidentityfile
  100. SSHusername
  101. SSHpassword
  102. SSHtimeout
  103. SSHretries
  104. -->
  105. <xsl:template name="getThorClusterDetails">
  106. <xsl:param name="interval" select="12"/>
  107. <xsl:call-template name="printHeader">
  108. <xsl:with-param name="header" select="@name"/>
  109. </xsl:call-template>
  110. <xsl:call-template name="printVariable">
  111. <xsl:with-param name="var" select="'interval'"/>
  112. <xsl:with-param name="val" select="$interval"/>
  113. </xsl:call-template>
  114. <xsl:call-template name="printVariable">
  115. <xsl:with-param name="var" select="'daliserver'"/>
  116. <xsl:with-param name="val">
  117. <xsl:call-template name="getDaliServers">
  118. <xsl:with-param name="daliServer" select="@daliServers"/>
  119. </xsl:call-template>
  120. </xsl:with-param>
  121. </xsl:call-template>
  122. <xsl:call-template name="printVariable">
  123. <xsl:with-param name="var" select="'localthor'"/>
  124. <xsl:with-param name="val" select="@localThor"/>
  125. </xsl:call-template>
  126. <xsl:call-template name="printVariable">
  127. <xsl:with-param name="var" select="'thormaster'"/>
  128. <xsl:with-param name="val">
  129. <xsl:call-template name="getNetAddress">
  130. <xsl:with-param name="computer" select="ThorMasterProcess/@computer"/>
  131. </xsl:call-template>
  132. </xsl:with-param>
  133. </xsl:call-template>
  134. <xsl:call-template name="printVariable">
  135. <xsl:with-param name="var" select="'thorprimary'"/>
  136. <xsl:with-param name="val" select="@nodeGroup"/>
  137. </xsl:call-template>
  138. <xsl:call-template name="printVariable">
  139. <xsl:with-param name="var" select="'thorname'"/>
  140. <xsl:with-param name="val" select="@name"/>
  141. </xsl:call-template>
  142. <xsl:call-template name="printVariable">
  143. <xsl:with-param name="var" select="'SSHidentityfile'"/>
  144. <xsl:with-param name="val" select="SSH/@SSHidentityfile"/>
  145. </xsl:call-template>
  146. <xsl:call-template name="printVariable">
  147. <xsl:with-param name="var" select="'SSHusername'"/>
  148. <xsl:with-param name="val" select="SSH/@SSHusername"/>
  149. </xsl:call-template>
  150. <xsl:call-template name="printVariable">
  151. <xsl:with-param name="var" select="'SSHpassword'"/>
  152. <xsl:with-param name="val" select="SSH/@SSHpassword"/>
  153. </xsl:call-template>
  154. <xsl:call-template name="printVariable">
  155. <xsl:with-param name="var" select="'SSHtimeout'"/>
  156. <xsl:with-param name="val" select="SSH/@SSHtimeout"/>
  157. </xsl:call-template>
  158. <xsl:call-template name="printVariable">
  159. <xsl:with-param name="var" select="'SSHretries'"/>
  160. <xsl:with-param name="val" select="SSH/@SSHretries"/>
  161. </xsl:call-template>
  162. </xsl:template>
  163. <!--getThorClusterDetails-->
  164. <!-- printHeader -->
  165. <xsl:template name="printHeader">
  166. <xsl:param name="header"/>
  167. <xsl:text>[</xsl:text><xsl:value-of select="$header"/><xsl:text>]&#xa;</xsl:text>
  168. </xsl:template>
  169. <!-- printHeader -->
  170. <!-- printVariable -->
  171. <xsl:template name="printVariable">
  172. <xsl:param name="var"/>
  173. <xsl:param name="val"/>
  174. <xsl:value-of select="$var"/><xsl:text>=</xsl:text><xsl:value-of select="$val"/><xsl:text>&#xa;</xsl:text>
  175. </xsl:template>
  176. <!-- printVar -->
  177. <!--getDaliServers-->
  178. <xsl:template name="getDaliServers">
  179. <xsl:param name="daliServer"/>
  180. <xsl:for-each select="/Environment/Software/DaliServerProcess[@name=$daliServer]/Instance">
  181. <xsl:call-template name="getNetAddress">
  182. <xsl:with-param name="computer" select="@computer"/>
  183. </xsl:call-template>
  184. <xsl:if test="string(@port) != ''">:<xsl:value-of select="@port"/></xsl:if>
  185. <xsl:if test="position() != last()">, </xsl:if>
  186. </xsl:for-each>
  187. </xsl:template>
  188. <!--getDaliServers-->
  189. <!--getNetAddress-->
  190. <xsl:template name="getNetAddress">
  191. <xsl:param name="computer"/>
  192. <xsl:value-of select="/Environment/Hardware/Computer[@name=$computer]/@netAddress"/>
  193. </xsl:template>
  194. <!--getNetAddress-->
  195. </xsl:stylesheet>