bosh_vcloud_cpi 0.7.7 → 0.7.8
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: fcbdf7f3f5c6a9d0852c992f96b106ddd67503f0
|
4
|
+
data.tar.gz: a48e39654ba4916e2c28cf221f1e949ce4224e55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad0c6cd71dbe20b8e184e75660ff18d7cb727dee725b9c9a6f47f8f8f941a2b867cb2f3e5b03b8ad32c30af8282b501d37fdb7dbece810d0251416de5e9ef0fb
|
7
|
+
data.tar.gz: 0ccad8d4448fb37560df3cfbf6128ffe4caad3e833f463c398ec7d10998b9d24e5e7c3290bf5d8255b88ba618a1d4055a761675729303b31131a61635a1cdf83
|
data/lib/cloud/vcloud/errors.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'base64'
|
2
2
|
require 'uri'
|
3
3
|
require 'rest_client'
|
4
|
+
require 'common/common'
|
4
5
|
|
5
6
|
require_relative 'cache'
|
6
7
|
require_relative 'file_uploader'
|
@@ -188,7 +189,7 @@ module VCloudCloud
|
|
188
189
|
WAIT_DELAY = 5 # delay in seconds for pooling next task status
|
189
190
|
COOKIE_TIMEOUT = 600 # default timeout in seconds, if not specified in configuration file, after which session must be re-created
|
190
191
|
RETRY_MAX = 3 # maximum attempts
|
191
|
-
RETRY_DELAY =
|
192
|
+
RETRY_DELAY = 0.1 # wait time before retrying
|
192
193
|
|
193
194
|
def cookie_available?
|
194
195
|
@cookie && Time.now < @cookie_expiration
|
@@ -219,6 +220,21 @@ module VCloudCloud
|
|
219
220
|
end
|
220
221
|
end
|
221
222
|
|
223
|
+
def raise_specific_error(response, e)
|
224
|
+
begin
|
225
|
+
wrapped_response = VCloudSdk::Xml::WrapperFactory.wrap_document response.body
|
226
|
+
rescue => ex
|
227
|
+
@logger.debug "Wrap document raise error: #{ex.message}"
|
228
|
+
end
|
229
|
+
|
230
|
+
unless wrapped_response.nil?
|
231
|
+
if wrapped_response.is_a?VCloudSdk::Xml::Error
|
232
|
+
wrapped_response.exception(e)
|
233
|
+
end
|
234
|
+
end
|
235
|
+
raise e
|
236
|
+
end
|
237
|
+
|
222
238
|
def send_request(method, path, options = {})
|
223
239
|
path = path.href unless path.is_a?(String)
|
224
240
|
|
@@ -238,11 +254,19 @@ module VCloudCloud
|
|
238
254
|
params[:cookies] = @cookie if !options[:login] && cookie_available?
|
239
255
|
params[:payload] = options[:payload].to_s if options[:payload]
|
240
256
|
params[:headers].merge! options[:headers] if options[:headers]
|
241
|
-
|
257
|
+
|
258
|
+
errors = [RestClient::Exception, OpenSSL::SSL::SSLError, OpenSSL::X509::StoreError]
|
259
|
+
Bosh::Common.retryable(sleep: @retry_delay, tries: 20, on: errors) do |tries, error|
|
242
260
|
@logger.debug "REST REQ #{method.to_s.upcase} #{params[:url]} #{params[:headers].inspect} #{params[:cookies].inspect} #{params[:payload]}"
|
261
|
+
@logger.warn "Attempting to retry #{method.to_s.upcase} request against #{params[:url]} after #{tries} unsuccessful attempts. Latest error: #{error.inspect}" if tries > 1
|
262
|
+
|
243
263
|
RestClient::Request.execute params do |response, request, result, &block|
|
244
264
|
@logger.debug "REST RES #{response.code} #{response.headers.inspect} #{response.body}"
|
245
|
-
|
265
|
+
begin
|
266
|
+
response.return! request, result, &block
|
267
|
+
rescue => e
|
268
|
+
raise_specific_error(response, e)
|
269
|
+
end
|
246
270
|
end
|
247
271
|
end
|
248
272
|
end
|
@@ -271,24 +295,5 @@ module VCloudCloud
|
|
271
295
|
def wrap_response(response)
|
272
296
|
VCloudSdk::Xml::WrapperFactory.wrap_document response
|
273
297
|
end
|
274
|
-
|
275
|
-
def retry_for_network_issue
|
276
|
-
retries = 0
|
277
|
-
delay = @retry_delay
|
278
|
-
result = nil
|
279
|
-
loop do
|
280
|
-
begin
|
281
|
-
result = yield
|
282
|
-
break
|
283
|
-
rescue RestClient::Exception => ex
|
284
|
-
raise ex if retries >= @retry_max
|
285
|
-
@logger.error "RestClient exception (retry after #{delay}ms): #{ex}"
|
286
|
-
sleep(delay / 1000)
|
287
|
-
delay *= 2
|
288
|
-
retries += 1
|
289
|
-
end
|
290
|
-
end
|
291
|
-
result
|
292
|
-
end
|
293
298
|
end
|
294
299
|
end
|
@@ -96,6 +96,10 @@ module VCloudSdk
|
|
96
96
|
href.split('/')[-1]
|
97
97
|
end
|
98
98
|
|
99
|
+
def error
|
100
|
+
@root["Error"]
|
101
|
+
end
|
102
|
+
|
99
103
|
def name
|
100
104
|
@root["name"]
|
101
105
|
end
|
@@ -311,3 +315,4 @@ require_relative "wrapper_classes/vdc"
|
|
311
315
|
require_relative "wrapper_classes/vdc_storage_profile"
|
312
316
|
require_relative "wrapper_classes/virtual_hardware_section"
|
313
317
|
require_relative "wrapper_classes/vm"
|
318
|
+
require_relative "wrapper_classes/error_wrapper"
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'cloud/vcloud/errors'
|
2
|
+
|
3
|
+
module VCloudSdk
|
4
|
+
module Xml
|
5
|
+
class Error < Wrapper
|
6
|
+
|
7
|
+
def major_error
|
8
|
+
@root["majorErrorCode"]
|
9
|
+
end
|
10
|
+
|
11
|
+
def minor_error
|
12
|
+
@root["minorErrorCode"]
|
13
|
+
end
|
14
|
+
|
15
|
+
def error_msg
|
16
|
+
@root["message"]
|
17
|
+
end
|
18
|
+
|
19
|
+
def exception(e)
|
20
|
+
if error_msg.include? "There is already a VM named" and major_error == "400"
|
21
|
+
raise VCloudCloud::ObjectExistsError
|
22
|
+
else
|
23
|
+
raise e
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bosh_vcloud_cpi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- VMware
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bosh_common
|
@@ -124,7 +124,7 @@ dependencies:
|
|
124
124
|
version: '0'
|
125
125
|
description: |-
|
126
126
|
BOSH vCloud CPI
|
127
|
-
|
127
|
+
a3d5f4
|
128
128
|
email: support@cloudfoundry.com
|
129
129
|
executables: []
|
130
130
|
extensions: []
|
@@ -175,6 +175,7 @@ files:
|
|
175
175
|
- lib/cloud/vcloud/xml/wrapper_classes/disk_attach_or_detach_params.rb
|
176
176
|
- lib/cloud/vcloud/xml/wrapper_classes/disk_create_params.rb
|
177
177
|
- lib/cloud/vcloud/xml/wrapper_classes/entity.rb
|
178
|
+
- lib/cloud/vcloud/xml/wrapper_classes/error_wrapper.rb
|
178
179
|
- lib/cloud/vcloud/xml/wrapper_classes/file.rb
|
179
180
|
- lib/cloud/vcloud/xml/wrapper_classes/hard_disk_item_wrapper.rb
|
180
181
|
- lib/cloud/vcloud/xml/wrapper_classes/instantiate_vapp_template_params.rb
|