mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-30 22:50:10 +03:00
(cherry picked from commit 40483a5b51783ad5f9aa51f0801a2f7b5b9f7a67)
This commit is contained in:
parent
d305167c6e
commit
280f6a6b81
@ -68,7 +68,15 @@ class Storage
|
||||
end
|
||||
end
|
||||
|
||||
def self.get_image_import_template(ds_name, image_path, image_type, image_prefix, ipool, type, ds_id)
|
||||
def self.get_image_import_template(disk, ipool, type, ds_id, opts = {})
|
||||
|
||||
VCenterDriver::VIHelper.check_opts(opts, [:persistent])
|
||||
|
||||
ds_name = disk[:datastore].name
|
||||
image_path = disk[:path]
|
||||
image_type = disk[:type]
|
||||
image_prefix = disk[:prefix]
|
||||
|
||||
one_image = {}
|
||||
one_image[:template] = ""
|
||||
|
||||
@ -93,7 +101,7 @@ class Storage
|
||||
one_image[:template] << "NAME=\"#{image_name}\"\n"
|
||||
one_image[:template] << "PATH=\"vcenter://#{image_path}\"\n"
|
||||
one_image[:template] << "TYPE=\"#{image_type}\"\n"
|
||||
one_image[:template] << "PERSISTENT=\"YES\"\n"
|
||||
one_image[:template] << "PERSISTENT=\"#{opts[:persistent]}\"\n"
|
||||
one_image[:template] << "VCENTER_IMPORTED=\"YES\"\n"
|
||||
one_image[:template] << "DEV_PREFIX=\"#{image_prefix}\"\n"
|
||||
else
|
||||
|
@ -35,19 +35,23 @@ class VIHelper
|
||||
clusters.each do |id|
|
||||
return id unless id == -1
|
||||
end
|
||||
|
||||
return -1
|
||||
end
|
||||
|
||||
def self.one_managed?(object)
|
||||
if object.class.ancestors.include?(OpenNebula::XMLElement)
|
||||
managed = object["TEMPLATE/OPENNEBULA_MANAGED"] || object["USER_TEMPLATE/OPENNEBULA_MANAGED"]
|
||||
|
||||
return managed != "NO"
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
def self.check_opts(opts, att_list)
|
||||
att_list.each do |att|
|
||||
raise "#{att} option is mandatory" if opts[att].nil?
|
||||
end
|
||||
end
|
||||
|
||||
def self.one_item(the_class, id, exit_if_fail = true)
|
||||
item = the_class.new_with_id(id, client)
|
||||
rc = item.info
|
||||
|
@ -71,6 +71,10 @@ class Template
|
||||
end
|
||||
end
|
||||
|
||||
def wild?
|
||||
self.class == VCenterDriver::VirtualMachine
|
||||
end
|
||||
|
||||
def get_dc
|
||||
item = @item
|
||||
|
||||
@ -270,13 +274,8 @@ class Template
|
||||
break
|
||||
end
|
||||
|
||||
image_import = VCenterDriver::Datastore.get_image_import_template(disk[:datastore].name,
|
||||
disk[:path],
|
||||
disk[:type],
|
||||
disk[:prefix],
|
||||
ipool,
|
||||
type,
|
||||
datastore_found["ID"])
|
||||
opts = {:persistent => wild? ? "YES":"NO"}
|
||||
image_import = VCenterDriver::Datastore.get_image_import_template(disk, ipool, type, datastore_found["ID"], opts)
|
||||
#Image is already in the datastore
|
||||
if image_import[:one]
|
||||
# This is the disk info
|
||||
|
Loading…
x
Reference in New Issue
Block a user