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

ensure machine_options and configs are symbolised for chef13 #1

Merged
merged 1 commit into from
Apr 17, 2017
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: 20 additions & 1 deletion lib/chef/provisioning/vsphere_driver/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ def self.symbolize_keys(h)
] : h
end

def deep_symbolize(hash_like)
if hash_like.nil? || hash_like.empty?
return {}
end
r = {}
hash_like.each do |key, value|
value = deep_symbolize(value) if value.respond_to?(:values)
r[key.to_sym] = value
end
r
end

def initialize(driver_url, config)
super(driver_url, config)

Expand Down Expand Up @@ -110,6 +122,7 @@ def initialize(driver_url, config)
# -- vm_folder: name of the vSphere folder containing the VM
#
def allocate_machine(action_handler, machine_spec, machine_options)
machine_options=deep_symbolize(machine_options)
merge_options! machine_options

if machine_spec.location
Expand Down Expand Up @@ -146,9 +159,10 @@ def allocate_machine(action_handler, machine_spec, machine_options)

def merge_options!(machine_options)
@config = Cheffish::MergedConfig.new(
{ machine_options: machine_options },
{ :machine_options => machine_options },
@config
)
@config=deep_symbolize(@config.to_h)
end

def add_machine_spec_location(vm, machine_spec)
Expand Down Expand Up @@ -202,6 +216,7 @@ def machine_msg(name, id, action)
end

def ready_machine(action_handler, machine_spec, machine_options)
machine_options=deep_symbolize(machine_options)
merge_options! machine_options

vm = start_machine(action_handler, machine_spec, machine_options)
Expand Down Expand Up @@ -393,11 +408,13 @@ def has_ip?(ip, vm)

# Connect to machine without acquiring it
def connect_to_machine(machine_spec, machine_options)
machine_options=deep_symbolize(machine_options)
merge_options! machine_options
machine_for(machine_spec, machine_options)
end

def destroy_machine(action_handler, machine_spec, machine_options)
machine_options=deep_symbolize(machine_options)
merge_options! machine_options
vm = vm_for(machine_spec)
if vm
Expand All @@ -417,6 +434,7 @@ def destroy_machine(action_handler, machine_spec, machine_options)
end

def stop_machine(action_handler, machine_spec, machine_options)
machine_options=deep_symbolize(machine_options)
merge_options! machine_options
vm = vm_for(machine_spec)
if vm
Expand All @@ -427,6 +445,7 @@ def stop_machine(action_handler, machine_spec, machine_options)
end

def start_machine(action_handler, machine_spec, machine_options)
machine_options=deep_symbolize(machine_options)
merge_options! machine_options
vm = vm_for(machine_spec)
if vm
Expand Down