Skip to content

Commit

Permalink
F OpenNebula#964: Allow FILES_DS for vCenter (OpenNebula#3351)
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiojvg authored and Tino Vázquez committed May 24, 2019
1 parent c53b101 commit d00b00a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1454,6 +1454,15 @@ def sync(deploy = {})
# 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

Expand All @@ -1478,6 +1487,18 @@ def sync(deploy = {})
@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|
Expand Down

0 comments on commit d00b00a

Please sign in to comment.