6 SCRIPT_NAME=$(basename $0)
8 for dir in /lib/udev /sbin; do
9 if [ -f $dir/vol_id -a -x $dir/vol_id ]; then
14 if [ -z "$VOL_ID" ]; then
15 log_error "vol_id not found, please install udev"
19 get_api5_arguments() {
20 TEMP=`getopt -o o:n:i:b:s: -n '$0' -- "$@"`
21 if [ $? != 0 ] ; then log_error "Terminating..."; exit 1 ; fi
22 # Note the quotes around `$TEMP': they are essential!
26 -i|-n) instance=$2; shift 2;;
28 -o) old_name=$2; shift 2;;
30 -b) blockdev=$2; shift 2;;
32 -s) swapdev=$2; shift 2;;
36 *) log_error "Internal error!" >&2; exit 1;;
39 if [ -z "$instance" -o -z "$blockdev" ]; then
40 log_error "Missing OS API Argument (-i, -n, or -b)"
43 if [ "$SCRIPT_NAME" != "export" -a -z "$swapdev" ]; then
44 log_error "Missing OS API Argument -s (swapdev)"
47 if [ "$SCRIPT_NAME" = "rename" -a -z "$old_name" ]; then
48 log_error "Missing OS API Argument -o (old_name)"
53 get_api10_arguments() {
54 if [ -z "$INSTANCE_NAME" -o -z "$HYPERVISOR" -o -z "$DISK_COUNT" ]; then
55 log_error "Missing OS API Variable:"
56 log_error "(INSTANCE_NAME HYPERVISOR or DISK_COUNT)"
59 instance=$INSTANCE_NAME
60 if [ $DISK_COUNT -lt 1 -o -z "$DISK_0_PATH" ]; then
61 log_error "At least one disk is needed"
65 if [ "$SCRIPT_NAME" = "rename" -a -z "$OLD_INSTANCE_NAME" ]; then
66 log_error "Missing OS API Variable OLD_INSTANCE_NAME"
68 old_name=$OLD_INSTANCE_NAME
71 if [ -z "$OS_API_VERSION" -o "$OS_API_VERSION" = "5" ]; then
74 elif [ "$OS_API_VERSION" = "10" ]; then
76 if [ $SCRIPT_NAME = "import" -o $SCRIPT_NAME = "export" ]; then
77 log_error "import/export still not compatible with API version 10"
81 log_error "Unknown OS API VERSION $OS_API_VERSION"