1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

F #2320: migrate image gets proper format

This commit is contained in:
sergio semedi 2019-01-16 16:43:00 +01:00 committed by Tino Vázquez
parent 62fad9316b
commit a9d43e9f3a
2 changed files with 11 additions and 6 deletions

View File

@ -57,15 +57,9 @@ md5 = drv_action["/DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/MD5"]
sha1 = drv_action["/DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/SHA1"]
nodecomp = drv_action["/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/NO_DECOMPRESS"]
limit_bw = drv_action["/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/LIMIT_TRANSFER_BW"]
format = drv_action["IMAGE/TEMPLATE/FORMAT"]
check_valid img_path, "img_path"
if format != 'vmdk' && format != 'iso'
one_img = VCenterDriver::VIHelper.one_item(OpenNebula::Image, id)
one_img.replace({'FORMAT' => 'vmdk'})
end
# if image is already in a vCenter datastore return the path
if img_path.start_with? "vcenter://"
img_path = img_path.sub("vcenter://", "")

View File

@ -193,6 +193,17 @@ module OpenNebula
image = Image.new(Image.build_xml, @client)
rc = image.allocate(tmpl, options[:dsid])
ds = OpenNebula::Datastore.new_with_id(options[:dsid], @client)
image.info
ds.info
xpath = 'TEMPLATE/DRIVER'
if ds[xpath] == 'vcenter' && self['FORMAT'] != 'iso' && self['FORMAT'] != 'vmdk'
image.replace({'FORMAT' => 'vmdk'})
elsif ds[xpath] && ds[xpath] != 'vcenter' && self['FORMAT'] == 'vmdk'
image.replace({'FORMAT' => ds[xpath] })
end
return { :image => [rc] } if OpenNebula.is_error?(rc)
image_id = image.id