chef-provisioning-opennebula 0.4.6 → 0.4.7
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04a47001d99e4d12e8d704f0f441e80582955566
|
4
|
+
data.tar.gz: d7a148664849bd390c62620eb80434077a4bcb0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c92fd314d1d51900a3d6ea3ce52316fa6ebf5123c988fe815b2e1fdb2a926ddc790cd9b657f51cd6799c6790a91ced34b040e3c71a681a6d555e787d8c8cef7
|
7
|
+
data.tar.gz: 209eb0984670a5ecfe358c8db13369952ccec9f988b2698dc3eca504df14988a32610cf560a4fae163830ebf85e7d51588f7ad8bf7d0e5947c1bfcb5e3dd7ed3
|
@@ -87,7 +87,12 @@ class Chef
|
|
87
87
|
require 'opennebula'
|
88
88
|
rescue Gem::LoadError => e
|
89
89
|
e_inspect = e.inspect
|
90
|
-
|
90
|
+
unless e_inspect.include?('already activated')
|
91
|
+
info_out, info_err = Open3.capture2e("gem environment")
|
92
|
+
Chef::Log.fatal("Please check your environment settings")
|
93
|
+
Chef::Log.fatal(info_out + "\n" + info_err)
|
94
|
+
raise e
|
95
|
+
end
|
91
96
|
end
|
92
97
|
require 'chef/provisioning/opennebula_driver/one_lib'
|
93
98
|
gem_version = Gem.loaded_specs['opennebula'].version.to_s
|
@@ -203,6 +208,10 @@ class Chef
|
|
203
208
|
return machine_spec unless instance.nil?
|
204
209
|
|
205
210
|
unless machine_options[:bootstrap_options]
|
211
|
+
instance = retry_one("Retrying allocate_machine.instance_for (missing bootstrap options)") do
|
212
|
+
instance_for(machine_spec)
|
213
|
+
end
|
214
|
+
return machine_spec unless instance.nil?
|
206
215
|
fail "'bootstrap_options' must be specified"
|
207
216
|
end
|
208
217
|
check_unique_names(machine_options, machine_spec)
|
@@ -643,25 +652,12 @@ class Chef
|
|
643
652
|
|
644
653
|
transport = Chef::Provisioning::Transport::SSH.new(machine_spec.reference['ip'], username, ssh_options, options, config)
|
645
654
|
|
646
|
-
|
655
|
+
retries = connection_timeout.to_i / 3
|
656
|
+
rc = @one.retry_one("Waiting for SSH connection", retries, 3) { transport.available? ? true : nil }
|
647
657
|
fail "Failed to establish SSH connection to '#{machine_spec.name}'" if rc.nil?
|
648
658
|
transport
|
649
659
|
end
|
650
660
|
|
651
|
-
# Retry an operation until the timeout expires. Will always try at least once.
|
652
|
-
def retryable_operation(msg = "operation", timeout = 15, delay = 3)
|
653
|
-
return nil unless block_given?
|
654
|
-
start = Time.now
|
655
|
-
loop do
|
656
|
-
return true if yield
|
657
|
-
Chef::Log.info(msg)
|
658
|
-
sleep delay
|
659
|
-
break if (Time.now - start) > timeout
|
660
|
-
end
|
661
|
-
Chef::Log.error("Timed out waiting for operation to complete: '#{msg}'")
|
662
|
-
nil
|
663
|
-
end
|
664
|
-
|
665
661
|
def convergence_strategy_for(machine_spec, machine_options)
|
666
662
|
# TODO: Support Windoze VMs (see chef-provisioning-vagrant)
|
667
663
|
convergence_options = Cheffish::MergedConfig.new(machine_options ? machine_options[:convergence_options] || {} : {})
|
@@ -173,34 +173,41 @@ class Chef
|
|
173
173
|
fail "Did not find VM with ID: #{id}" unless vm
|
174
174
|
|
175
175
|
# Wait up to 10 min for the VM to be ready
|
176
|
-
rc =
|
176
|
+
rc = retry_one("wait for VM #{id} to be ready", 300, 2) do
|
177
177
|
vm.info
|
178
178
|
if vm.lcm_state_str != 'LCM_INIT'
|
179
179
|
short_lcm = OpenNebula::VirtualMachine::SHORT_LCM_STATES[vm.lcm_state_str]
|
180
180
|
fail "'#{vm.name}'' failed. Current state: #{vm.lcm_state_str}" if short_lcm == 'fail'
|
181
181
|
end
|
182
182
|
fail "'#{vm.name}'' failed. Current state: #{vm.state_str}" if vm.state_str == 'FAILED'
|
183
|
-
Chef::Log.info("current state: '#{vm.lcm_state_str}' short: '#{short_lcm}'")
|
184
|
-
|
183
|
+
Chef::Log.info("current state #{vm.name}: '#{vm.lcm_state_str}' short: '#{short_lcm}'")
|
184
|
+
vm.lcm_state_str.casecmp(end_state) == 0 ? true : nil
|
185
185
|
end
|
186
186
|
fail "wait_for_vm timed out: '#{id}'" if rc.nil?
|
187
187
|
vm
|
188
188
|
end
|
189
189
|
|
190
|
-
# Retry
|
191
|
-
def
|
190
|
+
# Retry ONE operation
|
191
|
+
def retry_one(msg = "retry_one", retries = 3, retry_delay = 5, return_nil = false, return_error = false)
|
192
192
|
return nil unless block_given?
|
193
|
-
|
193
|
+
count = 1
|
194
194
|
rc = nil
|
195
195
|
loop do
|
196
196
|
rc = yield
|
197
|
-
return true unless OpenNebula.is_error?(rc)
|
198
197
|
Chef::Log.info(msg)
|
199
|
-
|
200
|
-
|
198
|
+
if OpenNebula.is_error?(rc)
|
199
|
+
return rc if return_error
|
200
|
+
elsif rc.nil?
|
201
|
+
return rc if return_nil
|
202
|
+
else
|
203
|
+
return rc
|
204
|
+
end
|
205
|
+
sleep retry_delay
|
206
|
+
break if count == retries
|
207
|
+
count += 1
|
201
208
|
end
|
202
|
-
Chef::Log.info("
|
203
|
-
|
209
|
+
Chef::Log.info("FAIL: one_lib.retry_one '#{msg}'")
|
210
|
+
rc
|
204
211
|
end
|
205
212
|
|
206
213
|
def rename_vm(res, name)
|
@@ -269,7 +276,7 @@ DEV_PREFIX = #{img_config[:prefix]}
|
|
269
276
|
state = 'INIT'
|
270
277
|
pool = get_pool(:image)
|
271
278
|
|
272
|
-
|
279
|
+
retry_one("wait for IMAGE #{img_id} to be ready", 600, 2) do
|
273
280
|
pool.info!(-2, img_id, img_id)
|
274
281
|
pool.each do |img|
|
275
282
|
next unless img.id == img_id
|
@@ -279,7 +286,7 @@ DEV_PREFIX = #{img_config[:prefix]}
|
|
279
286
|
state = cur_state
|
280
287
|
break
|
281
288
|
end
|
282
|
-
|
289
|
+
(state == 'INIT' || state == 'LOCKED') ? nil : true
|
283
290
|
end
|
284
291
|
fail "Failed to create #{name} image. State = '#{state}'" if state != 'READY'
|
285
292
|
Chef::Log.info("Image #{name} is in READY state")
|
@@ -368,10 +375,6 @@ DEV_PREFIX = #{img_config[:prefix]}
|
|
368
375
|
unless t_hash['CONTEXT']['SSH_PUBLIC_KEY']
|
369
376
|
t_hash['CONTEXT']['SSH_PUBLIC_KEY'] = "$USER[SSH_PUBLIC_KEY]"
|
370
377
|
end
|
371
|
-
unless t_hash['CONTEXT']['USER_DATA']
|
372
|
-
t_hash['CONTEXT']['USER_DATA'] = "#cloud-config\n" \
|
373
|
-
"manage_etc_hosts: true\n"
|
374
|
-
end
|
375
378
|
tpl = create_template(t_hash)
|
376
379
|
Chef::Log.debug(tpl)
|
377
380
|
tpl
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-provisioning-opennebula
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew J. Brown
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2016-
|
15
|
+
date: 2016-08-19 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: chef
|
@@ -96,6 +96,20 @@ dependencies:
|
|
96
96
|
- - ">="
|
97
97
|
- !ruby/object:Gem::Version
|
98
98
|
version: 1.8.3
|
99
|
+
- !ruby/object:Gem::Dependency
|
100
|
+
name: http-cookie
|
101
|
+
requirement: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: 1.0.2
|
106
|
+
type: :runtime
|
107
|
+
prerelease: false
|
108
|
+
version_requirements: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 1.0.2
|
99
113
|
- !ruby/object:Gem::Dependency
|
100
114
|
name: rspec
|
101
115
|
requirement: !ruby/object:Gem::Requirement
|