attach-disk-4.2.0.patch

For OpenNebula 4.0+ - WH Wang, 09/13/2013 09:33 AM

Download (1.35 KB)

View differences:

./attach_disk 2013-09-13 17:12:42.793368462 +0800
40 40
done < <($XPATH     $DISK_XPATH/DRIVER \
41 41
                    $DISK_XPATH/TYPE \
42 42
                    $DISK_XPATH/READONLY \
43
                    $DISK_XPATH/CACHE)
43
                    $DISK_XPATH/CACHE \
44
                    $DISK_XPATH/SOURCE)
44 45

  
45 46
DRIVER="${XPATH_ELEMENTS[0]:-$DEFAULT_TYPE}"
46 47
TYPE="${XPATH_ELEMENTS[1]}"
47 48
READONLY="${XPATH_ELEMENTS[2]}"
48 49
CACHE="${XPATH_ELEMENTS[3]}"
50
IMG_SRC="${XPATH_ELEMENTS[4]}"
49 51

  
50 52
TYPE=$(echo "$TYPE"|tr A-Z a-z)
51 53

  
52 54
case "$TYPE" in
53 55
block)
54
    TYPE_SOURCE="dev"
56
    TYPE_SOURCE="dev='$SOURCE'"
55 57
    TYPE_XML="block"
56 58
    DEVICE="disk"
57 59
    ;;
58 60
cdrom)
59
    TYPE_SOURCE="file"
61
    TYPE_SOURCE="file='$SOURCE'"
60 62
    TYPE_XML="file"
61 63
    DEVICE="cdrom"
62 64
    ;;
65
rbd)
66
    TYPE_SOURCE="protocol='rbd' name='$IMG_SRC'"
67
    TYPE_XML="network"
68
    DEVICE="disk"
69
    ;;
63 70
*) 
64 71
    #NOTE: This includes TYPE=FS and TYPE=SWAP
65
    TYPE_SOURCE="file"
72
    TYPE_SOURCE="file='$SOURCE'"
66 73
    TYPE_XML="file"
67 74
    DEVICE="disk"
68 75
    ;;
......
83 90
cat <<EOF > $ATTACH_FILE
84 91
<disk type='$TYPE_XML' device='$DEVICE'>
85 92
  <driver name='qemu' type='$DRIVER' $CACHE/>
86
  <source $TYPE_SOURCE='$SOURCE'/>
93
  <source $TYPE_SOURCE/>
87 94
  <target dev='$TARGET'/>
88 95
  $READONLY
89 96
</disk>