azure-armrest 0.0.7 → 0.0.8
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 +7 -0
- data/azure-armrest.gemspec +1 -1
- data/lib/azure/armrest.rb +0 -1
- data/lib/azure/armrest/model/base_model.rb +11 -3
- data/lib/azure/armrest/model/storage_account.rb +3 -3
- data/lib/azure/armrest/resource_provider_service.rb +23 -3
- data/lib/azure/armrest/storage_account_service.rb +43 -1
- data/lib/azure/armrest/version.rb +1 -1
- metadata +6 -7
- data/lib/azure/armrest/event_service.rb +0 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 198f8903222b20b0bbea81928db29aab7436dbae
|
4
|
+
data.tar.gz: 25a4b584d105a275782a32635e69faa78e6d6250
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6c3ab976bc6b91665dafccfcfc5e317023c9feddeb61ec580764fe07858d095be9cb8bb8d715c8c4cf53ec589ae76b8cb6657f759152a014f11c729a0f0d11e
|
7
|
+
data.tar.gz: 9023b4532602c882d34282208cf4941b7cf5bd130e641d7da11b3c8fdca5235a075df763454bded12bc389df91ebd21aa0b4185dfa45ca3a2ff2bc2c9b17beb4
|
data/CHANGES
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
= 0.0.8 - 10-Nov-2015
|
2
|
+
* Added the list_private_images method to the StorageAccountService class.
|
3
|
+
* Added the list_all method to the ResourceGroupService class.
|
4
|
+
* Removed the EventService class for now. It did not actually work, and will
|
5
|
+
eventually be re-implemented as part of a group of Insights classes.
|
6
|
+
* Added a .to_h and .to_hash method for the BaseModel class.
|
7
|
+
|
1
8
|
= 0.0.7 - 5-Nov-2015
|
2
9
|
* Refactored our BaseModel class so that it no longer uses Delegate or OpenStruct.
|
3
10
|
* Added more methods to the StorageAccount model, and modified methods so that
|
data/azure-armrest.gemspec
CHANGED
@@ -20,7 +20,7 @@ behind the scenes.
|
|
20
20
|
EOF
|
21
21
|
|
22
22
|
spec.add_dependency 'json'
|
23
|
-
spec.add_dependency 'rest-client', '
|
23
|
+
spec.add_dependency 'rest-client', '~> 2.0.0.rc'
|
24
24
|
spec.add_dependency 'cache_method', '~> 0.2.7'
|
25
25
|
spec.add_dependency 'azure-signature', '~> 0.2.0'
|
26
26
|
spec.add_dependency 'activesupport', '>= 1.2.0'
|
data/lib/azure/armrest.rb
CHANGED
@@ -29,7 +29,6 @@ require 'azure/armrest/availability_set_service'
|
|
29
29
|
require 'azure/armrest/virtual_machine_service'
|
30
30
|
require 'azure/armrest/virtual_machine_image_service'
|
31
31
|
require 'azure/armrest/virtual_machine_extension_service'
|
32
|
-
require 'azure/armrest/event_service'
|
33
32
|
require 'azure/armrest/template_deployment_service'
|
34
33
|
require 'azure/armrest/resource_service'
|
35
34
|
require 'azure/armrest/resource_group_service'
|
@@ -54,14 +54,14 @@ module Azure
|
|
54
54
|
end
|
55
55
|
|
56
56
|
if json.is_a?(Hash)
|
57
|
-
hash = json
|
57
|
+
@hash = json
|
58
58
|
@json = json.to_json
|
59
59
|
else
|
60
|
-
hash = JSON.parse(json)
|
60
|
+
@hash = JSON.parse(json)
|
61
61
|
@json = json
|
62
62
|
end
|
63
63
|
|
64
|
-
__setobj__(hash)
|
64
|
+
__setobj__(@hash.dup)
|
65
65
|
end
|
66
66
|
|
67
67
|
def resource_group
|
@@ -72,6 +72,14 @@ module Azure
|
|
72
72
|
@resource_group = rg
|
73
73
|
end
|
74
74
|
|
75
|
+
def to_h
|
76
|
+
@hash
|
77
|
+
end
|
78
|
+
|
79
|
+
def to_hash
|
80
|
+
@hash
|
81
|
+
end
|
82
|
+
|
75
83
|
def to_json
|
76
84
|
@json
|
77
85
|
end
|
@@ -10,6 +10,7 @@ module Azure
|
|
10
10
|
class ContainerProperty < BaseModel; end
|
11
11
|
class Blob < BaseModel; end
|
12
12
|
class BlobProperty < BaseModel; end
|
13
|
+
class PrivateImage < BlobProperty; end
|
13
14
|
class BlobServiceProperty < BaseModel; end
|
14
15
|
class BlobServiceStat < BaseModel; end
|
15
16
|
class BlobMetadata < BaseModel; end
|
@@ -95,9 +96,8 @@ module Azure
|
|
95
96
|
doc = Nokogiri::XML(response.body)
|
96
97
|
|
97
98
|
doc.xpath('//Blobs/Blob').map do |node|
|
98
|
-
|
99
|
-
|
100
|
-
blob
|
99
|
+
hash = Hash.from_xml(node.to_s)['Blob'].merge(:container => container)
|
100
|
+
Blob.new(hash)
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
@@ -47,13 +47,32 @@ module Azure
|
|
47
47
|
response = rest_get(build_url)
|
48
48
|
JSON.parse(response)["value"]
|
49
49
|
end
|
50
|
+
|
50
51
|
private :_list
|
51
52
|
|
52
|
-
# Cannot directly cache list method, because Marshal used by
|
53
|
-
# cannot dump anonymous
|
54
|
-
#
|
53
|
+
# Cannot directly cache list method, because Marshal used by cache_method
|
54
|
+
# cannot dump anonymous classes, including the ones derived from
|
55
|
+
# Azure::Armrest::BaseModel.
|
56
|
+
#
|
57
|
+
# The same applies to other cached methods in this class.
|
55
58
|
cache_method(:_list, cache_time)
|
56
59
|
|
60
|
+
# List all the providers for Azure. This may include results that are
|
61
|
+
# not available for the current subscription.
|
62
|
+
#
|
63
|
+
def list_all
|
64
|
+
_list_all.map{ |hash| Azure::Armrest::ResourceProvider.new(hash) }
|
65
|
+
end
|
66
|
+
|
67
|
+
def _list_all
|
68
|
+
url = File.join(Azure::Armrest::RESOURCE, 'providers')
|
69
|
+
url << "?api-version=#{@api_version}"
|
70
|
+
response = rest_get(url)
|
71
|
+
JSON.parse(response)['value']
|
72
|
+
end
|
73
|
+
|
74
|
+
cache_method(:_list_all, cache_time)
|
75
|
+
|
57
76
|
# Return information about a specific +namespace+ provider. The results
|
58
77
|
# of this method are cached.
|
59
78
|
#
|
@@ -65,6 +84,7 @@ module Azure
|
|
65
84
|
url = build_url(namespace)
|
66
85
|
rest_get(url).body
|
67
86
|
end
|
87
|
+
|
68
88
|
private :_get
|
69
89
|
|
70
90
|
cache_method(:_get, cache_time)
|
@@ -70,7 +70,6 @@ module Azure
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
-
|
74
73
|
# Returns the primary and secondary access keys for the given
|
75
74
|
# storage account as a hash.
|
76
75
|
#
|
@@ -98,6 +97,49 @@ module Azure
|
|
98
97
|
JSON.parse(response)
|
99
98
|
end
|
100
99
|
|
100
|
+
# Returns a list of images that are available for provisioning for all
|
101
|
+
# storage accounts in the provided resource group. The custom keys
|
102
|
+
# :uri and :operating_system have been added for convenience.
|
103
|
+
#
|
104
|
+
def list_private_images(group = armrest_configuration.resource_group)
|
105
|
+
results = []
|
106
|
+
threads = []
|
107
|
+
mutex = Mutex.new
|
108
|
+
|
109
|
+
list(group).each do |lstorage_account|
|
110
|
+
threads << Thread.new(lstorage_account) do |storage_account|
|
111
|
+
key = list_account_keys(storage_account.name, group).fetch('key1')
|
112
|
+
|
113
|
+
storage_account.all_blobs(key).each do |blob|
|
114
|
+
next unless File.extname(blob.name).downcase == '.vhd'
|
115
|
+
next unless blob.properties.lease_state.downcase == 'available'
|
116
|
+
|
117
|
+
blob_properties = storage_account.blob_properties(blob.container, blob.name, key)
|
118
|
+
next unless blob_properties.respond_to?(:x_ms_meta_microsoftazurecompute_osstate)
|
119
|
+
next unless blob_properties.x_ms_meta_microsoftazurecompute_osstate.downcase == 'generalized'
|
120
|
+
|
121
|
+
mutex.synchronize do
|
122
|
+
hash = blob.to_h.merge(
|
123
|
+
:storage_account => storage_account.to_h,
|
124
|
+
:blob_properties => blob_properties.to_h,
|
125
|
+
:operating_system => blob_properties.try(:x_ms_meta_microsoftazurecompute_ostype),
|
126
|
+
:uri => File.join(
|
127
|
+
storage_account.properties.primary_endpoints.blob,
|
128
|
+
blob.container,
|
129
|
+
blob.name
|
130
|
+
)
|
131
|
+
)
|
132
|
+
results << StorageAccount::PrivateImage.new(hash)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
threads.each(&:join)
|
139
|
+
|
140
|
+
results.flatten
|
141
|
+
end
|
142
|
+
|
101
143
|
private
|
102
144
|
|
103
145
|
def validate_account_type(account_type)
|
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.0.
|
4
|
+
version: 0.0.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: 2015-11-
|
14
|
+
date: 2015-11-10 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: json
|
@@ -31,16 +31,16 @@ dependencies:
|
|
31
31
|
name: rest-client
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
requirements:
|
34
|
-
- -
|
34
|
+
- - "~>"
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: 2.0.0.
|
36
|
+
version: 2.0.0.rc
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
|
-
- -
|
41
|
+
- - "~>"
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 2.0.0.
|
43
|
+
version: 2.0.0.rc
|
44
44
|
- !ruby/object:Gem::Dependency
|
45
45
|
name: cache_method
|
46
46
|
requirement: !ruby/object:Gem::Requirement
|
@@ -193,7 +193,6 @@ files:
|
|
193
193
|
- lib/azure/armrest.rb
|
194
194
|
- lib/azure/armrest/armrest_service.rb
|
195
195
|
- lib/azure/armrest/availability_set_service.rb
|
196
|
-
- lib/azure/armrest/event_service.rb
|
197
196
|
- lib/azure/armrest/exception.rb
|
198
197
|
- lib/azure/armrest/model/base_model.rb
|
199
198
|
- lib/azure/armrest/model/storage_account.rb
|
@@ -1,32 +0,0 @@
|
|
1
|
-
module Azure
|
2
|
-
module Armrest
|
3
|
-
class EventService < ArmrestService
|
4
|
-
|
5
|
-
def initialize(armrest_configuration, _options = {})
|
6
|
-
super
|
7
|
-
|
8
|
-
@base_url += "providers/microsoft.insights/eventtypes/management/values"
|
9
|
-
@base_url += "?api-version=#{armrest_configuration.api_version}"
|
10
|
-
end
|
11
|
-
|
12
|
-
# check what data type the event channel is
|
13
|
-
|
14
|
-
def get_rg_events(starttime, endtime, channels, rg_name )
|
15
|
-
@uri += build_filter += " and resourceGroupName eq '#{rg_name}'"
|
16
|
-
end
|
17
|
-
|
18
|
-
def get_resource_events(starttime, endtime, channels, resource_uri )
|
19
|
-
@uri += build_filter += " and resourceUri eq '#{resource_uri}'"
|
20
|
-
end
|
21
|
-
|
22
|
-
def build_filter(starttime, endtime, channels)
|
23
|
-
"$filter=eventTimestamp ge '#{starttime}' and eventTimestamp le '#{endtime}'
|
24
|
-
and eventChannels eq '#{channels}'"
|
25
|
-
end
|
26
|
-
|
27
|
-
def select_properties(property_names)
|
28
|
-
"&$select={property_names}"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|