fog-azure-rm 0.0.6 → 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.
Files changed (138) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +13 -0
  3. data/lib/fog/azurerm/compute.rb +6 -0
  4. data/lib/fog/azurerm/docs/compute.md +67 -11
  5. data/lib/fog/azurerm/docs/network.md +59 -0
  6. data/lib/fog/azurerm/docs/storage.md +107 -35
  7. data/lib/fog/azurerm/models/compute/server.rb +15 -9
  8. data/lib/fog/azurerm/models/compute/virtual_machine_extension.rb +78 -0
  9. data/lib/fog/azurerm/models/compute/virtual_machine_extensions.rb +30 -0
  10. data/lib/fog/azurerm/models/network/express_route_circuit.rb +21 -21
  11. data/lib/fog/azurerm/models/network/express_route_circuit_peering.rb +21 -21
  12. data/lib/fog/azurerm/models/network/express_route_service_provider.rb +8 -8
  13. data/lib/fog/azurerm/models/network/network_security_rule.rb +27 -0
  14. data/lib/fog/azurerm/models/network/network_security_rules.rb +31 -0
  15. data/lib/fog/azurerm/models/network/subnet.rb +16 -12
  16. data/lib/fog/azurerm/models/network/virtual_network_gateway.rb +6 -6
  17. data/lib/fog/azurerm/models/storage/{containers.rb → directories.rb} +10 -10
  18. data/lib/fog/azurerm/models/storage/{container.rb → directory.rb} +13 -13
  19. data/lib/fog/azurerm/models/storage/file.rb +151 -0
  20. data/lib/fog/azurerm/models/storage/files.rb +31 -0
  21. data/lib/fog/azurerm/network.rb +6 -0
  22. data/lib/fog/azurerm/requests/compute/create_or_update_vm_extension.rb +63 -0
  23. data/lib/fog/azurerm/requests/compute/create_virtual_machine.rb +45 -8
  24. data/lib/fog/azurerm/requests/compute/delete_vm_extension.rb +28 -0
  25. data/lib/fog/azurerm/requests/compute/get_vm_extension.rb +46 -0
  26. data/lib/fog/azurerm/requests/network/create_or_update_express_route_circuit.rb +44 -31
  27. data/lib/fog/azurerm/requests/network/create_or_update_express_route_circuit_peering.rb +23 -13
  28. data/lib/fog/azurerm/requests/network/create_or_update_network_security_rule.rb +59 -0
  29. data/lib/fog/azurerm/requests/network/create_or_update_virtual_network_gateway.rb +23 -15
  30. data/lib/fog/azurerm/requests/network/delete_network_security_rule.rb +30 -0
  31. data/lib/fog/azurerm/requests/network/get_available_ipaddresses_count.rb +23 -0
  32. data/lib/fog/azurerm/requests/network/get_network_security_rule.rb +47 -0
  33. data/lib/fog/azurerm/requests/network/list_network_security_groups.rb +1 -1
  34. data/lib/fog/azurerm/requests/network/list_network_security_rules.rb +51 -0
  35. data/lib/fog/azurerm/requests/storage/acquire_blob_lease.rb +29 -0
  36. data/lib/fog/azurerm/requests/storage/acquire_container_lease.rb +29 -0
  37. data/lib/fog/azurerm/requests/storage/check_blob_exist.rb +25 -0
  38. data/lib/fog/azurerm/requests/storage/compare_blob.rb +73 -0
  39. data/lib/fog/azurerm/requests/storage/copy_blob.rb +30 -0
  40. data/lib/fog/azurerm/requests/storage/copy_blob_from_uri.rb +30 -0
  41. data/lib/fog/azurerm/requests/storage/delete_blob.rb +27 -0
  42. data/lib/fog/azurerm/requests/storage/download_blob_to_file.rb +56 -0
  43. data/lib/fog/azurerm/requests/storage/get_blob_metadata.rb +37 -9
  44. data/lib/fog/azurerm/requests/storage/get_blob_properties.rb +53 -0
  45. data/lib/fog/azurerm/requests/storage/get_container_metadata.rb +2 -2
  46. data/lib/fog/azurerm/requests/storage/list_blobs.rb +82 -0
  47. data/lib/fog/azurerm/requests/storage/list_containers.rb +1 -1
  48. data/lib/fog/azurerm/requests/storage/release_blob_lease.rb +27 -0
  49. data/lib/fog/azurerm/requests/storage/release_container_lease.rb +27 -0
  50. data/lib/fog/azurerm/requests/storage/set_blob_metadata.rb +4 -4
  51. data/lib/fog/azurerm/requests/storage/set_blob_properties.rb +26 -0
  52. data/lib/fog/azurerm/requests/storage/set_container_metadata.rb +3 -3
  53. data/lib/fog/azurerm/requests/storage/upload_block_blob_from_file.rb +60 -0
  54. data/lib/fog/azurerm/storage.rb +26 -8
  55. data/lib/fog/azurerm/utilities/general.rb +14 -1
  56. data/lib/fog/azurerm/version.rb +1 -1
  57. data/test/api_stub.rb +8 -4
  58. data/test/api_stub/models/compute/virtual_machine_extension.rb +31 -0
  59. data/test/api_stub/models/network/network_security_rule.rb +30 -0
  60. data/test/api_stub/models/storage/{container.rb → directory.rb} +1 -1
  61. data/test/api_stub/models/storage/file.rb +178 -0
  62. data/test/api_stub/requests/compute/virtual_machine.rb +119 -0
  63. data/test/api_stub/requests/compute/virtual_machine_extension.rb +46 -0
  64. data/test/api_stub/requests/network/network_security_rule.rb +72 -0
  65. data/test/api_stub/requests/storage/{container.rb → directory.rb} +2 -2
  66. data/test/api_stub/requests/storage/file.rb +164 -0
  67. data/test/integration/availability_set.rb +6 -0
  68. data/test/integration/blob.rb +205 -0
  69. data/test/integration/credentials/azure.yml +4 -4
  70. data/test/integration/deployment.rb +9 -0
  71. data/test/integration/external_load_balancer.rb +9 -0
  72. data/test/integration/internal_load_balancer.rb +8 -0
  73. data/test/integration/network_security_group.rb +9 -0
  74. data/test/integration/network_security_rule.rb +86 -0
  75. data/test/integration/server.rb +62 -9
  76. data/test/integration/server_custom_image.rb +118 -0
  77. data/test/integration/subnet.rb +12 -1
  78. data/test/integration/virtual_machine_extension.rb +148 -0
  79. data/test/integration/virtual_network.rb +9 -1
  80. data/test/integration/virtual_network_gateway.rb +7 -29
  81. data/test/integration/virtual_network_gateway_connection_to_express_route.rb +116 -0
  82. data/test/models/compute/test_virtual_machine_extension.rb +61 -0
  83. data/test/models/compute/test_virtual_machine_extensions.rb +36 -0
  84. data/test/models/network/test_express_route_circuit.rb +4 -10
  85. data/test/models/network/test_express_route_circuit_peering.rb +4 -10
  86. data/test/models/network/test_network_interface.rb +4 -8
  87. data/test/models/network/test_network_security_rule.rb +14 -0
  88. data/test/models/network/test_network_security_rules.rb +42 -0
  89. data/test/models/network/test_subnet.rb +5 -0
  90. data/test/models/storage/test_directories.rb +106 -0
  91. data/test/models/storage/test_directory.rb +125 -0
  92. data/test/models/storage/test_file.rb +258 -0
  93. data/test/models/storage/test_files.rb +67 -0
  94. data/test/models/storage/test_storage_account.rb +2 -4
  95. data/test/requests/compute/test_create_virtual_machine.rb +19 -5
  96. data/test/requests/compute/test_create_vm_extension.rb +35 -0
  97. data/test/requests/compute/test_get_vm_extension.rb +26 -0
  98. data/test/requests/compute/test_update_vm_extension.rb +35 -0
  99. data/test/requests/network/test_create_or_update_network_security_rule.rb +28 -0
  100. data/test/requests/network/test_delete_network_security_rule.rb +25 -0
  101. data/test/requests/network/test_get_available_ipaddresses_count.rb +18 -0
  102. data/test/requests/network/test_get_network_security_rule.rb +26 -0
  103. data/test/requests/network/test_list_network_security_groups.rb +2 -2
  104. data/test/requests/network/test_list_network_security_rules.rb +26 -0
  105. data/test/requests/storage/test_acquire_blob_lease.rb +17 -0
  106. data/test/requests/storage/test_acquire_container_lease.rb +17 -0
  107. data/test/requests/storage/test_check_blob_exist.rb +17 -0
  108. data/test/requests/storage/test_compare_blob.rb +17 -0
  109. data/test/requests/storage/test_copy_blob.rb +17 -0
  110. data/test/requests/storage/test_copy_blob_from_uri.rb +17 -0
  111. data/test/requests/storage/test_create_container.rb +2 -2
  112. data/test/requests/storage/test_delete_blob.rb +22 -0
  113. data/test/requests/storage/test_delete_container.rb +1 -1
  114. data/test/requests/storage/test_download_blob_to_file.rb +25 -0
  115. data/test/requests/storage/test_get_blob_metadata.rb +2 -2
  116. data/test/requests/storage/test_get_blob_properties.rb +23 -0
  117. data/test/requests/storage/test_get_container_access_control_list.rb +2 -2
  118. data/test/requests/storage/test_get_container_metadata.rb +2 -2
  119. data/test/requests/storage/test_get_container_properties.rb +2 -2
  120. data/test/requests/storage/test_list_blobs_in_container.rb +23 -0
  121. data/test/requests/storage/test_list_containers.rb +2 -2
  122. data/test/requests/storage/test_release_blob_lease.rb +16 -0
  123. data/test/requests/storage/test_release_container_lease.rb +16 -0
  124. data/test/requests/storage/test_set_blob_metadata.rb +1 -1
  125. data/test/requests/storage/test_set_blob_properties.rb +16 -0
  126. data/test/requests/storage/test_set_container_metadata.rb +1 -1
  127. data/test/requests/storage/test_upload_block_blob_from_file.rb +23 -0
  128. data/test/test_helper.rb +116 -3
  129. metadata +73 -15
  130. data/.DS_Store +0 -0
  131. data/lib/fog/azurerm/fog_azure_rm_exception.rb +0 -13
  132. data/lib/fog/azurerm/models/storage/blob.rb +0 -13
  133. data/lib/fog/azurerm/models/storage/blobs.rb +0 -22
  134. data/test/api_stub/models/storage/blob.rb +0 -17
  135. data/test/api_stub/requests/storage/blob.rb +0 -24
  136. data/test/models/storage/test_blobs.rb +0 -32
  137. data/test/models/storage/test_container.rb +0 -67
  138. data/test/models/storage/test_containers.rb +0 -56
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 17db5794c8186b1a029c4bae7d938443d2392db2
4
- data.tar.gz: 19682802907daf630ab3bd1ad6ce6a0d88cbf678
3
+ metadata.gz: 4b685851346e42d9a032133a02a6c3a12ccf5896
4
+ data.tar.gz: f018a73de0ea3dcec83d57c9f355b0b76571fded
5
5
  SHA512:
6
- metadata.gz: c23376452f1441ef55a1e9a7eff0dbecc2daa024e689151b7db49ee27b44fe35dd90cbd8e5df7c253baae0cad07923298043430baa64a188b7fef9a6e912d1ca
7
- data.tar.gz: b2ab099ace9089b714a1318bb56603a9b4fee9ba9e7abf76fde9e1c2164aa32f1feff1d2f74d2ba5b5c511336eb8784122762e26313d859a5ef701f8ad0c5ef0
6
+ metadata.gz: 42f964d72836337a5057cacf99ce98c144e62e99461ab1fe00e92c9ac83d291b7e8c6a465babc116481894d221c8ed65f70396ecb18b69c688fb5e96e7feab89
7
+ data.tar.gz: afcd011ce4a78237e5515eba3ff43559bfa77c9cf5b539367ad54fb33d2d893b533768f40d6b7ef89668b03a93cd87118dcec079518aad7cfc59ca22410c5f7a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ ## 0.0.7
2
+
3
+ **Added:**
4
+ - Compute Service - Added support to create virtual machine from a custom image.
5
+ - Network Service - Added Network Security Rule.
6
+ - Network Service - Added Get Available IP Addresses count in Subnet
7
+ - Compute Service - Virtual Machine Extension
8
+ - Added Blob count, blob exist, blob compare,blob copy, lease blob, release lease blob, delete blob, set blob properties,
9
+ get blob properties, set blob metadata, get blob metadata, get blob, list blob functionality for storage
10
+ - Added get container properties, get container metadata, set container metadata, get container, list container,
11
+ delete container, Get the access control list of the container
12
+
13
+
1
14
  ## 0.0.6
2
15
 
3
16
  **Added:**
@@ -26,12 +26,17 @@ module Fog
26
26
  request :check_vm_status
27
27
  request :attach_data_disk_to_vm
28
28
  request :detach_data_disk_from_vm
29
+ request :create_or_update_vm_extension
30
+ request :delete_vm_extension
31
+ request :get_vm_extension
29
32
 
30
33
  model_path 'fog/azurerm/models/compute'
31
34
  model :availability_set
32
35
  collection :availability_sets
33
36
  model :server
34
37
  collection :servers
38
+ model :virtual_machine_extension
39
+ collection :virtual_machine_extensions
35
40
 
36
41
  # This class provides the mock implementation for unit tests.
37
42
  class Mock
@@ -61,6 +66,7 @@ module Fog
61
66
  @compute_mgmt_client.subscription_id = options[:subscription_id]
62
67
  @storage_mgmt_client = ::Azure::ARM::Storage::StorageManagementClient.new(credentials)
63
68
  @storage_mgmt_client.subscription_id = options[:subscription_id]
69
+ @storage_service = Fog::Storage::AzureRM.new(tenant_id: options[:tenant_id], client_id: options[:client_id], client_secret: options[:client_secret], subscription_id: options[:subscription_id])
64
70
  end
65
71
  end
66
72
  end
@@ -39,14 +39,16 @@ Create a new linux server
39
39
  password: '<Password for VM>',
40
40
  disable_password_authentication: false,
41
41
  network_interface_card_id: '/subscriptions/{Subscription-Id}/resourceGroups/{Resource-Group-Name}/providers/Microsoft.Network/networkInterfaces/{Network-Interface-Id}',
42
- publisher: 'Canonical',
43
- offer: 'UbuntuServer',
44
- sku: '14.04.2-LTS',
45
- version: 'latest',
42
+ publisher: 'Canonical', # Not required if custom image is being used
43
+ offer: 'UbuntuServer', # Not required if custom image is being used
44
+ sku: '14.04.2-LTS', # Not required if custom image is being used
45
+ version: 'latest', # Not required if custom image is being used
46
46
  platform: 'Linux',
47
- custom_data: 'echo customData' # Optional
47
+ vhd_path: '<Path of VHD>', # Optional, if you want to create the VM from a custom image.
48
+ custom_data: 'echo customData', # Optional, if you want to add custom data in this VM.
48
49
  )
49
50
  ```
51
+
50
52
  Create a new windows server
51
53
 
52
54
  ```ruby
@@ -60,14 +62,16 @@ Create a new windows server
60
62
  password: '<Password for VM>',
61
63
  disable_password_authentication: false,
62
64
  network_interface_card_id: '/subscriptions/{Subscription-Id}/resourceGroups/{Resource-Group-Name}/providers/Microsoft.Network/networkInterfaces/{Network-Interface-Id}',
63
- publisher: 'MicrosoftWindowsServerEssentials',
64
- offer: 'WindowsServerEssentials',
65
- sku: 'WindowsServerEssentials',
66
- version: 'latest',
65
+ publisher: 'MicrosoftWindowsServerEssentials', # Not required if custom image is being used
66
+ offer: 'WindowsServerEssentials', # Not required if custom image is being used
67
+ sku: 'WindowsServerEssentials', # Not required if custom image is being used
68
+ version: 'latest', # Not required if custom image is being used
67
69
  platform: 'Windows',
68
- custom_data: 'echo customData' # Optional
70
+ vhd_path: '<Path of VHD>', # Optional, if you want to create the VM from a custom image.
71
+ custom_data: 'echo customData' # Optional, if you want to add custom data in this VM.
69
72
  )
70
73
  ```
74
+
71
75
  For more information about custom_data; see link: https://msdn.microsoft.com/en-us/library/azure/mt163591.aspx
72
76
 
73
77
  ## List Servers
@@ -98,7 +102,7 @@ Get a single record of Server
98
102
  Get the server object and attach a Data Disk to it.
99
103
 
100
104
  ```ruby
101
- server.attach_data_disk('<Disk Name>', <Size in GB>, '<Storage Account Name>)
105
+ server.attach_data_disk('<Disk Name>', <Size in GB>, '<Storage Account Name>')
102
106
  ```
103
107
 
104
108
  ## Detach a Data Disk from Server
@@ -171,5 +175,57 @@ Get an availability set object from the get method and then destroy that availab
171
175
  availability_set.destroy
172
176
  ```
173
177
 
178
+ ## Create Virtual Machine Extension
179
+
180
+ Installs an extension to the specified virtual machine.
181
+
182
+ ```ruby
183
+ azure_compute_service.virtual_machine_extensions.create(
184
+ name: <Extension Name>,
185
+ resource_group: <Resource Group>,
186
+ location: <Location>,
187
+ vm_name: <Virtual Machine Name>, # Extension will be installed on this VM
188
+ publisher: <Extension publisher>,
189
+ type: <Extension type>,
190
+ type_handler_version: <Extension version>,
191
+ auto_upgrade_minor_version: <true|false>, # Optional
192
+ settings: {JSON object}, # Format: {"key": "value", "key": {"key": "value"}}
193
+ protected_settings: {JSON object}
194
+ )
195
+ ```
196
+
197
+ ## Get Extension from Virtual Machine
198
+
199
+ Retrieves the given extension from the virtual machine
200
+
201
+ ```ruby
202
+ vm_extension = azure_compute_service.virtual_machine_extensions.get(
203
+ '<Resource Group Name>', '<Virtual Machine Name>', '<Extension Name>'
204
+ )
205
+ ```
206
+
207
+ ## Update Extension
208
+
209
+ Update the given extension. The attributes that can be modified are
210
+ - auto_upgrade_minor_version
211
+ - settings
212
+ - protected_settings
213
+
214
+ ```ruby
215
+ vm_extension.update(
216
+ auto_upgrade_minor_version: <true|false>,
217
+ settings: {JSON object},
218
+ protected_settings: {JSON object}
219
+ )
220
+ ```
221
+
222
+ ## Destroy Extension
223
+
224
+ Destroy the given extension from the virtual machine
225
+
226
+ ```ruby
227
+ vm_extension.destroy
228
+ ```
229
+
174
230
  ## Support and Feedback
175
231
  Your feedback is appreciated! If you have specific issues with the fog ARM, you should file an issue via Github.
@@ -201,6 +201,14 @@ Detach Route Table from Subnet
201
201
  puts "#{subnet.route_table_id}"
202
202
  ```
203
203
 
204
+ ## List Number of Available IP Addresses in Subnet
205
+
206
+ The parameter is a boolean which checks if the Virtual Network the Subnet belongs to is attached to an Express Route Circuit or not
207
+
208
+ ```ruby
209
+ puts "#{subnet.get_available_ipaddresses_count(false)}"
210
+ ```
211
+
204
212
  ## Destroy a single Subnet
205
213
 
206
214
  Get a subnet object from the get method and then destroy that subnet.
@@ -454,6 +462,57 @@ Get a network security group object from the get method and then destroy that ne
454
462
  nsg.destroy
455
463
  ```
456
464
 
465
+ ## Create Network Security Rule
466
+
467
+ Network security rule requires a resource group and network security group to create.
468
+
469
+ ```ruby
470
+ azure_network_service.network_security_rules.create(
471
+ name: '<Security Rule name>',
472
+ resource_group: '<Resource Group name>',
473
+ protocol: 'tcp',
474
+ network_security_group_name: '<Network Security Group name>',
475
+ source_port_range: '22',
476
+ destination_port_range: '22',
477
+ source_address_prefix: '0.0.0.0/0',
478
+ destination_address_prefix: '0.0.0.0/0',
479
+ access: 'Allow',
480
+ priority: '100',
481
+ direction: 'Inbound'
482
+ )
483
+ ```
484
+
485
+ ## List Network Security Rules
486
+
487
+ List all the network security rules in a resource group and network security group
488
+
489
+ ```ruby
490
+ network_security_rules = azure_network_service.network_security_rules(resource_group: '<Resource Group name>',
491
+ network_security_group_name: '<Network Security Group name>')
492
+ network_security_rules.each do |network_security_rule|
493
+ puts network_security_rule.name
494
+ end
495
+ ```
496
+
497
+ ## Retrieve a single Network Security Rule
498
+
499
+ Get a single record of Network Security Rule
500
+
501
+ ```ruby
502
+ network_security_rule = azure_network_service
503
+ .network_security_rules
504
+ .get(<Resource Group Name>','<Network Security Group name>', '<Security Rule name>')
505
+ puts "#{network_security_rule.name}"
506
+ ```
507
+
508
+ ## Destroy a Network Security Rule
509
+
510
+ Get a network security rule object from the get method and then destroy that network security rule.
511
+
512
+ ```ruby
513
+ network_security_rule.destroy
514
+ ```
515
+
457
516
  ## Create External Load Balancer
458
517
 
459
518
  Create a new load balancer.
@@ -55,7 +55,7 @@ azure_storage_service = Fog::Storage.new(
55
55
  Check Storage Account Name Availability.This operation checks that account name is valid and is not already in use.
56
56
 
57
57
  ```ruby
58
- azure_storage_service.storage_accounts.check_name_availability('<Storage Account name>')
58
+ azure_storage_service.storage_accounts.check_name_availability('<Storage Account name>')
59
59
  ```
60
60
 
61
61
  ## Create Storage Account
@@ -153,77 +153,149 @@ puts "#{container.name}"
153
153
  List all the storage containers in the current storage accounts.
154
154
 
155
155
  ```ruby
156
- azure_storage_service.containers.each do |container|
157
- puts "#{container.name}"
156
+ azure_storage_service.directories.each do |directory|
157
+ puts "#{directory.name}"
158
158
  end
159
159
  ```
160
160
 
161
- ## Get storage container properties
161
+ ## Get the access control list of the storage container
162
+
163
+ Get the permissions for the specified container. The permissions indicate whether container data may be accessed publicly.
164
+
165
+ ```ruby
166
+ directory = azure_storage_service.directories.get('<container name>')
167
+ access_control_list = directory.get_access_control_list('<container name>')
168
+ puts "#{access_control_list.inspect}"
169
+ ```
170
+
171
+ ## Delete the storage container
172
+
173
+ Mark the specified container for deletion. The container and any blobs contained within it are later deleted during garbage collection.
174
+
175
+ ```ruby
176
+ directory = azure_storage_service.directories.get('<container name>')
177
+ result = directory.destroy
178
+ puts "#{result}"
179
+ ```
180
+
181
+ ## Upload a local file as a blob
182
+ ```ruby
183
+ new_cloud_file = azure_storage_service.files.get('<Container name>', '<Blob name>').create(file_path: '<file path>')
184
+ puts "#{new_cloud_file.inspect}"
185
+ ```
186
+
187
+ ## Copy Blob from one container to another
188
+ ```ruby
189
+ puts storage_data.copy_blob('<destination_container_name>', '<destination_blob_name>', '<source_container_name>', '<source_blob_name>')
190
+ ```
191
+
192
+ ## Download a blob to a local file
193
+ ```ruby
194
+ blob = azure_storage_service.files.get('<Container name>', '<Blob name>').save_to_file('<file path>')
195
+ puts "#{blob.inspect}"
196
+ puts "File Size: #{::File.size <file_path>}"
197
+ ```
198
+
199
+ ## Delete the storage blob
200
+
201
+ Mark the specified blob for deletion. The blob is later deleted during garbage collection.
202
+
203
+ ```ruby
204
+ cloud_file = azure_storage_service.files.get('<container name>', '<blob name>')
205
+ result = cloud_file.destroy
206
+ puts "#{result}"
207
+ ```
208
+
209
+ Note that in order to delete a blob, you must delete all of its snapshots.
210
+
211
+ ```ruby
212
+ cloud_file = azure_storage_service.files.get('<container name>', '<blob name>')
213
+ result = cloud_file.destroy(delete_snapshots: 'only')
214
+ puts "#{result}"
215
+
216
+ result = cloud_file.destroy
217
+ puts "#{result}"
218
+ ```
219
+
220
+ You can delete both at the same time by specifying the option.
221
+
222
+ ```ruby
223
+ cloud_file = azure_storage_service.files.get('<container name>', '<blob name>')
224
+ result = cloud_file.destroy(delete_snapshots: 'inlcude')
225
+ puts "#{result}"
226
+ ```
227
+
228
+ ## Properties
229
+
230
+ ### Get storage container properties
162
231
 
163
232
  Get the storage container properties. The properties will not fetch the access control list. Call `get_container_access_control_list` to fetch it.
164
233
 
165
234
  ```ruby
166
- container = azure_storage_service.containers.get('<container name>')
167
- properties = container.get_properties
235
+ directory = azure_storage_service.directories.get('<container name>')
236
+ properties = directory.get_properties
168
237
  puts "#{properties.inspect}"
169
238
  ```
170
239
 
171
- ## Get the access control list of the storage container
240
+ ### Get storage blob properties
172
241
 
173
- Get the permissions for the specified container. The permissions indicate whether container data may be accessed publicly.
242
+ Get the storage blob properties.
174
243
 
175
244
  ```ruby
176
- container = azure_storage_service.containers.get('<container name>')
177
- access_control_list = container.get_access_control_list('<container name>')
178
- puts "#{access_control_list.inspect}"
245
+ cloud_file = azure_storage_service.files.get('<container name>', '<blob name>')
246
+ properties = cloud_file.get_properties
247
+ puts "#{properties.inspect}"
179
248
  ```
180
249
 
181
- ## Delete the storage container
250
+ ### Set storage blob properties
182
251
 
183
- Mark the specified container for deletion. The container and any blobs contained within it are later deleted during garbage collection.
252
+ Set the storage blob properties. The properties are passed in name/value pairs.
184
253
 
185
254
  ```ruby
186
- container = azure_storage_service.containers.get('<container name>')
187
- result = container.destroy
188
- puts "#{result}"
255
+ cloud_file = azure_storage_service.files.get('<container name>', '<blob name>')
256
+ properties = {
257
+ "content_language" => "English",
258
+ "content_disposition" => "attachment"
259
+ }
260
+ cloud_file.set_properties(properties)
189
261
  ```
190
262
 
191
- ### Metadata
263
+ ## Metadata
192
264
 
193
265
  Metadata allows us to provide descriptive information about specific containers or blobs. This is simply providing name/value pairs of data we want to set on the container or blob.
194
266
 
195
- ## Get Blob Metadata
267
+ ### Get Blob Metadata
196
268
 
197
269
  ```ruby
198
- azure_storage_service.blobs.get_blob_metadata('<Container name>', '<Blob name>')
270
+ azure_storage_service.files.get('<Container name>', '<Blob name>').get_metadata
199
271
  ```
200
272
 
201
- ## Set Blob Metadata
273
+ ### Set Blob Metadata
202
274
 
203
275
  ```ruby
204
- metadata = {
205
- "Category" => "Images",
206
- "Resolution" => "High"
207
- }
208
- azure_storage_service.blobs.set_blob_metadata('<Container name>', '<Blob name>', metadata)
276
+ metadata = {
277
+ "Category" => "Images",
278
+ "Resolution" => "High"
279
+ }
280
+ azure_storage_service.files.get('<Container name>', '<Blob name>').set_metadata(metadata)
209
281
  ```
210
282
 
211
- ## Get Container Metadata
283
+ ### Get Container Metadata
212
284
 
213
285
  ```ruby
214
- azure_storage_service.containers.get_container_metadata('<Container name>')
286
+ azure_storage_service.directories.get_metadata('<Container name>')
215
287
  ```
216
288
 
217
- ## Set Container Metadata
289
+ ### Set Container Metadata
218
290
 
219
291
  ```ruby
220
- metadata = {
221
- "CreatedBy" => "User",
222
- "SourceMachine" => "Mymachine",
223
- "category" => "guidance",
224
- "docType" => "textDocuments"
225
- }
226
- azure_storage_service.containers.set_container_metadata('<Container name>', metadata)
292
+ metadata = {
293
+ "CreatedBy" => "User",
294
+ "SourceMachine" => "Mymachine",
295
+ "category" => "guidance",
296
+ "docType" => "textDocuments"
297
+ }
298
+ azure_storage_service.directories.set_metadata('<Container name>', metadata)
227
299
  ```
228
300
 
229
301
  ## Support and Feedback
@@ -29,6 +29,7 @@ module Fog
29
29
  attribute :network_interface_card_id
30
30
  attribute :availability_set_id
31
31
  attribute :custom_data
32
+ attribute :vhd_path
32
33
 
33
34
  def self.parse(vm)
34
35
  hash = {}
@@ -39,10 +40,12 @@ module Fog
39
40
  hash['vm_size'] = vm.hardware_profile.vm_size
40
41
  hash['os_disk_name'] = vm.storage_profile.os_disk.name
41
42
  hash['os_disk_vhd_uri'] = vm.storage_profile.os_disk.vhd.uri
42
- hash['publisher'] = vm.storage_profile.image_reference.publisher
43
- hash['offer'] = vm.storage_profile.image_reference.offer
44
- hash['sku'] = vm.storage_profile.image_reference.sku
45
- hash['version'] = vm.storage_profile.image_reference.version
43
+ unless vm.storage_profile.image_reference.nil?
44
+ hash['publisher'] = vm.storage_profile.image_reference.publisher
45
+ hash['offer'] = vm.storage_profile.image_reference.offer
46
+ hash['sku'] = vm.storage_profile.image_reference.sku
47
+ hash['version'] = vm.storage_profile.image_reference.version
48
+ end
46
49
  hash['username'] = vm.os_profile.admin_username
47
50
  hash['custom_data'] = vm.os_profile.custom_data
48
51
  hash['data_disks'] = []
@@ -60,17 +63,19 @@ module Fog
60
63
  end
61
64
  hash['network_interface_card_id'] = vm.network_profile.network_interfaces[0].id
62
65
  hash['availability_set_id'] = vm.availability_set.id unless vm.availability_set.nil?
66
+
63
67
  hash
64
68
  end
65
69
 
66
70
  def save
67
71
  requires :name, :location, :resource_group, :vm_size, :storage_account_name,
68
- :username, :password, :network_interface_card_id, :publisher, :offer, :sku, :version
72
+ :username, :password, :network_interface_card_id
69
73
  requires :disable_password_authentication if platform.casecmp('linux').zero?
74
+ requires :publisher, :offer, :sku, :version if vhd_path.nil?
70
75
  ssh_key_path = "/home/#{username}/.ssh/authorized_keys" unless ssh_key_data.nil?
71
76
  virtual_machine_params = get_virtual_machine_params(ssh_key_path)
72
77
  vm = service.create_virtual_machine(virtual_machine_params)
73
- merge_attributes(Fog::Compute::AzureRM::Server.parse(vm))
78
+ merge_attributes(Server.parse(vm))
74
79
  end
75
80
 
76
81
  def destroy
@@ -111,12 +116,12 @@ module Fog
111
116
 
112
117
  def attach_data_disk(disk_name, disk_size, storage_account_name)
113
118
  vm = service.attach_data_disk_to_vm(resource_group, name, disk_name, disk_size, storage_account_name)
114
- merge_attributes(Fog::Compute::AzureRM::Server.parse(vm))
119
+ merge_attributes(Server.parse(vm))
115
120
  end
116
121
 
117
122
  def detach_data_disk(disk_name)
118
123
  vm = service.detach_data_disk_from_vm(resource_group, name, disk_name)
119
- merge_attributes(Fog::Compute::AzureRM::Server.parse(vm))
124
+ merge_attributes(Server.parse(vm))
120
125
  end
121
126
 
122
127
  private
@@ -142,7 +147,8 @@ module Fog
142
147
  platform: platform,
143
148
  provision_vm_agent: provision_vm_agent,
144
149
  enable_automatic_updates: enable_automatic_updates,
145
- custom_data: custom_data
150
+ custom_data: custom_data,
151
+ vhd_path: vhd_path
146
152
  }
147
153
  end
148
154
  end