fog-azure-rm 0.5.0 → 0.5.1

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
2
  SHA256:
3
- metadata.gz: c7723f74bbee0611351af2564fa5d3435354be5a5ed212a12fdae7ab5050a88c
4
- data.tar.gz: 142a0f7e06a32ff2e83fe9b87c62ff115edc7e6b0601e37e5c967c45f91b1ed6
3
+ metadata.gz: 8bbc50c7d4fbbabb86aba1deadc5eb4aca39cc918f932a3f3592fe4607837d20
4
+ data.tar.gz: 79cb44095e818ef6814504c83987d9bba1cdd7326a0271b47b32da10b26e1685
5
5
  SHA512:
6
- metadata.gz: 9cd47cf5c5ad0b765a791dd1faaef235139671c2fa8bac0c01d5b404ca66390ae91e1f490f4a3e6308074399f4c4d8192f52d5433cc6408eed457641bf90f2f2
7
- data.tar.gz: 31215199cce2b823e2e0d80ccd6ee593f425deadaf65a389f6fc656c6372f0fee07442186faad44a9105860fbf3e1833b1d072a987ee2540c93308b58f993524
6
+ metadata.gz: 14a073c135bce2dc64a1dc72b1b8cf7dbe1c3f325e7ea39efc68996fa30f8264e55646beb5e75e5bae2d65c1d6256be72741ba378091b498c76ba9defde84773
7
+ data.tar.gz: 4c81e3b71e14d684ca0d0564ef8d16c2c592e1cf76394f9e040593c3aa71fa3f462e26275d5affbd2225409aaee7a3857a45885f7cb9f4d2508ac0969d90da22
@@ -1,3 +1,8 @@
1
+ ## 0.5.1
2
+
3
+ **Added**
4
+ - Added Managed Disk Caching Option
5
+
1
6
  ## 0.5.0
2
7
 
3
8
  **Added**
@@ -160,7 +160,7 @@ async_response = fog_compute_service.servers.create_async(
160
160
  os_disk_name: '<Disk Name>' # [Optional], name of the os disk
161
161
  )
162
162
  ```
163
- Following methods are available to handle async respoonse:
163
+ Following methods are available to handle async response:
164
164
  - state
165
165
  - pending?
166
166
  - rejected?
@@ -310,10 +310,10 @@ fog_compute_service.managed_disks.create(
310
310
 
311
311
  ## Attach a Managed Data Disk to Server
312
312
 
313
- Get the server object and attach a Data Disk to it.
313
+ Get the server object and attach a Data Disk with Disk Caching Option to it. Possible <Disk Caching Option> values include: "None", "ReadOnly", "ReadWrite". By Default "None" set.
314
314
 
315
315
  ```ruby
316
- server.attach_managed_disk('<Disk Name>', '<Disk Resource Group Name>')
316
+ server.attach_managed_disk('<Disk Name>', '<Disk Resource Group Name>', '<Async Option>', '<Disk Caching Option>')
317
317
  ```
318
318
 
319
319
  ## Detach a Managed Data Disk from Server
@@ -173,8 +173,8 @@ module Fog
173
173
  async ? create_fog_async_response(response) : merge_attributes(Fog::Compute::AzureRM::Server.parse(response))
174
174
  end
175
175
 
176
- def attach_managed_disk(disk_name, disk_resource_group, async = false)
177
- response = service.attach_data_disk_to_vm(data_disk_params(disk_name, nil, nil, disk_resource_group), async)
176
+ def attach_managed_disk(disk_name, disk_resource_group, async = false, caching = 'None')
177
+ response = service.attach_data_disk_to_vm(data_disk_params(disk_name, nil, nil, disk_resource_group, caching), async)
178
178
  async ? create_fog_async_response(response) : merge_attributes(Fog::Compute::AzureRM::Server.parse(response))
179
179
  end
180
180
 
@@ -239,14 +239,15 @@ module Fog
239
239
  }
240
240
  end
241
241
 
242
- def data_disk_params(disk_name, disk_size = nil, storage_account = nil, disk_resource_group = nil)
242
+ def data_disk_params(disk_name, disk_size = nil, storage_account = nil, disk_resource_group = nil, caching = nil)
243
243
  {
244
244
  vm_name: name,
245
245
  vm_resource_group: resource_group,
246
246
  disk_name: disk_name,
247
247
  disk_size_gb: disk_size,
248
248
  storage_account_name: storage_account,
249
- disk_resource_group: disk_resource_group
249
+ disk_resource_group: disk_resource_group,
250
+ caching: caching
250
251
  }
251
252
  end
252
253
 
@@ -11,6 +11,7 @@ module Fog
11
11
  disk_resource_group = disk_params[:disk_resource_group]
12
12
  disk_size = disk_params[:disk_size_gb]
13
13
  storage_account_name = disk_params[:storage_account_name]
14
+ caching = disk_params[:caching] || nil
14
15
 
15
16
  msg = "Attaching Data Disk #{disk_name} to Virtual Machine #{vm_name} in Resource Group #{vm_resource_group}"
16
17
  Fog::Logger.debug msg
@@ -24,7 +25,7 @@ module Fog
24
25
  data_disk = get_unmanaged_disk_object(disk_name, disk_size, lun, storage_account_name, access_key)
25
26
  elsif disk_resource_group
26
27
  # Managed data disk
27
- data_disk = get_data_disk_object(disk_resource_group, disk_name, lun)
28
+ data_disk = get_data_disk_object(disk_resource_group, disk_name, lun, caching)
28
29
  end
29
30
  vm.storage_profile.data_disks.push(data_disk)
30
31
  begin
@@ -75,7 +76,7 @@ module Fog
75
76
  lun_range_list[0]
76
77
  end
77
78
 
78
- def get_data_disk_object(disk_resource_group, disk_name, lun)
79
+ def get_data_disk_object(disk_resource_group, disk_name, lun, caching)
79
80
  msg = "Getting Managed Disk #{disk_name} from Resource Group #{disk_resource_group}"
80
81
  begin
81
82
  disk = @compute_mgmt_client.disks.get(disk_resource_group, disk_name)
@@ -88,6 +89,18 @@ module Fog
88
89
  managed_disk.lun = lun
89
90
  managed_disk.create_option = Azure::ARM::Compute::Models::DiskCreateOptionTypes::Attach
90
91
 
92
+ # Managed Disk Caching Type
93
+ managed_disk.caching = case caching
94
+ when 'ReadOnly'
95
+ Azure::ARM::Compute::Models::CachingTypes::ReadOnly
96
+ when 'ReadWrite'
97
+ Azure::ARM::Compute::Models::CachingTypes::ReadWrite
98
+ when 'None', nil
99
+ Azure::ARM::Compute::Models::CachingTypes::None
100
+ else
101
+ raise "Invalid Disk Caching Option: #{caching}"
102
+ end
103
+
91
104
  # Managed disk parameter
92
105
  managed_disk_params = Azure::ARM::Compute::Models::ManagedDiskParameters.new
93
106
  managed_disk_params.id = disk.id
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module AzureRM
3
- VERSION = '0.5.0'.freeze
3
+ VERSION = '0.5.1'.freeze
4
4
  end
5
5
  end
@@ -134,7 +134,7 @@ begin
134
134
  name: 'TestVM-Managed',
135
135
  location: LOCATION,
136
136
  resource_group: 'TestRG-VM',
137
- vm_size: 'Basic_A0',
137
+ vm_size: 'Standard_B2s',
138
138
  storage_account_name: nil,
139
139
  username: 'testuser',
140
140
  password: 'Confiz=123',
@@ -238,6 +238,30 @@ begin
238
238
  )
239
239
  puts "Created Managed Disk: #{managed_disk.name}"
240
240
 
241
+ managed_disk_ro = compute.managed_disks.create(
242
+ name: 'ManagedDataDiskRO',
243
+ location: LOCATION,
244
+ resource_group_name: 'TestRG-VM',
245
+ account_type: 'Standard_LRS',
246
+ disk_size_gb: 100,
247
+ creation_data: {
248
+ create_option: 'Empty'
249
+ }
250
+ )
251
+ puts "Created Managed Disk: #{managed_disk_ro.name}"
252
+
253
+ managed_disk_rw = compute.managed_disks.create(
254
+ name: 'ManagedDataDiskRW',
255
+ location: LOCATION,
256
+ resource_group_name: 'TestRG-VM',
257
+ account_type: 'Standard_LRS',
258
+ disk_size_gb: 100,
259
+ creation_data: {
260
+ create_option: 'Empty'
261
+ }
262
+ )
263
+ puts "Created Managed Disk: #{managed_disk_rw.name}"
264
+
241
265
  ########################################################################################################################
242
266
  ###################### Attach Managed Data Disk to VM ######################
243
267
  ########################################################################################################################
@@ -245,6 +269,12 @@ begin
245
269
  managed_vm.attach_managed_disk('ManagedDataDisk', 'TestRG-VM')
246
270
  puts 'Attached Managed Data Disk to VM!'
247
271
 
272
+ managed_vm.attach_managed_disk('ManagedDataDiskRO', 'TestRG-VM', false, 'ReadOnly')
273
+ puts 'Attached Managed Data Disk with Disk Caching ReadOnly to VM!'
274
+
275
+ managed_vm.attach_managed_disk('ManagedDataDiskRW', 'TestRG-VM', false, 'ReadWrite')
276
+ puts 'Attached Managed Data Disk with Disk Caching ReadWrite to VM!'
277
+
248
278
  ########################################################################################################################
249
279
  ###################### Detach Data Disk from VM ######################
250
280
  ########################################################################################################################
@@ -252,6 +282,12 @@ begin
252
282
  managed_vm.detach_managed_disk('ManagedDataDisk')
253
283
  puts 'Detached Managed Data Disk from VM!'
254
284
 
285
+ managed_vm.detach_managed_disk('ManagedDataDiskRO')
286
+ puts 'Detached Managed Data Disk with Disk Caching ReadOnly from VM!'
287
+
288
+ managed_vm.detach_managed_disk('ManagedDataDiskRW')
289
+ puts 'Detached Managed Data Disk with Disk Caching ReadWrite from VM!'
290
+
255
291
  ########################################################################################################################
256
292
  ###################### Delete Managed Data Disk ######################
257
293
  ########################################################################################################################
@@ -259,6 +295,12 @@ begin
259
295
  managed_disk.destroy
260
296
  puts 'Deleted managed data disk!'
261
297
 
298
+ managed_disk_ro.destroy
299
+ puts 'Deleted managed data disk with Disk Caching ReadOnly!'
300
+
301
+ managed_disk_rw.destroy
302
+ puts 'Deleted managed data disk with Disk Caching ReadWrite!'
303
+
262
304
  ########################################################################################################################
263
305
  ###################### List VM in a resource group ######################
264
306
  ########################################################################################################################
@@ -216,6 +216,12 @@ class TestServer < Minitest::Test
216
216
  @service.stub :attach_data_disk_to_vm, response do
217
217
  assert_instance_of Fog::Compute::AzureRM::Server, @server.attach_managed_disk('disk_name', 'resoure_group')
218
218
  end
219
+ @service.stub :attach_data_disk_to_vm, response do
220
+ assert_instance_of Fog::Compute::AzureRM::Server, @server.attach_managed_disk('disk_name', 'resoure_group', false, 'ReadOnly')
221
+ end
222
+ @service.stub :attach_data_disk_to_vm, response do
223
+ assert_instance_of Fog::Compute::AzureRM::Server, @server.attach_managed_disk('disk_name', 'resoure_group', false, 'ReadWrite')
224
+ end
219
225
 
220
226
  async_response = Concurrent::Promise.execute { 10 }
221
227
  @service.stub :attach_data_disk_to_vm, async_response do
@@ -42,6 +42,22 @@ class TestAttachDataDiskToVM < Minitest::Test
42
42
  end
43
43
  end
44
44
  end
45
+ @virtual_machines.stub :get, @get_vm_response do
46
+ @disks.stub :get, @get_managed_disk_response do
47
+ @virtual_machines.stub :create_or_update, @get_vm_managed_disk_response do
48
+ input_params = { vm_name: 'ManagedVM', vm_resource_group: 'ManagedRG', disk_name: 'ManagedDataDisk1', disk_size_gb: 100, disk_resource_group: 'ManagedRG', caching: 'ReadOnly' }
49
+ assert_equal @service.attach_data_disk_to_vm(input_params, false), @get_vm_managed_disk_response
50
+ end
51
+ end
52
+ end
53
+ @virtual_machines.stub :get, @get_vm_response do
54
+ @disks.stub :get, @get_managed_disk_response do
55
+ @virtual_machines.stub :create_or_update, @get_vm_managed_disk_response do
56
+ input_params = { vm_name: 'ManagedVM', vm_resource_group: 'ManagedRG', disk_name: 'ManagedDataDisk1', disk_size_gb: 100, disk_resource_group: 'ManagedRG', caching: 'ReadWrite' }
57
+ assert_equal @service.attach_data_disk_to_vm(input_params, false), @get_vm_managed_disk_response
58
+ end
59
+ end
60
+ end
45
61
  end
46
62
 
47
63
  def test_attach_data_disk_to_vm_failure
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-azure-rm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shaffan Chaudhry
@@ -18,7 +18,7 @@ authors:
18
18
  autorequire:
19
19
  bindir: bin
20
20
  cert_chain: []
21
- date: 2019-02-28 00:00:00.000000000 Z
21
+ date: 2019-03-26 00:00:00.000000000 Z
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
24
24
  name: rake
@@ -1059,7 +1059,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1059
1059
  - !ruby/object:Gem::Version
1060
1060
  version: '0'
1061
1061
  requirements: []
1062
- rubygems_version: 3.0.2
1062
+ rubygems_version: 3.0.3
1063
1063
  signing_key:
1064
1064
  specification_version: 4
1065
1065
  summary: Module for the 'fog' gem to support Azure Resource Manager cloud services.