azure-armrest 0.9.7 → 0.9.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
- SHA1:
3
- metadata.gz: c06e7097d8652955d4ba02fd9a45af7b4877dc10
4
- data.tar.gz: 66613b67f52124b592b474ba5539d4323442f059
2
+ SHA256:
3
+ metadata.gz: 308fa0471db6fcfcf327950d653656c9b8f920664f328784720d6d79fb8d92c7
4
+ data.tar.gz: 2df3fed1b871bb4d037acd2e66d9dac4720a96b29399d1875ca454cef5b0b0ee
5
5
  SHA512:
6
- metadata.gz: a5b83e1622e46b89b2f37f2cb5e7db17b8ba9a052ea95660c6c01e66031fe1dea2adebe310cddef974213b7d2f0fc444cff34ba12a2b411d69f33c6e7bd4abc2
7
- data.tar.gz: 1edb37efd68be1ac101298cf7059b06ca16f008d6b7d9b21d166a5710ea5be42db14dc60855c7bf3bfaaa1b403a2a561dd820b9bd17efba99890a43a924b2460
6
+ metadata.gz: d0e1fe0a64713a2ad3decb326ba5e182eb72e53e2960de6d1ddf1daab03ec1579046c4ed38fafa17434c8f1b9afb6519486a138f8f9a77e8e80444a9f0b0b18e
7
+ data.tar.gz: df7b6ef4e32b62a81b6d394b6e44a303bd8631ac17fc8bc260e3f852e6058c3dc38e799529c3f36e0a0091ae6245ac9bda43fa6fbe9a9bfd0222199e297f4463
data/CHANGES CHANGED
@@ -1,3 +1,12 @@
1
+ = 0.9.8 - 14-mar-2018
2
+ * Performance of the VirtualMachineImageService#list_all method has been
3
+ dramatically improved.
4
+ * Added the StorageAccountService#get_by_url method.
5
+ * Fixed an error message in the StorageAccountService#list_private_images method.
6
+ * Added an error check for invalid ID strings in the
7
+ ResourceGroupBasedService#get_by_id method.
8
+ * Minor doc updates.
9
+
1
10
  = 0.9.7 - 5-Mar-2018
2
11
  * Added get_by_id support for templates and template operations.
3
12
 
@@ -1,7 +1,7 @@
1
1
  module Azure
2
2
  module Armrest
3
3
  module Network
4
- # Base class for managing subnets
4
+ # Base class for managing routes in a route table
5
5
  class RouteService < ResourceGroupBasedSubservice
6
6
  def initialize(armrest_configuration, options = {})
7
7
  super(armrest_configuration, 'routeTables', 'routes', 'Microsoft.Network', options)
@@ -1,9 +1,9 @@
1
1
  module Azure
2
2
  module Armrest
3
3
  module Network
4
- # Class for managing load balancers
4
+ # Class for managing route tables
5
5
  class RouteTableService < ResourceGroupBasedService
6
- # Creates and returns a new LoadBalancerService instance.
6
+ # Creates and returns a new RouteTableService instance.
7
7
  #
8
8
  def initialize(armrest_configuration, options = {})
9
9
  super(armrest_configuration, 'routeTables', 'Microsoft.Network', options)
@@ -212,6 +212,7 @@ module Azure
212
212
  }xi
213
213
 
214
214
  match = regex.match(id_string)
215
+ raise ArgumentError, "Invalid ID string: #{id_string}" unless match
215
216
  Hash[match.names.zip(match.captures)]
216
217
  end
217
218
 
@@ -28,6 +28,33 @@ module Azure
28
28
  super(filter).each { |model| model.configuration = configuration }
29
29
  end
30
30
 
31
+ # Retrieve information about the storage account using a URI. You may optionally
32
+ # specify a resource group name, which will slightly faster. By default it will
33
+ # use the resource group specified in the service configuration, if any.
34
+ #
35
+ # Example:
36
+ #
37
+ # sas = Azure::Armrest::StorageAccountService.new(<config>)
38
+ # url = https://foo.blob.core.windows.net/vhds/dberger1201691213010.vhd"
39
+ #
40
+ # sas.get_from_url(url)
41
+ # sas.get_from_url(url, some_resource_group)
42
+ #
43
+ def get_from_url(url, resource_group = configuration.resource_group)
44
+ uri = Addressable::URI.parse(url)
45
+ name = uri.host.split('.').first
46
+
47
+ unless resource_group
48
+ rservice = Azure::Armrest::ResourceService.new(configuration)
49
+ filter = "resourceType eq 'Microsoft.Storage/storageAccounts' and name eq '#{name}'"
50
+ resource = rservice.list_all(:filter => filter, :all => true).first
51
+ raise ArgumentError, "unable to find resource group for #{url}" unless resource
52
+ resource_group = resource.id[/resourceGroups\/(.*?)\//i, 1]
53
+ end
54
+
55
+ get(name, resource_group)
56
+ end
57
+
31
58
  # Creates a new storage account, or updates an existing account with the
32
59
  # specified parameters.
33
60
  #
@@ -191,26 +218,11 @@ module Azure
191
218
  get_private_images(storage_accounts)
192
219
  end
193
220
 
194
- # Return the storage account for the virtual machine model +vm+.
221
+ # Return the storage account for the virtual machine model +vm+. Note that
222
+ # this method returns the storage account for the OS disk.
195
223
  #
196
224
  def get_from_vm(vm)
197
- uri = Addressable::URI.parse(vm.properties.storage_profile.os_disk.vhd.uri)
198
-
199
- # The uri looks like https://foo123.blob.core.windows.net/vhds/something123.vhd
200
- name = uri.host.split('.').first # storage name, e.g. 'foo123'
201
-
202
- # Look for the storage account in the VM's resource group first. If
203
- # it's not found, look through all the storage accounts.
204
- begin
205
- acct = get(name, vm.resource_group)
206
- rescue Azure::Armrest::NotFoundException => err
207
- acct = list_all(:name => name).first
208
- raise err unless acct
209
- end
210
-
211
- acct.configuration = configuration
212
-
213
- acct
225
+ get_from_url(vm.properties.storage_profile.os_disk.vhd.uri)
214
226
  end
215
227
 
216
228
  # Get information for the underlying VHD file based on the properties
@@ -296,7 +308,7 @@ module Azure
296
308
  :skip_accessors_definition => true
297
309
  )
298
310
  rescue Errno::ECONNREFUSED, Azure::Armrest::TimeoutException => err
299
- msg = "Unable to collect blob properties for #{blob.name_from_hash}/#{blob.container_from_hash}: #{err}"
311
+ msg = "Unable to collect blob properties for #{blob.name_from_hash}/#{blob[:container]}: #{err}"
300
312
  log('warn', msg)
301
313
  next
302
314
  end
@@ -1,6 +1,6 @@
1
1
  module Azure
2
2
  module Armrest
3
3
  # The version of the azure-armrest library.
4
- VERSION = '0.9.7'.freeze
4
+ VERSION = '0.9.8'.freeze
5
5
  end
6
6
  end
@@ -31,23 +31,28 @@ module Azure
31
31
  def list_all(location = @location)
32
32
  raise ArgumentError, "No location specified" unless location
33
33
 
34
+ mutex = Mutex.new
34
35
  images = []
35
- publishers(location).each do |publisher|
36
- offers(location, publisher.name).each do |offer|
37
- skus(offer.name, location, publisher.name).each do |sku|
38
- versions(sku.name, offer.name, location, publisher.name).each do |version|
39
- images << Azure::Armrest::VirtualMachineImage.new(
36
+
37
+ Parallel.each(publishers(location), :in_threads => configuration.max_threads) do |publisher|
38
+ Parallel.each(offers(location, publisher.name), :in_threads => configuration.max_threads) do |offer|
39
+ Parallel.each(skus(offer.name, location, publisher.name), :in_threads => configuration.max_threads) do |sku|
40
+ Parallel.each(versions(sku.name, offer.name, location, publisher.name), :in_threads => configuration.max_threads) do |version|
41
+ mutex.synchronize do
42
+ images << Azure::Armrest::VirtualMachineImage.new(
40
43
  :location => version.location,
41
44
  :publisher => publisher.name,
42
45
  :offer => offer.name,
43
46
  :sku => sku.name,
44
47
  :version => version.name,
45
48
  :id => "#{publisher.name}:#{offer.name}:#{sku.name}:#{version.name}"
46
- )
49
+ )
50
+ end
47
51
  end
48
52
  end
49
53
  end
50
54
  end
55
+
51
56
  images
52
57
  end
53
58
 
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.9.7
4
+ version: 0.9.8
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: 2018-03-05 00:00:00.000000000 Z
14
+ date: 2018-03-14 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: json
@@ -291,7 +291,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
291
291
  version: '0'
292
292
  requirements: []
293
293
  rubyforge_project:
294
- rubygems_version: 2.6.11
294
+ rubygems_version: 2.7.6
295
295
  signing_key:
296
296
  specification_version: 4
297
297
  summary: An interface for ARM/JSON Azure REST API