1*0Sstevel@tonic-gate<?xml version="1.0" encoding="utf-8" ?> 2*0Sstevel@tonic-gate 3*0Sstevel@tonic-gate<!-- 4*0Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 5*0Sstevel@tonic-gate * Use is subject to license terms. 6*0Sstevel@tonic-gate * 7*0Sstevel@tonic-gate * CDDL HEADER START 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 10*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 11*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 12*0Sstevel@tonic-gate * with the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 15*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 16*0Sstevel@tonic-gate * See the License for the specific language governing permissions 17*0Sstevel@tonic-gate * and limitations under the License. 18*0Sstevel@tonic-gate * 19*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 20*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 21*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 22*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 23*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 24*0Sstevel@tonic-gate * 25*0Sstevel@tonic-gate * CDDL HEADER END 26*0Sstevel@tonic-gate * 27*0Sstevel@tonic-gate * ident "%Z%%M% %I% %E% SMI" 28*0Sstevel@tonic-gate * 29*0Sstevel@tonic-gate * Used by metassist(1M) to create a Bourne shell script from an XML 30*0Sstevel@tonic-gate * file conforming to the volume-config DTD. 31*0Sstevel@tonic-gate * 32*0Sstevel@tonic-gate * See volume-config(4) for a detailed description of the volume- 33*0Sstevel@tonic-gate * config syntax. 34*0Sstevel@tonic-gate --> 35*0Sstevel@tonic-gate<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 36*0Sstevel@tonic-gate <xsl:output method="text"/> 37*0Sstevel@tonic-gate 38*0Sstevel@tonic-gate <!-- Set a default lang --> 39*0Sstevel@tonic-gate <xsl:param name="lang">en</xsl:param> 40*0Sstevel@tonic-gate 41*0Sstevel@tonic-gate <!-- The file containing localized <message> elements --> 42*0Sstevel@tonic-gate <!-- Currently set to local doc until an i18n scheme is established --> 43*0Sstevel@tonic-gate <xsl:variable name="msgfile" select="document('')"/> 44*0Sstevel@tonic-gate <xsl:variable name="langprefix" select="substring-before($lang,'-')"/> 45*0Sstevel@tonic-gate 46*0Sstevel@tonic-gate <!-- Root template --> 47*0Sstevel@tonic-gate <xsl:template match="/"> 48*0Sstevel@tonic-gate 49*0Sstevel@tonic-gate <!-- Use Bourne shell --> 50*0Sstevel@tonic-gate <xsl:text>#!/bin/sh 51*0Sstevel@tonic-gate 52*0Sstevel@tonic-gate# 53*0Sstevel@tonic-gate# </xsl:text> 54*0Sstevel@tonic-gate <xsl:call-template name="gettext"> 55*0Sstevel@tonic-gate <xsl:with-param name="msgid">Environment</xsl:with-param> 56*0Sstevel@tonic-gate </xsl:call-template> 57*0Sstevel@tonic-gate 58*0Sstevel@tonic-gate <xsl:text> 59*0Sstevel@tonic-gate# 60*0Sstevel@tonic-gate 61*0Sstevel@tonic-gate# </xsl:text> 62*0Sstevel@tonic-gate <xsl:call-template name="gettext"> 63*0Sstevel@tonic-gate <xsl:with-param name="msgid">Amend PATH</xsl:with-param> 64*0Sstevel@tonic-gate </xsl:call-template> 65*0Sstevel@tonic-gate 66*0Sstevel@tonic-gate <xsl:text> 67*0Sstevel@tonic-gatePATH="/usr/sbin:/usr/bin:$PATH" 68*0Sstevel@tonic-gateexport PATH 69*0Sstevel@tonic-gate 70*0Sstevel@tonic-gate# </xsl:text> 71*0Sstevel@tonic-gate <xsl:call-template name="gettext"> 72*0Sstevel@tonic-gate <xsl:with-param name="msgid">Disk set name</xsl:with-param> 73*0Sstevel@tonic-gate </xsl:call-template> 74*0Sstevel@tonic-gate 75*0Sstevel@tonic-gate <!-- Set disk set --> 76*0Sstevel@tonic-gate <xsl:text>
</xsl:text> 77*0Sstevel@tonic-gate <xsl:text>diskset='</xsl:text> 78*0Sstevel@tonic-gate <xsl:value-of select="//diskset/@name" /> 79*0Sstevel@tonic-gate 80*0Sstevel@tonic-gate <!-- 
 is a newline entity --> 81*0Sstevel@tonic-gate <xsl:text>'
</xsl:text> 82*0Sstevel@tonic-gate 83*0Sstevel@tonic-gate <xsl:text> 84*0Sstevel@tonic-gate# 85*0Sstevel@tonic-gate# </xsl:text> 86*0Sstevel@tonic-gate <xsl:call-template name="gettext"> 87*0Sstevel@tonic-gate <xsl:with-param name="msgid">Functions</xsl:with-param> 88*0Sstevel@tonic-gate </xsl:call-template> 89*0Sstevel@tonic-gate 90*0Sstevel@tonic-gate <xsl:text> 91*0Sstevel@tonic-gate# 92*0Sstevel@tonic-gate 93*0Sstevel@tonic-gate# </xsl:text> 94*0Sstevel@tonic-gate <xsl:call-template name="gettext"> 95*0Sstevel@tonic-gate <xsl:with-param name="msgid">Echo (verbose) and exec given command, exit on error</xsl:with-param> 96*0Sstevel@tonic-gate </xsl:call-template> 97*0Sstevel@tonic-gate 98*0Sstevel@tonic-gate <xsl:text> 99*0Sstevel@tonic-gateexecho () { 100*0Sstevel@tonic-gate test -n "$verbose" && echo "$@" 101*0Sstevel@tonic-gate "$@" || exit 102*0Sstevel@tonic-gate} 103*0Sstevel@tonic-gate 104*0Sstevel@tonic-gate# </xsl:text> 105*0Sstevel@tonic-gate <xsl:call-template name="gettext"> 106*0Sstevel@tonic-gate <xsl:with-param name="msgid">Get full /dev/rdsk path of given slice</xsl:with-param> 107*0Sstevel@tonic-gate </xsl:call-template> 108*0Sstevel@tonic-gate 109*0Sstevel@tonic-gate <xsl:text> 110*0Sstevel@tonic-gatefullpath () { 111*0Sstevel@tonic-gate case "$1" in 112*0Sstevel@tonic-gate /dev/dsk/*|/dev/did/dsk/*) echo "$1" | sed 's/dsk/rdsk/' ;; 113*0Sstevel@tonic-gate /*) echo "$1" ;; 114*0Sstevel@tonic-gate *) echo /dev/rdsk/"$1" ;; 115*0Sstevel@tonic-gate esac 116*0Sstevel@tonic-gate} 117*0Sstevel@tonic-gate 118*0Sstevel@tonic-gate# </xsl:text> 119*0Sstevel@tonic-gate <xsl:call-template name="gettext"> 120*0Sstevel@tonic-gate <xsl:with-param name="msgid">Run fmthard, ignore partboot error, error if output</xsl:with-param> 121*0Sstevel@tonic-gate </xsl:call-template> 122*0Sstevel@tonic-gate 123*0Sstevel@tonic-gate <xsl:text> 124*0Sstevel@tonic-gatefmthard_special () { 125*0Sstevel@tonic-gate ignore='Error writing partboot' 126*0Sstevel@tonic-gate out=`fmthard "$@" 2>&1` 127*0Sstevel@tonic-gate result=$? 128*0Sstevel@tonic-gate echo "$out" | 129*0Sstevel@tonic-gate case "$out" in 130*0Sstevel@tonic-gate *"$ignore"*) grep -v "$ignore"; return 0 ;; 131*0Sstevel@tonic-gate '') return "$result" ;; 132*0Sstevel@tonic-gate *) cat; return 1 ;; 133*0Sstevel@tonic-gate esac >&2 134*0Sstevel@tonic-gate} 135*0Sstevel@tonic-gate 136*0Sstevel@tonic-gate# 137*0Sstevel@tonic-gate# </xsl:text> 138*0Sstevel@tonic-gate <xsl:call-template name="gettext"> 139*0Sstevel@tonic-gate <xsl:with-param name="msgid">Main</xsl:with-param> 140*0Sstevel@tonic-gate </xsl:call-template> 141*0Sstevel@tonic-gate 142*0Sstevel@tonic-gate <xsl:text> 143*0Sstevel@tonic-gate# 144*0Sstevel@tonic-gate 145*0Sstevel@tonic-gate# </xsl:text> 146*0Sstevel@tonic-gate <xsl:call-template name="gettext"> 147*0Sstevel@tonic-gate <xsl:with-param name="msgid">Verify root</xsl:with-param> 148*0Sstevel@tonic-gate </xsl:call-template> 149*0Sstevel@tonic-gate 150*0Sstevel@tonic-gate <xsl:text> 151*0Sstevel@tonic-gateif [ "`id | sed 's/^[^(]*(\([^)]*\).*/\1/'`" != root ] 152*0Sstevel@tonic-gatethen 153*0Sstevel@tonic-gate echo "</xsl:text> 154*0Sstevel@tonic-gate 155*0Sstevel@tonic-gate <xsl:call-template name="gettext"> 156*0Sstevel@tonic-gate <xsl:with-param name="msgid">This script must be run as root.</xsl:with-param> 157*0Sstevel@tonic-gate </xsl:call-template> 158*0Sstevel@tonic-gate 159*0Sstevel@tonic-gate <xsl:text>" >&2 160*0Sstevel@tonic-gate exit 1; 161*0Sstevel@tonic-gatefi 162*0Sstevel@tonic-gate 163*0Sstevel@tonic-gate# </xsl:text> 164*0Sstevel@tonic-gate <xsl:call-template name="gettext"> 165*0Sstevel@tonic-gate <xsl:with-param name="msgid">Check for verbose option</xsl:with-param> 166*0Sstevel@tonic-gate </xsl:call-template> 167*0Sstevel@tonic-gate 168*0Sstevel@tonic-gate <xsl:text> 169*0Sstevel@tonic-gatecase "$1" in 170*0Sstevel@tonic-gate -v) verbose=1 ;; 171*0Sstevel@tonic-gate *) verbose= ;; 172*0Sstevel@tonic-gateesac 173*0Sstevel@tonic-gate </xsl:text> 174*0Sstevel@tonic-gate 175*0Sstevel@tonic-gate <!-- Create disk set --> 176*0Sstevel@tonic-gate <xsl:apply-templates select="//diskset" mode="create"/> 177*0Sstevel@tonic-gate 178*0Sstevel@tonic-gate <!-- Format unused slices --> 179*0Sstevel@tonic-gate <xsl:apply-templates select="//slice[@sizeinblocks = 0]" mode="create"/> 180*0Sstevel@tonic-gate 181*0Sstevel@tonic-gate <!-- Add disks to set --> 182*0Sstevel@tonic-gate <xsl:apply-templates select="//disk" mode="add"/> 183*0Sstevel@tonic-gate 184*0Sstevel@tonic-gate <!-- Format used slices --> 185*0Sstevel@tonic-gate <xsl:apply-templates select="//slice[@sizeinblocks != 0]" mode="create"/> 186*0Sstevel@tonic-gate 187*0Sstevel@tonic-gate <!-- Create HSPs --> 188*0Sstevel@tonic-gate <xsl:apply-templates select="//hsp" mode="create"/> 189*0Sstevel@tonic-gate 190*0Sstevel@tonic-gate <!-- Create stripes --> 191*0Sstevel@tonic-gate <xsl:apply-templates select="//stripe" mode="create"/> 192*0Sstevel@tonic-gate 193*0Sstevel@tonic-gate <!-- Create concats --> 194*0Sstevel@tonic-gate <xsl:apply-templates select="//concat" mode="create"/> 195*0Sstevel@tonic-gate 196*0Sstevel@tonic-gate <!-- Create mirrors --> 197*0Sstevel@tonic-gate <xsl:apply-templates select="//mirror" mode="create"/> 198*0Sstevel@tonic-gate 199*0Sstevel@tonic-gate </xsl:template> 200*0Sstevel@tonic-gate 201*0Sstevel@tonic-gate <!-- "Create disk set" template --> 202*0Sstevel@tonic-gate <xsl:template match="diskset" mode="create"> 203*0Sstevel@tonic-gate <xsl:text>
# </xsl:text> 204*0Sstevel@tonic-gate <xsl:call-template name="gettext"> 205*0Sstevel@tonic-gate <xsl:with-param name="msgid">Does the disk set exist?</xsl:with-param> 206*0Sstevel@tonic-gate </xsl:call-template> 207*0Sstevel@tonic-gate 208*0Sstevel@tonic-gate <xsl:text> 209*0Sstevel@tonic-gateif metaset -s "$diskset" >/dev/null 2>&1 210*0Sstevel@tonic-gatethen 211*0Sstevel@tonic-gate # </xsl:text> 212*0Sstevel@tonic-gate <xsl:call-template name="gettext"> 213*0Sstevel@tonic-gate <xsl:with-param name="msgid">Take control of disk set</xsl:with-param> 214*0Sstevel@tonic-gate </xsl:call-template> 215*0Sstevel@tonic-gate 216*0Sstevel@tonic-gate <xsl:text> 217*0Sstevel@tonic-gate execho metaset -s "$diskset" -t 218*0Sstevel@tonic-gateelse 219*0Sstevel@tonic-gate # </xsl:text> 220*0Sstevel@tonic-gate <xsl:call-template name="gettext"> 221*0Sstevel@tonic-gate <xsl:with-param name="msgid">Create the disk set</xsl:with-param> 222*0Sstevel@tonic-gate </xsl:call-template> 223*0Sstevel@tonic-gate 224*0Sstevel@tonic-gate <xsl:text> 225*0Sstevel@tonic-gate autotakeargs= 226*0Sstevel@tonic-gate /usr/sbin/clinfo || autotakeargs='-A enable' 227*0Sstevel@tonic-gate execho metaset -s "$diskset" $autotakeargs -a -h `uname -n | cut -f1 -d.` 228*0Sstevel@tonic-gatefi 229*0Sstevel@tonic-gate </xsl:text> 230*0Sstevel@tonic-gate </xsl:template> 231*0Sstevel@tonic-gate 232*0Sstevel@tonic-gate <!-- "Add disk" template --> 233*0Sstevel@tonic-gate <xsl:template match="disk" mode="add"> 234*0Sstevel@tonic-gate <!-- Add comment --> 235*0Sstevel@tonic-gate <xsl:if test="position() = 1"> 236*0Sstevel@tonic-gate <xsl:text>
# </xsl:text> 237*0Sstevel@tonic-gate <xsl:call-template name="gettext"> 238*0Sstevel@tonic-gate <xsl:with-param name="msgid">Add disks to set</xsl:with-param> 239*0Sstevel@tonic-gate </xsl:call-template> 240*0Sstevel@tonic-gate <xsl:text>
</xsl:text> 241*0Sstevel@tonic-gate </xsl:if> 242*0Sstevel@tonic-gate 243*0Sstevel@tonic-gate <!-- Output command --> 244*0Sstevel@tonic-gate <xsl:call-template name="parameterize"> 245*0Sstevel@tonic-gate <xsl:with-param name="string">execho metaset -s "$diskset" -a {1}</xsl:with-param> 246*0Sstevel@tonic-gate <xsl:with-param name="1" select="@name"/> 247*0Sstevel@tonic-gate </xsl:call-template> 248*0Sstevel@tonic-gate 249*0Sstevel@tonic-gate <xsl:text>
</xsl:text> 250*0Sstevel@tonic-gate </xsl:template> 251*0Sstevel@tonic-gate 252*0Sstevel@tonic-gate <!-- "Create slice" template --> 253*0Sstevel@tonic-gate <xsl:template match="slice" mode="create"> 254*0Sstevel@tonic-gate 255*0Sstevel@tonic-gate <!-- Add comment --> 256*0Sstevel@tonic-gate <xsl:if test="position() = 1"> 257*0Sstevel@tonic-gate <xsl:text>
# </xsl:text> 258*0Sstevel@tonic-gate <xsl:call-template name="gettext"> 259*0Sstevel@tonic-gate <xsl:with-param name="msgid">Format slices</xsl:with-param> 260*0Sstevel@tonic-gate </xsl:call-template> 261*0Sstevel@tonic-gate <xsl:text>
</xsl:text> 262*0Sstevel@tonic-gate </xsl:if> 263*0Sstevel@tonic-gate 264*0Sstevel@tonic-gate <!-- Does this slice have a start sector and size? --> 265*0Sstevel@tonic-gate <xsl:if test="(@startsector and @sizeinblocks) or (@sizeinblocks = 0)"> 266*0Sstevel@tonic-gate 267*0Sstevel@tonic-gate <!-- Output command --> 268*0Sstevel@tonic-gate <xsl:call-template name="parameterize"> 269*0Sstevel@tonic-gate <xsl:with-param name="string">execho fmthard_special -d {1}:{5}:0:{2}:{3} `fullpath {4}`</xsl:with-param> 270*0Sstevel@tonic-gate <xsl:with-param name="1"> 271*0Sstevel@tonic-gate <xsl:call-template name="getslice"> 272*0Sstevel@tonic-gate <xsl:with-param name="device" select="@name" /> 273*0Sstevel@tonic-gate </xsl:call-template> 274*0Sstevel@tonic-gate </xsl:with-param> 275*0Sstevel@tonic-gate <xsl:with-param name="2"> 276*0Sstevel@tonic-gate <xsl:choose> 277*0Sstevel@tonic-gate <!-- When zeroing out a slice, use 0 for start sector --> 278*0Sstevel@tonic-gate <xsl:when test="@sizeinblocks = 0">0</xsl:when> 279*0Sstevel@tonic-gate <!-- Otherwise, use the start sector supplied --> 280*0Sstevel@tonic-gate <xsl:otherwise> 281*0Sstevel@tonic-gate <xsl:value-of select="@startsector" /> 282*0Sstevel@tonic-gate </xsl:otherwise> 283*0Sstevel@tonic-gate </xsl:choose> 284*0Sstevel@tonic-gate </xsl:with-param> 285*0Sstevel@tonic-gate <xsl:with-param name="3" select="@sizeinblocks" /> 286*0Sstevel@tonic-gate <xsl:with-param name="4" select="@name" /> 287*0Sstevel@tonic-gate <xsl:with-param name="5"> 288*0Sstevel@tonic-gate <xsl:choose> 289*0Sstevel@tonic-gate <!-- When zeroing out a slice, use 0 (V_UNASSIGNED) slice tag --> 290*0Sstevel@tonic-gate <xsl:when test="@sizeinblocks = 0">0</xsl:when> 291*0Sstevel@tonic-gate <!-- Otherwise, use 4 (V_USR) --> 292*0Sstevel@tonic-gate <xsl:otherwise>4</xsl:otherwise> 293*0Sstevel@tonic-gate </xsl:choose> 294*0Sstevel@tonic-gate </xsl:with-param> 295*0Sstevel@tonic-gate </xsl:call-template> 296*0Sstevel@tonic-gate 297*0Sstevel@tonic-gate <xsl:text>
</xsl:text> 298*0Sstevel@tonic-gate </xsl:if> 299*0Sstevel@tonic-gate </xsl:template> 300*0Sstevel@tonic-gate 301*0Sstevel@tonic-gate <!-- Template for a "create volume" comment --> 302*0Sstevel@tonic-gate <xsl:template name="createdevcomment"> 303*0Sstevel@tonic-gate <!-- Indent parameter --> 304*0Sstevel@tonic-gate <xsl:param name = "indent" /> 305*0Sstevel@tonic-gate 306*0Sstevel@tonic-gate <xsl:text>
</xsl:text> 307*0Sstevel@tonic-gate <xsl:value-of select="$indent" /> 308*0Sstevel@tonic-gate <xsl:text># </xsl:text> 309*0Sstevel@tonic-gate 310*0Sstevel@tonic-gate <!-- Add comment --> 311*0Sstevel@tonic-gate <xsl:call-template name="gettext"> 312*0Sstevel@tonic-gate <xsl:with-param name="msgid">Create {1} {2}</xsl:with-param> 313*0Sstevel@tonic-gate <xsl:with-param name="1" select="name()"/> 314*0Sstevel@tonic-gate <xsl:with-param name="2" select="@name"/> 315*0Sstevel@tonic-gate </xsl:call-template> 316*0Sstevel@tonic-gate 317*0Sstevel@tonic-gate <xsl:text>
</xsl:text> 318*0Sstevel@tonic-gate </xsl:template> 319*0Sstevel@tonic-gate 320*0Sstevel@tonic-gate <!-- "Create hsp" template --> 321*0Sstevel@tonic-gate <xsl:template match="hsp" mode="create"> 322*0Sstevel@tonic-gate 323*0Sstevel@tonic-gate <!-- Does this HSP contain slice elements? --> 324*0Sstevel@tonic-gate <xsl:if test="slice"> 325*0Sstevel@tonic-gate 326*0Sstevel@tonic-gate <xsl:text>
# </xsl:text> 327*0Sstevel@tonic-gate 328*0Sstevel@tonic-gate <!-- Add comment --> 329*0Sstevel@tonic-gate <xsl:call-template name="gettext"> 330*0Sstevel@tonic-gate <xsl:with-param name="msgid">Does {1} exist?</xsl:with-param> 331*0Sstevel@tonic-gate <xsl:with-param name="1" select="@name"/> 332*0Sstevel@tonic-gate </xsl:call-template> 333*0Sstevel@tonic-gate 334*0Sstevel@tonic-gate <xsl:text>
</xsl:text> 335*0Sstevel@tonic-gate 336*0Sstevel@tonic-gate <!-- Output command to test for existence of HSP --> 337*0Sstevel@tonic-gate <xsl:call-template name="parameterize"> 338*0Sstevel@tonic-gate <xsl:with-param name="string">metahs -s "$diskset" -i {1} >/dev/null 2>&1 || {</xsl:with-param> 339*0Sstevel@tonic-gate <xsl:with-param name="1" select="@name"/> 340*0Sstevel@tonic-gate </xsl:call-template> 341*0Sstevel@tonic-gate 342*0Sstevel@tonic-gate <!-- Add comment --> 343*0Sstevel@tonic-gate <xsl:call-template name="createdevcomment"> 344*0Sstevel@tonic-gate <xsl:with-param name = "indent" xml:space="preserve"> </xsl:with-param> 345*0Sstevel@tonic-gate </xsl:call-template> 346*0Sstevel@tonic-gate 347*0Sstevel@tonic-gate <!-- Output command to create HSP --> 348*0Sstevel@tonic-gate <xsl:call-template name="parameterize"> 349*0Sstevel@tonic-gate <xsl:with-param name="string"> execho metainit -s "$diskset" {1}</xsl:with-param> 350*0Sstevel@tonic-gate <xsl:with-param name="1" select="@name"/> 351*0Sstevel@tonic-gate </xsl:call-template> 352*0Sstevel@tonic-gate 353*0Sstevel@tonic-gate <xsl:text>
}

# </xsl:text> 354*0Sstevel@tonic-gate 355*0Sstevel@tonic-gate <!-- Add comment --> 356*0Sstevel@tonic-gate <xsl:call-template name="gettext"> 357*0Sstevel@tonic-gate <xsl:with-param name="msgid">Add slices to {1}</xsl:with-param> 358*0Sstevel@tonic-gate <xsl:with-param name="1" select="@name"/> 359*0Sstevel@tonic-gate </xsl:call-template> 360*0Sstevel@tonic-gate 361*0Sstevel@tonic-gate <xsl:text>
</xsl:text> 362*0Sstevel@tonic-gate 363*0Sstevel@tonic-gate <xsl:for-each select="slice"> 364*0Sstevel@tonic-gate 365*0Sstevel@tonic-gate <!-- Output command --> 366*0Sstevel@tonic-gate <xsl:call-template name="parameterize"> 367*0Sstevel@tonic-gate <xsl:with-param name="string">execho metahs -s "$diskset" -a {1} {2}</xsl:with-param> 368*0Sstevel@tonic-gate <xsl:with-param name="1" select="../@name"/> 369*0Sstevel@tonic-gate <xsl:with-param name="2" select="@name"/> 370*0Sstevel@tonic-gate </xsl:call-template> 371*0Sstevel@tonic-gate 372*0Sstevel@tonic-gate <xsl:text>
</xsl:text> 373*0Sstevel@tonic-gate 374*0Sstevel@tonic-gate </xsl:for-each> 375*0Sstevel@tonic-gate </xsl:if> 376*0Sstevel@tonic-gate 377*0Sstevel@tonic-gate </xsl:template> 378*0Sstevel@tonic-gate 379*0Sstevel@tonic-gate <!-- "Create stripe/concat" template --> 380*0Sstevel@tonic-gate <xsl:template match="stripe|concat" mode="create"> 381*0Sstevel@tonic-gate 382*0Sstevel@tonic-gate <!-- Does this stripe/concat contain slice elements? --> 383*0Sstevel@tonic-gate <xsl:if test="slice"> 384*0Sstevel@tonic-gate 385*0Sstevel@tonic-gate <!-- Add comment --> 386*0Sstevel@tonic-gate <xsl:call-template name="createdevcomment"/> 387*0Sstevel@tonic-gate 388*0Sstevel@tonic-gate <!-- Output command --> 389*0Sstevel@tonic-gate <xsl:text>execho metainit -s "$diskset" </xsl:text> 390*0Sstevel@tonic-gate <xsl:value-of select="@name" /> 391*0Sstevel@tonic-gate 392*0Sstevel@tonic-gate <xsl:choose> 393*0Sstevel@tonic-gate <!-- Stripe-specific parameters --> 394*0Sstevel@tonic-gate <xsl:when test="name() = 'stripe'"> 395*0Sstevel@tonic-gate <xsl:text> 1 </xsl:text> 396*0Sstevel@tonic-gate <xsl:value-of select="count(slice)" /> 397*0Sstevel@tonic-gate 398*0Sstevel@tonic-gate <xsl:for-each select="slice"> 399*0Sstevel@tonic-gate <xsl:text> </xsl:text> 400*0Sstevel@tonic-gate <xsl:value-of select="@name" /> 401*0Sstevel@tonic-gate </xsl:for-each> 402*0Sstevel@tonic-gate 403*0Sstevel@tonic-gate <!-- Does this stripe contain an interlace attribute? --> 404*0Sstevel@tonic-gate <xsl:if test="@interlace"> 405*0Sstevel@tonic-gate 406*0Sstevel@tonic-gate <!-- Write interlace with unit string --> 407*0Sstevel@tonic-gate <xsl:variable name="interlace" 408*0Sstevel@tonic-gate select="substring-before(@interlace, 'KB')"/> 409*0Sstevel@tonic-gate <xsl:choose> 410*0Sstevel@tonic-gate <xsl:when test="$interlace != ''"> 411*0Sstevel@tonic-gate <xsl:value-of select="concat(' -i ', $interlace, 'k')" /> 412*0Sstevel@tonic-gate </xsl:when> 413*0Sstevel@tonic-gate <xsl:otherwise> 414*0Sstevel@tonic-gate <xsl:variable name="interlace" 415*0Sstevel@tonic-gate select="substring-before(@interlace, 'MB')"/> 416*0Sstevel@tonic-gate <xsl:choose> 417*0Sstevel@tonic-gate <xsl:when test="$interlace != ''"> 418*0Sstevel@tonic-gate <xsl:value-of select="concat(' -i ', $interlace, 'm')" /> 419*0Sstevel@tonic-gate </xsl:when> 420*0Sstevel@tonic-gate <xsl:otherwise> 421*0Sstevel@tonic-gate <xsl:variable name="interlace" 422*0Sstevel@tonic-gate select="substring-before(@interlace, 'BLOCKS')"/> 423*0Sstevel@tonic-gate <xsl:if test="$interlace != ''"> 424*0Sstevel@tonic-gate <xsl:value-of select="concat(' -i ', $interlace, 'b')" /> 425*0Sstevel@tonic-gate </xsl:if> 426*0Sstevel@tonic-gate </xsl:otherwise> 427*0Sstevel@tonic-gate </xsl:choose> 428*0Sstevel@tonic-gate </xsl:otherwise> 429*0Sstevel@tonic-gate </xsl:choose> 430*0Sstevel@tonic-gate </xsl:if> 431*0Sstevel@tonic-gate </xsl:when> 432*0Sstevel@tonic-gate 433*0Sstevel@tonic-gate <!-- Concat-specific parameters --> 434*0Sstevel@tonic-gate <xsl:otherwise> 435*0Sstevel@tonic-gate <xsl:text> </xsl:text> 436*0Sstevel@tonic-gate <xsl:value-of select="count(slice)" /> 437*0Sstevel@tonic-gate 438*0Sstevel@tonic-gate <xsl:for-each select="slice"> 439*0Sstevel@tonic-gate <xsl:text> 1 </xsl:text> 440*0Sstevel@tonic-gate <xsl:value-of select="@name" /> 441*0Sstevel@tonic-gate </xsl:for-each> 442*0Sstevel@tonic-gate </xsl:otherwise> 443*0Sstevel@tonic-gate </xsl:choose> 444*0Sstevel@tonic-gate 445*0Sstevel@tonic-gate <xsl:text>
</xsl:text> 446*0Sstevel@tonic-gate </xsl:if> 447*0Sstevel@tonic-gate 448*0Sstevel@tonic-gate <!-- Does this stripe/concat contain hsp elements? --> 449*0Sstevel@tonic-gate <xsl:if test="hsp"> 450*0Sstevel@tonic-gate 451*0Sstevel@tonic-gate <xsl:text>
# </xsl:text> 452*0Sstevel@tonic-gate 453*0Sstevel@tonic-gate <!-- Add comment --> 454*0Sstevel@tonic-gate <xsl:call-template name="gettext"> 455*0Sstevel@tonic-gate <xsl:with-param name="msgid">Associate {1} {2} with hot spare pool {3}</xsl:with-param> 456*0Sstevel@tonic-gate <xsl:with-param name="1" select="name()"/> 457*0Sstevel@tonic-gate <xsl:with-param name="2" select="@name"/> 458*0Sstevel@tonic-gate <xsl:with-param name="3" select="hsp/@name"/> 459*0Sstevel@tonic-gate </xsl:call-template> 460*0Sstevel@tonic-gate 461*0Sstevel@tonic-gate <xsl:text>
</xsl:text> 462*0Sstevel@tonic-gate 463*0Sstevel@tonic-gate <!-- Output command --> 464*0Sstevel@tonic-gate <xsl:call-template name="parameterize"> 465*0Sstevel@tonic-gate <xsl:with-param name="string">execho metaparam -s "$diskset" -h {1} {2}</xsl:with-param> 466*0Sstevel@tonic-gate <xsl:with-param name="1" select="hsp/@name"/> 467*0Sstevel@tonic-gate <xsl:with-param name="2" select="@name"/> 468*0Sstevel@tonic-gate </xsl:call-template> 469*0Sstevel@tonic-gate 470*0Sstevel@tonic-gate <xsl:text>
</xsl:text> 471*0Sstevel@tonic-gate </xsl:if> 472*0Sstevel@tonic-gate </xsl:template> 473*0Sstevel@tonic-gate 474*0Sstevel@tonic-gate <!-- "Create mirror" template --> 475*0Sstevel@tonic-gate <xsl:template match="mirror" mode="create"> 476*0Sstevel@tonic-gate <!-- Add comment --> 477*0Sstevel@tonic-gate <xsl:call-template name="createdevcomment"/> 478*0Sstevel@tonic-gate 479*0Sstevel@tonic-gate <!-- Attach submirrors --> 480*0Sstevel@tonic-gate <xsl:for-each select="stripe|concat"> 481*0Sstevel@tonic-gate <xsl:choose > 482*0Sstevel@tonic-gate <xsl:when test="position() = 1"> 483*0Sstevel@tonic-gate 484*0Sstevel@tonic-gate <!-- Output create command --> 485*0Sstevel@tonic-gate <xsl:call-template name="parameterize"> 486*0Sstevel@tonic-gate <xsl:with-param name="string">execho metainit -s "$diskset" {1} -m {2}</xsl:with-param> 487*0Sstevel@tonic-gate <xsl:with-param name="1" select="../@name"/> 488*0Sstevel@tonic-gate <xsl:with-param name="2" select="@name"/> 489*0Sstevel@tonic-gate </xsl:call-template> 490*0Sstevel@tonic-gate 491*0Sstevel@tonic-gate <!-- Read option --> 492*0Sstevel@tonic-gate <xsl:choose > 493*0Sstevel@tonic-gate <!-- Geometric --> 494*0Sstevel@tonic-gate <xsl:when test="../@read = 'GEOMETRIC'"> 495*0Sstevel@tonic-gate <xsl:text> -g</xsl:text> 496*0Sstevel@tonic-gate </xsl:when> 497*0Sstevel@tonic-gate 498*0Sstevel@tonic-gate <!-- First --> 499*0Sstevel@tonic-gate <xsl:when test="../@read = 'FIRST'"> 500*0Sstevel@tonic-gate <xsl:text> -r</xsl:text> 501*0Sstevel@tonic-gate </xsl:when> 502*0Sstevel@tonic-gate </xsl:choose> 503*0Sstevel@tonic-gate 504*0Sstevel@tonic-gate <!-- Write option - serial --> 505*0Sstevel@tonic-gate <xsl:if test="../@write = 'SERIAL'"> 506*0Sstevel@tonic-gate <xsl:text> -S</xsl:text> 507*0Sstevel@tonic-gate </xsl:if> 508*0Sstevel@tonic-gate 509*0Sstevel@tonic-gate <!-- Pass number --> 510*0Sstevel@tonic-gate <xsl:if test="../@passnum"> 511*0Sstevel@tonic-gate <xsl:text> </xsl:text> 512*0Sstevel@tonic-gate <xsl:value-of select="../@passnum" /> 513*0Sstevel@tonic-gate </xsl:if> 514*0Sstevel@tonic-gate 515*0Sstevel@tonic-gate <xsl:text>
</xsl:text> 516*0Sstevel@tonic-gate </xsl:when> 517*0Sstevel@tonic-gate 518*0Sstevel@tonic-gate <xsl:otherwise> 519*0Sstevel@tonic-gate <!-- Output attach command --> 520*0Sstevel@tonic-gate <xsl:call-template name="parameterize"> 521*0Sstevel@tonic-gate <xsl:with-param name="string">execho metattach -s "$diskset" {1} {2}</xsl:with-param> 522*0Sstevel@tonic-gate <xsl:with-param name="1" select="../@name"/> 523*0Sstevel@tonic-gate <xsl:with-param name="2" select="@name"/> 524*0Sstevel@tonic-gate </xsl:call-template> 525*0Sstevel@tonic-gate 526*0Sstevel@tonic-gate <xsl:text>
</xsl:text> 527*0Sstevel@tonic-gate </xsl:otherwise> 528*0Sstevel@tonic-gate </xsl:choose> 529*0Sstevel@tonic-gate </xsl:for-each> 530*0Sstevel@tonic-gate </xsl:template> 531*0Sstevel@tonic-gate 532*0Sstevel@tonic-gate <!-- Get the slice index from a device string --> 533*0Sstevel@tonic-gate <xsl:template name="getslice"> 534*0Sstevel@tonic-gate <xsl:param name="device" /> 535*0Sstevel@tonic-gate 536*0Sstevel@tonic-gate <xsl:choose> 537*0Sstevel@tonic-gate 538*0Sstevel@tonic-gate <!-- Does $device contain 's'? --> 539*0Sstevel@tonic-gate <xsl:when test="contains($device, 's')"> 540*0Sstevel@tonic-gate 541*0Sstevel@tonic-gate <!-- Recurse with remaining text --> 542*0Sstevel@tonic-gate <xsl:call-template name="getslice"> 543*0Sstevel@tonic-gate <xsl:with-param name="device" select="substring-after($device, 's')" /> 544*0Sstevel@tonic-gate </xsl:call-template> 545*0Sstevel@tonic-gate </xsl:when> 546*0Sstevel@tonic-gate 547*0Sstevel@tonic-gate <!-- No match --> 548*0Sstevel@tonic-gate <xsl:otherwise> 549*0Sstevel@tonic-gate <xsl:value-of select="$device" /> 550*0Sstevel@tonic-gate </xsl:otherwise> 551*0Sstevel@tonic-gate 552*0Sstevel@tonic-gate </xsl:choose> 553*0Sstevel@tonic-gate </xsl:template> 554*0Sstevel@tonic-gate 555*0Sstevel@tonic-gate <!-- Generic (global) search and replace template --> 556*0Sstevel@tonic-gate <xsl:template name="searchreplace"> 557*0Sstevel@tonic-gate <xsl:param name="text" /> 558*0Sstevel@tonic-gate <xsl:param name="search" /> 559*0Sstevel@tonic-gate <xsl:param name="replace" /> 560*0Sstevel@tonic-gate 561*0Sstevel@tonic-gate <xsl:choose> 562*0Sstevel@tonic-gate 563*0Sstevel@tonic-gate <!-- Does $text contain $search? --> 564*0Sstevel@tonic-gate <xsl:when test="contains($text, $search)"> 565*0Sstevel@tonic-gate 566*0Sstevel@tonic-gate <!-- Print text before match --> 567*0Sstevel@tonic-gate <xsl:value-of select="substring-before($text, $search)" /> 568*0Sstevel@tonic-gate 569*0Sstevel@tonic-gate <!-- Print replaced text --> 570*0Sstevel@tonic-gate <xsl:value-of select="$replace" /> 571*0Sstevel@tonic-gate 572*0Sstevel@tonic-gate <!-- Recurse with remaining text --> 573*0Sstevel@tonic-gate <xsl:call-template name="searchreplace"> 574*0Sstevel@tonic-gate <xsl:with-param name="text" select="substring-after($text, $search)" /> 575*0Sstevel@tonic-gate <xsl:with-param name="search" select="$search" /> 576*0Sstevel@tonic-gate <xsl:with-param name="replace" select="$replace" /> 577*0Sstevel@tonic-gate </xsl:call-template> 578*0Sstevel@tonic-gate </xsl:when> 579*0Sstevel@tonic-gate 580*0Sstevel@tonic-gate <!-- No match --> 581*0Sstevel@tonic-gate <xsl:otherwise> 582*0Sstevel@tonic-gate <xsl:value-of select="$text" /> 583*0Sstevel@tonic-gate </xsl:otherwise> 584*0Sstevel@tonic-gate 585*0Sstevel@tonic-gate </xsl:choose> 586*0Sstevel@tonic-gate </xsl:template> 587*0Sstevel@tonic-gate 588*0Sstevel@tonic-gate <!-- 589*0Sstevel@tonic-gate * Given a message ID (msgid), find a localized message string 590*0Sstevel@tonic-gate * stored in $msgfile as a xsl:variable. Return the first 591*0Sstevel@tonic-gate * occurance of: 592*0Sstevel@tonic-gate * 593*0Sstevel@tonic-gate * 1. The message localized for the language code and country 594*0Sstevel@tonic-gate * code, ie. "en-us" 595*0Sstevel@tonic-gate * 596*0Sstevel@tonic-gate * 2. The message localized for a sublanguage 597*0Sstevel@tonic-gate * 598*0Sstevel@tonic-gate * 3. The message localized for the language code only, ie. "en" 599*0Sstevel@tonic-gate * 600*0Sstevel@tonic-gate * 4. The message localized for the language code, with any 601*0Sstevel@tonic-gate * country code, ie. "en-gb" 602*0Sstevel@tonic-gate * 603*0Sstevel@tonic-gate * 5. $msgid 604*0Sstevel@tonic-gate * 605*0Sstevel@tonic-gate * Parameters: 606*0Sstevel@tonic-gate * 607*0Sstevel@tonic-gate * msgid: The message identification key 608*0Sstevel@tonic-gate * 609*0Sstevel@tonic-gate * 1, 2, 3, 4, 5: Parameters to replace "{1}", "{2}", "{3}", 610*0Sstevel@tonic-gate * "{4}", "{5}" respectively, in the retrieved message 611*0Sstevel@tonic-gate --> 612*0Sstevel@tonic-gate <xsl:template name="gettext"> 613*0Sstevel@tonic-gate <xsl:param name="msgid"/> 614*0Sstevel@tonic-gate <xsl:param name="1"/> 615*0Sstevel@tonic-gate <xsl:param name="2"/> 616*0Sstevel@tonic-gate <xsl:param name="3"/> 617*0Sstevel@tonic-gate <xsl:param name="4"/> 618*0Sstevel@tonic-gate <xsl:param name="5"/> 619*0Sstevel@tonic-gate <xsl:variable name="messages" select="$msgfile//message[@msgid=$msgid]"/> 620*0Sstevel@tonic-gate 621*0Sstevel@tonic-gate <xsl:call-template name="parameterize"> 622*0Sstevel@tonic-gate <xsl:with-param name="1" select="$1"/> 623*0Sstevel@tonic-gate <xsl:with-param name="2" select="$2"/> 624*0Sstevel@tonic-gate <xsl:with-param name="3" select="$3"/> 625*0Sstevel@tonic-gate <xsl:with-param name="4" select="$4"/> 626*0Sstevel@tonic-gate <xsl:with-param name="5" select="$5"/> 627*0Sstevel@tonic-gate <xsl:with-param name="string"> 628*0Sstevel@tonic-gate 629*0Sstevel@tonic-gate <xsl:choose> 630*0Sstevel@tonic-gate 631*0Sstevel@tonic-gate <!-- Exact match for $lang --> 632*0Sstevel@tonic-gate <xsl:when test="$messages[@xml:lang=$lang]"> 633*0Sstevel@tonic-gate <xsl:value-of select="$messages[@xml:lang=$lang][1]"/> 634*0Sstevel@tonic-gate </xsl:when> 635*0Sstevel@tonic-gate 636*0Sstevel@tonic-gate <!-- Sublanguage of $lang --> 637*0Sstevel@tonic-gate <xsl:when test="$messages[lang($lang)]"> 638*0Sstevel@tonic-gate <xsl:value-of name="message" select="$messages[lang($lang)][1]"/> 639*0Sstevel@tonic-gate </xsl:when> 640*0Sstevel@tonic-gate 641*0Sstevel@tonic-gate <!-- Exact match for $langprefix --> 642*0Sstevel@tonic-gate <xsl:when test="$messages[@xml:lang=$langprefix]"> 643*0Sstevel@tonic-gate <xsl:value-of select="$messages[@xml:lang=$langprefix][1]"/> 644*0Sstevel@tonic-gate </xsl:when> 645*0Sstevel@tonic-gate 646*0Sstevel@tonic-gate <!-- Sublanguage of $langprefix --> 647*0Sstevel@tonic-gate <xsl:when test="$messages[lang($langprefix)]"> 648*0Sstevel@tonic-gate <xsl:value-of select="$messages[lang($langprefix)][1]"/> 649*0Sstevel@tonic-gate </xsl:when> 650*0Sstevel@tonic-gate 651*0Sstevel@tonic-gate <!-- No match found, return msgid --> 652*0Sstevel@tonic-gate <xsl:otherwise> 653*0Sstevel@tonic-gate <xsl:value-of select="$msgid"/> 654*0Sstevel@tonic-gate </xsl:otherwise> 655*0Sstevel@tonic-gate 656*0Sstevel@tonic-gate </xsl:choose> 657*0Sstevel@tonic-gate </xsl:with-param> 658*0Sstevel@tonic-gate </xsl:call-template> 659*0Sstevel@tonic-gate </xsl:template> 660*0Sstevel@tonic-gate 661*0Sstevel@tonic-gate <!-- Parameterize up to 5 parameters --> 662*0Sstevel@tonic-gate <xsl:template name="parameterize"> 663*0Sstevel@tonic-gate <xsl:param name="string"/> 664*0Sstevel@tonic-gate <xsl:param name="1"/> 665*0Sstevel@tonic-gate <xsl:param name="2"/> 666*0Sstevel@tonic-gate <xsl:param name="3"/> 667*0Sstevel@tonic-gate <xsl:param name="4"/> 668*0Sstevel@tonic-gate <xsl:param name="5"/> 669*0Sstevel@tonic-gate 670*0Sstevel@tonic-gate <xsl:call-template name="searchreplace"> 671*0Sstevel@tonic-gate <xsl:with-param name="text"> 672*0Sstevel@tonic-gate <xsl:call-template name="searchreplace"> 673*0Sstevel@tonic-gate <xsl:with-param name="text"> 674*0Sstevel@tonic-gate <xsl:call-template name="searchreplace"> 675*0Sstevel@tonic-gate <xsl:with-param name="text"> 676*0Sstevel@tonic-gate <xsl:call-template name="searchreplace"> 677*0Sstevel@tonic-gate <xsl:with-param name="text"> 678*0Sstevel@tonic-gate <xsl:call-template name="searchreplace"> 679*0Sstevel@tonic-gate <xsl:with-param name="text" select="$string"/> 680*0Sstevel@tonic-gate <xsl:with-param name="search">{1}</xsl:with-param> 681*0Sstevel@tonic-gate <xsl:with-param name="replace" select="$1"/> 682*0Sstevel@tonic-gate </xsl:call-template> 683*0Sstevel@tonic-gate </xsl:with-param> 684*0Sstevel@tonic-gate <xsl:with-param name="search">{2}</xsl:with-param> 685*0Sstevel@tonic-gate <xsl:with-param name="replace" select="$2"/> 686*0Sstevel@tonic-gate </xsl:call-template> 687*0Sstevel@tonic-gate </xsl:with-param> 688*0Sstevel@tonic-gate <xsl:with-param name="search">{3}</xsl:with-param> 689*0Sstevel@tonic-gate <xsl:with-param name="replace" select="$3"/> 690*0Sstevel@tonic-gate </xsl:call-template> 691*0Sstevel@tonic-gate </xsl:with-param> 692*0Sstevel@tonic-gate <xsl:with-param name="search">{4}</xsl:with-param> 693*0Sstevel@tonic-gate <xsl:with-param name="replace" select="$4"/> 694*0Sstevel@tonic-gate </xsl:call-template> 695*0Sstevel@tonic-gate </xsl:with-param> 696*0Sstevel@tonic-gate <xsl:with-param name="search">{5}</xsl:with-param> 697*0Sstevel@tonic-gate <xsl:with-param name="replace" select="$5"/> 698*0Sstevel@tonic-gate </xsl:call-template> 699*0Sstevel@tonic-gate </xsl:template> 700*0Sstevel@tonic-gate 701*0Sstevel@tonic-gate <!-- Localized message strings used throughout --> 702*0Sstevel@tonic-gate <xsl:template name="localization"> 703*0Sstevel@tonic-gate <message xml:lang="de" msgid="Sample message">Beispielanzeige</message> 704*0Sstevel@tonic-gate </xsl:template> 705*0Sstevel@tonic-gate 706*0Sstevel@tonic-gate</xsl:stylesheet> 707