cloudstack_client 1.5.11 → 1.5.12

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f12a44b9de9caef1d8ca803d2661fbf236b45428b00e9a9e88f222c630aee140
4
- data.tar.gz: 90e786e18f99f3a6fcb19b94298d617f42d18d8892722e288da76891945bf9b3
3
+ metadata.gz: 58ccc2b4e84e160367f416922cc1489c7344c4e64c5fd5b047d91a5c6cedebb3
4
+ data.tar.gz: e55008e191421c0cbf993e7c51d25d9a1638c39322f97db97eb583e4925aef0e
5
5
  SHA512:
6
- metadata.gz: 92cd5f09d2864d21556c524262ce2187ded3a28c65c1a324bc7a8a236d98e0f44261bb0a334b879955efdc0e1065c58235bf7c6077fd1635d2bad8657ec70308
7
- data.tar.gz: 11a672cd0b5f2dbd377a0e4684a1a71c090ddb29e4b90b1e938f87c3eac1df638bb22d49570830442af687aa197fa7bfea3fbbf7de453aaa0e008ddd5d1e6345
6
+ metadata.gz: 718ddbe8ed71342f2a2067497c71863c0407722bed849aed2e1061978ecbd6440bacedc4c3f20fcd5f0c395e969ab664f4d8d63afbebd381fe51eb5d5d3d38c9
7
+ data.tar.gz: 2f67eab635a6a61bae7df757bde727d2d4ccaa03f3b2a654dccea02e7fab0069913f7faef5924be50bc4a0037164119e4c36aedb9854c63d8db327df2c255d29
data/.travis.yml CHANGED
@@ -1,7 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.7
4
- - 3.0
3
+ - 3.2
4
+ - 3.4
5
+ - 4.0
5
6
  before_install:
6
7
  - gem update --system
7
8
  - gem install bundler
data/Gemfile.lock CHANGED
@@ -7,11 +7,11 @@ GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
9
  bond (0.5.1)
10
- minitest (5.26.1)
10
+ minitest (5.27.0)
11
11
  rake (13.3.1)
12
12
  ripl (0.7.1)
13
13
  bond (~> 0.5.1)
14
- thor (1.4.0)
14
+ thor (1.5.0)
15
15
 
16
16
  PLATFORMS
17
17
  x86_64-linux
@@ -24,4 +24,4 @@ DEPENDENCIES
24
24
  thor (~> 1.1)
25
25
 
26
26
  BUNDLED WITH
27
- 2.5.22
27
+ 2.6.9
data/README.md CHANGED
@@ -120,13 +120,15 @@ test:
120
120
  ```
121
121
 
122
122
  ### Configuration options
123
+
123
124
  You can pass `options` as 4th argument in `CloudstackClient::Client.new`. All its keys are optional.
124
125
 
125
126
  ```ruby
126
127
  options = {
127
128
  symbolize_keys: true, # pass symbolize_names: true in JSON#parse for Cloudstack responses, default: false
128
129
  host: 'localhost', # custom host header to be used in Net::Http. May be useful when Cloudstack is set up locally via docker (i.e. Cloudstack-simulator), default: parsed from config[:url] via Net::Http
129
- read_timeout: 10 # timeout in seconds of a connection to the Cloudstack, default: 60
130
+ read_timeout: 10, # timeout in seconds of a connection to the Cloudstack, default: 60
131
+ request_retries: 3 # number of attempts for HTTP requests before raising a ConnectionError, default: 1 (no retries). Uses incremental back-off between attempts.
130
132
  }
131
133
  cs = CloudstackClient::Client.new(config[:url], config[:api_key], config[:secret_key], options)
132
134
  ```
@@ -10,11 +10,12 @@ module CloudstackClient
10
10
  include Utils
11
11
 
12
12
  attr_accessor :api_url, :api_key, :secret_key, :verbose, :debug, :symbolize_keys, :host, :read_timeout
13
- attr_accessor :async_poll_interval, :async_timeout
13
+ attr_accessor :async_poll_interval, :async_timeout, :request_retries
14
14
 
15
15
  DEF_POLL_INTERVAL = 2.0
16
16
  DEF_ASYNC_TIMEOUT = 400
17
17
  DEF_REQ_TIMEOUT = 60
18
+ DEF_REQUEST_RETRIES = 1
18
19
 
19
20
  def initialize(api_url, api_key, secret_key, options = {})
20
21
  @api_url = api_url
@@ -27,6 +28,7 @@ module CloudstackClient
27
28
  @read_timeout = options[:read_timeout] || DEF_REQ_TIMEOUT
28
29
  @async_poll_interval = options[:async_poll_interval] || DEF_POLL_INTERVAL
29
30
  @async_timeout = options[:async_timeout] || DEF_ASYNC_TIMEOUT
31
+ @request_retries = options[:request_retries] || DEF_REQUEST_RETRIES
30
32
  @options = options
31
33
  validate_input!
32
34
  end
@@ -50,12 +52,19 @@ module CloudstackClient
50
52
  end
51
53
  http.read_timeout = @read_timeout
52
54
 
55
+ retries = 0
53
56
  begin
54
57
  req = Net::HTTP::Get.new(uri.request_uri)
55
58
  req['Host'] = host if host.present?
56
59
  response = http.request(req)
57
- rescue
58
- raise ConnectionError, "API URL \'#{@api_url}\' is not reachable."
60
+ rescue => e
61
+ retries += 1
62
+ if retries < @request_retries
63
+ sleep(retries) # incremental back-off
64
+ print "." if @verbose
65
+ retry
66
+ end
67
+ raise ConnectionError, "API URL \'#{@api_url}\' is not reachable (after #{retries} attempt#{'s' if retries > 1}): #{e.message}"
59
68
  end
60
69
 
61
70
  begin
@@ -87,7 +96,7 @@ module CloudstackClient
87
96
  #
88
97
  # The contents of the 'jobresult' element are returned upon completion of the command.
89
98
 
90
- def send_async_request(params, **opts)
99
+ def send_async_request(params, opts = {})
91
100
  data = send_request(params, opts)
92
101
 
93
102
  params = {
@@ -121,6 +130,7 @@ module CloudstackClient
121
130
  raise InputError, "API SECRET KEY not set." if @secret_key == nil
122
131
  raise InputError, "ASYNC POLL INTERVAL must be at least 1." if @async_poll_interval < 1.0
123
132
  raise InputError, "ASYNC TIMEOUT must be at least 60." if @async_timeout < 60
133
+ raise InputError, "REQUEST RETRIES must be at least 1." if @request_retries < 1
124
134
  end
125
135
 
126
136
  def params_to_data(params)
@@ -1,3 +1,3 @@
1
1
  module CloudstackClient
2
- VERSION = "1.5.11"
2
+ VERSION = "1.5.12"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudstack_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.11
4
+ version: 1.5.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nik Wolfgramm