このプラグイン例では、components ディレクトリに Container.xml ファイルがあります。このコンポーネントは型付けされておらず、Solaris 10 OS が稼働しているシステムを別々のゾーンに区分化するように設計されています。このあとに示す例では、次の要素を指定してコンポーネントを作成しています。
<component> 要素の path、name、 description、platform の各要素では、コンポーネントタイプに固有の情報を指定しています。
<varlist> 要素では、ユーザーがこのコンポーネントタイプに基づくコンポーネントをカスタマイズできるようにする複数の変数を定義しています。
<componentReflList> 要素では、container_util コンポーネントを呼び出して、コンポーネントに対する複数の処理を行っています。
<installList> 要素では、<execNative> ステップを呼び出して、Solaris のコマンドを実行してゾーンを作成しています。
<uninstallList> 要素では、<execNative> ステップを呼び出して、Solaris のコマンドを実行してゾーンを削除しています。
<controllList> 要素では、<execNative> ステップを呼び出して、さまざまなシステムチェックを行うシェルスクリプトを実行しています。
<?xml version="1.0" encoding="UTF-8"?> <component platform='system#Solaris 10' installPath=':[installPath]' xmlns='http://www.sun.com/schema/SPS' name='Container' version='5.2' description='Solaris Container' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' limitToHostSet='com.sun.solaris#global_zones' softwareVendor='Sun Microsystems' path='/com/sun/solaris' xsi:schemaLocation='http://www.sun.com/schema/SPS component.xsd'> <varList> <var name='installPath' default=':[target:local_zone_default_name]' prompt='Zone Name'></var> <var name='local_zone_filesystem' default=':[target:local_zone_default_filesystem]' prompt='SPARSE,FULL'></var> <var name='local_zone_connection_type' default=':[target:local_zone_connection_type]' access='PRIVATE'></var> <var name='local_zone_port' default=':[target:local_zone_port]' access='PRIVATE'></var> <var name='local_zone_advanced_params' default=':[target:local_zone_advanced_params]' access='PRIVATE'></var> <var name='n1sps_cli_host' default=':[target:n1sps_cli_host]' access='PRIVATE'></var> <var name='n1sps_cli_path' default=':[target:n1sps_cli_path]' access='PRIVATE'></var> <var name='zoneIfaceDetails' default='' prompt='Semicolon separted network_interface,IPAddress/netmask pairs. Example: hme0,123.123.123.123/24;eri0,124.124.124.124/8.'></var> <var name='zoneFsLayout' default='' prompt="Semicolon separted filesystem infos. Example: dir=/usr/local special=/opt/local raw=/dev/rdsk/c0t0d0s7 type=lofs [ro,nodevices];dir=/opt/mystuff special=/empty type=lofs ro. (see 'man zonecfg')"></var> </varList> <targetRef hostName=':[installPath]' typeName='com.sun.solaris#local_zone'> <agent params=':[local_zone_advanced_params]' ipAddr=':[installPath]' port=':[local_zone_port]' connection=':[local_zone_connection_type]'></agent> </targetRef> <componentRefList> <componentRef name='container_util' installMode='TOPLEVEL'> <component name='container_util' path='/com/sun/solaris' version='1.1'></component> </componentRef> </componentRefList> <installList> <installSteps returns='false' name='create'> <varList> <var name='raHomeDir' default=':[target:sys.raHomeDir]'></var> <var name='raDataDir' default=':[target:sys.raDataDir]'></var> <var name='raTmpDir' default=':[target:sys.raTmpDir]'></var> <var name='binPath' default=':[target:sys.raDataDir]:[/]systemcomps:[/]com.sun.solaris: [/]container_util'></var> <var name='local_zone_base_path' default=':[target:local_zone_base_path]'></var> </varList> <try> <block> <checkDependency> <toplevelRef name='container_util'></toplevelRef> </checkDependency> </block> <catch> <install blockName='default'> <toplevelRef name='container_util'></toplevelRef> </install> </catch> </try> <createDependency name='local_zone'> <toplevelRef name='container_util'></toplevelRef> </createDependency> <execNative userToRunAs='root' timeout='10800'> <exec cmd=':[binPath]/sps_zcreate.sh'> <arg value=':[installPath]'></arg> <arg value=':[local_zone_base_path]'></arg> <arg value=':[local_zone_filesystem]'></arg> <arg value=':[zoneIfaceDetails]'></arg> <arg value=':[zoneFsLayout]'></arg> </exec> </execNative> <execNative userToRunAs='root'> <exec cmd=':[binPath]/sps_zinstall.sh'> <arg value=':[installPath]'></arg> <arg value=':[raHomeDir]'></arg> <arg value=':[raDataDir]'></arg> <arg value=':[raTmpDir]'></arg> <arg value=':[local_zone_connection_type]'></arg> <arg value=':[local_zone_port]'></arg> <arg value=':[local_zone_advanced_params]'></arg> </exec> </execNative> <execNative userToRunAs='root'> <exec cmd=':[binPath]/sps_zboot.sh'> <arg value=':[installPath]'></arg> </exec> </execNative> <execNative userToRunAs='root'> <exec cmd=':[binPath]/sps_sysidwait_zhalt.sh'> <arg value=':[installPath]'></arg> </exec> </execNative> </installSteps> <installSteps returns='false' name='markOnly'></installSteps> </installList> <uninstallList> <uninstallSteps returns='false' name='delete'> <varList> <var name='binPath' default=':[target:sys.raDataDir]:[/]systemcomps:[/]com.sun.solaris: [/]container_util'></var> </varList> <dependantCleanup> <uninstall blockName='unprep'> <thisComponent></thisComponent> </uninstall> </dependantCleanup> <checkDependency> <toplevelRef name='container_util'></toplevelRef> </checkDependency> <call blockName='deactivate'> <thisComponent></thisComponent> </call> <execNative userToRunAs='root'> <exec cmd=':[binPath]/sps_zdelete.sh'> <arg value=':[installPath]'></arg> </exec> </execNative> </uninstallSteps> <uninstallSteps returns='false' name='markOnly'> <dependantCleanup> <uninstall blockName='unprep'> <thisComponent></thisComponent> </uninstall> </dependantCleanup> </uninstallSteps> </uninstallList> <controlList> <control returns='false' name='activate'> <varList> <var name='raHomeDir' default=':[target:sys.raHomeDir]'></var> <var name='binPath' default=':[target:sys.raDataDir]:[/]systemcomps:[/]com.sun.solaris: [/]container_util'></var> </varList> <checkDependency> <toplevelRef name='container_util'></toplevelRef> </checkDependency> <execNative userToRunAs='root'> <exec cmd=':[binPath]/sps_zboot.sh'> <arg value=':[installPath]'></arg> </exec> </execNative> <execNative userToRunAs='root'> <exec cmd=':[binPath]/sps_svcwait.sh'> <arg value=':[installPath]'></arg> <arg value='/milestone/multi-user'></arg> </exec> <successCriteria></successCriteria> </execNative> <if> <condition> <equals value2='SSH' value1=':[local_zone_connection_type]'></equals> </condition> <then></then> <else> <execNative userToRunAs='root'> <exec cmd=':[binPath]/sps_zra.sh'> <arg value=':[installPath]'></arg> <arg value=':[raHomeDir]'></arg> <arg value='start noprompt'></arg> </exec> </execNative> </else> </if> <try> <block> <retarget host=':[n1sps_cli_host]'> <varList> <var name='sessionID' default=':[session:sys:sessionID]'></var> </varList> <execNative timeout='60'> <inputText><![CDATA[ /bin/pkginfo -q SUNWspscl if [ $? -eq 0 ]; then N1SPS_CLI=`/bin/pkginfo -r SUNWspscl`/cli/bin/cr_cli else N1SPS_CLI=`/bin/ls :[n1sps_cli_path] | /bin/tail -1` if [ -z "$N1SPS_CLI" ]; then echo "N1 SPS cli not found" exit 1 fi fi echo "Testing connection to RA on local zone ':[installPath]'" index=1 while [ $index -le 3 ];do output=`$N1SPS_CLI -cmd net.ping -d :[installPath]::[local_zone_port] -s :[sessionID]` echo $output | grep "Succeeded" if [ $? -eq 0 ]; then exit 0 fi index=`expr $index + 1` done exit 1 ]]></inputText> <exec cmd='/bin/sh'></exec> </execNative> <execNative> <inputText><![CDATA[ /bin/pkginfo -q SUNWspscl if [ $? -eq 0 ]; then N1SPS_CLI=`/bin/pkginfo -r SUNWspscl`/cli/bin/cr_cli else N1SPS_CLI=`/bin/ls :[n1sps_cli_path] | /bin/tail -1` if [ -z "$N1SPS_CLI" ]; then echo "N1 SPS cli not found" exit 1 fi fi echo "prep local zone ':[installPath]'" $N1SPS_CLI -cmd pe.h.prep -tar NM::[installPath] -s :[sessionID] ]]></inputText> <exec cmd='/bin/sh'></exec> </execNative> </retarget> </block> <catch></catch> </try> </control> <control returns='false' name='deactivate'> <varList> <var name='raHomeDir' default=':[target:sys.raHomeDir]'></var> <var name='binPath' default=':[target:sys.raDataDir]: [/]systemcomps:[/]com.sun.solaris:[/]container_util'></var> </varList> <checkDependency> <toplevelRef name='container_util'></toplevelRef> </checkDependency> <execNative userToRunAs='root'> <exec cmd=':[binPath]/sps_zhalt.sh'> <arg value=':[installPath]'></arg> <arg value=':[raHomeDir]'></arg> </exec> <successCriteria></successCriteria> </execNative> </control> </controlList> </component>