瀏覽代碼

HPCC-17519 Backupnode_vars XSLT rework

Signed-off-by: Michael Gardner <michael.gardner@lexisnexis.com>
Michael Gardner 8 年之前
父節點
當前提交
8f92be0770

+ 146 - 71
initfiles/componentfiles/configxml/backupnode_vars.xsl

@@ -27,87 +27,162 @@
 
     <xsl:template match="BackupNodeProcess">
         <xsl:if test="@name = $process">
-            <xsl:text>&#xa;</xsl:text>
-            <xsl:text>[default]</xsl:text>
-            <xsl:text>&#xa;</xsl:text>
-            <xsl:text>thorlist=</xsl:text>
-            <xsl:call-template name="getThorClusterList"/>
-            <xsl:call-template name="getThorClusterDetails"/>
+            <xsl:call-template name="printHeader">
+                <xsl:with-param name="header" select="'default'"/>
+            </xsl:call-template>
+            <xsl:call-template name="printVariable">
+                <xsl:with-param name="var" select="'thorlist'"/>
+                <xsl:with-param name="val">
+                    <xsl:call-template name="getNodeList"/>
+                </xsl:with-param>
+            </xsl:call-template>
+            <xsl:call-template name="printClusterDetails"/>
         </xsl:if>
     </xsl:template>
 
-    <!--getThorClusterList-->
-    <xsl:template name="getThorClusterList">
-        <xsl:for-each select="/Environment/Software/BackupNodeProcess/NodeGroup">
-            <xsl:value-of select="@name"/>
-            <xsl:if test="position() != last()">
-                <xsl:text>,</xsl:text>
-            </xsl:if>
-        </xsl:for-each>
+    <!-- getNodeList 
+        return NodeGroups in csv list
+    -->
+    <xsl:template name="getNodeList">
+        <xsl:choose>
+            <xsl:when test="NodeGroup">
+                <xsl:for-each select="NodeGroup">
+                    <xsl:variable name="nodeName" select="@name"/>
+                    <xsl:for-each select="/Environment/Software/ThorCluster">
+                        <xsl:if test="($nodeName = @name) and (((@localThor = 'false' or not(@localThor)) and not(@nodeGroup)) or (@nodeGroup = @name))">
+                            <xsl:value-of select="@name"/><xsl:text>,</xsl:text>
+                        </xsl:if>
+                    </xsl:for-each>
+                </xsl:for-each>
+            </xsl:when>
+            <xsl:otherwise>
+                <xsl:for-each select="/Environment/Software/ThorCluster">
+                    <xsl:if test="((@localThor = 'false' or not(@localThor)) and not(@nodeGroup)) or (@nodeGroup = @name)">
+                        <xsl:value-of select="@name"/><xsl:text>,</xsl:text>
+                    </xsl:if>
+                </xsl:for-each>
+            </xsl:otherwise>
+        </xsl:choose>
     </xsl:template>
-    <!--getThorClusterList-->
+    <!-- getNodeList -->
+
+    <xsl:template name="printClusterDetails">
+        <xsl:choose>
+            <xsl:when test="NodeGroup">
+                <xsl:for-each select="NodeGroup">
+                    <xsl:variable name="nodeName" select="@name"/>
+                    <xsl:variable name="interval" select="@interval"/>
+                    <xsl:for-each select="/Environment/Software/ThorCluster[@name=$nodeName]">
+                        <xsl:if test="((@localThor = 'false' or not(@localThor)) and not(@nodeGroup)) or (@nodeGroup = @name)">
+                            <xsl:call-template name="getThorClusterDetails">
+                                <xsl:with-param name="interval" select="$interval"/>
+                            </xsl:call-template>
+                        </xsl:if>
+                    </xsl:for-each>
+                </xsl:for-each>
+            </xsl:when>
+            <xsl:otherwise>
+                <xsl:for-each select="/Environment/Software/ThorCluster">
+                    <xsl:if test="((@localThor = 'false' or not(@localThor)) and not(@nodeGroup)) or (@nodeGroup = @name)">
+                        <xsl:call-template name="getThorClusterDetails">
+                        </xsl:call-template>
+                    </xsl:if>
+                </xsl:for-each>
+            </xsl:otherwise>
+        </xsl:choose>		
+    </xsl:template>
+
 
     <!--getThorClusterDetails-->
+    <!--
+        [header]
+        interval
+        daliserver
+        localthor
+        thormaster
+        thorprimary
+        thorname
+        SSHidentityfile
+        SSHusername
+        SSHpassword
+        SSHtimeout
+        SSHretries
+    -->
     <xsl:template name="getThorClusterDetails">
-        <xsl:for-each select="/Environment/Software/BackupNodeProcess/NodeGroup">
-            <xsl:variable name="name" select="@name"/>
-            <!--header-->
-            <xsl:text>&#xa;</xsl:text>
-            <xsl:text>[</xsl:text>
-            <xsl:value-of select="@name"/>
-            <xsl:text>]</xsl:text>
-            <!--interval-->
-            <xsl:text>&#xa;</xsl:text>
-            <xsl:text>interval=</xsl:text>
-            <xsl:value-of select="@interval"/>
-            <!--daliserver-->
-            <xsl:text>&#xa;</xsl:text>
-            <xsl:text>daliserver=</xsl:text>
-            <xsl:call-template name="getDaliServers">
-                <xsl:with-param name="daliServer" select="/Environment/Software/ThorCluster[@name=$name]/@daliServers"/>
-            </xsl:call-template>
-            <!--localthor-->
-            <xsl:text>&#xa;</xsl:text>
-            <xsl:text>localthor=</xsl:text>
-            <xsl:value-of select="/Environment/Software/ThorCluster[@name=$name]/@localThor"/>
-            <!--thormaster-->
-            <xsl:text>&#xa;</xsl:text>
-            <xsl:text>thormaster=</xsl:text>
-            <xsl:call-template name="getNetAddress">
-                <xsl:with-param name="computer" select="/Environment/Software/ThorCluster[@name=$name]/ThorMasterProcess/@computer"/>
-            </xsl:call-template>
-            <!--thorprimary-->
-            <xsl:text>&#xa;</xsl:text>
-            <xsl:text>thorprimary=</xsl:text>
-            <xsl:value-of select="/Environment/Software/ThorCluster[@name=$name]/@nodeGroup"/>
-            <!--thorname-->
-            <xsl:text>&#xa;</xsl:text>
-            <xsl:text>thorname=</xsl:text>
-            <xsl:value-of select="@name"/>
-            <!--SSHidentityfile-->
-            <xsl:text>&#xa;</xsl:text>
-            <xsl:text>SSHidentityfile=</xsl:text>
-            <xsl:value-of select="/Environment/Software/ThorCluster[@name=$name]/SSH/@SSHidentityfile"/>
-            <!--SSHusername-->
-            <xsl:text>&#xa;</xsl:text>
-            <xsl:text>SSHusername=</xsl:text>
-            <xsl:value-of select="/Environment/Software/ThorCluster[@name=$name]/SSH/@SSHusername"/>
-            <!--SSHpassword-->
-            <xsl:text>&#xa;</xsl:text>
-            <xsl:text>SSHpassword=</xsl:text>
-            <xsl:value-of select="/Environment/Software/ThorCluster[@name=$name]/SSH/@SSHpassword"/>
-            <!--SSHtimeout-->
-            <xsl:text>&#xa;</xsl:text>
-            <xsl:text>SSHtimeout=</xsl:text>
-            <xsl:value-of select="/Environment/Software/ThorCluster[@name=$name]/SSH/@SSHtimeout"/>
-            <!--SSHretries-->
-            <xsl:text>&#xa;</xsl:text>
-            <xsl:text>SSHretries=</xsl:text>
-            <xsl:value-of select="/Environment/Software/ThorCluster[@name=$name]/SSH/@SSHretries"/>
-        </xsl:for-each>
+        <xsl:param name="interval" select="12"/>
+        <xsl:call-template name="printHeader">
+            <xsl:with-param name="header" select="@name"/>
+        </xsl:call-template>
+        <xsl:call-template name="printVariable">
+            <xsl:with-param name="var" select="'interval'"/>
+            <xsl:with-param name="val" select="$interval"/>
+        </xsl:call-template>
+        <xsl:call-template name="printVariable">
+            <xsl:with-param name="var" select="'daliserver'"/>
+            <xsl:with-param name="val">
+                <xsl:call-template name="getDaliServers">
+                    <xsl:with-param name="daliServer" select="@daliServers"/>
+                </xsl:call-template>
+            </xsl:with-param>
+        </xsl:call-template>
+        <xsl:call-template name="printVariable">
+            <xsl:with-param name="var" select="'localthor'"/>
+            <xsl:with-param name="val" select="@localThor"/>
+        </xsl:call-template>
+        <xsl:call-template name="printVariable">
+            <xsl:with-param name="var" select="'thormaster'"/>
+            <xsl:with-param name="val">
+                <xsl:call-template name="getNetAddress">
+                    <xsl:with-param name="computer" select="ThorMasterProcess/@computer"/>
+                </xsl:call-template>
+            </xsl:with-param>
+        </xsl:call-template>
+        <xsl:call-template name="printVariable">
+            <xsl:with-param name="var" select="'thorprimary'"/>
+            <xsl:with-param name="val" select="@nodeGroup"/>
+        </xsl:call-template>
+        <xsl:call-template name="printVariable">
+            <xsl:with-param name="var" select="'thorname'"/>
+            <xsl:with-param name="val" select="@name"/>
+        </xsl:call-template>
+        <xsl:call-template name="printVariable">
+            <xsl:with-param name="var" select="'SSHidentityfile'"/>
+            <xsl:with-param name="val" select="SSH/@SSHidentityfile"/>
+        </xsl:call-template>
+        <xsl:call-template name="printVariable">
+            <xsl:with-param name="var" select="'SSHusername'"/>
+            <xsl:with-param name="val" select="SSH/@SSHusername"/>
+        </xsl:call-template>
+        <xsl:call-template name="printVariable">
+            <xsl:with-param name="var" select="'SSHpassword'"/>
+            <xsl:with-param name="val" select="SSH/@SSHpassword"/>
+        </xsl:call-template>
+        <xsl:call-template name="printVariable">
+            <xsl:with-param name="var" select="'SSHtimeout'"/>
+            <xsl:with-param name="val" select="SSH/@SSHtimeout"/>
+        </xsl:call-template>
+        <xsl:call-template name="printVariable">
+            <xsl:with-param name="var" select="'SSHretries'"/>
+            <xsl:with-param name="val" select="SSH/@SSHretries"/>
+        </xsl:call-template>
     </xsl:template>
     <!--getThorClusterDetails-->
 
+    <!-- printHeader -->
+    <xsl:template name="printHeader">
+        <xsl:param name="header"/>
+        <xsl:text>[</xsl:text><xsl:value-of select="$header"/><xsl:text>]&#xa;</xsl:text>
+    </xsl:template>
+    <!-- printHeader -->
+
+    <!-- printVariable -->
+    <xsl:template name="printVariable">
+        <xsl:param name="var"/>
+        <xsl:param name="val"/>
+        <xsl:value-of select="$var"/><xsl:text>=</xsl:text><xsl:value-of select="$val"/><xsl:text>&#xa;</xsl:text>
+    </xsl:template>
+    <!-- printVar -->
+
     <!--getDaliServers-->
     <xsl:template name="getDaliServers">
         <xsl:param name="daliServer"/>

+ 1 - 1
initfiles/componentfiles/configxml/cgencomplist_linux.xml

@@ -49,7 +49,7 @@
     <File name="esp.xsl" method="xslt" destName="esp.xml"/>
   </Component>
   <Component name="backupnode" processName="BackupNode" schema="backupnode.xsd">
-    <File name="backupnode_vars.xsl" method="xslt" destName="backupnode.conf"></File>
+    <File name="backupnode_vars.xsl" method="xslt" destName="backupnode.conf"/>
   </Component>
   <Component name="ldapServer" processName="LDAPServerProcess">
     <File name="ldapserver.xsl" method="xslt" destName=".ldaprc"/>

+ 1 - 1
initfiles/componentfiles/configxml/cgencomplist_win.xml

@@ -68,7 +68,7 @@
     <File name="sasha.xsl" method="xslt" destName="sashaconf.xml"/>
   </Component>
   <Component name="backupnode" processName="BackupNode" schema="backupnode.xsd">
-    <File name="backupnode.xsl" method="xslt" destName="backupnode.xml"></File>
+    <File name="backupnode.xsl" method="xslt" destName="backupnode.xml"/>
   </Component>
   <Component name="thor" processName='ThorCluster' schema='thor.xsd'>
     <File name="thor.xsl" method="xslt" destName="thor.xml"/>

+ 0 - 7
initfiles/sbin/backup.sh.in

@@ -48,16 +48,9 @@ cfg.section.${target}
 
 # determine if this is a valid target for backupnode
 
-if [[ "${localthor}" == "true" ]]; then
-    log "${header} Not a multi node system.  Skipping as backup target"
-    exit 0
-fi
 nodegroup=${thorprimary}
 if [[ -z "$thorprimary" ]]; then
     nodegroup=${thorname}
-elif [[ "${nodegroup}" != "${target}" ]]; then
-    log "${header} This target is not the primary in the nodeGroup ${nodegroup}.  Skipping as backup target"
-    exit 0
 fi
 
 log "${header} Backup will occur every ${interval} hours"