Revision c25a863c

View differences:

src/datastore_mad/remotes/vcenter/mkfs
43 43
host_id      = drv_action["/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/VCENTER_ONE_HOST_ID"]
44 44
ds_image_dir = drv_action["/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/VCENTER_DS_IMAGE_DIR"] || "one"
45 45
img_id       = drv_action["/DS_DRIVER_ACTION_DATA/IMAGE/ID"]
46
adapter_type = drv_action["/DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/VCENTER_ADAPTER_TYPE"]
47
disk_type    = drv_action["/DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/VCENTER_DISK_TYPE"]
46
adapter_type = drv_action["/DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/VCENTER_ADAPTER_TYPE"] ||
47
                VCenterDriver::VIHelper.get_default("IMAGE/TEMPLATE/VCENTER_ADAPTER_TYPE")
48
disk_type    = drv_action["/DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/VCENTER_DISK_TYPE"] ||
49
                VCenterDriver::VIHelper.get_default("IMAGE/TEMPLATE/VCENTER_DISK_TYPE")
48 50
size         = drv_action["/DS_DRIVER_ACTION_DATA/IMAGE/SIZE"]
49 51
fs_type      = drv_action["/DS_DRIVER_ACTION_DATA/IMAGE/FSTYPE"]
50 52

  
src/tm_mad/vcenter/mkimage
61 61

  
62 62
# Get adapter and disk type
63 63
one_vm = VCenterDriver::VIHelper.one_item(OpenNebula::VirtualMachine, vmid)
64
adapter_type = one_vm["/VM/TEMPLATE/DISK[DISK_ID=#{disk_id}]/VCENTER_ADAPTER_TYPE"]
65

  
66
# TODO disk_type support, that info is not coming thin, thick...
67
disk_type = one_vm["/VM/TEMPLATE/DISK[DISK_ID=#{disk_id}]/VCENTER_DISK_TYPE"]
68
disk_type = "thin" if disk_type.nil? || disk_type.empty?
64
adapter_type = one_vm["/VM/TEMPLATE/DISK[DISK_ID=#{disk_id}]/VCENTER_ADAPTER_TYPE"] ||
65
               VCenterDriver::VIHelper.get_default("IMAGE/TEMPLATE/VCENTER_ADAPTER_TYPE")
66
disk_type = one_vm["/VM/TEMPLATE/DISK[DISK_ID=#{disk_id}]/VCENTER_DISK_TYPE"] ||
67
            VCenterDriver::VIHelper.get_default("IMAGE/TEMPLATE/VCENTER_DISK_TYPE")
69 68

  
70 69
check_valid adapter_type, "adapter_type"
70
check_valid disk_type, "disk_type"
71 71

  
72 72
begin
73 73
    vi_client = VCenterDriver::VIClient.new_from_host(host_id)
src/vmm_mad/remotes/lib/vcenter_driver/vi_helper.rb
1 1
module VCenterDriver
2 2

  
3 3
class VIHelper
4

  
5
    ETC_LOCATION = "/etc/one/" if !defined?(ETC_LOCATION)
6
    VCENTER_DRIVER_DEFAULT = "#{ETC_LOCATION}/vcenter_driver.default"
7

  
4 8
    def self.client
5 9
        @@client ||= OpenNebula::Client.new
6 10
    end
......
54 58
        return element
55 59
    end
56 60

  
61
    def self.get_default(xpath)
62
        begin
63
            xml = OpenNebula::XMLElement.new
64
            xml.initialize_xml(File.read(VCENTER_DRIVER_DEFAULT), 'VCENTER')
65
            return xml[xpath]
66
        rescue
67
            return nil
68
        end
69
    end
70

  
57 71
end # class VIHelper
58 72

  
59 73
end # module VCenterDriver

Also available in: Unified diff