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 +4 -4
- data/.travis.yml +3 -2
- data/Gemfile.lock +3 -3
- data/README.md +3 -1
- data/lib/cloudstack_client/connection.rb +14 -4
- data/lib/cloudstack_client/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 58ccc2b4e84e160367f416922cc1489c7344c4e64c5fd5b047d91a5c6cedebb3
|
|
4
|
+
data.tar.gz: e55008e191421c0cbf993e7c51d25d9a1638c39322f97db97eb583e4925aef0e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 718ddbe8ed71342f2a2067497c71863c0407722bed849aed2e1061978ecbd6440bacedc4c3f20fcd5f0c395e969ab664f4d8d63afbebd381fe51eb5d5d3d38c9
|
|
7
|
+
data.tar.gz: 2f67eab635a6a61bae7df757bde727d2d4ccaa03f3b2a654dccea02e7fab0069913f7faef5924be50bc4a0037164119e4c36aedb9854c63d8db327df2c255d29
|
data/.travis.yml
CHANGED
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.
|
|
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.
|
|
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.
|
|
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
|
-
|
|
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,
|
|
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)
|