azure-armrest 0.1.1 → 0.1.2
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 +5 -0
- data/lib/azure/armrest/armrest_service.rb +28 -23
- data/lib/azure/armrest/availability_set_service.rb +2 -2
- data/lib/azure/armrest/model/base_model.rb +14 -16
- data/lib/azure/armrest/resource_group_based_service.rb +5 -5
- data/lib/azure/armrest/resource_group_based_subservice.rb +6 -6
- data/lib/azure/armrest/resource_group_service.rb +3 -3
- data/lib/azure/armrest/resource_provider_service.rb +3 -3
- data/lib/azure/armrest/resource_service.rb +4 -4
- data/lib/azure/armrest/storage_account_service.rb +10 -9
- data/lib/azure/armrest/template_deployment_service.rb +5 -5
- data/lib/azure/armrest/version.rb +1 -1
- data/lib/azure/armrest/virtual_machine_extension_service.rb +10 -10
- data/lib/azure/armrest/virtual_machine_image_service.rb +3 -3
- data/lib/azure/armrest/virtual_machine_service.rb +12 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db15c7c2486506cdae662e57d6a5ff870a405537
|
4
|
+
data.tar.gz: 94a95cd28468371f916dab1394cb25f7a6f23773
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6bb034e35c08f91d1a34f4454ba4bc53af3ec8c263665b5d9a423273cc6534542fe061afd254e20c0d58d5c6f8d69c8bb04e2b8730d5bf60b3c360e24f68b4f
|
7
|
+
data.tar.gz: ce4243411b2067a1371c8305d553068fd1d9e5baea71960ceb3a02d5bec928e6f3ee044374d4134025f474422e4b189f04ef88739b0231e672486cab88969d72
|
data/CHANGES
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
= 0.1.2 - 2-Mar-2016
|
2
|
+
* When selecting the appropriate api version string, we now reject dates
|
3
|
+
that are ahead of the current date.
|
4
|
+
* Some minor rubocop cleanup.
|
5
|
+
|
1
6
|
= 0.1.1 - 26-Feb-2016
|
2
7
|
* Added proxy support for both the storage model and main configure method.
|
3
8
|
* Added the SqlDatabaseService and SqlServerService classes.
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'time'
|
1
2
|
require_relative 'model/base_model'
|
2
3
|
|
3
4
|
module Azure
|
@@ -59,6 +60,8 @@ module Azure
|
|
59
60
|
# Configuration to access azure APIs
|
60
61
|
attr_accessor :armrest_configuration
|
61
62
|
|
63
|
+
alias configuration armrest_configuration
|
64
|
+
|
62
65
|
# Base url used for REST calls.
|
63
66
|
attr_accessor :base_url
|
64
67
|
|
@@ -187,7 +190,7 @@ module Azure
|
|
187
190
|
# Returns a list of the available resource providers.
|
188
191
|
#
|
189
192
|
def providers
|
190
|
-
url = url_with_api_version(
|
193
|
+
url = url_with_api_version(configuration.api_version, @base_url, 'providers')
|
191
194
|
resp = rest_get(url)
|
192
195
|
JSON.parse(resp.body)["value"].map{ |hash| Azure::Armrest::ResourceProvider.new(hash) }
|
193
196
|
end
|
@@ -195,7 +198,7 @@ module Azure
|
|
195
198
|
# Returns information about the specific provider +namespace+.
|
196
199
|
#
|
197
200
|
def provider_info(provider)
|
198
|
-
url = url_with_api_version(
|
201
|
+
url = url_with_api_version(configuration.api_version, @base_url, 'providers', provider)
|
199
202
|
response = rest_get(url)
|
200
203
|
Azure::Armrest::ResourceProvider.new(response)
|
201
204
|
end
|
@@ -221,7 +224,7 @@ module Azure
|
|
221
224
|
# Returns a list of subscriptions for the tenant.
|
222
225
|
#
|
223
226
|
def subscriptions
|
224
|
-
url = url_with_api_version(
|
227
|
+
url = url_with_api_version(configuration.api_version, @base_url, 'subscriptions')
|
225
228
|
response = rest_get(url)
|
226
229
|
JSON.parse(response.body)["value"].map{ |hash| Azure::Armrest::Subscription.new(hash) }
|
227
230
|
end
|
@@ -230,12 +233,12 @@ module Azure
|
|
230
233
|
# subscription ID that was provided in the constructor if none is
|
231
234
|
# specified.
|
232
235
|
#
|
233
|
-
def subscription_info(subscription_id =
|
236
|
+
def subscription_info(subscription_id = configuration.subscription_id)
|
234
237
|
url = url_with_api_version(
|
235
|
-
|
238
|
+
configuration.api_version,
|
236
239
|
@base_url,
|
237
240
|
'subscriptions',
|
238
|
-
|
241
|
+
subscription_id
|
239
242
|
)
|
240
243
|
|
241
244
|
response = rest_get(url)
|
@@ -247,11 +250,11 @@ module Azure
|
|
247
250
|
# resource group.
|
248
251
|
#
|
249
252
|
def resources(resource_group = nil)
|
250
|
-
url_comps = [@base_url, 'subscriptions',
|
253
|
+
url_comps = [@base_url, 'subscriptions', configuration.subscription_id]
|
251
254
|
url_comps += ['resourcegroups', resource_group] if resource_group
|
252
255
|
url_comps << 'resources'
|
253
256
|
|
254
|
-
url = url_with_api_version(
|
257
|
+
url = url_with_api_version(configuration.api_version, url_comps)
|
255
258
|
response = rest_get(url)
|
256
259
|
|
257
260
|
JSON.parse(response)["value"].map{ |hash| Azure::Armrest::Resource.new(hash) }
|
@@ -261,10 +264,10 @@ module Azure
|
|
261
264
|
#
|
262
265
|
def resource_groups
|
263
266
|
url = url_with_api_version(
|
264
|
-
|
267
|
+
configuration.api_version,
|
265
268
|
@base_url,
|
266
269
|
'subscriptions',
|
267
|
-
|
270
|
+
configuration.subscription_id,
|
268
271
|
'resourcegroups'
|
269
272
|
)
|
270
273
|
response = rest_get(url)
|
@@ -275,12 +278,12 @@ module Azure
|
|
275
278
|
# subscription, or the resource group specified in the constructor if
|
276
279
|
# none is provided.
|
277
280
|
#
|
278
|
-
def resource_group_info(resource_group =
|
281
|
+
def resource_group_info(resource_group = configuration.resource_group)
|
279
282
|
url = url_with_api_version(
|
280
|
-
|
283
|
+
configuration.api_version,
|
281
284
|
@base_url,
|
282
285
|
'subscriptions',
|
283
|
-
|
286
|
+
configuration.subscription_id,
|
284
287
|
'resourcegroups',
|
285
288
|
resource_group
|
286
289
|
)
|
@@ -293,10 +296,10 @@ module Azure
|
|
293
296
|
#
|
294
297
|
def tags
|
295
298
|
url = url_with_api_version(
|
296
|
-
|
299
|
+
configuration.api_version,
|
297
300
|
@base_url,
|
298
301
|
'subscriptions',
|
299
|
-
|
302
|
+
configuration.subscription_id,
|
300
303
|
'tagNames'
|
301
304
|
)
|
302
305
|
resp = rest_get(url)
|
@@ -306,7 +309,7 @@ module Azure
|
|
306
309
|
# Returns a list of tenants that can be accessed.
|
307
310
|
#
|
308
311
|
def tenants
|
309
|
-
url = url_with_api_version(
|
312
|
+
url = url_with_api_version(configuration.api_version, @base_url, 'tenants')
|
310
313
|
resp = rest_get(url)
|
311
314
|
JSON.parse(resp.body)['value'].map{ |hash| Azure::Armrest::Tenant.new(hash) }
|
312
315
|
end
|
@@ -377,11 +380,11 @@ module Azure
|
|
377
380
|
def rest_execute(url, body = nil, http_method = :get)
|
378
381
|
options = {
|
379
382
|
:url => url,
|
380
|
-
:proxy =>
|
383
|
+
:proxy => configuration.proxy,
|
381
384
|
:headers => {
|
382
|
-
:accept =>
|
383
|
-
:content_type =>
|
384
|
-
:authorization =>
|
385
|
+
:accept => configuration.accept,
|
386
|
+
:content_type => configuration.content_type,
|
387
|
+
:authorization => configuration.token
|
385
388
|
}
|
386
389
|
}
|
387
390
|
|
@@ -435,8 +438,10 @@ module Azure
|
|
435
438
|
provider_info = {}
|
436
439
|
info.resource_types.each do |resource|
|
437
440
|
provider_info[resource.resource_type.downcase] = {
|
438
|
-
'api_version' => resource.api_versions.reject{ |version|
|
439
|
-
|
441
|
+
'api_version' => resource.api_versions.reject{ |version|
|
442
|
+
version =~ /preview/i || Time.parse(version) > Time.now
|
443
|
+
}.first,
|
444
|
+
'locations' => resource.locations - [''] # Ignore empty elements
|
440
445
|
}
|
441
446
|
end
|
442
447
|
# TODO: how does base model handle method naming collision?
|
@@ -466,7 +471,7 @@ module Azure
|
|
466
471
|
elsif @@providers_hash.has_key?(provider.downcase)
|
467
472
|
@@providers_hash[provider.downcase][service.downcase]['api_version']
|
468
473
|
else
|
469
|
-
|
474
|
+
configuration.api_version
|
470
475
|
end
|
471
476
|
end
|
472
477
|
end # ArmrestService
|
@@ -6,8 +6,8 @@ module Azure
|
|
6
6
|
class AvailabilitySetService < ResourceGroupBasedService
|
7
7
|
# Create and return a new AvailabilitySetService instance.
|
8
8
|
#
|
9
|
-
def initialize(
|
10
|
-
super(
|
9
|
+
def initialize(configuration, options = {})
|
10
|
+
super(configuration, 'availabilitySets', 'Microsoft.Compute', options)
|
11
11
|
end
|
12
12
|
|
13
13
|
def list_all
|
@@ -43,17 +43,17 @@ module Azure
|
|
43
43
|
# person.to_json # => Returns original JSON
|
44
44
|
#
|
45
45
|
def initialize(json)
|
46
|
-
# Find the exclusion list for the model of next level (@
|
46
|
+
# Find the exclusion list for the model of next level (@embed_model)
|
47
47
|
# '#' is the separator between levels. Remove attributes
|
48
48
|
# before the first separator.
|
49
49
|
child_excl_list = self.class.send(:excl_list).map do |e|
|
50
|
-
e.index('#') ? e[e.index('#') + 1
|
50
|
+
e.index('#') ? e[e.index('#') + 1..-1] : ''
|
51
51
|
end
|
52
|
-
@
|
53
|
-
attr_hash
|
52
|
+
@embed_model = Class.new(BaseModel) do
|
53
|
+
attr_hash(*child_excl_list)
|
54
54
|
end
|
55
55
|
|
56
|
-
if json.
|
56
|
+
if json.kind_of?(Hash)
|
57
57
|
@hash = json
|
58
58
|
@json = json.to_json
|
59
59
|
else
|
@@ -68,9 +68,7 @@ module Azure
|
|
68
68
|
@resource_group ||= id[/resourceGroups\/(.+?)\//i, 1] rescue nil
|
69
69
|
end
|
70
70
|
|
71
|
-
|
72
|
-
@resource_group = rg
|
73
|
-
end
|
71
|
+
attr_writer :resource_group
|
74
72
|
|
75
73
|
def to_h
|
76
74
|
@hash
|
@@ -94,9 +92,9 @@ module Azure
|
|
94
92
|
|
95
93
|
def inspect
|
96
94
|
string = "<#{self.class} "
|
97
|
-
method_list = methods(false).select{ |m| !m.to_s.include?('=') }
|
98
|
-
string << method_list.map{ |m| "#{m}=#{send(m).inspect}" }.join(
|
99
|
-
string <<
|
95
|
+
method_list = methods(false).select { |m| !m.to_s.include?('=') }
|
96
|
+
string << method_list.map { |m| "#{m}=#{send(m).inspect}" }.join(', ')
|
97
|
+
string << '>'
|
100
98
|
end
|
101
99
|
|
102
100
|
def ==(other)
|
@@ -137,11 +135,11 @@ module Azure
|
|
137
135
|
obj.each do |key, value|
|
138
136
|
snake = snake_case(key)
|
139
137
|
unless excl_list.include?(snake) # Must deal with nested models
|
140
|
-
if value.
|
141
|
-
newval = value.map { |elem| elem.
|
138
|
+
if value.kind_of?(Array)
|
139
|
+
newval = value.map { |elem| elem.kind_of?(Hash) ? @embed_model.new(elem) : elem }
|
142
140
|
obj[key] = newval
|
143
|
-
elsif value.
|
144
|
-
obj[key] = @
|
141
|
+
elsif value.kind_of?(Hash)
|
142
|
+
obj[key] = @embed_model.new(value)
|
145
143
|
end
|
146
144
|
end
|
147
145
|
|
@@ -156,7 +154,7 @@ module Azure
|
|
156
154
|
end
|
157
155
|
|
158
156
|
def snake_case(name)
|
159
|
-
name.to_s.gsub(/(.)([A-Z])/,'\1_\2').downcase
|
157
|
+
name.to_s.gsub(/(.)([A-Z])/, '\1_\2').downcase
|
160
158
|
end
|
161
159
|
end
|
162
160
|
|
@@ -2,7 +2,7 @@ module Azure
|
|
2
2
|
module Armrest
|
3
3
|
# Base class for services that need to run in a resource group
|
4
4
|
class ResourceGroupBasedService < ArmrestService
|
5
|
-
def create(name, rgroup =
|
5
|
+
def create(name, rgroup = configuration.resource_group, options = {})
|
6
6
|
validate_resource_group(rgroup)
|
7
7
|
validate_resource(name)
|
8
8
|
|
@@ -14,7 +14,7 @@ module Azure
|
|
14
14
|
|
15
15
|
alias update create
|
16
16
|
|
17
|
-
def list(rgroup =
|
17
|
+
def list(rgroup = configuration.resource_group)
|
18
18
|
validate_resource_group(rgroup)
|
19
19
|
|
20
20
|
url = build_url(rgroup)
|
@@ -30,7 +30,7 @@ module Azure
|
|
30
30
|
JSON.parse(response)['value'].map { |hash| model_class.new(hash) }
|
31
31
|
end
|
32
32
|
|
33
|
-
def get(name, rgroup =
|
33
|
+
def get(name, rgroup = configuration.resource_group)
|
34
34
|
validate_resource_group(rgroup)
|
35
35
|
validate_resource(name)
|
36
36
|
|
@@ -40,7 +40,7 @@ module Azure
|
|
40
40
|
model_class.new(response)
|
41
41
|
end
|
42
42
|
|
43
|
-
def delete(name, rgroup =
|
43
|
+
def delete(name, rgroup = configuration.resource_group)
|
44
44
|
validate_resource_group(rgroup)
|
45
45
|
validate_resource(name)
|
46
46
|
|
@@ -64,7 +64,7 @@ module Azure
|
|
64
64
|
# arguments provided, and appends it with the api_version.
|
65
65
|
#
|
66
66
|
def build_url(resource_group = nil, *args)
|
67
|
-
url = File.join(Azure::Armrest::COMMON_URI,
|
67
|
+
url = File.join(Azure::Armrest::COMMON_URI, configuration.subscription_id)
|
68
68
|
url = File.join(url, 'resourceGroups', resource_group) if resource_group
|
69
69
|
url = File.join(url, 'providers', @provider, @service_name)
|
70
70
|
url = File.join(url, *args) unless args.empty?
|
@@ -6,12 +6,12 @@ module Azure
|
|
6
6
|
# all other service classes should subclass, and call super within their
|
7
7
|
# own constructors.
|
8
8
|
#
|
9
|
-
def initialize(
|
9
|
+
def initialize(configuration, service_name, subservice_name, default_provider, options)
|
10
10
|
@subservice_name = subservice_name
|
11
|
-
super(
|
11
|
+
super(configuration, service_name, default_provider, options)
|
12
12
|
end
|
13
13
|
|
14
|
-
def create(resource, subresource, rgroup =
|
14
|
+
def create(resource, subresource, rgroup = configuration.resource_group, options = {})
|
15
15
|
validate_resource_group(rgroup)
|
16
16
|
validate_resource(resource)
|
17
17
|
validate_subresource(subresource)
|
@@ -20,7 +20,7 @@ module Azure
|
|
20
20
|
|
21
21
|
alias update create
|
22
22
|
|
23
|
-
def list(resource, rgroup =
|
23
|
+
def list(resource, rgroup = configuration.resource_group)
|
24
24
|
validate_resource_group(rgroup)
|
25
25
|
validate_resource(resource)
|
26
26
|
|
@@ -32,14 +32,14 @@ module Azure
|
|
32
32
|
|
33
33
|
alias list_all list
|
34
34
|
|
35
|
-
def get(resource, subresource, rgroup =
|
35
|
+
def get(resource, subresource, rgroup = configuration.resource_group)
|
36
36
|
validate_resource_group(rgroup)
|
37
37
|
validate_resource(resource)
|
38
38
|
validate_subresource(subresource)
|
39
39
|
super(combine(resource, subresource), rgroup)
|
40
40
|
end
|
41
41
|
|
42
|
-
def delete(resource, subresource, rgroup =
|
42
|
+
def delete(resource, subresource, rgroup = configuration.resource_group)
|
43
43
|
validate_resource_group(rgroup)
|
44
44
|
validate_resource(resource)
|
45
45
|
validate_subresource(subresource)
|
@@ -6,8 +6,8 @@ module Azure
|
|
6
6
|
|
7
7
|
# Creates and returns a new ResourceGroupService object.
|
8
8
|
#
|
9
|
-
def initialize(
|
10
|
-
super(
|
9
|
+
def initialize(configuration, options = {})
|
10
|
+
super(configuration, 'resourceGroups', 'Microsoft.Resources', options)
|
11
11
|
end
|
12
12
|
|
13
13
|
# List all the resources for the current subscription. You can optionally
|
@@ -70,7 +70,7 @@ module Azure
|
|
70
70
|
private
|
71
71
|
|
72
72
|
def build_url(group = nil, *args)
|
73
|
-
id =
|
73
|
+
id = configuration.subscription_id
|
74
74
|
url = File.join(Azure::Armrest::COMMON_URI, id, 'resourcegroups')
|
75
75
|
url = File.join(url, group) if group
|
76
76
|
url = File.join(url, *args) unless args.empty?
|
@@ -23,8 +23,8 @@ module Azure
|
|
23
23
|
#
|
24
24
|
# You can also set the provider. The default is 'Microsoft.Resources'.
|
25
25
|
#
|
26
|
-
def initialize(
|
27
|
-
super(
|
26
|
+
def initialize(configuration, options = {})
|
27
|
+
super(configuration, 'resourceGroups', 'Microsoft.Resources', options)
|
28
28
|
|
29
29
|
if options[:cache_time]
|
30
30
|
@cache_time = options[:cache_time]
|
@@ -126,7 +126,7 @@ module Azure
|
|
126
126
|
private
|
127
127
|
|
128
128
|
def build_url(namespace = nil, *args)
|
129
|
-
id =
|
129
|
+
id = configuration.subscription_id
|
130
130
|
url = File.join(Azure::Armrest::COMMON_URI, id, 'providers')
|
131
131
|
url = File.join(url, namespace) if namespace
|
132
132
|
url = File.join(url, *args) unless args.empty?
|
@@ -6,8 +6,8 @@ module Azure
|
|
6
6
|
|
7
7
|
# Creates and returns a new ResourceService object.
|
8
8
|
#
|
9
|
-
def initialize(
|
10
|
-
super(
|
9
|
+
def initialize(configuration, options = {})
|
10
|
+
super(configuration, 'subscriptions', 'Microsoft.Resources', options)
|
11
11
|
end
|
12
12
|
|
13
13
|
# List all the resources for the current subscription. You can optionally
|
@@ -23,7 +23,7 @@ module Azure
|
|
23
23
|
# rs.list(:filter => "location eq 'centralus'")
|
24
24
|
#
|
25
25
|
def list(options = {})
|
26
|
-
subscription_id =
|
26
|
+
subscription_id = configuration.subscription_id
|
27
27
|
|
28
28
|
if options[:resource_group]
|
29
29
|
url = File.join(
|
@@ -46,7 +46,7 @@ module Azure
|
|
46
46
|
# Move the resources from +source_group+ under +source_subscription+,
|
47
47
|
# which may be a different subscription.
|
48
48
|
#
|
49
|
-
def move(source_group, source_subscription =
|
49
|
+
def move(source_group, source_subscription = configuration.subscription_id)
|
50
50
|
url = File.join(
|
51
51
|
Azure::Armrest::COMMON_URI, source_subscription,
|
52
52
|
'resourcegroups', source_group, 'moveresources'
|
@@ -15,9 +15,9 @@ module Azure
|
|
15
15
|
|
16
16
|
# Creates and returns a new StorageAccountService (SAS) instance.
|
17
17
|
#
|
18
|
-
def initialize(
|
18
|
+
def initialize(configuration, options = {})
|
19
19
|
options = {'api_version' => '2015-05-01-preview'}.merge(options) # Must hard code for now
|
20
|
-
super(
|
20
|
+
super(configuration, 'storageAccounts', 'Microsoft.Storage', options)
|
21
21
|
end
|
22
22
|
|
23
23
|
# Creates a new storage account, or updates an existing account with the
|
@@ -48,16 +48,17 @@ module Azure
|
|
48
48
|
#
|
49
49
|
# sas = Azure::Armrest::StorageAccountService(config)
|
50
50
|
#
|
51
|
-
# sas.create(
|
51
|
+
# sas.create(
|
52
|
+
# "yourstorageaccount1",
|
53
|
+
# "yourresourcegroup",
|
52
54
|
# {
|
53
55
|
# :location => "West US",
|
54
56
|
# :properties => {:accountType => "Standard_ZRS"},
|
55
57
|
# :tags => {:YourCompany => true}
|
56
|
-
# }
|
57
|
-
# "yourresourcegroup"
|
58
|
+
# }
|
58
59
|
# )
|
59
60
|
#
|
60
|
-
def create(account_name, rgroup =
|
61
|
+
def create(account_name, rgroup = configuration.resource_group, options = {})
|
61
62
|
validating = options.delete(:validating)
|
62
63
|
validate_account_type(options[:properties][:accountType])
|
63
64
|
validate_account_name(account_name)
|
@@ -70,7 +71,7 @@ module Azure
|
|
70
71
|
# Returns the primary and secondary access keys for the given
|
71
72
|
# storage account as a hash.
|
72
73
|
#
|
73
|
-
def list_account_keys(account_name, group =
|
74
|
+
def list_account_keys(account_name, group = configuration.resource_group)
|
74
75
|
validate_resource_group(group)
|
75
76
|
|
76
77
|
url = build_url(group, account_name, 'listKeys')
|
@@ -86,7 +87,7 @@ module Azure
|
|
86
87
|
# "keyName": "key1|key2"
|
87
88
|
# }
|
88
89
|
#
|
89
|
-
def regenerate_storage_account_keys(account_name, group =
|
90
|
+
def regenerate_storage_account_keys(account_name, group = configuration.resource_group, options = {})
|
90
91
|
validate_resource_group(group)
|
91
92
|
|
92
93
|
url = build_url(group, account_name, 'regenerateKey')
|
@@ -98,7 +99,7 @@ module Azure
|
|
98
99
|
# storage accounts in the provided resource group. The custom keys
|
99
100
|
# :uri and :operating_system have been added for convenience.
|
100
101
|
#
|
101
|
-
def list_private_images(group =
|
102
|
+
def list_private_images(group = configuration.resource_group)
|
102
103
|
results = []
|
103
104
|
threads = []
|
104
105
|
mutex = Mutex.new
|
@@ -3,14 +3,14 @@ module Azure
|
|
3
3
|
# Base class for managing templates and deployments
|
4
4
|
class TemplateDeploymentService < ResourceGroupBasedService
|
5
5
|
|
6
|
-
def initialize(
|
6
|
+
def initialize(configuration, options = {})
|
7
7
|
# Has to be hard coded for now
|
8
8
|
options = {'api_version' => '2014-04-01-preview'}.merge(options)
|
9
|
-
super(
|
9
|
+
super(configuration, 'deployments', 'Microsoft.Resources', options)
|
10
10
|
end
|
11
11
|
|
12
12
|
# Get names of all deployments in a resource group
|
13
|
-
def list_names(resource_group =
|
13
|
+
def list_names(resource_group = configuration.resource_group)
|
14
14
|
list(resource_group).map(&:name)
|
15
15
|
end
|
16
16
|
|
@@ -20,7 +20,7 @@ module Azure
|
|
20
20
|
end
|
21
21
|
|
22
22
|
# Get all operations of a deployment in a resource group
|
23
|
-
def list_deployment_operations(deploy_name, resource_group =
|
23
|
+
def list_deployment_operations(deploy_name, resource_group = configuration.resource_group)
|
24
24
|
validate_resource_group(resource_group)
|
25
25
|
validate_resource(deploy_name)
|
26
26
|
|
@@ -30,7 +30,7 @@ module Azure
|
|
30
30
|
end
|
31
31
|
|
32
32
|
# Get the operation of a deployment in a resource group
|
33
|
-
def get_deployment_operation(op_id, deploy_name, resource_group =
|
33
|
+
def get_deployment_operation(op_id, deploy_name, resource_group = configuration.resource_group)
|
34
34
|
validate_resource_group(resource_group)
|
35
35
|
validate_resource(deploy_name)
|
36
36
|
raise ArgumentError, "must specify operation id" unless op_id
|
@@ -7,7 +7,7 @@ module Azure
|
|
7
7
|
|
8
8
|
# Creates and returns a new VirtualMachineExtensionService object.
|
9
9
|
#
|
10
|
-
def initialize(
|
10
|
+
def initialize(_configuration, options = {})
|
11
11
|
super
|
12
12
|
set_service_api_version(options, 'virtualMachines/extensions')
|
13
13
|
end
|
@@ -29,7 +29,7 @@ module Azure
|
|
29
29
|
# For convenience, you may also specify a :resource_group as an option.
|
30
30
|
#
|
31
31
|
def create(vm_name, ext_name, options = {}, rgroup = nil)
|
32
|
-
rgroup ||= options.delete(:resource_group) ||
|
32
|
+
rgroup ||= options.delete(:resource_group) || configuration.resource_group
|
33
33
|
|
34
34
|
raise ArgumentError, "no resource group provided" unless rgroup
|
35
35
|
|
@@ -50,7 +50,7 @@ module Azure
|
|
50
50
|
|
51
51
|
# Delete the given extension for the provided VM and resource group.
|
52
52
|
#
|
53
|
-
def delete(vm_name, ext_name, rgroup =
|
53
|
+
def delete(vm_name, ext_name, rgroup = configuration.resource_group)
|
54
54
|
raise ArgumentError, "no resource group provided" unless rgroup
|
55
55
|
url = build_url(rgroup, vm_name, ext_name)
|
56
56
|
response = rest_delete(url)
|
@@ -61,7 +61,7 @@ module Azure
|
|
61
61
|
# If the +instance_view+ option is true, it will retrieve instance
|
62
62
|
# view information instead.
|
63
63
|
#
|
64
|
-
def get(vm_name, ext_name, rgroup =
|
64
|
+
def get(vm_name, ext_name, rgroup = configuration.resource_group, instance_view = false)
|
65
65
|
raise ArgumentError, "no resource group provided" unless rgroup
|
66
66
|
url = build_url(rgroup, vm_name, ext_name)
|
67
67
|
url << "&expand=instanceView" if instance_view
|
@@ -70,13 +70,13 @@ module Azure
|
|
70
70
|
end
|
71
71
|
|
72
72
|
# Shortcut to get an extension in model view.
|
73
|
-
def get_model_view(vm_name, ext_name, rgroup =
|
73
|
+
def get_model_view(vm_name, ext_name, rgroup = configuration.resource_group)
|
74
74
|
raise ArgumentError, "no resource group provided" unless rgroup
|
75
75
|
get(vm_name, ext_name, rgroup, false)
|
76
76
|
end
|
77
77
|
|
78
78
|
# Shortcut to get an extension in instance view.
|
79
|
-
def get_instance_view(vm_name, ext_name, rgroup =
|
79
|
+
def get_instance_view(vm_name, ext_name, rgroup = configuration.resource_group)
|
80
80
|
raise ArgumentError, "no resource group provided" unless rgroup
|
81
81
|
get(vm_name, ext_name, rgroup, true)
|
82
82
|
end
|
@@ -90,7 +90,7 @@ module Azure
|
|
90
90
|
#--
|
91
91
|
# BUG: https://github.com/Azure/azure-xplat-cli/issues/1826
|
92
92
|
#
|
93
|
-
def list(vm_name, rgroup =
|
93
|
+
def list(vm_name, rgroup = configuration.resource_group, instance_view = false)
|
94
94
|
raise ArgumentError, "no resource group provided" unless rgroup
|
95
95
|
url = build_url(rgroup, vm_name)
|
96
96
|
url << "&expand=instanceView" if instance_view
|
@@ -99,13 +99,13 @@ module Azure
|
|
99
99
|
end
|
100
100
|
|
101
101
|
# Shortcut to get a list in model view.
|
102
|
-
def list_model_view(vmname, rgroup =
|
102
|
+
def list_model_view(vmname, rgroup = configuration.resource_group)
|
103
103
|
raise ArgumentError, "no resource group provided" unless rgroup
|
104
104
|
list(vmname, false, rgroup)
|
105
105
|
end
|
106
106
|
|
107
107
|
# Shortcut to get a list in instance view.
|
108
|
-
def list_instance_view(vmname, rgroup =
|
108
|
+
def list_instance_view(vmname, rgroup = configuration.resource_group)
|
109
109
|
raise ArgumentError, "no resource group provided" unless rgroup
|
110
110
|
list(vmname, true, rgroup)
|
111
111
|
end
|
@@ -118,7 +118,7 @@ module Azure
|
|
118
118
|
def build_url(resource_group, vm, *args)
|
119
119
|
url = File.join(
|
120
120
|
Azure::Armrest::COMMON_URI,
|
121
|
-
|
121
|
+
configuration.subscription_id,
|
122
122
|
'resourceGroups',
|
123
123
|
resource_group,
|
124
124
|
'providers',
|
@@ -16,8 +16,8 @@ module Azure
|
|
16
16
|
# :publisher options as well. The default provider is set to
|
17
17
|
# 'Microsoft.Compute'.
|
18
18
|
#
|
19
|
-
def initialize(
|
20
|
-
super(
|
19
|
+
def initialize(configuration, options = {})
|
20
|
+
super(configuration, nil, 'Microsoft.Compute', options)
|
21
21
|
|
22
22
|
@location = options[:location]
|
23
23
|
@publisher = options[:publisher]
|
@@ -103,7 +103,7 @@ module Azure
|
|
103
103
|
def build_url(location, *args)
|
104
104
|
url = File.join(
|
105
105
|
Azure::Armrest::COMMON_URI,
|
106
|
-
|
106
|
+
configuration.subscription_id,
|
107
107
|
'providers',
|
108
108
|
provider,
|
109
109
|
'locations',
|
@@ -12,8 +12,8 @@ module Azure
|
|
12
12
|
# default is 'Microsoft.ClassicCompute'. You may need to set this to
|
13
13
|
# 'Microsoft.Compute' for your purposes.
|
14
14
|
#
|
15
|
-
def initialize(
|
16
|
-
super(
|
15
|
+
def initialize(configuration, options = {})
|
16
|
+
super(configuration, 'virtualMachines', 'Microsoft.Compute', options)
|
17
17
|
end
|
18
18
|
|
19
19
|
# Return a list of available VM series (aka sizes, flavors, etc), such
|
@@ -27,7 +27,7 @@ module Azure
|
|
27
27
|
version = @@providers_hash[provider.downcase]['locations/vmsizes']['api_version']
|
28
28
|
|
29
29
|
url = url_with_api_version(
|
30
|
-
version, @base_url, 'subscriptions',
|
30
|
+
version, @base_url, 'subscriptions', configuration.subscription_id,
|
31
31
|
'providers', provider, 'locations', location, 'vmSizes'
|
32
32
|
)
|
33
33
|
|
@@ -44,19 +44,19 @@ module Azure
|
|
44
44
|
# * overwriteVhds - Boolean that indicates whether or not to overwrite any VHD's
|
45
45
|
# with the same prefix. The default is false.
|
46
46
|
#
|
47
|
-
def capture(vmname, options, group =
|
47
|
+
def capture(vmname, options, group = configuration.resource_group)
|
48
48
|
vm_operate('capture', vmname, group, options)
|
49
49
|
end
|
50
50
|
|
51
51
|
# Stop the VM +vmname+ in +group+ and deallocate the tenant in Fabric.
|
52
52
|
#
|
53
|
-
def deallocate(vmname, group =
|
53
|
+
def deallocate(vmname, group = configuration.resource_group)
|
54
54
|
vm_operate('deallocate', vmname, group)
|
55
55
|
end
|
56
56
|
|
57
57
|
# Sets the OSState for the +vmname+ in +group+ to 'Generalized'.
|
58
58
|
#
|
59
|
-
def generalize(vmname, group =
|
59
|
+
def generalize(vmname, group = configuration.resource_group)
|
60
60
|
vm_operate('generalize', vmname, group)
|
61
61
|
end
|
62
62
|
|
@@ -67,21 +67,21 @@ module Azure
|
|
67
67
|
# parameter is false, it will retrieve an instance view. The difference is
|
68
68
|
# in the details of the information retrieved.
|
69
69
|
#
|
70
|
-
def get(vmname, group =
|
70
|
+
def get(vmname, group = configuration.resource_group, model_view = true)
|
71
71
|
model_view ? super(vmname, group) : get_instance_view(vmname, group)
|
72
72
|
end
|
73
73
|
|
74
74
|
# Convenient wrapper around the get method that retrieves the model view
|
75
75
|
# for +vmname+ in resource_group +group+.
|
76
76
|
#
|
77
|
-
def get_model_view(vmname, group =
|
77
|
+
def get_model_view(vmname, group = configuration.resource_group)
|
78
78
|
get(vmname, group, true)
|
79
79
|
end
|
80
80
|
|
81
81
|
# Convenient wrapper around the get method that retrieves the instance view
|
82
82
|
# for +vmname+ in resource_group +group+.
|
83
83
|
#
|
84
|
-
def get_instance_view(vmname, group =
|
84
|
+
def get_instance_view(vmname, group = configuration.resource_group)
|
85
85
|
raise ArgumentError, "must specify resource group" unless group
|
86
86
|
raise ArgumentError, "must specify name of the resource" unless vmname
|
87
87
|
|
@@ -96,7 +96,7 @@ module Azure
|
|
96
96
|
# This is an asynchronous operation that returns a response object
|
97
97
|
# which you can inspect, such as response.code or response.headers.
|
98
98
|
#
|
99
|
-
def restart(vmname, group =
|
99
|
+
def restart(vmname, group = configuration.resource_group)
|
100
100
|
vm_operate('restart', vmname, group)
|
101
101
|
end
|
102
102
|
|
@@ -106,7 +106,7 @@ module Azure
|
|
106
106
|
# This is an asynchronous operation that returns a response object
|
107
107
|
# which you can inspect, such as response.code or response.headers.
|
108
108
|
#
|
109
|
-
def start(vmname, group =
|
109
|
+
def start(vmname, group = configuration.resource_group)
|
110
110
|
vm_operate('start', vmname, group)
|
111
111
|
end
|
112
112
|
|
@@ -116,7 +116,7 @@ module Azure
|
|
116
116
|
# This is an asynchronous operation that returns a response object
|
117
117
|
# which you can inspect, such as response.code or response.headers.
|
118
118
|
#
|
119
|
-
def stop(vmname, group =
|
119
|
+
def stop(vmname, group = configuration.resource_group)
|
120
120
|
vm_operate('powerOff', vmname, group)
|
121
121
|
end
|
122
122
|
|
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.1.
|
4
|
+
version: 0.1.2
|
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: 2016-02
|
14
|
+
date: 2016-03-02 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: json
|