Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

F #964: Allow FILES_DS for vCenter #3351

Merged
merged 1 commit into from
May 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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