Revision ade6513a src/datastore_mad/remotes/fs/export

View differences:

src/datastore_mad/remotes/fs/export
45 45
while IFS= read -r -d '' element; do
46 46
    XPATH_ELEMENTS[i++]="$element"
47 47
done < <($XPATH     /DS_DRIVER_ACTION_DATA/IMAGE/SOURCE \
48
                    /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/BRIDGE_LIST \
49
                    /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/EXPORT_DIR \
50
                    /DS_DRIVER_ACTION_DATA/DATASTORE/BASE_PATH)
48
                    /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/BRIDGE_LIST)
51 49
unset i
52 50

  
53 51
SRC="${XPATH_ELEMENTS[i++]}"
54 52
BRIDGE_LIST="${XPATH_ELEMENTS[i++]}"
55
EXPORT_DIR="${XPATH_ELEMENTS[i++]}"
56
BASE_PATH="${XPATH_ELEMENTS[i++]}"
57 53

  
58
EXPORT_DIR="${EXPORT_DIR-$BASE_PATH}"
59

  
60
# -------------------- Convert image to qcow2 format ---------------------------
61
# TODO:
62
#   Export directories needs to be defined, probably in oned.conf
63
#   BRIDGE_LIST needs to be handled
64 54
#-------------------------------------------------------------------------------
55
# Output image source and format
56
#-------------------------------------------------------------------------------
57

  
58
INFO_SCRIPT=$(cat <<EOF
59

  
60
CHECKSUM=\$(${MD5SUM} ${SRC} | cut -f1 -d' ')
61
SIZE=\$(${DU} -LBM ${SRC} | cut -f1)
62
FORMAT=\$(${QEMU_IMG} info ${SRC} 2>/dev/null | grep -Po '(?<=file format: )\w+')
63

  
64
echo "<CHECKSUM>\$CHECKSUM</CHECKSUM>"
65
echo "<SIZE>\$SIZE</SIZE>"
66
echo "<FORMAT>\$FORMAT</FORMAT>"
67

  
68
EOF
69
)
65 70

  
66
log "Removing $SRC from the image repository"
71
if [ -n "$BRIDGE_LIST" ]; then
72
    HOST=`get_destination_host $ID`
73
    INFO=$(ssh_monitor_and_log "$HOST" "$INFO_SCRIPT" "Image info script" 2>&1)
74
    SRC="ssh://$HOST:$SRC"
75
else
76
    INFO=$(monitor_and_log "$INFO_SCRIPT" "Image info script" 2>&1)
77
fi
78

  
79
INFO_STATUS=$?
80

  
81
if [ "$INFO_STATUS" != "0" ]; then
82
    echo "$INFO"
83
    exit $INFO_STATUS
84
fi
67 85

  
68
exec_and_log "$QEMU_IMG convert -O qcow2 $SRC $SRC.export" \
69
	"Error converting image to qcow2 format"
86
echo "<IMPORT_INFO><IMPORT_SOURCE>$SRC</IMPORT_SOURCE> \
87
      $INFO \
88
      <DISPOSE>NO</DISPOSE></IMPORT_INFO>"
70 89

  
71
echo "$SRC.export"

Also available in: Unified diff