Skip to content

Commit

Permalink
[vsphere] Supplied a mock implementation for cloudinit_to_customspec.
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvdrum committed Feb 8, 2015
1 parent a05e7db commit f161203
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/fog/vsphere/requests/compute/cloudinit_to_customspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Compute
class Vsphere
class Real
def cloudinit_to_customspec(user_data)
raise ArgumentError, "user_data cant be nil" if user_data.nil?
raise ArgumentError, "user_data can't be nil" if user_data.nil?
custom_spec = { 'customization_spec' => Hash.new }
user_data = YAML.load(user_data)
custom_spec['hostname'] = user_data['hostname'] if user_data.key?('hostname')
Expand All @@ -19,8 +19,17 @@ def cloudinit_to_customspec(user_data)

class Mock
def cloudinit_to_customspec(user_data)
raise ArgumentError, "user_data cant be nil" if user_data.nil?
true
raise ArgumentError, "user_data can't be nil" if user_data.nil?
custom_spec = { 'customization_spec' => Hash.new }
user_data = YAML.load(user_data)
custom_spec['hostname'] = user_data['hostname'] if user_data.key?('hostname')
custom_spec['ipsettings'] = { 'ip' => user_data['ip'] } if user_data.key?('ip')
custom_spec['ipsettings']['subnetMask'] = user_data['netmask'] if user_data.key?('netmask')
custom_spec['ipsettings']['dnsServerList'] = user_data['dns'] if user_data.key?('dns')
custom_spec['domain'] = user_data['domain'] if user_data.key?('domain')
custom_spec['dnsSuffixList'] = user_data['domain'] if user_data.key?('domain')
custom_spec['time_zone'] = user_data['timezone'] if user_data.key?('timezone')
custom_spec
end
end
end
Expand Down

0 comments on commit f161203

Please sign in to comment.