mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
Migrate images to/from KVM / vCenter DS (#2382)
This commit is contained in:
parent
2841ccabfb
commit
01f7846904
@ -257,6 +257,10 @@ while true; do
|
||||
export MAX_SIZE="$2"
|
||||
shift 2
|
||||
;;
|
||||
--convert)
|
||||
export CONVERT="$2"
|
||||
shift 2
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
@ -393,3 +397,40 @@ fi
|
||||
if [ "$TO" != "-" ]; then
|
||||
unarchive "$TO"
|
||||
fi
|
||||
|
||||
# Function to know what is the original image type
|
||||
# Figure out what type of image it is
|
||||
function get_original_type
|
||||
{
|
||||
command_get_type="qemu-img info "$TO""
|
||||
output_get_type=$(eval "$command_get_type")
|
||||
|
||||
split=$(echo $output_get_type | tr ":" "\n")
|
||||
count=0
|
||||
format=""
|
||||
|
||||
for pal in $split
|
||||
do
|
||||
if [ "$count" == 4 ]; then
|
||||
format=$pal
|
||||
break
|
||||
fi
|
||||
count=$((count+1))
|
||||
done
|
||||
echo $format
|
||||
}
|
||||
|
||||
# Convert the image to a given type into a tmp image with qemu-img
|
||||
if [ ! -z "$CONVERT" ]; then
|
||||
|
||||
tmpimage=$TO".tmp"
|
||||
|
||||
original_type=$(get_original_type)
|
||||
convert_type=$CONVERT
|
||||
|
||||
convert="qemu-img convert -f "$original_type" -O "$convert_type" "$TO" "$tmpimage""
|
||||
|
||||
# Move tmp image to get the final image
|
||||
mvcommand="mv "$tmpimage" "$TO""
|
||||
eval "$mvcommand"
|
||||
fi
|
@ -92,6 +92,7 @@ if VCenterDriver::FileHelper.is_remote_or_needs_unpack?(img_path)
|
||||
downsh_args << "--sha1 #{sha1} " if sha1 && !sha1.empty?
|
||||
downsh_args << "--nodecomp " if nodecomp && !nodecomp.empty?
|
||||
downsh_args << "--limit #{limit_bw} " if limit_bw && !limit_bw.empty?
|
||||
downsh_args << "--convert vmdk"
|
||||
|
||||
downloader = "#{File.dirname(__FILE__)}/../downloader.sh #{downsh_args}"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user