Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 54 lines (47 sloc) 1.135 kB
f77e728 Initial import of hg.uk.xensource.com/carbon/trunk/api.hg c/s 9691:9a…
Xen hg user authored
1 #!/bin/sh
2
3a6c49b Fix trivial shell warning
Mike McClurg authored
3 function usage
f77e728 Initial import of hg.uk.xensource.com/carbon/trunk/api.hg c/s 9691:9a…
Xen hg user authored
4 {
5 echo
6 echo Usage:
7 echo $0 "<VDI uuid> [ command to execute, defaults to /bin/sh ]"
8 echo
9 echo Block attaches a VDI to the control domain, executes a command \(typically a shell\),
10 echo detaches and destroys the VBD when the command finishes.
11
12 }
13
14 VDI=$1
15 # check that the VDI actually exists
16 if [ -z "$(xe vdi-list params=uuid uuid=${VDI})" ]; then
17 echo Failed to find VDI with UUID: ${VDI}
18 usage
19 exit 1
20 fi
5b5627a @zli Some minor improvements to the with-vdi script
zli authored
21
f77e728 Initial import of hg.uk.xensource.com/carbon/trunk/api.hg c/s 9691:9a…
Xen hg user authored
22 COMMAND=$2
cbb71bb @zli CA-67761: ommit the DEVICE=xxx line when executing batch script
zli authored
23 if [ -n "$COMMAND" ]; then
24 if ! which "$COMMAND" > /dev/null ; then
25 echo Failed to find command: ${COMMAND}
26 usage
27 exit 1
28 else
29 shift 1
30 COMMAND=$*
31 fi
f77e728 Initial import of hg.uk.xensource.com/carbon/trunk/api.hg c/s 9691:9a…
Xen hg user authored
32 fi
33
13b8348 @jonludlam Move everything over to using Fhs.ml / @ substitution
jonludlam authored
34 . @INVENTORY@
f77e728 Initial import of hg.uk.xensource.com/carbon/trunk/api.hg c/s 9691:9a…
Xen hg user authored
35
36 if [ `xe vdi-param-get uuid=${VDI} param-name=read-only` = "true" ] ; then
37 MODE=RO
38 else
39 MODE=RW
40 fi
81662ee CA-45278: Make with-vdi VBDs unpluggable.
Daniel Stodden authored
41 VBD=`xe vbd-create vm-uuid=${CONTROL_DOMAIN_UUID} vdi-uuid=${VDI} device=autodetect mode=${MODE} unpluggable=true`
f77e728 Initial import of hg.uk.xensource.com/carbon/trunk/api.hg c/s 9691:9a…
Xen hg user authored
42 xe vbd-plug uuid=${VBD}
43 DEVICE=`xe vbd-param-get uuid=${VBD} param-name=device`
44 export DEVICE
cbb71bb @zli CA-67761: ommit the DEVICE=xxx line when executing batch script
zli authored
45 if [ -z "$COMMAND" ]; then
46 echo DEVICE=${DEVICE}
47 COMMAND=/bin/sh
48 fi
f77e728 Initial import of hg.uk.xensource.com/carbon/trunk/api.hg c/s 9691:9a…
Xen hg user authored
49 ${COMMAND}
5b5627a @zli Some minor improvements to the with-vdi script
zli authored
50 RC=$?
6831ae9 CA-45049: Add some vbd-unplug grace time in with-vdi.
Daniel Stodden authored
51 xe vbd-unplug uuid=${VBD} timeout=15
f77e728 Initial import of hg.uk.xensource.com/carbon/trunk/api.hg c/s 9691:9a…
Xen hg user authored
52 xe vbd-destroy uuid=${VBD}
5b5627a @zli Some minor improvements to the with-vdi script
zli authored
53 exit ${RC}
Something went wrong with that request. Please try again.