1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-02-03 13:47:01 +03:00

F #964: Allow FILES_DS for vCenter (#3351)

This commit is contained in:
sergiojvg 2019-05-24 05:24:23 -05:00 committed by Tino Vázquez
parent c53b1018b9
commit d00b00a072

View File

@ -1454,6 +1454,15 @@ class VirtualMachine < VCenterDriver::Template
# get token and context
extraconfig += extraconfig_context
# get file_ds
if (files = one_item["TEMPLATE/CONTEXT/FILES_DS"])
file_id = 0
files.split(' ').each do |file|
extraconfig += extraconfig_file(file, file_id)
file_id += 1
end
end
# vnc configuration (for config_array hash)
extraconfig += extraconfig_vnc
@ -1478,6 +1487,18 @@ class VirtualMachine < VCenterDriver::Template
@item.ReconfigVM_Task(:spec => spec).wait_for_completion
end
def extraconfig_file(file, id)
path, name = file.split(':')
name = name.gsub('\'', '')
file_content = Base64.encode64(File.read(path))
file_content.prepend("#{name}\n")
[
{ :key => "guestinfo.opennebula.file.#{id}",
:value => file_content }
]
end
def extraconfig_context
context_text = "# Context variables generated by OpenNebula\n"
one_item.each('TEMPLATE/CONTEXT/*') do |context_element|