chef-provisioning-fog 0.26.1 → 0.26.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +29 -8
  3. data/Rakefile +23 -12
  4. data/chef-provisioning-fog.gemspec +24 -27
  5. data/lib/chef/provider/fog_key_pair.rb +49 -53
  6. data/lib/chef/provider/scaleway_volume.rb +46 -48
  7. data/lib/chef/provisioning/driver_init/fog.rb +1 -1
  8. data/lib/chef/provisioning/fog_driver/driver.rb +646 -653
  9. data/lib/chef/provisioning/fog_driver/providers/aws.rb +411 -422
  10. data/lib/chef/provisioning/fog_driver/providers/aws/credentials.rb +88 -90
  11. data/lib/chef/provisioning/fog_driver/providers/cloudstack.rb +32 -34
  12. data/lib/chef/provisioning/fog_driver/providers/digitalocean.rb +98 -100
  13. data/lib/chef/provisioning/fog_driver/providers/google.rb +27 -34
  14. data/lib/chef/provisioning/fog_driver/providers/joyent.rb +53 -55
  15. data/lib/chef/provisioning/fog_driver/providers/openstack.rb +139 -146
  16. data/lib/chef/provisioning/fog_driver/providers/rackspace.rb +40 -44
  17. data/lib/chef/provisioning/fog_driver/providers/scaleway.rb +183 -189
  18. data/lib/chef/provisioning/fog_driver/providers/softlayer.rb +61 -64
  19. data/lib/chef/provisioning/fog_driver/providers/vcair.rb +72 -78
  20. data/lib/chef/provisioning/fog_driver/providers/xenserver.rb +56 -69
  21. data/lib/chef/provisioning/fog_driver/recipe_dsl.rb +11 -12
  22. data/lib/chef/provisioning/fog_driver/version.rb +1 -1
  23. data/lib/chef/resource/fog_key_pair.rb +8 -8
  24. data/lib/chef/resource/scaleway_volume.rb +8 -8
  25. data/spec/spec_helper.rb +7 -7
  26. data/spec/support/chef/provisioning/fog_driver/providers/testdriver.rb +3 -3
  27. data/spec/unit/chef/provisioning/fog_driver/driver_spec.rb +39 -38
  28. data/spec/unit/fog_driver_spec.rb +6 -8
  29. data/spec/unit/providers/aws/credentials_spec.rb +10 -10
  30. data/spec/unit/providers/rackspace_spec.rb +5 -6
  31. data/spec/unit/providers/scaleway_spec.rb +9 -9
  32. data/spec/unit/providers/softlayer.rb +7 -7
  33. metadata +6 -36
  34. data/README.md +0 -357
@@ -3,28 +3,22 @@ class Chef
3
3
  module FogDriver
4
4
  module Providers
5
5
  class Google < FogDriver::Driver
6
- Driver.register_provider_class('Google', FogDriver::Providers::Google)
6
+ Driver.register_provider_class("Google", FogDriver::Providers::Google)
7
7
 
8
8
  def creator
9
- ''
9
+ ""
10
10
  end
11
11
 
12
12
  def convergence_strategy_for(machine_spec, machine_options)
13
- machine_options = Cheffish::MergedConfig.new(machine_options, {
14
- :convergence_options => {:ohai_hints => {'gce' => {}}}
15
- })
13
+ machine_options = Cheffish::MergedConfig.new(machine_options,
14
+ convergence_options: { ohai_hints: { "gce" => {} } })
16
15
  super(machine_spec, machine_options)
17
16
  end
18
17
 
19
- def converge_floating_ips(action_handler, machine_spec, machine_options, server)
20
- end
18
+ def converge_floating_ips(action_handler, machine_spec, machine_options, server); end
21
19
 
22
20
  def server_for(machine_spec)
23
- if machine_spec.name
24
- compute.servers.get(machine_spec.name)
25
- else
26
- nil
27
- end
21
+ compute.servers.get(machine_spec.name) if machine_spec.name
28
22
  end
29
23
 
30
24
  def servers_for(machine_specs)
@@ -35,29 +29,29 @@ class Chef
35
29
  result
36
30
  end
37
31
 
38
- def bootstrap_options_for(action_handler, machine_spec, machine_options)
32
+ def bootstrap_options_for(_action_handler, machine_spec, machine_options)
39
33
  bootstrap_options = symbolize_keys(machine_options[:bootstrap_options] || {})
40
- bootstrap_options[:image_name] ||= 'debian-7-wheezy-v20150325'
41
- bootstrap_options[:machine_type] ||= 'n1-standard-1'
42
- bootstrap_options[:zone_name] ||= 'europe-west1-b'
34
+ bootstrap_options[:image_name] ||= "debian-7-wheezy-v20150325"
35
+ bootstrap_options[:machine_type] ||= "n1-standard-1"
36
+ bootstrap_options[:zone_name] ||= "europe-west1-b"
43
37
  bootstrap_options[:name] ||= machine_spec.name
44
38
  bootstrap_options[:disk_size] ||= 10
45
39
  disk_type_prefix = "https://www.googleapis.com/compute/v1/projects/#{compute_options[:google_project]}/zones/#{bootstrap_options[:zone_name]}/diskTypes/"
46
- standard_disk_type = disk_type_prefix + 'pd-standard'
47
- if bootstrap_options[:disk_type].nil?
48
- bootstrap_options[:disk_type] = standard_disk_type
49
- else
50
- bootstrap_options[:disk_type] = disk_type_prefix + bootstrap_options[:disk_type]
51
- end
40
+ standard_disk_type = disk_type_prefix + "pd-standard"
41
+ bootstrap_options[:disk_type] = if bootstrap_options[:disk_type].nil?
42
+ standard_disk_type
43
+ else
44
+ disk_type_prefix + bootstrap_options[:disk_type]
45
+ end
52
46
 
53
47
  if bootstrap_options[:disks].nil?
54
48
  # create the persistent boot disk
55
49
  disk_defaults = {
56
- :name => machine_spec.name,
57
- :size_gb => bootstrap_options[:disk_size],
58
- :zone_name => bootstrap_options[:zone_name],
59
- :source_image => bootstrap_options[:image_name],
60
- :type => bootstrap_options[:disk_type],
50
+ name: machine_spec.name,
51
+ size_gb: bootstrap_options[:disk_size],
52
+ zone_name: bootstrap_options[:zone_name],
53
+ source_image: bootstrap_options[:image_name],
54
+ type: bootstrap_options[:disk_type]
61
55
  }
62
56
 
63
57
  disk = compute.disks.create(disk_defaults)
@@ -70,7 +64,7 @@ class Chef
70
64
 
71
65
  def destroy_machine(action_handler, machine_spec, machine_options)
72
66
  server = server_for(machine_spec)
73
- if server && server.state != 'archive'
67
+ if server && server.state != "archive"
74
68
  action_handler.perform_action "destroy machine #{machine_spec.name} (#{machine_spec.location['server_id']} at #{driver_url})" do
75
69
  server.destroy
76
70
  end
@@ -80,19 +74,18 @@ class Chef
80
74
  strategy.cleanup_convergence(action_handler, machine_spec)
81
75
  end
82
76
 
83
- def self.compute_options_for(provider, id, config)
77
+ def self.compute_options_for(provider, _id, config)
84
78
  new_compute_options = {}
85
79
  new_compute_options[:provider] = provider
86
- new_config = { :driver_options => { :compute_options => new_compute_options }}
80
+ new_config = { driver_options: { compute_options: new_compute_options } }
87
81
  new_defaults = {
88
- :driver_options => { :compute_options => {} },
89
- :machine_options => { :bootstrap_options => {}, :ssh_options => {} }
82
+ driver_options: { compute_options: {} },
83
+ machine_options: { bootstrap_options: {}, ssh_options: {} }
90
84
  }
91
85
  result = Cheffish::MergedConfig.new(new_config, config, new_defaults)
92
86
 
93
- [result, '']
87
+ [result, ""]
94
88
  end
95
-
96
89
  end
97
90
  end
98
91
  end
@@ -1,63 +1,61 @@
1
- require 'fog/joyent'
1
+ require "fog/joyent"
2
2
 
3
3
  # fog:Joyent:<joyent_url>
4
4
  class Chef
5
- module Provisioning
6
- module FogDriver
7
- module Providers
8
- class Joyent < FogDriver::Driver
9
-
10
- Driver.register_provider_class('Joyent', FogDriver::Providers::Joyent)
11
-
12
- def creator
13
- compute_options[:joyent_username]
14
- end
15
-
16
- def bootstrap_options_for(machine_spec, machine_options)
17
- bootstrap_options = symbolize_keys(machine_options[:bootstrap_options] || {})
18
-
19
- bootstrap_options[:tags] = default_tags(machine_spec, bootstrap_options[:tags] || {})
20
-
21
- bootstrap_options[:tags].each do |key, val|
22
- bootstrap_options["tag.#{key}"] = val
5
+ module Provisioning
6
+ module FogDriver
7
+ module Providers
8
+ class Joyent < FogDriver::Driver
9
+ Driver.register_provider_class("Joyent", FogDriver::Providers::Joyent)
10
+
11
+ def creator
12
+ compute_options[:joyent_username]
13
+ end
14
+
15
+ def bootstrap_options_for(machine_spec, machine_options)
16
+ bootstrap_options = symbolize_keys(machine_options[:bootstrap_options] || {})
17
+
18
+ bootstrap_options[:tags] = default_tags(machine_spec, bootstrap_options[:tags] || {})
19
+
20
+ bootstrap_options[:tags].each do |key, val|
21
+ bootstrap_options["tag.#{key}"] = val
22
+ end
23
+
24
+ bootstrap_options[:name] ||= machine_spec.name
25
+
26
+ bootstrap_options
27
+ end
28
+
29
+ def find_floating_ips(_server, _action_handler)
30
+ []
31
+ end
32
+
33
+ def self.compute_options_for(provider, id, config)
34
+ new_compute_options = {}
35
+ new_compute_options[:provider] = provider
36
+ new_config = { driver_options: { compute_options: new_compute_options } }
37
+ new_defaults = {
38
+ driver_options: { compute_options: {} },
39
+ machine_options: { bootstrap_options: {} }
40
+ }
41
+ result = Cheffish::MergedConfig.new(new_config, config, new_defaults)
42
+
43
+ new_compute_options[:joyent_url] = id if id && id != ""
44
+ credential = Fog.credentials
45
+
46
+ new_compute_options[:joyent_username] ||= credential[:joyent_username]
47
+ new_compute_options[:joyent_password] ||= credential[:joyent_password]
48
+ new_compute_options[:joyent_keyname] ||= credential[:joyent_keyname]
49
+ new_compute_options[:joyent_keyfile] ||= credential[:joyent_keyfile]
50
+ new_compute_options[:joyent_url] ||= credential[:joyent_url]
51
+ new_compute_options[:joyent_version] ||= credential[:joyent_version]
52
+
53
+ id = result[:driver_options][:compute_options][:joyent_url]
54
+
55
+ [result, id]
56
+ end
23
57
  end
24
-
25
- bootstrap_options[:name] ||= machine_spec.name
26
-
27
- bootstrap_options
28
58
  end
29
-
30
- def find_floating_ips(server, action_handler)
31
- []
32
- end
33
-
34
- def self.compute_options_for(provider, id, config)
35
- new_compute_options = {}
36
- new_compute_options[:provider] = provider
37
- new_config = { :driver_options => { :compute_options => new_compute_options }}
38
- new_defaults = {
39
- :driver_options => { :compute_options => {} },
40
- :machine_options => { :bootstrap_options => {} }
41
- }
42
- result = Cheffish::MergedConfig.new(new_config, config, new_defaults)
43
-
44
- new_compute_options[:joyent_url] = id if (id && id != '')
45
- credential = Fog.credentials
46
-
47
- new_compute_options[:joyent_username] ||= credential[:joyent_username]
48
- new_compute_options[:joyent_password] ||= credential[:joyent_password]
49
- new_compute_options[:joyent_keyname] ||= credential[:joyent_keyname]
50
- new_compute_options[:joyent_keyfile] ||= credential[:joyent_keyfile]
51
- new_compute_options[:joyent_url] ||= credential[:joyent_url]
52
- new_compute_options[:joyent_version] ||= credential[:joyent_version]
53
-
54
- id = result[:driver_options][:compute_options][:joyent_url]
55
-
56
- [result, id]
57
- end
58
-
59
59
  end
60
60
  end
61
61
  end
62
- end
63
- end
@@ -1,169 +1,162 @@
1
1
  # fog:OpenStack:https://identifyhost:portNumber/v2.0
2
2
  class Chef
3
- module Provisioning
4
- module FogDriver
5
- module Providers
6
- class OpenStack < FogDriver::Driver
7
-
8
- Driver.register_provider_class('OpenStack', FogDriver::Providers::OpenStack)
9
-
10
- def creator
11
- compute_options[:openstack_username]
12
- end
13
-
14
- def convergence_strategy_for(machine_spec, machine_options)
15
- machine_options = Cheffish::MergedConfig.new(machine_options, {
16
- :convergence_options => {:ohai_hints => {'openstack' => {}}}
17
- })
18
- super(machine_spec, machine_options)
19
- end
3
+ module Provisioning
4
+ module FogDriver
5
+ module Providers
6
+ class OpenStack < FogDriver::Driver
7
+ Driver.register_provider_class("OpenStack", FogDriver::Providers::OpenStack)
8
+
9
+ def creator
10
+ compute_options[:openstack_username]
11
+ end
20
12
 
21
- def create_winrm_transport(machine_spec, machine_options, server)
22
- if machine_options[:winrm].nil?
23
- fail "You must provide winrm settings in machine_options to use the winrm transport!"
24
- end
25
- remote_host = determine_remote_host machine_spec, server
26
- Chef::Log::info("Connecting to server #{remote_host}")
27
- port = machine_options[:winrm][:port] || 5985
28
- endpoint = "http://#{remote_host}:#{port}/wsman"
29
- type = machine_options[:winrm][:type] || :negotiate
30
- decrypted_password = machine_options[:winrm][:password] || ''
31
- options = {
32
- :user => machine_options[:winrm][:username] || 'Administrator',
33
- :pass => decrypted_password,
34
- :disable_sspi => !!machine_options[:winrm][:disable_sspi] || false,
35
- :basic_auth_only => !!machine_options[:winrm][:basic_auth_only] || false
36
- }
37
- Chef::Provisioning::Transport::WinRM.new(endpoint, type, options, {})
38
- end
13
+ def convergence_strategy_for(machine_spec, machine_options)
14
+ machine_options = Cheffish::MergedConfig.new(machine_options,
15
+ convergence_options: { ohai_hints: { "openstack" => {} } })
16
+ super(machine_spec, machine_options)
17
+ end
39
18
 
40
- def self.compute_options_for(provider, id, config)
41
- new_compute_options = {}
42
- new_compute_options[:provider] = provider
43
- new_config = { :driver_options => { :compute_options => new_compute_options }}
44
- new_defaults = {
45
- :driver_options => { :compute_options => {} },
46
- :machine_options => { :bootstrap_options => {} }
47
- }
48
- result = Cheffish::MergedConfig.new(new_config, config, new_defaults)
19
+ def create_winrm_transport(machine_spec, machine_options, server)
20
+ if machine_options[:winrm].nil?
21
+ raise "You must provide winrm settings in machine_options to use the winrm transport!"
22
+ end
23
+ remote_host = determine_remote_host machine_spec, server
24
+ Chef::Log.info("Connecting to server #{remote_host}")
25
+ port = machine_options[:winrm][:port] || 5985
26
+ endpoint = "http://#{remote_host}:#{port}/wsman"
27
+ type = machine_options[:winrm][:type] || :negotiate
28
+ decrypted_password = machine_options[:winrm][:password] || ""
29
+ options = {
30
+ user: machine_options[:winrm][:username] || "Administrator",
31
+ pass: decrypted_password,
32
+ disable_sspi: !!machine_options[:winrm][:disable_sspi] || false,
33
+ basic_auth_only: !!machine_options[:winrm][:basic_auth_only] || false
34
+ }
35
+ Chef::Provisioning::Transport::WinRM.new(endpoint, type, options, {})
36
+ end
49
37
 
50
- new_compute_options[:openstack_auth_url] = id if (id && id != '')
38
+ def self.compute_options_for(provider, id, config)
39
+ new_compute_options = {}
40
+ new_compute_options[:provider] = provider
41
+ new_config = { driver_options: { compute_options: new_compute_options } }
42
+ new_defaults = {
43
+ driver_options: { compute_options: {} },
44
+ machine_options: { bootstrap_options: {} }
45
+ }
46
+ result = Cheffish::MergedConfig.new(new_config, config, new_defaults)
51
47
 
52
- credential = Fog.credentials.find_all{ |k,v|
53
- k.to_s.start_with?('openstack') }
54
- credential.each { |k,v|
55
- new_compute_options[k] ||= v
56
- }
48
+ new_compute_options[:openstack_auth_url] = id if id && id != ""
57
49
 
58
- id = result[:driver_options][:compute_options][:openstack_auth_url]
50
+ credential = Fog.credentials.find_all do |k, _v|
51
+ k.to_s.start_with?("openstack")
52
+ end
53
+ credential.each do |k, v|
54
+ new_compute_options[k] ||= v
55
+ end
59
56
 
60
- [result, id]
61
- end
57
+ id = result[:driver_options][:compute_options][:openstack_auth_url]
62
58
 
63
- # Image methods
64
- def allocate_image(action_handler, image_spec, image_options, machine_spec, machine_options)
65
- image = image_for(image_spec)
66
- if image
67
- raise "The image already exists, why are you asking me to create it? I can't do that, Dave."
68
- end
69
- action_handler.perform_action "Create image #{image_spec.name} from machine #{machine_spec.name} with options #{image_options.inspect}" do
70
- response = compute.create_image(
71
- machine_spec.reference['server_id'], image_spec.name,
72
- {
73
- description: "The Image named '#{image_spec.name}"
74
- })
75
-
76
- image_spec.reference = {
77
- driver_url: driver_url,
78
- driver_version: FogDriver::VERSION,
79
- image_id: response.body['image']['id'],
80
- creator: creator,
81
- allocated_it: Time.new.to_i
82
- }
83
- end
84
- end
59
+ [result, id]
60
+ end
85
61
 
86
- def ready_image(action_handler, image_spec, image_options)
87
- actual_image = image_for(image_spec)
88
- if actual_image.nil?
89
- raise 'Cannot ready an image that does not exist'
90
- else
91
- if actual_image.status != 'ACTIVE'
92
- action_handler.report_progress 'Waiting for image to be active ...'
93
- wait_until_ready_image(action_handler, image_spec, actual_image)
94
- else
95
- action_handler.report_progress "Image #{image_spec.name} is active!"
62
+ # Image methods
63
+ def allocate_image(action_handler, image_spec, image_options, machine_spec, _machine_options)
64
+ image = image_for(image_spec)
65
+ if image
66
+ raise "The image already exists, why are you asking me to create it? I can't do that, Dave."
67
+ end
68
+ action_handler.perform_action "Create image #{image_spec.name} from machine #{machine_spec.name} with options #{image_options.inspect}" do
69
+ response = compute.create_image(
70
+ machine_spec.reference["server_id"], image_spec.name,
71
+ description: "The Image named '#{image_spec.name}"
72
+ )
73
+
74
+ image_spec.reference = {
75
+ driver_url: driver_url,
76
+ driver_version: FogDriver::VERSION,
77
+ image_id: response.body["image"]["id"],
78
+ creator: creator,
79
+ allocated_it: Time.new.to_i
80
+ }
81
+ end
96
82
  end
97
- end
98
- end
99
83
 
100
- def destroy_image(action_handler, image_spec, image_options)
101
- image = image_for(image_spec)
102
- unless image.status == "DELETED"
103
- image.destroy
104
- end
105
- end
84
+ def ready_image(action_handler, image_spec, _image_options)
85
+ actual_image = image_for(image_spec)
86
+ if actual_image.nil?
87
+ raise "Cannot ready an image that does not exist"
88
+ else
89
+ if actual_image.status != "ACTIVE"
90
+ action_handler.report_progress "Waiting for image to be active ..."
91
+ wait_until_ready_image(action_handler, image_spec, actual_image)
92
+ else
93
+ action_handler.report_progress "Image #{image_spec.name} is active!"
94
+ end
95
+ end
96
+ end
106
97
 
107
- def wait_until_ready_image(action_handler, image_spec, image=nil)
108
- wait_until_image(action_handler, image_spec, image) { image.status == 'ACTIVE' }
109
- end
98
+ def destroy_image(_action_handler, image_spec, _image_options)
99
+ image = image_for(image_spec)
100
+ image.destroy unless image.status == "DELETED"
101
+ end
110
102
 
111
- def wait_until_image(action_handler, image_spec, image=nil, &block)
112
- image ||= image_for(image_spec)
113
- time_elapsed = 0
114
- sleep_time = 10
115
- max_wait_time = 300
116
- if !yield(image)
117
- action_handler.report_progress "waiting for image #{image_spec.name} (#{image.id} on #{driver_url}) to be active ..."
118
- while time_elapsed < max_wait_time && !yield(image)
119
- action_handler.report_progress "been waiting #{time_elapsed}/#{max_wait_time} -- sleeping #{sleep_time} seconds for image #{image_spec.name} (#{image.id} on #{driver_url}) to be ACTIVE instead of #{image.status}..."
120
- sleep(sleep_time)
121
- image.reload
122
- time_elapsed += sleep_time
103
+ def wait_until_ready_image(action_handler, image_spec, image = nil)
104
+ wait_until_image(action_handler, image_spec, image) { image.status == "ACTIVE" }
123
105
  end
124
- unless yield(image)
125
- raise "Image #{image.id} did not become ready within #{max_wait_time} seconds"
106
+
107
+ def wait_until_image(action_handler, image_spec, image = nil)
108
+ image ||= image_for(image_spec)
109
+ time_elapsed = 0
110
+ sleep_time = 10
111
+ max_wait_time = 300
112
+ unless yield(image)
113
+ action_handler.report_progress "waiting for image #{image_spec.name} (#{image.id} on #{driver_url}) to be active ..."
114
+ while time_elapsed < max_wait_time && !yield(image)
115
+ action_handler.report_progress "been waiting #{time_elapsed}/#{max_wait_time} -- sleeping #{sleep_time} seconds for image #{image_spec.name} (#{image.id} on #{driver_url}) to be ACTIVE instead of #{image.status}..."
116
+ sleep(sleep_time)
117
+ image.reload
118
+ time_elapsed += sleep_time
119
+ end
120
+ unless yield(image)
121
+ raise "Image #{image.id} did not become ready within #{max_wait_time} seconds"
122
+ end
123
+ action_handler.report_progress "Image #{image_spec.name} is now ready"
124
+ end
126
125
  end
127
- action_handler.report_progress "Image #{image_spec.name} is now ready"
128
- end
129
- end
130
126
 
131
- def image_for(image_spec)
132
- if image_spec.reference
133
- compute.images.get(image_spec.reference[:image_id]) || compute.images.get(image_spec.reference['image_id'])
134
- else
135
- nil
136
- end
137
- end
127
+ def image_for(image_spec)
128
+ if image_spec.reference
129
+ compute.images.get(image_spec.reference[:image_id]) || compute.images.get(image_spec.reference["image_id"])
130
+ end
131
+ end
138
132
 
139
- def determine_remote_host(machine_spec, server)
140
- transport_address_location = (machine_spec.reference['transport_address_location'] || :none).to_sym
141
-
142
- if machine_spec.reference['use_private_ip_for_ssh']
143
- # The machine_spec has the old config key, lets update it - a successful chef converge will save the machine_spec
144
- # TODO in 2.0 get rid of this update
145
- machine_spec.reference.delete('use_private_ip_for_ssh')
146
- machine_spec.reference['transport_address_location'] = :private_ip
147
- server.private_ip_address
148
- elsif transport_address_location == :ip_addresses
149
- server.ip_addresses.first
150
- elsif transport_address_location == :private_ip
151
- server.private_ip_address
152
- elsif transport_address_location == :public_ip
153
- server.public_ip_address
154
- elsif !server.public_ip_address && server.private_ip_address
155
- Chef::Log.warn("Server #{machine_spec.name} has no public floating_ip address. Using private floating_ip '#{server.private_ip_address}'. Set driver option 'transport_address_location' => :private_ip if this will always be the case ...")
156
- server.private_ip_address
157
- elsif server.public_ip_address
158
- server.public_ip_address
159
- else
160
- raise "Server #{server.id} has no private or public IP address!"
161
- # raise "Invalid 'transport_address_location'. They can only be 'public_ip', 'private_ip', or 'ip_addresses'."
133
+ def determine_remote_host(machine_spec, server)
134
+ transport_address_location = (machine_spec.reference["transport_address_location"] || :none).to_sym
135
+
136
+ if machine_spec.reference["use_private_ip_for_ssh"]
137
+ # The machine_spec has the old config key, lets update it - a successful chef converge will save the machine_spec
138
+ # TODO in 2.0 get rid of this update
139
+ machine_spec.reference.delete("use_private_ip_for_ssh")
140
+ machine_spec.reference["transport_address_location"] = :private_ip
141
+ server.private_ip_address
142
+ elsif transport_address_location == :ip_addresses
143
+ server.ip_addresses.first
144
+ elsif transport_address_location == :private_ip
145
+ server.private_ip_address
146
+ elsif transport_address_location == :public_ip
147
+ server.public_ip_address
148
+ elsif !server.public_ip_address && server.private_ip_address
149
+ Chef::Log.warn("Server #{machine_spec.name} has no public floating_ip address. Using private floating_ip '#{server.private_ip_address}'. Set driver option 'transport_address_location' => :private_ip if this will always be the case ...")
150
+ server.private_ip_address
151
+ elsif server.public_ip_address
152
+ server.public_ip_address
153
+ else
154
+ raise "Server #{server.id} has no private or public IP address!"
155
+ # raise "Invalid 'transport_address_location'. They can only be 'public_ip', 'private_ip', or 'ip_addresses'."
156
+ end
157
+ end
162
158
  end
163
159
  end
164
-
165
160
  end
166
161
  end
167
162
  end
168
- end
169
- end