azure-armrest 0.8.2 → 0.8.3
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/CHANGES +16 -0
- data/lib/azure/armrest/armrest_collection.rb +6 -4
- data/lib/azure/armrest/armrest_service.rb +28 -16
- data/lib/azure/armrest/configuration.rb +5 -0
- data/lib/azure/armrest/model/base_model.rb +4 -5
- data/lib/azure/armrest/model/storage_account.rb +45 -54
- data/lib/azure/armrest/storage/managed_storage_helper.rb +49 -49
- data/lib/azure/armrest/storage_account_service.rb +7 -28
- data/lib/azure/armrest/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 863c452f6343526b0a8cc17cdea4d4921124c49e
|
|
4
|
+
data.tar.gz: 15629ce4b260c94c51f3464a6963e2c5da44efd0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e829a6fdf4ef7bbccfbf63bf7d186ccd4df0fb48488d1591a646f9731fcbfd96e9f2e09966ab402c8989df026692a0f358a12b93b17bdd59fc487e04ae5605ff
|
|
7
|
+
data.tar.gz: 9cc08e023b518e4abb210379bae6b6d7e68fedde6ecb793aa3dd99951be46794638fe791f4a6e29517850a2533d1b96f9daaf93dee91d31181497572c3c20fdf
|
data/CHANGES
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
= 0.8.3 - 22-Sep-2017
|
|
2
|
+
* Most underlying requests will now automatically retry in certain
|
|
3
|
+
circumstances. Specifically, 409, 429 and most 50x errors will now
|
|
4
|
+
sleep and retry three times (by default) before giving up since
|
|
5
|
+
these errors are usually transient.
|
|
6
|
+
* Fixed an error handling bug in the StorageAccount#all_blobs method.
|
|
7
|
+
* Added the Configuration#max_retry accessor.
|
|
8
|
+
* Added the ArmrestCollection#next_link method (part of refactoring).
|
|
9
|
+
* The ArmrestService#wait method now takes an optional interval parameter.
|
|
10
|
+
* Refactored the ManagedStorageHelper#get_blob_raw method. It now does a better
|
|
11
|
+
job of waiting for, and releasing, the lock on the file.
|
|
12
|
+
* Some refactoring for speed, memory and the removal of duplicate code. Thanks
|
|
13
|
+
go to Nick LaMuro for the patches.
|
|
14
|
+
* General refactoring of the StorageAccountService class with regards to
|
|
15
|
+
passing configuration information.
|
|
16
|
+
|
|
1
17
|
= 0.8.2 - 30-Aug-2017
|
|
2
18
|
* The :list and :list_all methods for the ResourceProviderService class now
|
|
3
19
|
accepts a filter.
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
module Azure
|
|
4
4
|
module Armrest
|
|
5
5
|
class ArmrestCollection < Array
|
|
6
|
+
attr_accessor :next_link
|
|
6
7
|
attr_accessor :continuation_token
|
|
7
8
|
attr_accessor :response_headers
|
|
8
9
|
attr_accessor :response_code
|
|
@@ -21,7 +22,8 @@ module Azure
|
|
|
21
22
|
|
|
22
23
|
array.response_code = response.code
|
|
23
24
|
array.response_headers = response.headers
|
|
24
|
-
array.
|
|
25
|
+
array.next_link = json_response['nextLink']
|
|
26
|
+
array.continuation_token = parse_skip_token(array.next_link)
|
|
25
27
|
|
|
26
28
|
array
|
|
27
29
|
end
|
|
@@ -29,9 +31,9 @@ module Azure
|
|
|
29
31
|
private
|
|
30
32
|
|
|
31
33
|
# Parse the skip token value out of the nextLink attribute from a response.
|
|
32
|
-
def parse_skip_token(
|
|
33
|
-
return nil unless
|
|
34
|
-
|
|
34
|
+
def parse_skip_token(next_link)
|
|
35
|
+
return nil unless next_link
|
|
36
|
+
next_link[/.*?skipToken=(.*?)$/i, 1]
|
|
35
37
|
end
|
|
36
38
|
end
|
|
37
39
|
end
|
|
@@ -189,8 +189,8 @@ module Azure
|
|
|
189
189
|
# For most resources the +max_time+ argument should be more than sufficient.
|
|
190
190
|
# Certain resources, such as virtual machines, could take longer.
|
|
191
191
|
#
|
|
192
|
-
def wait(response, max_time = 60)
|
|
193
|
-
sleep_time = response.respond_to?(:retry_after) ? response.retry_after.to_i :
|
|
192
|
+
def wait(response, max_time = 60, default_interval = 10)
|
|
193
|
+
sleep_time = response.respond_to?(:retry_after) ? response.retry_after.to_i : default_interval
|
|
194
194
|
total_time = 0
|
|
195
195
|
|
|
196
196
|
until (status = poll(response)) =~ /^succe/i # success or succeeded
|
|
@@ -205,12 +205,24 @@ module Azure
|
|
|
205
205
|
class << self
|
|
206
206
|
private
|
|
207
207
|
|
|
208
|
-
def rest_execute(options, http_method = :get, encode = true)
|
|
208
|
+
def rest_execute(options, http_method = :get, encode = true, max_retries = 3)
|
|
209
|
+
tries ||= 0
|
|
209
210
|
url = encode ? Addressable::URI.encode(options[:url]) : options[:url]
|
|
210
211
|
options = options.merge(:method => http_method, :url => url)
|
|
211
212
|
RestClient::Request.execute(options)
|
|
212
|
-
rescue RestClient::Exception =>
|
|
213
|
-
|
|
213
|
+
rescue RestClient::Exception => err
|
|
214
|
+
if [409, 429, 500, 502, 503, 504].include?(err.http_code)
|
|
215
|
+
tries += 1
|
|
216
|
+
if tries <= max_retries
|
|
217
|
+
msg = "A rate limit or server side issue has occurred [#{err.http_code}]. Retry number #{tries}."
|
|
218
|
+
Azure::Armrest::Configuration.log.try(:log, Logger::WARN, msg)
|
|
219
|
+
sleep_time = err.response.headers[:retry_after] || 30
|
|
220
|
+
sleep(sleep_time)
|
|
221
|
+
retry
|
|
222
|
+
end
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
raise_api_exception(err)
|
|
214
226
|
end
|
|
215
227
|
|
|
216
228
|
def rest_get(options)
|
|
@@ -268,7 +280,7 @@ module Azure
|
|
|
268
280
|
|
|
269
281
|
# REST verb methods
|
|
270
282
|
|
|
271
|
-
def rest_execute(url, body = nil, http_method = :get, encode = true)
|
|
283
|
+
def rest_execute(url, body = nil, http_method = :get, encode = true, max_retries = 3)
|
|
272
284
|
options = {
|
|
273
285
|
:url => url,
|
|
274
286
|
:proxy => configuration.proxy,
|
|
@@ -283,35 +295,35 @@ module Azure
|
|
|
283
295
|
|
|
284
296
|
options[:payload] = body if body
|
|
285
297
|
|
|
286
|
-
self.class.send(:rest_execute, options, http_method, encode)
|
|
298
|
+
self.class.send(:rest_execute, options, http_method, encode, max_retries)
|
|
287
299
|
end
|
|
288
300
|
|
|
289
301
|
def rest_get(url)
|
|
290
|
-
rest_execute(url)
|
|
302
|
+
rest_execute(url, nil, :get, true, configuration.max_retries)
|
|
291
303
|
end
|
|
292
304
|
|
|
293
305
|
def rest_get_without_encoding(url)
|
|
294
|
-
rest_execute(url, nil, :get, false)
|
|
306
|
+
rest_execute(url, nil, :get, false, configuration.max_retries)
|
|
295
307
|
end
|
|
296
308
|
|
|
297
309
|
def rest_put(url, body = '')
|
|
298
|
-
rest_execute(url, body, :put)
|
|
310
|
+
rest_execute(url, body, :put, true, configuration.max_retries)
|
|
299
311
|
end
|
|
300
312
|
|
|
301
313
|
def rest_post(url, body = '')
|
|
302
|
-
rest_execute(url, body, :post)
|
|
314
|
+
rest_execute(url, body, :post, true, configuration.max_retries)
|
|
303
315
|
end
|
|
304
316
|
|
|
305
317
|
def rest_patch(url, body = '')
|
|
306
|
-
rest_execute(url, body, :patch)
|
|
318
|
+
rest_execute(url, body, :patch, true, configuration.max_retries)
|
|
307
319
|
end
|
|
308
320
|
|
|
309
321
|
def rest_delete(url)
|
|
310
|
-
rest_execute(url, nil, :delete)
|
|
322
|
+
rest_execute(url, nil, :delete, true, configuration.max_retries)
|
|
311
323
|
end
|
|
312
324
|
|
|
313
325
|
def rest_head(url)
|
|
314
|
-
rest_execute(url, nil, :head)
|
|
326
|
+
rest_execute(url, nil, :head, true, configuration.max_retries)
|
|
315
327
|
end
|
|
316
328
|
|
|
317
329
|
# Take an array of URI elements and join the together with the API version.
|
|
@@ -347,13 +359,13 @@ module Azure
|
|
|
347
359
|
# Make additional calls and concatenate the results if a continuation URL is found.
|
|
348
360
|
def get_all_results(response)
|
|
349
361
|
results = Azure::Armrest::ArmrestCollection.create_from_response(response, model_class)
|
|
350
|
-
nextlink =
|
|
362
|
+
nextlink = results.next_link
|
|
351
363
|
|
|
352
364
|
while nextlink
|
|
353
365
|
response = rest_get_without_encoding(nextlink)
|
|
354
366
|
more = Azure::Armrest::ArmrestCollection.create_from_response(response, model_class)
|
|
355
367
|
results.concat(more)
|
|
356
|
-
nextlink =
|
|
368
|
+
nextlink = more.next_link
|
|
357
369
|
end
|
|
358
370
|
|
|
359
371
|
results
|
|
@@ -69,6 +69,10 @@ module Azure
|
|
|
69
69
|
# default is Azure::Armrest::Environment::Public.
|
|
70
70
|
attr_accessor :environment
|
|
71
71
|
|
|
72
|
+
# Maximum number of attempts to retry an http request in the case of
|
|
73
|
+
# request throttling or server side service issues.
|
|
74
|
+
attr_accessor :max_retries
|
|
75
|
+
|
|
72
76
|
# Yields a new Azure::Armrest::Configuration objects. Note that you must
|
|
73
77
|
# specify a client_id, client_key, tenant_id. The subscription_id is optional
|
|
74
78
|
# but should be specified in most cases. All other parameters are optional.
|
|
@@ -102,6 +106,7 @@ module Azure
|
|
|
102
106
|
:proxy => ENV['http_proxy'],
|
|
103
107
|
:ssl_version => 'TLSv1',
|
|
104
108
|
:max_threads => 10,
|
|
109
|
+
:max_retries => 3,
|
|
105
110
|
:environment => Azure::Armrest::Environment::Public
|
|
106
111
|
}.merge(args.symbolize_keys)
|
|
107
112
|
|
|
@@ -58,7 +58,6 @@ module Azure
|
|
|
58
58
|
|
|
59
59
|
if json.kind_of?(Hash)
|
|
60
60
|
@hash = json
|
|
61
|
-
@json = json.to_json
|
|
62
61
|
else
|
|
63
62
|
@hash = JSON.parse(json)
|
|
64
63
|
@json = json
|
|
@@ -90,15 +89,15 @@ module Azure
|
|
|
90
89
|
# is for interface compatibility only.
|
|
91
90
|
#
|
|
92
91
|
def to_json(_options = nil)
|
|
93
|
-
@json
|
|
92
|
+
@json ||= @hash ? @hash.to_json : ""
|
|
94
93
|
end
|
|
95
94
|
|
|
96
95
|
def to_s
|
|
97
|
-
@json
|
|
96
|
+
@json ||= @hash ? @hash.to_json : ""
|
|
98
97
|
end
|
|
99
98
|
|
|
100
99
|
def to_str
|
|
101
|
-
@json
|
|
100
|
+
@json ||= @hash ? @hash.to_json : ""
|
|
102
101
|
end
|
|
103
102
|
|
|
104
103
|
def pretty_print(q)
|
|
@@ -180,7 +179,7 @@ module Azure
|
|
|
180
179
|
end
|
|
181
180
|
|
|
182
181
|
def add_accessor_methods(method, key)
|
|
183
|
-
method = "_#{method}" if
|
|
182
|
+
method = "_#{method}" if respond_to?(method)
|
|
184
183
|
instance_eval { define_singleton_method(method) { __getobj__[key] } }
|
|
185
184
|
instance_eval { define_singleton_method("#{method}=") { |val| __getobj__[key] = val } }
|
|
186
185
|
end
|
|
@@ -28,24 +28,15 @@ module Azure
|
|
|
28
28
|
# request. The default is 2016-05-31.
|
|
29
29
|
attr_accessor :storage_api_version
|
|
30
30
|
|
|
31
|
-
# An http proxy to use per request. Defaults to ENV['http_proxy'] if set.
|
|
32
|
-
attr_accessor :proxy
|
|
33
|
-
|
|
34
|
-
# The SSL version to use per request. Defaults to TLSv1.
|
|
35
|
-
attr_accessor :ssl_version
|
|
36
|
-
|
|
37
|
-
# The SSL verification method used for each request. The default is VERIFY_PEER.
|
|
38
|
-
attr_accessor :ssl_verify
|
|
39
|
-
|
|
40
31
|
# The default access key used when creating a signature for internal http requests.
|
|
41
32
|
attr_accessor :access_key
|
|
42
33
|
|
|
34
|
+
# The parent configuration object
|
|
35
|
+
attr_accessor :configuration
|
|
36
|
+
|
|
43
37
|
def initialize(json)
|
|
44
38
|
super
|
|
45
39
|
@storage_api_version = '2016-05-31'
|
|
46
|
-
@proxy = ENV['http_proxy']
|
|
47
|
-
@ssl_version = 'TLSv1'
|
|
48
|
-
@ssl_verify = nil
|
|
49
40
|
end
|
|
50
41
|
|
|
51
42
|
# Returns a list of tables for the given storage account +key+. Note
|
|
@@ -290,9 +281,9 @@ module Azure
|
|
|
290
281
|
:url => url,
|
|
291
282
|
:payload => '',
|
|
292
283
|
:headers => headers,
|
|
293
|
-
:proxy => proxy,
|
|
294
|
-
:ssl_version => ssl_version,
|
|
295
|
-
:ssl_verify => ssl_verify
|
|
284
|
+
:proxy => configuration.proxy,
|
|
285
|
+
:ssl_version => configuration.ssl_version,
|
|
286
|
+
:ssl_verify => configuration.ssl_verify
|
|
296
287
|
)
|
|
297
288
|
|
|
298
289
|
Azure::Armrest::ResponseHeaders.new(response.headers).tap do |rh|
|
|
@@ -335,9 +326,9 @@ module Azure
|
|
|
335
326
|
:url => dst_url,
|
|
336
327
|
:payload => '',
|
|
337
328
|
:headers => headers,
|
|
338
|
-
:proxy => proxy,
|
|
339
|
-
:ssl_version => ssl_version,
|
|
340
|
-
:ssl_verify => ssl_verify
|
|
329
|
+
:proxy => configuration.proxy,
|
|
330
|
+
:ssl_version => configuration.ssl_version,
|
|
331
|
+
:ssl_verify => configuration.ssl_verify
|
|
341
332
|
)
|
|
342
333
|
|
|
343
334
|
Azure::Armrest::ResponseHeaders.new(response.headers).tap do |rh|
|
|
@@ -385,9 +376,9 @@ module Azure
|
|
|
385
376
|
:url => url,
|
|
386
377
|
:payload => content,
|
|
387
378
|
:headers => headers,
|
|
388
|
-
:proxy => proxy,
|
|
389
|
-
:ssl_version => ssl_version,
|
|
390
|
-
:ssl_verify => ssl_verify
|
|
379
|
+
:proxy => configuration.proxy,
|
|
380
|
+
:ssl_version => configuration.ssl_version,
|
|
381
|
+
:ssl_verify => configuration.ssl_verify
|
|
391
382
|
)
|
|
392
383
|
|
|
393
384
|
Azure::Armrest::ResponseHeaders.new(response.headers).tap do |rh|
|
|
@@ -486,9 +477,9 @@ module Azure
|
|
|
486
477
|
:rest_head,
|
|
487
478
|
:url => url,
|
|
488
479
|
:headers => headers,
|
|
489
|
-
:proxy => proxy,
|
|
490
|
-
:ssl_version => ssl_version,
|
|
491
|
-
:ssl_verify => ssl_verify
|
|
480
|
+
:proxy => configuration.proxy,
|
|
481
|
+
:ssl_version => configuration.ssl_version,
|
|
482
|
+
:ssl_verify => configuration.ssl_verify
|
|
492
483
|
)
|
|
493
484
|
|
|
494
485
|
BlobProperty.new(response.headers.merge(:container => container, :name => blob))
|
|
@@ -525,9 +516,9 @@ module Azure
|
|
|
525
516
|
:rest_put,
|
|
526
517
|
:url => url,
|
|
527
518
|
:headers => headers,
|
|
528
|
-
:proxy => proxy,
|
|
529
|
-
:ssl_version => ssl_version,
|
|
530
|
-
:ssl_verify => ssl_verify
|
|
519
|
+
:proxy => configuration.proxy,
|
|
520
|
+
:ssl_version => configuration.ssl_version,
|
|
521
|
+
:ssl_verify => configuration.ssl_verify
|
|
531
522
|
)
|
|
532
523
|
|
|
533
524
|
BlobProperty.new(response.headers.merge(:container => container, :name => blob))
|
|
@@ -596,7 +587,7 @@ module Azure
|
|
|
596
587
|
begin
|
|
597
588
|
mutex.synchronize { array.concat(blobs(container.name, key, options)) }
|
|
598
589
|
rescue Errno::ECONNREFUSED, Azure::Armrest::TimeoutException => err
|
|
599
|
-
msg "Unable to gather blob information for #{container.name}: #{err}"
|
|
590
|
+
msg = "Unable to gather blob information for #{container.name}: #{err}"
|
|
600
591
|
log('warn', msg)
|
|
601
592
|
next
|
|
602
593
|
end
|
|
@@ -670,9 +661,9 @@ module Azure
|
|
|
670
661
|
:url => dst_url,
|
|
671
662
|
:payload => '',
|
|
672
663
|
:headers => headers,
|
|
673
|
-
:proxy => proxy,
|
|
674
|
-
:ssl_version => ssl_version,
|
|
675
|
-
:ssl_verify => ssl_verify
|
|
664
|
+
:proxy => configuration.proxy,
|
|
665
|
+
:ssl_version => configuration.ssl_version,
|
|
666
|
+
:ssl_verify => configuration.ssl_verify
|
|
676
667
|
)
|
|
677
668
|
|
|
678
669
|
blob = blob_properties(dst_container, dst_blob, key)
|
|
@@ -697,9 +688,9 @@ module Azure
|
|
|
697
688
|
:rest_delete,
|
|
698
689
|
:url => url,
|
|
699
690
|
:headers => headers,
|
|
700
|
-
:proxy => proxy,
|
|
701
|
-
:ssl_version => ssl_version,
|
|
702
|
-
:ssl_verify => ssl_verify
|
|
691
|
+
:proxy => configuration.proxy,
|
|
692
|
+
:ssl_version => configuration.ssl_version,
|
|
693
|
+
:ssl_verify => configuration.ssl_verify
|
|
703
694
|
)
|
|
704
695
|
|
|
705
696
|
headers = Azure::Armrest::ResponseHeaders.new(response.headers)
|
|
@@ -752,7 +743,7 @@ module Azure
|
|
|
752
743
|
end
|
|
753
744
|
|
|
754
745
|
hash['x-ms-date'] ||= Time.now.httpdate
|
|
755
|
-
hash['x-ms-version'] ||=
|
|
746
|
+
hash['x-ms-version'] ||= storage_api_version
|
|
756
747
|
hash['verb'] = 'PUT'
|
|
757
748
|
|
|
758
749
|
# Content length must be 0 (blank) for Page or Append blobs
|
|
@@ -772,9 +763,9 @@ module Azure
|
|
|
772
763
|
:url => url,
|
|
773
764
|
:payload => payload,
|
|
774
765
|
:headers => headers,
|
|
775
|
-
:proxy => proxy,
|
|
776
|
-
:ssl_version => ssl_version,
|
|
777
|
-
:ssl_verify => ssl_verify
|
|
766
|
+
:proxy => configuration.proxy,
|
|
767
|
+
:ssl_version => configuration.ssl_version,
|
|
768
|
+
:ssl_verify => configuration.ssl_verify
|
|
778
769
|
)
|
|
779
770
|
|
|
780
771
|
resp_headers = Azure::Armrest::ResponseHeaders.new(response.headers)
|
|
@@ -823,9 +814,9 @@ module Azure
|
|
|
823
814
|
:url => url,
|
|
824
815
|
:payload => '',
|
|
825
816
|
:headers => headers,
|
|
826
|
-
:proxy => proxy,
|
|
827
|
-
:ssl_version => ssl_version,
|
|
828
|
-
:ssl_verify => ssl_verify
|
|
817
|
+
:proxy => configuration.proxy,
|
|
818
|
+
:ssl_version => configuration.ssl_version,
|
|
819
|
+
:ssl_verify => configuration.ssl_verify
|
|
829
820
|
)
|
|
830
821
|
|
|
831
822
|
headers = Azure::Armrest::ResponseHeaders.new(response.headers)
|
|
@@ -899,9 +890,9 @@ module Azure
|
|
|
899
890
|
:rest_get,
|
|
900
891
|
:url => url,
|
|
901
892
|
:headers => headers,
|
|
902
|
-
:proxy => proxy,
|
|
903
|
-
:ssl_version => ssl_version,
|
|
904
|
-
:ssl_verify => ssl_verify
|
|
893
|
+
:proxy => configuration.proxy,
|
|
894
|
+
:ssl_version => configuration.ssl_version,
|
|
895
|
+
:ssl_verify => configuration.ssl_verify
|
|
905
896
|
)
|
|
906
897
|
end
|
|
907
898
|
|
|
@@ -954,9 +945,9 @@ module Azure
|
|
|
954
945
|
:rest_get,
|
|
955
946
|
:url => url,
|
|
956
947
|
:headers => headers,
|
|
957
|
-
:proxy => proxy,
|
|
958
|
-
:ssl_version => ssl_version,
|
|
959
|
-
:ssl_verify => ssl_verify
|
|
948
|
+
:proxy => configuration.proxy,
|
|
949
|
+
:ssl_version => configuration.ssl_version,
|
|
950
|
+
:ssl_verify => configuration.ssl_verify
|
|
960
951
|
)
|
|
961
952
|
end
|
|
962
953
|
|
|
@@ -973,9 +964,9 @@ module Azure
|
|
|
973
964
|
params = {
|
|
974
965
|
:url => url,
|
|
975
966
|
:headers => headers,
|
|
976
|
-
:proxy => proxy,
|
|
977
|
-
:ssl_version => ssl_version,
|
|
978
|
-
:ssl_verify => ssl_verify
|
|
967
|
+
:proxy => configuration.proxy,
|
|
968
|
+
:ssl_version => configuration.ssl_version,
|
|
969
|
+
:ssl_verify => configuration.ssl_verify
|
|
979
970
|
}
|
|
980
971
|
|
|
981
972
|
if %w[put post].include?(request_type.to_s.downcase)
|
|
@@ -1002,9 +993,9 @@ module Azure
|
|
|
1002
993
|
:rest_get,
|
|
1003
994
|
:url => url,
|
|
1004
995
|
:headers => headers,
|
|
1005
|
-
:proxy => proxy,
|
|
1006
|
-
:ssl_version => ssl_version,
|
|
1007
|
-
:ssl_verify => ssl_verify
|
|
996
|
+
:proxy => configuration.proxy,
|
|
997
|
+
:ssl_version => configuration.ssl_version,
|
|
998
|
+
:ssl_verify => configuration.ssl_verify
|
|
1008
999
|
)
|
|
1009
1000
|
end
|
|
1010
1001
|
|
|
@@ -1022,7 +1013,7 @@ module Azure
|
|
|
1022
1013
|
headers = {
|
|
1023
1014
|
'content-type' => content_type,
|
|
1024
1015
|
'x-ms-date' => Time.now.httpdate,
|
|
1025
|
-
'x-ms-version' =>
|
|
1016
|
+
'x-ms-version' => storage_api_version,
|
|
1026
1017
|
'auth_string' => true
|
|
1027
1018
|
}
|
|
1028
1019
|
|
|
@@ -58,64 +58,64 @@ module Azure::Armrest::Storage::ManagedStorageHelper
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
# This call will give us an operations URL in the headers.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
begin_get_access_url = build_url(resource_group, disk_name, 'BeginGetAccess')
|
|
62
|
+
begin_get_access_response = rest_post(begin_get_access_url, post_options.to_json)
|
|
63
|
+
|
|
64
|
+
headers = Azure::Armrest::ResponseHeaders.new(begin_get_access_response.headers)
|
|
65
|
+
status = wait(headers, 120, 5)
|
|
65
66
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
unless status.casecmp('succeeded').zero?
|
|
68
|
+
msg = "Unable to obtain an operations URL for #{disk_name}/#{resource_group}"
|
|
69
|
+
log('debug', "#{msg}: #{begin_get_access_response.headers}")
|
|
70
|
+
raise Azure::Armrest::NotFoundException.new(begin_get_access_response.code, msg, begin_get_access_response.body)
|
|
71
|
+
end
|
|
69
72
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
raise Azure::Armrest::NotFoundException.new(response.code, msg, response.body)
|
|
73
|
-
end
|
|
73
|
+
# Get the SAS URL from the BeginGetAccess call
|
|
74
|
+
op_url = headers.try(:azure_asyncoperation) || headers.location
|
|
74
75
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
body = Azure::Armrest::ResponseBody.new(response.body)
|
|
78
|
-
sas_url = body.try(:properties).try(:output).try(:access_sas)
|
|
76
|
+
# Dig the URL + SAS token URL out of the response
|
|
77
|
+
response = rest_get(op_url)
|
|
79
78
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
raise Azure::Armrest::NotFoundException.new(response.code, msg, response.body)
|
|
83
|
-
end
|
|
79
|
+
body = Azure::Armrest::ResponseBody.new(response.body)
|
|
80
|
+
sas_url = body.properties.output.access_sas
|
|
84
81
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
82
|
+
# The same restrictions that apply to the StorageAccont method also apply here.
|
|
83
|
+
range = options[:range] if options[:range]
|
|
84
|
+
range ||= options[:start_byte]..options[:end_byte] if options[:start_byte] && options[:end_byte]
|
|
85
|
+
range ||= options[:start_byte]..options[:start_byte] + options[:length] - 1 if options[:start_byte] && options[:length]
|
|
89
86
|
|
|
90
|
-
|
|
87
|
+
range_str = range ? "bytes=#{range.min}-#{range.max}" : nil
|
|
91
88
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
89
|
+
unless range_str || options[:entire_image]
|
|
90
|
+
raise ArgumentError, "must specify byte range or :entire_image flag"
|
|
91
|
+
end
|
|
95
92
|
|
|
96
|
-
|
|
97
|
-
|
|
93
|
+
headers = {}
|
|
94
|
+
headers['x-ms-range'] = range_str if range_str
|
|
98
95
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
96
|
+
# Need to make a raw call since we need to explicitly pass headers,
|
|
97
|
+
# but without encoding the URL or passing our configuration token.
|
|
98
|
+
max_retries = 5
|
|
99
|
+
retries = 0
|
|
100
|
+
|
|
101
|
+
begin
|
|
102
|
+
RestClient::Request.execute(
|
|
103
|
+
:method => :get,
|
|
104
|
+
:url => sas_url,
|
|
105
|
+
:headers => headers,
|
|
106
|
+
:proxy => configuration.proxy,
|
|
107
|
+
:ssl_version => configuration.ssl_version,
|
|
108
|
+
:ssl_verify => configuration.ssl_verify
|
|
109
|
+
)
|
|
110
|
+
rescue RestClient::Exception, Azure::Armrest::ForbiddenException => err
|
|
111
|
+
retries += 1
|
|
112
|
+
raise err unless retries < max_retries
|
|
113
|
+
log('warn', "get_blob_raw: #{err} - retry number #{retries}")
|
|
114
|
+
sleep 5
|
|
115
|
+
retry
|
|
116
|
+
end
|
|
117
|
+
ensure
|
|
118
|
+
if begin_get_access_response && status.casecmp('succeeded').zero?
|
|
119
119
|
end_url = build_url(resource_group, disk_name, 'EndGetAccess')
|
|
120
120
|
rest_post(end_url)
|
|
121
121
|
end
|
|
@@ -13,31 +13,19 @@ module Azure
|
|
|
13
13
|
# Same as other resource based get methods, but also sets the proxy on the model object.
|
|
14
14
|
#
|
|
15
15
|
def get(name, resource_group = configuration.resource_group)
|
|
16
|
-
super.tap
|
|
17
|
-
m.proxy = configuration.proxy
|
|
18
|
-
m.ssl_version = configuration.ssl_version
|
|
19
|
-
m.ssl_verify = configuration.ssl_verify
|
|
20
|
-
end
|
|
16
|
+
super.tap { |model| model.configuration = configuration }
|
|
21
17
|
end
|
|
22
18
|
|
|
23
19
|
# Same as other resource based list methods, but also sets the proxy on each model object.
|
|
24
20
|
#
|
|
25
21
|
def list(resource_group = configuration.resource_group)
|
|
26
|
-
super.each
|
|
27
|
-
m.proxy = configuration.proxy
|
|
28
|
-
m.ssl_version = configuration.ssl_version
|
|
29
|
-
m.ssl_verify = configuration.ssl_verify
|
|
30
|
-
end
|
|
22
|
+
super.each { |model| model.configuration = configuration }
|
|
31
23
|
end
|
|
32
24
|
|
|
33
25
|
# Same as other resource based list_all methods, but also sets the proxy on each model object.
|
|
34
26
|
#
|
|
35
27
|
def list_all(filter = {})
|
|
36
|
-
super(filter).each
|
|
37
|
-
m.proxy = configuration.proxy
|
|
38
|
-
m.ssl_version = configuration.ssl_version
|
|
39
|
-
m.ssl_verify = configuration.ssl_verify
|
|
40
|
-
end
|
|
28
|
+
super(filter).each { |model| model.configuration = configuration }
|
|
41
29
|
end
|
|
42
30
|
|
|
43
31
|
# Creates a new storage account, or updates an existing account with the
|
|
@@ -86,9 +74,7 @@ module Azure
|
|
|
86
74
|
url << "&validating=" << validating if validating
|
|
87
75
|
end
|
|
88
76
|
|
|
89
|
-
acct.
|
|
90
|
-
acct.ssl_version = configuration.ssl_version
|
|
91
|
-
acct.ssl_verify = configuration.ssl_verify
|
|
77
|
+
acct.configuration = configuration
|
|
92
78
|
|
|
93
79
|
acct
|
|
94
80
|
end
|
|
@@ -186,16 +172,7 @@ module Azure
|
|
|
186
172
|
# Note that for string values the comparison is caseless.
|
|
187
173
|
#
|
|
188
174
|
def list_all_private_images(filter = {})
|
|
189
|
-
storage_accounts = list_all
|
|
190
|
-
filter.all? do |method_name, value|
|
|
191
|
-
if value.kind_of?(String)
|
|
192
|
-
acct.public_send(method_name).casecmp(value).zero?
|
|
193
|
-
else
|
|
194
|
-
acct.public_send(method_name) == value
|
|
195
|
-
end
|
|
196
|
-
end
|
|
197
|
-
end
|
|
198
|
-
|
|
175
|
+
storage_accounts = list_all(filter)
|
|
199
176
|
get_private_images(storage_accounts)
|
|
200
177
|
end
|
|
201
178
|
|
|
@@ -231,6 +208,8 @@ module Azure
|
|
|
231
208
|
raise err unless acct
|
|
232
209
|
end
|
|
233
210
|
|
|
211
|
+
acct.configuration = configuration
|
|
212
|
+
|
|
234
213
|
acct
|
|
235
214
|
end
|
|
236
215
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: azure-armrest
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel J. Berger
|
|
@@ -11,7 +11,7 @@ authors:
|
|
|
11
11
|
autorequire:
|
|
12
12
|
bindir: bin
|
|
13
13
|
cert_chain: []
|
|
14
|
-
date: 2017-
|
|
14
|
+
date: 2017-09-22 00:00:00.000000000 Z
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|
|
17
17
|
name: json
|
|
@@ -302,7 +302,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
302
302
|
version: '0'
|
|
303
303
|
requirements: []
|
|
304
304
|
rubyforge_project:
|
|
305
|
-
rubygems_version: 2.6.
|
|
305
|
+
rubygems_version: 2.6.12
|
|
306
306
|
signing_key:
|
|
307
307
|
specification_version: 4
|
|
308
308
|
summary: An interface for ARM/JSON Azure REST API
|