initial import of PoC from testbed
This commit is contained in:
commit
c25772de7c
|
@ -0,0 +1,22 @@
|
|||
<?xml version='1.0'?>
|
||||
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
|
||||
<service_bundle type='manifest' name='export'>
|
||||
<service name='system/guesthandler-disarm' type='service' version='0'>
|
||||
<create_default_instance enabled='true'/>
|
||||
<single_instance/>
|
||||
<dependency name='fs' grouping='require_all' restart_on='none' type='service'>
|
||||
<service_fmri value='svc:/system/filesystem/local'/>
|
||||
</dependency>
|
||||
<exec_method name='start' type='method' exec='/opt/custom/bin/guesthandler.sh disarm' timeout_seconds='0'/>
|
||||
<exec_method name='stop' type='method' exec=':true' timeout_seconds='100'/>
|
||||
<property_group name='startd' type='framework'>
|
||||
<propval name='duration' type='astring' value='transient'/>
|
||||
</property_group>
|
||||
<stability value='Unstable'/>
|
||||
<template>
|
||||
<common_name>
|
||||
<loctext xml:lang='C'>Disable auto-booting for all zones</loctext>
|
||||
</common_name>
|
||||
</template>
|
||||
</service>
|
||||
</service_bundle>
|
|
@ -0,0 +1,77 @@
|
|||
#!/usr/bin/env bash
|
||||
# implement guest start-up and shutdown order to ensure proper operation
|
||||
# PREREQUISITE: 'vmadm update $UUID <<< "{\"set_tags\": {\"priority\": 0}}"' where 0 means 'OFF', the rest determines ascending and descending numerical order respectively
|
||||
|
||||
. /lib/svc/share/smf_include.sh
|
||||
|
||||
if [ -z "$SMF_FMRI" ]; then
|
||||
echo "this script can only be invoked by smf(5)"
|
||||
exit $SMF_EXIT_ERR_NOSMF
|
||||
fi
|
||||
|
||||
ME=$(basename ${0%.sh})
|
||||
|
||||
# start-up delay between VMs
|
||||
DELAY=30
|
||||
|
||||
function log {
|
||||
# helper function to log arbitrary messages via syslog
|
||||
logger -p daemon.notice -t $ME $@
|
||||
}
|
||||
|
||||
case $1 in
|
||||
start)
|
||||
# determine the order of VMs by boot priority
|
||||
ORDER=( $(vmadm lookup -j -o uuid,tags | json -c 'this.tags.priority > 0' -a uuid tags.priority | sort -nk2 | cut -d " " -f1) )
|
||||
# start guests
|
||||
for UUID in ${ORDER[*]}
|
||||
do
|
||||
# invoke vmadm
|
||||
vmadm start $UUID 2> /dev/null
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
# successful start, log and wait
|
||||
log $UUID managed to $1
|
||||
sleep $DELAY
|
||||
else
|
||||
# failed to start guest
|
||||
log $UUID failed to $1
|
||||
fi
|
||||
done
|
||||
;;
|
||||
|
||||
stop)
|
||||
# determine the order of VMs by reverse boot priority
|
||||
ORDER=( $(vmadm lookup -j -o uuid,tags state=running | json -a uuid tags.priority | sort -rnk2 | cut -d " " -f1) )
|
||||
# stop guests
|
||||
for UUID in ${ORDER[*]}
|
||||
do
|
||||
# invoke vmadm
|
||||
vmadm stop $UUID 2> /dev/null
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
# successful stop
|
||||
log $UUID managed to $1
|
||||
else
|
||||
# failed to stop guest
|
||||
log $UUID failed to $1
|
||||
fi
|
||||
done
|
||||
;;
|
||||
|
||||
disarm)
|
||||
# set the 'autoboot' attribute to 'false' for every installed guest on order to prevent automatic start-up without this script
|
||||
zoneadm list -pi | while IFS=":" read ID UUID STATE remainder; do
|
||||
if [[ $STATE == "installed" ]];
|
||||
then
|
||||
zonecfg -z $UUID set autoboot=false
|
||||
fi
|
||||
done
|
||||
log disarmed: set autoboot=false on all zones
|
||||
;;
|
||||
|
||||
*)
|
||||
exit 1;
|
||||
esac
|
||||
|
||||
exit $SMF_EXIT_OK
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version='1.0'?>
|
||||
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
|
||||
<service_bundle type='manifest' name='export'>
|
||||
<service name='system/guesthandler' type='service' version='0'>
|
||||
<create_default_instance enabled='true'/>
|
||||
<single_instance/>
|
||||
<dependency name='vmadmd' grouping='require_all' restart_on='none' type='service'>
|
||||
<service_fmri value='svc:/system/smartdc/vmadmd:default'/>
|
||||
</dependency>
|
||||
<exec_method name='start' type='method' exec='/opt/custom/bin/guesthandler.sh %m' timeout_seconds='0'/>
|
||||
<exec_method name='stop' type='method' exec='/opt/custom/bin/guesthandler.sh %m' timeout_seconds='0'/>
|
||||
<property_group name='startd' type='framework'>
|
||||
<propval name='duration' type='astring' value='transient'/>
|
||||
</property_group>
|
||||
<stability value='Unstable'/>
|
||||
<template>
|
||||
<common_name>
|
||||
<loctext xml:lang='C'>Ordered start-up and shutdown for zones</loctext>
|
||||
</common_name>
|
||||
</template>
|
||||
</service>
|
||||
</service_bundle>
|
|
@ -0,0 +1,32 @@
|
|||
<?xml version='1.0'?>
|
||||
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
|
||||
<service_bundle type='manifest' name='export'>
|
||||
<service name='system/zones' type='service' version='0'>
|
||||
<create_default_instance enabled='true'/>
|
||||
<single_instance/>
|
||||
<dependency name='multi-user-server' grouping='require_all' restart_on='none' type='service'>
|
||||
<service_fmri value='svc:/milestone/multi-user-server'/>
|
||||
</dependency>
|
||||
<dependency name='metadata' grouping='require_all' restart_on='none' type='service'>
|
||||
<service_fmri value='svc:/system/smartdc/metadata'/>
|
||||
</dependency>
|
||||
<dependency name='guesthandler-disarm' grouping='require_all' restart_on='none' type='service'>
|
||||
<service_fmri value='svc:/system/guesthandler-disarm'/>
|
||||
</dependency>
|
||||
<exec_method name='start' type='method' exec='/lib/svc/method/svc-zones %m' timeout_seconds='0'/>
|
||||
<exec_method name='stop' type='method' exec='/lib/svc/method/svc-zones %m' timeout_seconds='100'/>
|
||||
<property_group name='startd' type='framework'>
|
||||
<propval name='duration' type='astring' value='transient'/>
|
||||
</property_group>
|
||||
<stability value='Unstable'/>
|
||||
<template>
|
||||
<common_name>
|
||||
<loctext xml:lang='C'>Zones autoboot and graceful shutdown</loctext>
|
||||
</common_name>
|
||||
<documentation>
|
||||
<manpage title='zones' section='5' manpath='/usr/share/man'/>
|
||||
<manpage title='zonecfg' section='1M' manpath='/usr/share/man'/>
|
||||
</documentation>
|
||||
</template>
|
||||
</service>
|
||||
</service_bundle>
|
Loading…
Reference in New Issue