chef-provisioning-fog 0.21.0 → 0.22.0
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.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/chef-provisioning-fog.gemspec +1 -0
- data/lib/chef/provisioning/fog_driver/driver.rb +9 -5
- data/lib/chef/provisioning/fog_driver/providers/joyent.rb +1 -1
- data/lib/chef/provisioning/fog_driver/providers/softlayer.rb +3 -3
- data/lib/chef/provisioning/fog_driver/providers/vcair.rb +134 -89
- data/lib/chef/provisioning/fog_driver/providers/xenserver.rb +4 -4
- data/lib/chef/provisioning/fog_driver/recipe_dsl.rb +1 -1
- data/lib/chef/provisioning/fog_driver/version.rb +1 -1
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 538fa22ee7ffaaad27677cbd067e99179a59cc37
|
4
|
+
data.tar.gz: da1a648fc1a069032f7fa60f8028a2e8bfbbe021
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b4f738999c7633d975d6f60dadedb2efe3a350c290a312aa6a44aea95074520d41abfbda8783dee07024ef471a3943b79d210d39f129683e8e9d97eb4c84d37
|
7
|
+
data.tar.gz: 49d849f17d4187c47f397908b763c2fa41374c26953ab3abd2c4943bce670a5f533521e7843280074f90cc20ae1084d0f531877aa27204775c0e6ab3609b4c95
|
data/Gemfile
CHANGED
@@ -13,6 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.homepage = 'https://github.com/opscode/chef-provisioning-fog'
|
14
14
|
|
15
15
|
s.add_dependency 'chef-provisioning', '>= 1.0', '< 3.0'
|
16
|
+
s.add_dependency 'cheffish', '~> 4.0.0'
|
16
17
|
s.add_dependency 'fog', '>= 1.37.0'
|
17
18
|
s.add_dependency 'google-api-client', "~> 0.8.0"
|
18
19
|
s.add_dependency 'fog-softlayer' , '~> 1.1.0'
|
@@ -267,6 +267,8 @@ module FogDriver
|
|
267
267
|
|
268
268
|
# Not meant to be part of public interface
|
269
269
|
def transport_for(machine_spec, machine_options, server, action_handler = nil)
|
270
|
+
Chef::Log.debug("Creating transport for #{server}")
|
271
|
+
Chef::Log.debug("Machine Spec: #{machine_spec}")
|
270
272
|
if machine_spec.reference['is_windows']
|
271
273
|
action_handler.report_progress "Waiting for admin password on #{machine_spec.name} to be ready (may take up to 15 minutes)..." if action_handler
|
272
274
|
transport = create_winrm_transport(machine_spec, machine_options, server)
|
@@ -296,7 +298,7 @@ module FogDriver
|
|
296
298
|
end
|
297
299
|
|
298
300
|
def create_servers(action_handler, specs_and_options, parallelizer, &block)
|
299
|
-
specs_and_servers = servers_for(specs_and_options
|
301
|
+
specs_and_servers = servers_for(specs_and_options)
|
300
302
|
|
301
303
|
# Get the list of servers which exist, segmented by their bootstrap options
|
302
304
|
# (we will try to create a set of servers for each set of bootstrap options
|
@@ -324,7 +326,7 @@ module FogDriver
|
|
324
326
|
'allocated_at' => Time.now.to_i
|
325
327
|
)
|
326
328
|
|
327
|
-
bootstrap_options = bootstrap_options_for(
|
329
|
+
bootstrap_options = bootstrap_options_for(machine_spec, machine_options)
|
328
330
|
machine_spec.reference['key_name'] = bootstrap_options[:key_name] if bootstrap_options[:key_name]
|
329
331
|
by_bootstrap_options[bootstrap_options] ||= []
|
330
332
|
by_bootstrap_options[bootstrap_options] << machine_spec
|
@@ -551,9 +553,9 @@ module FogDriver
|
|
551
553
|
end
|
552
554
|
end
|
553
555
|
|
554
|
-
def servers_for(
|
556
|
+
def servers_for(specs_and_options)
|
555
557
|
result = {}
|
556
|
-
machine_specs.each do |machine_spec|
|
558
|
+
machine_specs.each do |machine_spec, machine_options|
|
557
559
|
if machine_spec.reference
|
558
560
|
if machine_spec.reference['driver_url'] != driver_url
|
559
561
|
raise "Switching a machine's driver from #{machine_spec.reference['driver_url']} to #{driver_url} for is not currently supported! Use machine :destroy and then re-create the machine on the new driver."
|
@@ -590,7 +592,7 @@ module FogDriver
|
|
590
592
|
'chef_default'
|
591
593
|
end
|
592
594
|
|
593
|
-
def bootstrap_options_for(
|
595
|
+
def bootstrap_options_for(machine_spec, machine_options)
|
594
596
|
bootstrap_options = symbolize_keys(machine_options[:bootstrap_options] || {})
|
595
597
|
|
596
598
|
bootstrap_options[:tags] = default_tags(machine_spec, bootstrap_options[:tags] || {})
|
@@ -669,6 +671,8 @@ module FogDriver
|
|
669
671
|
IO.read(bootstrap_options[:key_path])
|
670
672
|
elsif bootstrap_options[:key_name]
|
671
673
|
get_private_key(bootstrap_options[:key_name])
|
674
|
+
elsif machine_options.has_key?(:ssh_options) && machine_options[:ssh_options].has_key?(:keys)
|
675
|
+
IO.read(machine_options[:ssh_options][:keys].first)
|
672
676
|
else
|
673
677
|
# TODO make a way to suggest other keys to try ...
|
674
678
|
raise "No key found to connect to #{machine_spec.name} (#{machine_spec.reference.inspect})" \
|
@@ -13,7 +13,7 @@ module FogDriver
|
|
13
13
|
compute_options[:joyent_username]
|
14
14
|
end
|
15
15
|
|
16
|
-
def bootstrap_options_for(
|
16
|
+
def bootstrap_options_for(machine_spec, machine_options)
|
17
17
|
bootstrap_options = symbolize_keys(machine_options[:bootstrap_options] || {})
|
18
18
|
|
19
19
|
bootstrap_options[:tags] = default_tags(machine_spec, bootstrap_options[:tags] || {})
|
@@ -39,7 +39,7 @@ class Chef
|
|
39
39
|
[result, id]
|
40
40
|
end
|
41
41
|
|
42
|
-
def bootstrap_options_for(
|
42
|
+
def bootstrap_options_for(machine_spec, machine_options)
|
43
43
|
# probably best to only ADD options here since super class looks
|
44
44
|
# for some values; for example, :key_name doesn't get saved to
|
45
45
|
# chef_provisioning.reference if you remove it here.
|
@@ -104,9 +104,9 @@ class Chef
|
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
|
-
def servers_for(
|
107
|
+
def servers_for(specs_and_options)
|
108
108
|
result = {}
|
109
|
-
|
109
|
+
specs_and_options.each do |machine_spec, _machine_options|
|
110
110
|
result[machine_spec] = server_for(machine_spec)
|
111
111
|
end
|
112
112
|
|
@@ -1,38 +1,28 @@
|
|
1
|
-
# fog:
|
1
|
+
# fog:vcair:<vcair host>
|
2
2
|
class Chef
|
3
3
|
module Provisioning
|
4
4
|
module FogDriver
|
5
5
|
module Providers
|
6
6
|
class Vcair < FogDriver::Driver
|
7
|
-
Driver.register_provider_class('
|
7
|
+
Driver.register_provider_class('vcair', FogDriver::Providers::Vcair)
|
8
8
|
|
9
9
|
def creator
|
10
|
-
|
10
|
+
driver_options[:username]
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(driver_url, config)
|
14
|
+
super(driver_url, config)
|
15
|
+
|
16
|
+
@auth_params = {provider: 'vclouddirector'}
|
17
|
+
_fog, _vcair, @auth_params[:vcloud_director_host] = driver_url.split(':', 3)
|
18
|
+
@auth_params[:vcloud_director_username] = "#{driver_options[:username]}@#{driver_options[:org]}"
|
19
|
+
@auth_params[:vcloud_director_password] = driver_options[:password]
|
20
|
+
@auth_params[:vcloud_director_show_progress] = driver_options[:show_progress] || false
|
21
|
+
Chef::Log.debug('Initialized driver for vcair')
|
11
22
|
end
|
12
23
|
|
13
24
|
def compute
|
14
25
|
@compute ||= begin
|
15
|
-
Chef::Log.debug("vcair_username #{Chef::Config[:knife][:vcair_username]}")
|
16
|
-
Chef::Log.debug("vcair_org #{Chef::Config[:knife][:vcair_org]}")
|
17
|
-
Chef::Log.debug("vcair_api_host #{Chef::Config[:knife][:vcair_api_host]}")
|
18
|
-
#Chef::Log.debug("vcair_api_version #{Chef::Config[:knife][:vcair_api_version]}")
|
19
|
-
Chef::Log.debug("vcair_show_progress #{Chef::Config[:knife][:vcair_show_progress]}")
|
20
|
-
|
21
|
-
username = [
|
22
|
-
Chef::Config[:knife][:vcair_username],
|
23
|
-
Chef::Config[:knife][:vcair_org]
|
24
|
-
].join('@')
|
25
|
-
|
26
|
-
@auth_params = {
|
27
|
-
:provider => 'vclouddirector', #TODO: see compute_options_for, and grab else where
|
28
|
-
:vcloud_director_username => username,
|
29
|
-
:vcloud_director_password => Chef::Config[:knife][:vcair_password],
|
30
|
-
:vcloud_director_host => Chef::Config[:knife][:vcair_api_host],
|
31
|
-
#:vcair_api_host => Chef::Config[:knife][:vcair_api_host],
|
32
|
-
:vcloud_director_api_version => Chef::Config[:knife][:vcair_api_version],
|
33
|
-
:vcloud_director_show_progress => false
|
34
|
-
}
|
35
|
-
|
36
26
|
Fog::Compute.new(@auth_params)
|
37
27
|
rescue Excon::Errors::Unauthorized => e
|
38
28
|
error_message = "Connection failure, please check your username and password."
|
@@ -45,6 +35,23 @@ class Chef
|
|
45
35
|
end
|
46
36
|
end
|
47
37
|
|
38
|
+
# Overrides the parent method and adds some additional vCloud specific metadata
|
39
|
+
def create_servers(action_handler, specs_and_options, parallelizer, &block)
|
40
|
+
|
41
|
+
specs_and_options.each do |machine_spec, machine_options|
|
42
|
+
machine_spec.reference ||= {}
|
43
|
+
# Add some vCloud info to the machine_spec
|
44
|
+
bootstrap_options = bootstrap_options_for(machine_spec, machine_options)
|
45
|
+
machine_spec.reference['vdc'] = vdc(bootstrap_options).name
|
46
|
+
machine_spec.reference['net'] = net(bootstrap_options).name
|
47
|
+
|
48
|
+
# Save the key and whether we're using sudo
|
49
|
+
machine_spec.reference['key_name'] = bootstrap_options[:key_name] if bootstrap_options.has_key?(:key_name)
|
50
|
+
machine_spec.reference['sudo'] = bootstrap_options[:sudo] if bootstrap_options.has_key?(:sudo)
|
51
|
+
end
|
52
|
+
|
53
|
+
super
|
54
|
+
end
|
48
55
|
|
49
56
|
def create_many_servers(num_servers, bootstrap_options, parallelizer)
|
50
57
|
parallelizer.parallelize(1.upto(num_servers)) do |i|
|
@@ -52,25 +59,36 @@ class Chef
|
|
52
59
|
vm=nil
|
53
60
|
begin
|
54
61
|
begin
|
62
|
+
Chef::Log.debug('Creating vApp...')
|
55
63
|
instantiate(clean_bootstrap_options)
|
64
|
+
Chef::Log.debug('Created vApp')
|
56
65
|
rescue Fog::Errors::Error => e
|
57
66
|
unless e.minor_error_code == "DUPLICATE_NAME"
|
58
67
|
# if it's already there, just use the current one
|
59
68
|
raise e
|
60
69
|
end
|
70
|
+
Chef::Log.warn('Found existing vApp with the same name!')
|
61
71
|
end
|
62
|
-
|
63
|
-
|
64
|
-
|
72
|
+
vdc = vdc(clean_bootstrap_options)
|
73
|
+
|
74
|
+
Chef::Log.debug("Searching for #{bootstrap_options[:name]}...")
|
75
|
+
vapp = vdc.vapps.get_by_name(clean_bootstrap_options[:name])
|
76
|
+
raise "Couldn't find vApp #{bootstrap_options[:name]} that was just created!" if vapp.nil?
|
77
|
+
vm = vapp.vms.find {|v| v.vapp_name == clean_bootstrap_options[:name]}
|
78
|
+
raise "No VMs found in vApp!" if vm.nil?
|
79
|
+
Chef::Log.debug("Found #{vm.name}")
|
65
80
|
update_customization(clean_bootstrap_options, vm)
|
66
81
|
|
67
82
|
if bootstrap_options[:cpus]
|
68
|
-
vm.cpu =
|
83
|
+
vm.cpu = clean_bootstrap_options[:cpus]
|
69
84
|
end
|
70
85
|
if bootstrap_options[:memory]
|
71
|
-
vm.memory =
|
86
|
+
vm.memory = clean_bootstrap_options[:memory]
|
72
87
|
end
|
73
|
-
|
88
|
+
|
89
|
+
Chef::Log.debug("Updating network for #{vm.name}...")
|
90
|
+
update_network(clean_bootstrap_options, vapp, vm)
|
91
|
+
Chef::Log.debug("Updated network for #{vm.name}")
|
74
92
|
|
75
93
|
rescue Excon::Errors::BadRequest => e
|
76
94
|
response = Chef::JSONCompat.from_json(e.response.body)
|
@@ -107,10 +125,10 @@ class Chef
|
|
107
125
|
# NOTE: vCloud Air Fog does not get server.status via http every time
|
108
126
|
server.reload
|
109
127
|
|
110
|
-
if server.status == 'off'
|
128
|
+
if server.status == 'off' || server.status != 'on'
|
111
129
|
action_handler.perform_action "start machine #{machine_spec.name} (#{server.id} on #{driver_url})" do
|
112
130
|
server.power_on
|
113
|
-
machine_spec.
|
131
|
+
machine_spec.reference['started_at'] = Time.now.to_i
|
114
132
|
end
|
115
133
|
machine_spec.save(action_handler)
|
116
134
|
end
|
@@ -118,12 +136,13 @@ class Chef
|
|
118
136
|
|
119
137
|
|
120
138
|
def server_for(machine_spec)
|
121
|
-
if machine_spec.
|
122
|
-
|
139
|
+
if machine_spec.reference
|
140
|
+
Chef::Log.debug("Checking for VDC #{machine_spec.reference['vdc']}...")
|
141
|
+
vapp = org.vdcs.get_by_name(machine_spec.reference['vdc']).vapps.get_by_name(machine_spec.name)
|
123
142
|
|
124
143
|
server = unless vapp.nil?
|
125
144
|
unless vapp.vms.first.nil?
|
126
|
-
vapp.vms.find{|vm| vm.id == machine_spec.
|
145
|
+
vapp.vms.find{|vm| vm.id == machine_spec.reference['server_id'] }
|
127
146
|
end
|
128
147
|
end
|
129
148
|
else
|
@@ -131,26 +150,27 @@ class Chef
|
|
131
150
|
end
|
132
151
|
end
|
133
152
|
|
134
|
-
def servers_for(
|
153
|
+
def servers_for(specs_and_options)
|
135
154
|
result = {}
|
136
|
-
|
137
|
-
server_for(machine_spec)
|
155
|
+
specs_and_options.each do |machine_spec, _machine_options|
|
156
|
+
result[machine_spec] = server_for(machine_spec)
|
138
157
|
end
|
139
158
|
result
|
140
159
|
end
|
141
160
|
|
142
|
-
def ssh_options_for(machine_spec, machine_options, server)
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
161
|
+
# def ssh_options_for(machine_spec, machine_options, server)
|
162
|
+
# ssh_options = {
|
163
|
+
# auth_methods: ['password'],
|
164
|
+
# timeout: (machine_options[:ssh_timeout] || 600),
|
165
|
+
# password: machine_options[:ssh_password]
|
166
|
+
# }.merge(machine_options[:ssh_options] || {})
|
167
|
+
# end
|
148
168
|
|
149
169
|
def create_ssh_transport(machine_spec, machine_options, server)
|
150
170
|
ssh_options = ssh_options_for(machine_spec, machine_options, server)
|
151
|
-
username = machine_spec.
|
171
|
+
username = machine_spec.reference['ssh_username'] || default_ssh_username
|
152
172
|
options = {}
|
153
|
-
if machine_spec.
|
173
|
+
if machine_spec.reference[:sudo] || (!machine_spec.reference.has_key?(:sudo) && username != 'root')
|
154
174
|
options[:prefix] = 'sudo '
|
155
175
|
end
|
156
176
|
|
@@ -165,7 +185,7 @@ class Chef
|
|
165
185
|
|
166
186
|
#Enable pty by default
|
167
187
|
options[:ssh_pty_enable] = true
|
168
|
-
options[:ssh_gateway] = machine_spec.
|
188
|
+
options[:ssh_gateway] = machine_spec.reference['ssh_gateway'] if machine_spec.reference.has_key?('ssh_gateway')
|
169
189
|
|
170
190
|
Transport::SSH.new(remote_host, username, ssh_options, options, config)
|
171
191
|
end
|
@@ -190,7 +210,7 @@ class Chef
|
|
190
210
|
wait_for_transport(action_handler, machine_spec, machine_options, server)
|
191
211
|
rescue Fog::Errors::TimeoutError
|
192
212
|
# Only ever reboot once, and only if it's been less than 10 minutes since we stopped waiting
|
193
|
-
if machine_spec.
|
213
|
+
if machine_spec.reference['started_at'] || remaining_wait_time(machine_spec, machine_options) < -(10*60)
|
194
214
|
raise
|
195
215
|
else
|
196
216
|
# Sometimes (on EC2) the machine comes up but gets stuck or has
|
@@ -207,50 +227,64 @@ class Chef
|
|
207
227
|
end
|
208
228
|
|
209
229
|
def org
|
210
|
-
@org ||= compute.organizations.get_by_name(
|
230
|
+
@org ||= compute.organizations.get_by_name(driver_options[:org])
|
211
231
|
end
|
212
232
|
|
213
|
-
def vdc
|
214
|
-
if
|
215
|
-
@vdc ||= org.vdcs.get_by_name(
|
233
|
+
def vdc(bootstrap_options)
|
234
|
+
if bootstrap_options[:vdc]
|
235
|
+
@vdc ||= org.vdcs.get_by_name(bootstrap_options[:vdc])
|
236
|
+
raise "VDC #{bootstrap_options[:vdc]} not found" unless @vdc
|
216
237
|
else
|
217
238
|
@vdc ||= org.vdcs.first
|
239
|
+
raise 'No VDC found' unless @vdc
|
218
240
|
end
|
241
|
+
|
242
|
+
Chef::Log.debug("VDC set to #{@vdc.name}")
|
243
|
+
@vdc
|
219
244
|
end
|
220
245
|
|
221
|
-
def net
|
222
|
-
if
|
223
|
-
@net ||= org.networks.get_by_name(
|
246
|
+
def net(bootstrap_options)
|
247
|
+
if bootstrap_options[:net]
|
248
|
+
@net ||= org.networks.get_by_name(bootstrap_options[:net])
|
249
|
+
raise "Network #{bootstrap_options[:net]} not found" unless @net
|
224
250
|
else
|
225
251
|
# Grab first non-isolated (bridged, natRouted) network
|
226
252
|
@net ||= org.networks.find { |n| n if !n.fence_mode.match("isolated") }
|
253
|
+
raise 'No non-isolated network found' unless @net
|
227
254
|
end
|
255
|
+
|
256
|
+
Chef::Log.debug("Network set to #{@net.name}")
|
257
|
+
@net
|
228
258
|
end
|
229
259
|
|
230
260
|
def template(bootstrap_options)
|
231
|
-
#
|
232
|
-
#
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
261
|
+
# If we specify a catalog name, search for the image in it,
|
262
|
+
# otherwise return the first image we find in any catalog.
|
263
|
+
if bootstrap_options[:catalog_name].nil?
|
264
|
+
#TODO: maybe make a hash for caching
|
265
|
+
org.catalogs.map do |cat|
|
266
|
+
#cat.catalog_items.get_by_name(config_value(:image))
|
267
|
+
cat.catalog_items.get_by_name(bootstrap_options[:image_name])
|
268
|
+
end.compact.first
|
269
|
+
else
|
270
|
+
catalog = org.catalogs.get_by_name(bootstrap_options[:catalog_name])
|
271
|
+
raise "No catalog named #{bootstrap_options[:catalog_name]} could be found!" if catalog.nil?
|
272
|
+
catalog.catalog_items.get_by_name(bootstrap_options[:image_name])
|
273
|
+
end
|
239
274
|
end
|
240
275
|
|
241
276
|
def instantiate(bootstrap_options)
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
end
|
277
|
+
#node_name = config_value(:chef_node_name)
|
278
|
+
node_name = bootstrap_options[:name]
|
279
|
+
vdc = vdc(bootstrap_options)
|
280
|
+
net = net(bootstrap_options)
|
281
|
+
|
282
|
+
template(bootstrap_options).instantiate(
|
283
|
+
node_name,
|
284
|
+
vdc_id: vdc.id,
|
285
|
+
network_id: net.id,
|
286
|
+
description: "id:#{node_name}")
|
287
|
+
#rescue CloudExceptions::ServerCreateError => e
|
254
288
|
end
|
255
289
|
|
256
290
|
# Create a WinRM transport for a vCloud Air Vapp VM instance
|
@@ -259,7 +293,7 @@ class Chef
|
|
259
293
|
# @param [Fog::Compute::Server] server A Fog mapping to the AWS instance
|
260
294
|
# @return [ChefMetal::Transport::WinRM] A WinRM Transport object to talk to the server
|
261
295
|
def create_winrm_transport(machine_spec, machine_options, server)
|
262
|
-
port = machine_spec.
|
296
|
+
port = machine_spec.reference['winrm_port'] || 5985
|
263
297
|
endpoint = "http://#{server.ip_address}:#{port}/wsman"
|
264
298
|
type = :plaintext
|
265
299
|
|
@@ -276,6 +310,7 @@ class Chef
|
|
276
310
|
end
|
277
311
|
|
278
312
|
def update_customization(bootstrap_options, server)
|
313
|
+
Chef::Log.debug("Customizing vApp: #{server.name}")
|
279
314
|
## Initialization before first power on.
|
280
315
|
custom=server.customization
|
281
316
|
|
@@ -291,9 +326,9 @@ class Chef
|
|
291
326
|
end
|
292
327
|
password = case bootstrap_options[:protocol]
|
293
328
|
when 'ssh'
|
294
|
-
bootstrap_options[:ssh_options][:password]
|
329
|
+
bootstrap_options[:ssh_options][:password] unless bootstrap_options[:ssh_options].nil?
|
295
330
|
when 'winrm'
|
296
|
-
bootstrap_options[:winrm_options][:password]
|
331
|
+
bootstrap_options[:winrm_options][:password] unless bootstrap_options[:winrm_options].nil?
|
297
332
|
end
|
298
333
|
|
299
334
|
if password
|
@@ -313,11 +348,16 @@ class Chef
|
|
313
348
|
|
314
349
|
# DNS and Windows want AlphaNumeric and dashes for hostnames
|
315
350
|
# Windows can only handle 15 character hostnames
|
316
|
-
|
317
|
-
|
318
|
-
|
351
|
+
custom.computer_name = case server.operating_system
|
352
|
+
when /Windows/
|
353
|
+
bootstrap_options[:name].gsub(/\W/,"-").slice(0..14)
|
354
|
+
else
|
355
|
+
bootstrap_options[:name]
|
356
|
+
end
|
357
|
+
|
319
358
|
custom.enabled = true
|
320
359
|
custom.save
|
360
|
+
Chef::Log.debug("vApp customized: #{server.name}")
|
321
361
|
end
|
322
362
|
|
323
363
|
## vCloud Air
|
@@ -331,7 +371,11 @@ class Chef
|
|
331
371
|
#vapp = vdc.vapps.get_by_name(bootstrap_options[:name])
|
332
372
|
#vm = vapp.vms.find {|v| v.vapp_name == bootstrap_options[:name]}
|
333
373
|
return if vm.ip_address != "" # return if ip address is set, as this isn't a new VM
|
374
|
+
Chef::Log.debug('No IP address found. Must be a new VM.')
|
375
|
+
net = net(bootstrap_options)
|
376
|
+
Chef::Log.debug("Searching for network: #{net.name}")
|
334
377
|
nc = vapp.network_config.find { |netc| netc if netc[:networkName].match(net.name) }
|
378
|
+
Chef::Log.debug("Found network configuration: #{nc}")
|
335
379
|
networks_config = [nc]
|
336
380
|
section = {PrimaryNetworkConnectionIndex: 0}
|
337
381
|
section[:NetworkConnection] = networks_config.compact.each_with_index.map do |network, i|
|
@@ -360,23 +404,24 @@ class Chef
|
|
360
404
|
compute.process_task(nc_task)
|
361
405
|
end
|
362
406
|
|
363
|
-
def bootstrap_options_for(
|
364
|
-
bootstrap_options =
|
365
|
-
|
366
|
-
bootstrap_options[:tags] = default_tags(machine_spec, bootstrap_options[:tags] || {})
|
367
|
-
bootstrap_options[:name] ||= machine_spec.name
|
407
|
+
def self.bootstrap_options_for(machine_spec, machine_options)
|
408
|
+
bootstrap_options = machine_options.key?(:bootstrap_options) ? machine_options[:bootstrap_options] : {}
|
409
|
+
bootstrap_options[:name] = machine_spec.name unless machine_spec.nil?
|
368
410
|
|
369
|
-
bootstrap_options = bootstrap_options.merge(machine_options.configs[1])
|
370
411
|
bootstrap_options
|
371
412
|
end
|
372
413
|
|
373
414
|
def destroy_machine(action_handler, machine_spec, machine_options)
|
374
415
|
server = server_for(machine_spec)
|
416
|
+
Chef::Log.info("Destroying machine #{machine_spec.name}...")
|
417
|
+
bootstrap_options = bootstrap_options_for(machine_spec, machine_options)
|
418
|
+
vdc = vdc(bootstrap_options)
|
375
419
|
if server && server.status != 'archive' # TODO: does vCloud Air do archive?
|
376
|
-
action_handler.perform_action "destroy machine #{machine_spec.name} (#{machine_spec.
|
420
|
+
action_handler.perform_action "destroy machine #{machine_spec.name} (#{machine_spec.reference['server_id']} at #{driver_url})" do
|
377
421
|
#NOTE: currently doing 1 vm for 1 vapp
|
378
422
|
vapp = vdc.vapps.get_by_name(machine_spec.name)
|
379
423
|
if vapp
|
424
|
+
Chef::Log.debug("Found vApp #{machine_spec.name}")
|
380
425
|
vapp.power_off
|
381
426
|
vapp.undeploy
|
382
427
|
vapp.destroy
|
@@ -385,7 +430,7 @@ class Chef
|
|
385
430
|
end
|
386
431
|
end
|
387
432
|
end
|
388
|
-
machine_spec.
|
433
|
+
machine_spec.reference = nil
|
389
434
|
strategy = convergence_strategy_for(machine_spec, machine_options)
|
390
435
|
strategy.cleanup_convergence(action_handler, machine_spec)
|
391
436
|
end
|
@@ -11,7 +11,7 @@ class Chef
|
|
11
11
|
compute_options[:xenserver_username]
|
12
12
|
end
|
13
13
|
|
14
|
-
def bootstrap_options_for(
|
14
|
+
def bootstrap_options_for(machine_spec, machine_options)
|
15
15
|
bootstrap_options = super
|
16
16
|
bootstrap_options[:tags] = bootstrap_options[:tags].map {|k,v| "#{k}: #{v}" }
|
17
17
|
bootstrap_options
|
@@ -56,9 +56,9 @@ class Chef
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
def servers_for(
|
59
|
+
def servers_for(specs_and_options)
|
60
60
|
result = {}
|
61
|
-
|
61
|
+
specs_and_options.each do |machine_spec, _machine_options|
|
62
62
|
if machine_spec.reference
|
63
63
|
if machine_spec.reference['driver_url'] != driver_url
|
64
64
|
raise "Switching a machine's driver from #{machine_spec.reference['driver_url']} to #{driver_url} for is not currently supported! Use machine :destroy and then re-create the machine on the new driver."
|
@@ -209,7 +209,7 @@ end
|
|
209
209
|
# Otherwise machine_batch will fail since parallel calls will clash.
|
210
210
|
#
|
211
211
|
# See http://ruby-doc.org//stdlib-2.1.1//libdoc/xmlrpc/rdoc/XMLRPC/Client.html
|
212
|
-
#
|
212
|
+
#
|
213
213
|
module Fog
|
214
214
|
module XenServer
|
215
215
|
class Connection
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-provisioning-fog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.22.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Keiser
|
@@ -34,6 +34,20 @@ dependencies:
|
|
34
34
|
- - "<"
|
35
35
|
- !ruby/object:Gem::Version
|
36
36
|
version: '3.0'
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: cheffish
|
39
|
+
requirement: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 4.0.0
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - "~>"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 4.0.0
|
37
51
|
- !ruby/object:Gem::Dependency
|
38
52
|
name: fog
|
39
53
|
requirement: !ruby/object:Gem::Requirement
|