Revision d71f59e9 snf-image-host/create
b/snf-image-host/create | ||
---|---|---|
24 | 24 |
|
25 | 25 |
ganeti_os_main |
26 | 26 |
|
27 |
if [ "$IMAGE_TYPE" = custom ]; then |
|
28 |
image_file=/dev/null |
|
29 |
image_size=\ |
|
30 |
$($CURL -sI "$IMAGE_NAME" | grep ^Content-Length: | cut -d" " -f2) |
|
31 |
else |
|
32 |
image_file="$IMAGE_DIR/$IMAGE_NAME.$IMAGE_TYPE" |
|
33 |
image_size="$(stat -L -c %s "$image_file")" |
|
34 |
fi |
|
35 |
|
|
36 |
if [ ! -e "$image_file" ]; then |
|
37 |
log_error "Image file \`$image_file' does not exit." |
|
38 |
exit 1 |
|
39 |
fi |
|
27 |
case $BACKEND_TYPE in |
|
28 |
local) |
|
29 |
image_file="$IMAGE_DIR/$(echo "$IMAGE_NAME" | sed 's/^file://').$IMAGE_TYPE" |
|
30 |
if [ ! -e "$image_file" ]; then |
|
31 |
log_error "Image file \`$image_file' does not exit." |
|
32 |
exit 1 |
|
33 |
fi |
|
34 |
image_size="$(stat -L -c %s "$image_file")" |
|
35 |
;; |
|
36 |
network) |
|
37 |
image_cmd="$CURL $(printf "%q" "$IMAGE_NAME") 2> /dev/null" |
|
38 |
image_size=$($CURL -sI "$IMAGE_NAME" | grep ^Content-Length: | cut -d" " -f2) |
|
39 |
;; |
|
40 |
pithos) |
|
41 |
cmd_args= "--db $(printf "%q" "${PITHOS_DB}") \ |
|
42 |
--data $(printf "%q" "${PITHOS_DATA}") \ |
|
43 |
$(printf "%q" "${IMAGE_NAME}")" |
|
44 |
image_cmd="./pithcat $cmd_args" |
|
45 |
image_size=$(./pithcat -s $cmd_args) |
|
46 |
;; |
|
47 |
esac |
|
40 | 48 |
|
41 | 49 |
monitor="" #Empty if progress monitor support is disabled |
42 | 50 |
if [ "$progress_monitor_support" = "yes" ]; then |
... | ... | |
69 | 77 |
snf_export_PROPERTY_OSFAMILY="linux" |
70 | 78 |
fi |
71 | 79 |
;; |
72 |
diskdump|custom)
|
|
80 |
diskdump) |
|
73 | 81 |
target="$blockdev" |
74 | 82 |
;; |
75 | 83 |
esac |
76 | 84 |
|
77 |
if [ "$IMAGE_TYPE" = "custom" ]; then |
|
78 |
"$CURL" "$IMAGE_NAME" 2>/dev/null |\ |
|
79 |
$monitor dd bs=4M of="$target" oflag=direct |
|
80 |
else |
|
85 |
if [ "$BACKEND_TYPE" = "local" ]; then |
|
81 | 86 |
# dd the dump to its new home :-) |
82 | 87 |
# Deploying an image file on a target block device is a streaming copy |
83 | 88 |
# operation. Enable the direct I/O flag on the output fd to avoid polluting |
84 | 89 |
# the host cache with useless data. |
85 | 90 |
$monitor dd bs=4M if="$image_file" of="$target" oflag=direct |
91 |
else |
|
92 |
$image_cmd | $monitor dd bs=4M of="$target" oflag=direct |
|
86 | 93 |
fi |
87 | 94 |
|
88 | 95 |
# Create a floppy image |
Also available in: Unified diff