fog-azure-rm-temp 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (209) hide show
  1. checksums.yaml +4 -4
  2. data/.arclint +8 -0
  3. data/.travis.yml +28 -14
  4. data/CHANGELOG.md +77 -0
  5. data/CONTRIBUTORS.md +4 -0
  6. data/fog-azure-rm.gemspec +3 -2
  7. data/lib/fog/azurerm.rb +1 -0
  8. data/lib/fog/azurerm/async_response.rb +9 -1
  9. data/lib/fog/azurerm/compute.rb +3 -1
  10. data/lib/fog/azurerm/constants.rb +11 -3
  11. data/lib/fog/azurerm/dns.rb +3 -1
  12. data/lib/fog/azurerm/docs/application_gateway.md +119 -117
  13. data/lib/fog/azurerm/docs/compute.md +299 -202
  14. data/lib/fog/azurerm/docs/dns.md +44 -43
  15. data/lib/fog/azurerm/docs/key_vault.md +31 -28
  16. data/lib/fog/azurerm/docs/network.md +407 -404
  17. data/lib/fog/azurerm/docs/resources.md +52 -49
  18. data/lib/fog/azurerm/docs/sql.md +56 -54
  19. data/lib/fog/azurerm/docs/storage.md +92 -157
  20. data/lib/fog/azurerm/docs/traffic_manager.md +55 -53
  21. data/lib/fog/azurerm/models/application_gateway/gateway.rb +5 -1
  22. data/lib/fog/azurerm/models/compute/availability_set.rb +4 -1
  23. data/lib/fog/azurerm/models/compute/managed_disk.rb +0 -1
  24. data/lib/fog/azurerm/models/compute/server.rb +61 -11
  25. data/lib/fog/azurerm/models/compute/servers.rb +2 -2
  26. data/lib/fog/azurerm/models/dns/a_record.rb +15 -0
  27. data/lib/fog/azurerm/models/dns/cname_record.rb +15 -0
  28. data/lib/fog/azurerm/models/dns/record_set.rb +20 -8
  29. data/lib/fog/azurerm/models/key_vault/vault.rb +3 -1
  30. data/lib/fog/azurerm/models/network/load_balancer.rb +3 -1
  31. data/lib/fog/azurerm/models/network/local_network_gateway.rb +3 -1
  32. data/lib/fog/azurerm/models/network/network_interface.rb +3 -1
  33. data/lib/fog/azurerm/models/network/network_security_group.rb +4 -2
  34. data/lib/fog/azurerm/models/network/public_ip.rb +4 -2
  35. data/lib/fog/azurerm/models/network/virtual_network.rb +4 -2
  36. data/lib/fog/azurerm/models/resources/resource_group.rb +3 -1
  37. data/lib/fog/azurerm/models/sql/sql_database.rb +3 -3
  38. data/lib/fog/azurerm/models/sql/sql_server.rb +3 -2
  39. data/lib/fog/azurerm/models/storage/directories.rb +6 -1
  40. data/lib/fog/azurerm/models/storage/file.rb +2 -0
  41. data/lib/fog/azurerm/models/storage/storage_account.rb +4 -1
  42. data/lib/fog/azurerm/models/storage/storage_accounts.rb +7 -0
  43. data/lib/fog/azurerm/models/traffic_manager/traffic_manager_profile.rb +3 -1
  44. data/lib/fog/azurerm/requests/application_gateway/check_ag_exists.rb +1 -1
  45. data/lib/fog/azurerm/requests/application_gateway/create_or_update_application_gateway.rb +1 -0
  46. data/lib/fog/azurerm/requests/compute/attach_data_disk_to_vm.rb +2 -2
  47. data/lib/fog/azurerm/requests/compute/check_availability_set_exists.rb +1 -1
  48. data/lib/fog/azurerm/requests/compute/check_managed_disk_exists.rb +1 -1
  49. data/lib/fog/azurerm/requests/compute/check_vm_exists.rb +1 -1
  50. data/lib/fog/azurerm/requests/compute/check_vm_extension_exists.rb +2 -2
  51. data/lib/fog/azurerm/requests/compute/create_availability_set.rb +4 -2
  52. data/lib/fog/azurerm/requests/compute/create_image.rb +68 -0
  53. data/lib/fog/azurerm/requests/compute/create_virtual_machine.rb +302 -135
  54. data/lib/fog/azurerm/requests/compute/delete_image.rb +29 -0
  55. data/lib/fog/azurerm/requests/compute/get_image.rb +45 -0
  56. data/lib/fog/azurerm/requests/compute/get_virtual_machine.rb +4 -2
  57. data/lib/fog/azurerm/requests/dns/check_record_set_exists.rb +1 -1
  58. data/lib/fog/azurerm/requests/dns/check_zone_exists.rb +3 -2
  59. data/lib/fog/azurerm/requests/dns/create_or_update_record_set.rb +3 -2
  60. data/lib/fog/azurerm/requests/dns/create_or_update_zone.rb +1 -2
  61. data/lib/fog/azurerm/requests/key_vault/check_vault_exists.rb +1 -1
  62. data/lib/fog/azurerm/requests/key_vault/create_or_update_vault.rb +1 -0
  63. data/lib/fog/azurerm/requests/network/check_express_route_cir_auth_exists.rb +1 -1
  64. data/lib/fog/azurerm/requests/network/check_express_route_circuit_exists.rb +1 -1
  65. data/lib/fog/azurerm/requests/network/check_load_balancer_exists.rb +1 -1
  66. data/lib/fog/azurerm/requests/network/check_local_net_gateway_exists.rb +1 -1
  67. data/lib/fog/azurerm/requests/network/check_net_sec_group_exists.rb +1 -1
  68. data/lib/fog/azurerm/requests/network/check_net_sec_rule_exists.rb +1 -1
  69. data/lib/fog/azurerm/requests/network/check_network_interface_exists.rb +1 -1
  70. data/lib/fog/azurerm/requests/network/check_public_ip_exists.rb +1 -1
  71. data/lib/fog/azurerm/requests/network/check_subnet_exists.rb +1 -1
  72. data/lib/fog/azurerm/requests/network/check_virtual_network_exists.rb +1 -1
  73. data/lib/fog/azurerm/requests/network/check_vnet_gateway_connection_exists.rb +1 -1
  74. data/lib/fog/azurerm/requests/network/check_vnet_gateway_exists.rb +1 -1
  75. data/lib/fog/azurerm/requests/network/create_load_balancer.rb +4 -4
  76. data/lib/fog/azurerm/requests/network/create_or_update_express_route_circuit.rb +1 -1
  77. data/lib/fog/azurerm/requests/network/create_or_update_local_network_gateway.rb +1 -2
  78. data/lib/fog/azurerm/requests/network/create_or_update_network_interface.rb +4 -3
  79. data/lib/fog/azurerm/requests/network/create_or_update_network_security_group.rb +4 -3
  80. data/lib/fog/azurerm/requests/network/create_or_update_public_ip.rb +5 -3
  81. data/lib/fog/azurerm/requests/network/create_or_update_virtual_network.rb +4 -3
  82. data/lib/fog/azurerm/requests/network/create_or_update_virtual_network_gateway_connection.rb +1 -1
  83. data/lib/fog/azurerm/requests/resources/check_azure_resource_exists.rb +4 -4
  84. data/lib/fog/azurerm/requests/resources/create_resource_group.rb +2 -1
  85. data/lib/fog/azurerm/requests/resources/delete_resource_tag.rb +4 -4
  86. data/lib/fog/azurerm/requests/resources/tag_resource.rb +4 -4
  87. data/lib/fog/azurerm/requests/sql/create_or_update_database.rb +13 -10
  88. data/lib/fog/azurerm/requests/sql/create_or_update_sql_server.rb +8 -5
  89. data/lib/fog/azurerm/requests/storage/check_storage_account_exists.rb +1 -1
  90. data/lib/fog/azurerm/requests/storage/create_storage_account.rb +4 -2
  91. data/lib/fog/azurerm/requests/traffic_manager/check_traffic_manager_endpoint_exists.rb +1 -1
  92. data/lib/fog/azurerm/requests/traffic_manager/check_traffic_manager_profile_exists.rb +1 -1
  93. data/lib/fog/azurerm/requests/traffic_manager/create_or_update_traffic_manager_profile.rb +13 -3
  94. data/lib/fog/azurerm/storage.rb +0 -18
  95. data/lib/fog/azurerm/utilities/general.rb +21 -10
  96. data/lib/fog/azurerm/version.rb +1 -1
  97. data/rake-script.sh +7 -1
  98. data/rakefile +1 -1
  99. data/test/api_stub.rb +19 -2
  100. data/test/api_stub/models/compute/server.rb +21 -5
  101. data/test/api_stub/requests/compute/image.rb +41 -0
  102. data/test/api_stub/requests/compute/virtual_machine.rb +60 -62
  103. data/test/api_stub/requests/resources/resource_group.rb +1 -1
  104. data/test/integration/application_gateway.rb +8 -1
  105. data/test/integration/availability_set.rb +9 -2
  106. data/test/integration/external_load_balancer.rb +2 -1
  107. data/test/integration/internal_load_balancer.rb +2 -1
  108. data/test/integration/key_vault.rb +2 -1
  109. data/test/integration/managed_disk.rb +10 -5
  110. data/test/integration/network_interface.rb +2 -1
  111. data/test/integration/network_security_group.rb +2 -1
  112. data/test/integration/public_ip.rb +2 -1
  113. data/test/integration/record_set.rb +5 -5
  114. data/test/integration/resource_group.rb +5 -2
  115. data/test/integration/resource_tag.rb +4 -2
  116. data/test/integration/server.rb +113 -23
  117. data/test/integration/server_custom_image.rb +120 -20
  118. data/test/integration/sql_server.rb +10 -2
  119. data/test/integration/storage_account.rb +32 -20
  120. data/test/integration/traffic_manager.rb +6 -1
  121. data/test/integration/virtual_network.rb +2 -1
  122. data/test/integration/virtual_network_gateway_connection.rb +3 -3
  123. data/test/models/application_gateway/test_gateway.rb +2 -1
  124. data/test/models/compute/test_availability_set.rb +2 -1
  125. data/test/models/compute/test_managed_disk.rb +2 -1
  126. data/test/models/compute/test_server.rb +13 -4
  127. data/test/models/dns/test_zone.rb +2 -1
  128. data/test/models/key_vault/test_vault.rb +2 -1
  129. data/test/models/network/test_load_balancer.rb +2 -1
  130. data/test/models/network/test_network_interface.rb +2 -1
  131. data/test/models/network/test_network_security_group.rb +2 -1
  132. data/test/models/network/test_public_ip.rb +2 -1
  133. data/test/models/network/test_virtual_network.rb +2 -1
  134. data/test/models/resources/test_resource_group.rb +2 -1
  135. data/test/models/sql/test_database.rb +2 -1
  136. data/test/models/sql/test_sql_server.rb +2 -1
  137. data/test/models/storage/test_storage_account.rb +2 -1
  138. data/test/models/traffic_manager/test_traffic_manager_profile.rb +2 -1
  139. data/test/requests/application_gateway/test_check_ag_exists.rb +11 -4
  140. data/test/requests/compute/test_attach_data_disk_to_vm.rb +2 -2
  141. data/test/requests/compute/test_check_availability_set_exists.rb +9 -2
  142. data/test/requests/compute/test_check_managed_disk_exists.rb +9 -2
  143. data/test/requests/compute/test_check_vm_exists.rb +9 -2
  144. data/test/requests/compute/test_check_vm_extension_exists.rb +9 -2
  145. data/test/requests/compute/test_create_image.rb +27 -0
  146. data/test/requests/compute/test_create_virtual_machine.rb +41 -17
  147. data/test/requests/compute/test_delete_image.rb +23 -0
  148. data/test/requests/compute/test_get_image.rb +23 -0
  149. data/test/requests/dns/test_check_record_set_exists.rb +9 -2
  150. data/test/requests/dns/test_check_zone_exists.rb +16 -2
  151. data/test/requests/key_vault/test_check_vault_exists.rb +9 -2
  152. data/test/requests/network/test_check_express_route_cir_auth_exists.rb +9 -2
  153. data/test/requests/network/test_check_express_route_circuit_exists.rb +9 -2
  154. data/test/requests/network/test_check_load_balancer_exists.rb +9 -2
  155. data/test/requests/network/test_check_local_net_gateway_exists.rb +11 -4
  156. data/test/requests/network/test_check_net_sec_group_exists.rb +9 -2
  157. data/test/requests/network/test_check_net_sec_rule_exists.rb +9 -2
  158. data/test/requests/network/test_check_network_interface_exists.rb +9 -2
  159. data/test/requests/network/test_check_public_ip_exists.rb +9 -2
  160. data/test/requests/network/test_check_subnet_exists.rb +9 -2
  161. data/test/requests/network/test_check_virtual_network_exists.rb +10 -4
  162. data/test/requests/network/test_check_vnet_gateway_connection_exists.rb +9 -2
  163. data/test/requests/network/test_check_vnet_gateway_exists.rb +9 -2
  164. data/test/requests/network/test_create_load_balancer.rb +3 -2
  165. data/test/requests/network/test_create_network_interface.rb +4 -3
  166. data/test/requests/network/test_create_or_update_network_security_group.rb +3 -2
  167. data/test/requests/network/test_create_or_update_virtual_network.rb +5 -3
  168. data/test/requests/network/test_create_public_ip.rb +3 -2
  169. data/test/requests/network/test_update_public_ip.rb +3 -2
  170. data/test/requests/resources/test_create_resource_group.rb +3 -2
  171. data/test/requests/resources/test_delete_resource_tag.rb +3 -3
  172. data/test/requests/resources/test_tag_resource.rb +3 -3
  173. data/test/requests/storage/test_check_storage_account_exists.rb +8 -1
  174. data/test/requests/traffic_manager/test_check_traffic_manager_endpoint_exists.rb +9 -2
  175. data/test/requests/traffic_manager/test_check_traffic_manager_profile_exists.rb +9 -2
  176. data/test/test_helper.rb +5 -14
  177. metadata +67 -75
  178. data/lib/fog/azurerm/models/storage/recovery_vault.rb +0 -50
  179. data/lib/fog/azurerm/models/storage/recovery_vaults.rb +0 -27
  180. data/lib/fog/azurerm/requests/storage/create_or_update_recovery_vault.rb +0 -54
  181. data/lib/fog/azurerm/requests/storage/delete_recovery_vault.rb +0 -35
  182. data/lib/fog/azurerm/requests/storage/disable_backup_protection.rb +0 -60
  183. data/lib/fog/azurerm/requests/storage/enable_backup_protection.rb +0 -61
  184. data/lib/fog/azurerm/requests/storage/get_all_backup_jobs.rb +0 -56
  185. data/lib/fog/azurerm/requests/storage/get_backup_container.rb +0 -53
  186. data/lib/fog/azurerm/requests/storage/get_backup_item.rb +0 -58
  187. data/lib/fog/azurerm/requests/storage/get_backup_job_for_vm.rb +0 -53
  188. data/lib/fog/azurerm/requests/storage/get_backup_protection_policy.rb +0 -64
  189. data/lib/fog/azurerm/requests/storage/get_recovery_vault.rb +0 -49
  190. data/lib/fog/azurerm/requests/storage/list_recovery_vaults.rb +0 -48
  191. data/lib/fog/azurerm/requests/storage/set_recovery_vault_context.rb +0 -36
  192. data/lib/fog/azurerm/requests/storage/start_backup.rb +0 -54
  193. data/test/api_stub/models/storage/recovery_vault.rb +0 -23
  194. data/test/api_stub/requests/storage/recovery_vault.rb +0 -189
  195. data/test/models/storage/test_recovery_vault.rb +0 -61
  196. data/test/models/storage/test_recovery_vaults.rb +0 -47
  197. data/test/requests/storage/test_create_recovery_vault.rb +0 -35
  198. data/test/requests/storage/test_delete_recovery_vault.rb +0 -34
  199. data/test/requests/storage/test_disable_backup_protection.rb +0 -52
  200. data/test/requests/storage/test_enable_backup_protection.rb +0 -66
  201. data/test/requests/storage/test_get_all_backup_jobs.rb +0 -35
  202. data/test/requests/storage/test_get_backup_container.rb +0 -35
  203. data/test/requests/storage/test_get_backup_item.rb +0 -35
  204. data/test/requests/storage/test_get_backup_job_for_vm.rb +0 -26
  205. data/test/requests/storage/test_get_backup_protection_policy.rb +0 -35
  206. data/test/requests/storage/test_get_recovery_vault.rb +0 -35
  207. data/test/requests/storage/test_list_recovery_vault.rb +0 -35
  208. data/test/requests/storage/test_set_recovery_vault_context.rb +0 -34
  209. data/test/requests/storage/test_start_backup.rb +0 -55
@@ -0,0 +1,29 @@
1
+ module Fog
2
+ module Compute
3
+ class AzureRM
4
+ # This class provides the actual implementation for service calls.
5
+ class Real
6
+ def delete_image(resource_group, vm_name)
7
+ msg = "Deleting Image: #{vm_name}-osImage"
8
+ Fog::Logger.debug msg
9
+ image_name = "#{vm_name}-osImage"
10
+ begin
11
+ @compute_mgmt_client.images.delete(resource_group, image_name)
12
+ rescue MsRestAzure::AzureOperationError => e
13
+ raise_azure_exception(e, msg)
14
+ end
15
+ Fog::Logger.debug "Image #{image_name} deleted successfully."
16
+ true
17
+ end
18
+ end
19
+
20
+ # This class provides the mock implementation for unit tests.
21
+ class Mock
22
+ def delete_image(*)
23
+ Fog::Logger.debug 'Image fog-test-server-osImage from Resource group fog-test-rg deleted successfully.'
24
+ true
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,45 @@
1
+ module Fog
2
+ module Compute
3
+ class AzureRM
4
+ # Real class for Compute Request
5
+ class Real
6
+ def get_image(resource_group_name, image_name)
7
+ msg = "Getting Image #{image_name} in Resource Group #{resource_group_name}"
8
+ Fog::Logger.debug msg
9
+ begin
10
+ image = @compute_mgmt_client.images.get(resource_group_name, image_name)
11
+ rescue MsRestAzure::AzureOperationError => e
12
+ raise_azure_exception(e, msg)
13
+ end
14
+ Fog::Logger.debug "#{msg} successful"
15
+ image
16
+ end
17
+ end
18
+
19
+ # Mock class for Compute Request
20
+ class Mock
21
+ def get_image(*)
22
+ body = {
23
+ 'id' => '/subscriptions/########-####-####-####-############/resourceGroups/TestRG/providers/Microsoft.Compute/images/TestImage',
24
+ 'name' => 'TestImage',
25
+ 'resource_group' => 'TestRG',
26
+ 'location' => 'West US',
27
+ 'storage_profile' => {
28
+ 'os_disk' => {
29
+ 'os_type' => 'Linux',
30
+ 'os_state' => 'Generalized',
31
+ 'blob_uri' => 'https://myblob.blob.core.windows.net/images/testimage.vhd',
32
+ 'caching' => 'ReadWrite',
33
+ 'disk_size_gb' => '5'
34
+ },
35
+ 'data_disks' => []
36
+ },
37
+ 'provisioning_state' => 'Succeeded'
38
+ }
39
+ image_mapper = Azure::ARM::Compute::Models::Image.mapper
40
+ @compute_mgmt_client.deserialize(image_mapper, body, 'result.body')
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -1,3 +1,5 @@
1
+ INSTANCE_VIEW = 'instanceView'.freeze
2
+
1
3
  module Fog
2
4
  module Compute
3
5
  class AzureRM
@@ -8,9 +10,9 @@ module Fog
8
10
  Fog::Logger.debug msg
9
11
  begin
10
12
  if async
11
- response = @compute_mgmt_client.virtual_machines.get_async(resource_group, name)
13
+ response = @compute_mgmt_client.virtual_machines.get_async(resource_group, name, INSTANCE_VIEW)
12
14
  else
13
- response = @compute_mgmt_client.virtual_machines.get(resource_group, name)
15
+ response = @compute_mgmt_client.virtual_machines.get(resource_group, name, INSTANCE_VIEW)
14
16
  end
15
17
  rescue MsRestAzure::AzureOperationError => e
16
18
  raise_azure_exception(e, msg)
@@ -11,7 +11,7 @@ module Fog
11
11
  Fog::Logger.debug "Record set #{name} exists."
12
12
  true
13
13
  rescue MsRestAzure::AzureOperationError => e
14
- if e.body['code'] == 'NotFound'
14
+ if resource_not_found?(e)
15
15
  Fog::Logger.debug "Record set #{name} doesn't exist."
16
16
  false
17
17
  else
@@ -9,8 +9,9 @@ module Fog
9
9
  begin
10
10
  zone = @dns_client.zones.get(resource_group, name)
11
11
  rescue MsRestAzure::AzureOperationError => e
12
- if !e.body['error'].nil? && e.body['error']['code'] == ERROR_CODE_RESOURCE_NOT_FOUND
13
- zone = nil
12
+ if resource_not_found?(e)
13
+ Fog::Logger.debug "Zone #{name} doesn't exist."
14
+ return false
14
15
  else
15
16
  raise_azure_exception(e, msg)
16
17
  end
@@ -34,9 +34,10 @@ module Fog
34
34
  end
35
35
  record_set.arecords = a_type_records_array
36
36
  when 'CNAME'
37
- record_set.cname_record = record_set_params[:records].first # because cname only has 1 value and we know the object is an array passed in.
37
+ cname_record = Azure::ARM::Dns::Models::CnameRecord.new
38
+ cname_record.cname = record_set_params[:records].first # because cname only has 1 value and we know the object is an array passed in.
39
+ record_set.cname_record = cname_record
38
40
  end
39
-
40
41
  record_set
41
42
  end
42
43
  end
@@ -25,9 +25,8 @@ module Fog
25
25
  zone.type = zone_params[:type]
26
26
  zone.number_of_record_sets = zone_params[:number_of_record_sets]
27
27
  zone.max_number_of_record_sets = zone_params[:max_number_of_record_sets]
28
- zone.tags = zone_params[:tags] if zone.tags.nil?
28
+ zone.tags = zone_params[:tags]
29
29
  zone.etag = zone_params[:etag]
30
-
31
30
  zone
32
31
  end
33
32
  end
@@ -11,7 +11,7 @@ module Fog
11
11
  Fog::Logger.debug "Vault #{vault_name} exists."
12
12
  true
13
13
  rescue MsRestAzure::AzureOperationError => e
14
- if e.body['error']['code'] == 'ResourceNotFound'
14
+ if resource_not_found?(e)
15
15
  Fog::Logger.debug "Vault #{vault_name} doesn't exist."
16
16
  false
17
17
  else
@@ -21,6 +21,7 @@ module Fog
21
21
  def get_vault_param_object(vault_hash)
22
22
  vault_param = Azure::ARM::KeyVault::Models::VaultCreateOrUpdateParameters.new
23
23
  vault_param.location = vault_hash[:location]
24
+ vault_param.tags = vault_hash[:tags]
24
25
  vault_param.properties = get_vault_properties_object(vault_hash)
25
26
  vault_param
26
27
  end
@@ -11,7 +11,7 @@ module Fog
11
11
  Fog::Logger.debug "Express Route Circuit Authorization #{authorization_name} exists."
12
12
  true
13
13
  rescue MsRestAzure::AzureOperationError => e
14
- if e.body['error']['code'] == 'ResourceNotFound'
14
+ if resource_not_found?(e)
15
15
  Fog::Logger.debug "Express Route Circuit Authorization #{authorization_name} doesn't exist."
16
16
  false
17
17
  else
@@ -11,7 +11,7 @@ module Fog
11
11
  Fog::Logger.debug "Express Route Circuit #{circuit_name} exists."
12
12
  true
13
13
  rescue MsRestAzure::AzureOperationError => e
14
- if e.body['error']['code'] == 'ResourceNotFound'
14
+ if resource_not_found?(e)
15
15
  Fog::Logger.debug "Express Route Circuit #{circuit_name} doesn't exist."
16
16
  false
17
17
  else
@@ -11,7 +11,7 @@ module Fog
11
11
  Fog::Logger.debug "Load Balancer #{load_balancer_name} exists."
12
12
  true
13
13
  rescue MsRestAzure::AzureOperationError => e
14
- if e.body['error']['code'] == 'ResourceNotFound'
14
+ if resource_not_found?(e)
15
15
  Fog::Logger.debug "Load Balancer #{load_balancer_name} doesn't exist."
16
16
  false
17
17
  else
@@ -11,7 +11,7 @@ module Fog
11
11
  Fog::Logger.debug "Local Network Gateway #{local_network_gateway_name} exists."
12
12
  true
13
13
  rescue MsRestAzure::AzureOperationError => e
14
- if e.body['error']['code'] == 'ResourceNotFound'
14
+ if resource_not_found?(e)
15
15
  Fog::Logger.debug "Local Network Gateway #{local_network_gateway_name} doesn't exist."
16
16
  false
17
17
  else
@@ -11,7 +11,7 @@ module Fog
11
11
  Fog::Logger.debug "Network Security Group #{security_group_name} exists."
12
12
  true
13
13
  rescue MsRestAzure::AzureOperationError => e
14
- if e.body['error']['code'] == 'ResourceNotFound'
14
+ if resource_not_found?(e)
15
15
  Fog::Logger.debug "Network Security Group #{security_group_name} doesn't exist."
16
16
  false
17
17
  else
@@ -11,7 +11,7 @@ module Fog
11
11
  Fog::Logger.debug "Network Security Rule #{security_rule_name} exists."
12
12
  true
13
13
  rescue MsRestAzure::AzureOperationError => e
14
- if !e.body['error'].nil? && (e.body['error']['code'] == ERROR_CODE_RESOURCE_NOT_FOUND || e.body['error']['code'] == ERROR_CODE_NOT_FOUND)
14
+ if resource_not_found?(e)
15
15
  Fog::Logger.debug "Network Security Rule #{security_rule_name} doesn't exist."
16
16
  false
17
17
  else
@@ -11,7 +11,7 @@ module Fog
11
11
  Fog::Logger.debug "Network Interface #{nic_name} exists."
12
12
  true
13
13
  rescue MsRestAzure::AzureOperationError => e
14
- if e.body['error']['code'] == 'ResourceNotFound'
14
+ if resource_not_found?(e)
15
15
  Fog::Logger.debug "Network Interface #{nic_name} doesn't exist."
16
16
  false
17
17
  else
@@ -11,7 +11,7 @@ module Fog
11
11
  Fog::Logger.debug "Public IP #{name} exists."
12
12
  true
13
13
  rescue MsRestAzure::AzureOperationError => e
14
- if e.body['error']['code'] == 'ResourceNotFound'
14
+ if resource_not_found?(e)
15
15
  Fog::Logger.debug "Public IP #{name} doesn't exist."
16
16
  false
17
17
  else
@@ -11,7 +11,7 @@ module Fog
11
11
  Fog::Logger.debug "Subnet #{subnet_name} exists."
12
12
  true
13
13
  rescue MsRestAzure::AzureOperationError => e
14
- if !e.body['error'].nil? && (e.body['error']['code'] == ERROR_CODE_RESOURCE_NOT_FOUND || e.body['error']['code'] == ERROR_CODE_NOT_FOUND)
14
+ if resource_not_found?(e)
15
15
  Fog::Logger.debug "Subnet #{subnet_name} doesn't exist."
16
16
  false
17
17
  else
@@ -11,7 +11,7 @@ module Fog
11
11
  Fog::Logger.debug "Virtual Network #{name} exists."
12
12
  true
13
13
  rescue MsRestAzure::AzureOperationError => e
14
- if e.error_code == 'ResourceNotFound'
14
+ if resource_not_found?(e)
15
15
  Fog::Logger.debug "Virtual Network #{name} doesn't exist."
16
16
  false
17
17
  else
@@ -11,7 +11,7 @@ module Fog
11
11
  Fog::Logger.debug "Virtual Network Gateway Connection #{gateway_connection_name} exists."
12
12
  true
13
13
  rescue MsRestAzure::AzureOperationError => e
14
- if e.body['error']['code'] == 'ResourceNotFound'
14
+ if resource_not_found?(e)
15
15
  Fog::Logger.debug "Virtual Network Gateway Connection #{gateway_connection_name} doesn't exist."
16
16
  false
17
17
  else
@@ -11,7 +11,7 @@ module Fog
11
11
  Fog::Logger.debug "Virtual Network Gateway #{network_gateway_name} exists."
12
12
  true
13
13
  rescue MsRestAzure::AzureOperationError => e
14
- if e.body['error']['code'] == 'ResourceNotFound'
14
+ if resource_not_found?(e)
15
15
  Fog::Logger.debug "Virtual Network Gateway #{network_gateway_name} doesn't exist."
16
16
  false
17
17
  else
@@ -3,10 +3,10 @@ module Fog
3
3
  class AzureRM
4
4
  # Real class for Load-Balancer Request
5
5
  class Real
6
- def create_load_balancer(name, location, resource_group, frontend_ip_configurations, backend_address_pool_names, load_balancing_rules, probes, inbound_nat_rules, inbound_nat_pools)
6
+ def create_load_balancer(name, location, resource_group, frontend_ip_configurations, backend_address_pool_names, load_balancing_rules, probes, inbound_nat_rules, inbound_nat_pools, tags)
7
7
  msg = "Creating Load-Balancer: #{name}"
8
8
  Fog::Logger.debug msg
9
- load_balancer = define_load_balancer(name, location, frontend_ip_configurations, backend_address_pool_names, load_balancing_rules, probes, inbound_nat_rules, inbound_nat_pools)
9
+ load_balancer = define_load_balancer(name, location, frontend_ip_configurations, backend_address_pool_names, load_balancing_rules, probes, inbound_nat_rules, inbound_nat_pools, tags)
10
10
  begin
11
11
  load_balancer = @network_client.load_balancers.create_or_update(resource_group, name, load_balancer)
12
12
  rescue MsRestAzure::AzureOperationError => e
@@ -18,11 +18,11 @@ module Fog
18
18
 
19
19
  private
20
20
 
21
- def define_load_balancer(name, location, frontend_ip_configurations, backend_address_pool_names, load_balancing_rules, probes, inbound_nat_rules, inbound_nat_pools)
21
+ def define_load_balancer(name, location, frontend_ip_configurations, backend_address_pool_names, load_balancing_rules, probes, inbound_nat_rules, inbound_nat_pools, tags)
22
22
  load_balancer = Azure::ARM::Network::Models::LoadBalancer.new
23
23
  load_balancer.name = name
24
24
  load_balancer.location = location
25
-
25
+ load_balancer.tags = tags
26
26
  if frontend_ip_configurations
27
27
  frontend_ip_configuration_arr = define_lb_frontend_ip_configurations(frontend_ip_configurations)
28
28
  load_balancer.frontend_ipconfigurations = frontend_ip_configuration_arr
@@ -47,7 +47,7 @@ module Fog
47
47
  express_route_circuit.name = circuit_name
48
48
  express_route_circuit.location = location
49
49
  express_route_circuit.sku = sku
50
- express_route_circuit.tags = tags if express_route_circuit.tags.nil?
50
+ express_route_circuit.tags = tags
51
51
  express_route_circuit
52
52
  end
53
53
 
@@ -25,13 +25,12 @@ module Fog
25
25
  local_network_gateway.local_network_address_space = get_local_network_address_space_object(local_network_gateway_params[:local_network_address_space_prefixes]) if local_network_gateway_params[:local_network_address_space_prefixes]
26
26
  local_network_gateway.gateway_ip_address = local_network_gateway_params[:gateway_ip_address] if local_network_gateway_params[:gateway_ip_address]
27
27
  local_network_gateway.bgp_settings = get_bgp_settings_object(local_network_gateway_params)
28
-
29
28
  local_network_gateway.name = local_network_gateway_params[:name]
30
29
  local_network_gateway.type = local_network_gateway_params[:type]
31
30
  local_network_gateway.location = local_network_gateway_params[:location]
32
31
  local_network_gateway.tags = local_network_gateway_params[:tags] if local_network_gateway.tags.nil?
33
32
  local_network_gateway.provisioning_state = local_network_gateway_params[:provisioning_state]
34
-
33
+ local_network_gateway.tags = local_network_gateway_params[:tags]
35
34
  local_network_gateway
36
35
  end
37
36
 
@@ -4,10 +4,10 @@ module Fog
4
4
  class AzureRM
5
5
  # Real class for Network Request
6
6
  class Real
7
- def create_or_update_network_interface(resource_group_name, name, location, subnet_id, public_ip_address_id, network_security_group_id, ip_config_name, private_ip_allocation_method, private_ip_address, load_balancer_backend_address_pools_ids, load_balancer_inbound_nat_rules_ids)
7
+ def create_or_update_network_interface(resource_group_name, name, location, subnet_id, public_ip_address_id, network_security_group_id, ip_config_name, private_ip_allocation_method, private_ip_address, load_balancer_backend_address_pools_ids, load_balancer_inbound_nat_rules_ids, tags)
8
8
  msg = "Creating/Updating Network Interface Card: #{name}"
9
9
  Fog::Logger.debug msg
10
- network_interface = get_network_interface_object(name, location, subnet_id, public_ip_address_id, network_security_group_id, ip_config_name, private_ip_allocation_method, private_ip_address, load_balancer_backend_address_pools_ids, load_balancer_inbound_nat_rules_ids)
10
+ network_interface = get_network_interface_object(name, location, subnet_id, public_ip_address_id, network_security_group_id, ip_config_name, private_ip_allocation_method, private_ip_address, load_balancer_backend_address_pools_ids, load_balancer_inbound_nat_rules_ids, tags)
11
11
  begin
12
12
  network_interface_obj = @network_client.network_interfaces.create_or_update(resource_group_name, name, network_interface)
13
13
  rescue MsRestAzure::AzureOperationError => e
@@ -19,7 +19,7 @@ module Fog
19
19
 
20
20
  private
21
21
 
22
- def get_network_interface_object(name, location, subnet_id, public_ip_address_id, network_security_group_id, ip_config_name, private_ip_allocation_method, private_ip_address, load_balancer_backend_address_pools_ids, load_balancer_inbound_nat_rules_ids)
22
+ def get_network_interface_object(name, location, subnet_id, public_ip_address_id, network_security_group_id, ip_config_name, private_ip_allocation_method, private_ip_address, load_balancer_backend_address_pools_ids, load_balancer_inbound_nat_rules_ids, tags)
23
23
  if public_ip_address_id
24
24
  public_ipaddress = Azure::ARM::Network::Models::PublicIPAddress.new
25
25
  public_ipaddress.id = public_ip_address_id
@@ -59,6 +59,7 @@ module Fog
59
59
  network_interface.name = name
60
60
  network_interface.location = location
61
61
  network_interface.ip_configurations = [ip_configs]
62
+ network_interface.tags = tags
62
63
 
63
64
  if network_security_group_id
64
65
  network_security_group = Azure::ARM::Network::Models::NetworkSecurityGroup.new
@@ -3,11 +3,11 @@ module Fog
3
3
  class AzureRM
4
4
  # Real class for Network Request
5
5
  class Real
6
- def create_or_update_network_security_group(resource_group_name, security_group_name, location, security_rules)
6
+ def create_or_update_network_security_group(resource_group_name, security_group_name, location, security_rules, tags)
7
7
  msg = "Creating/Updating Network Security Group #{security_group_name} in Resource Group #{resource_group_name}."
8
8
  Fog::Logger.debug msg
9
9
 
10
- security_group = get_security_group_object(security_rules, location)
10
+ security_group = get_security_group_object(security_rules, location, tags)
11
11
 
12
12
  begin
13
13
  security_group = @network_client.network_security_groups.begin_create_or_update(resource_group_name, security_group_name, security_group)
@@ -21,10 +21,11 @@ module Fog
21
21
 
22
22
  private
23
23
 
24
- def get_security_group_object(security_rules, location)
24
+ def get_security_group_object(security_rules, location, tags)
25
25
  security_group = Azure::ARM::Network::Models::NetworkSecurityGroup.new
26
26
  security_group.security_rules = get_security_rule_objects(security_rules)
27
27
  security_group.location = location
28
+ security_group.tags = tags
28
29
  security_group
29
30
  end
30
31
 
@@ -3,10 +3,10 @@ module Fog
3
3
  class AzureRM
4
4
  # Real class for Network Request
5
5
  class Real
6
- def create_or_update_public_ip(resource_group, name, location, public_ip_allocation_method, idle_timeout_in_minutes, domain_name_label)
6
+ def create_or_update_public_ip(resource_group, name, location, public_ip_allocation_method, idle_timeout_in_minutes, domain_name_label, tags)
7
7
  msg = "Creating/Updating PublicIP #{name} in Resource Group #{resource_group}."
8
8
  Fog::Logger.debug msg
9
- public_ip = get_public_ip_object(name, location, public_ip_allocation_method, idle_timeout_in_minutes, domain_name_label)
9
+ public_ip = get_public_ip_object(name, location, public_ip_allocation_method, idle_timeout_in_minutes, domain_name_label, tags)
10
10
  begin
11
11
  public_ip_obj = @network_client.public_ipaddresses.create_or_update(resource_group, name, public_ip)
12
12
  rescue MsRestAzure::AzureOperationError => e
@@ -18,12 +18,14 @@ module Fog
18
18
 
19
19
  private
20
20
 
21
- def get_public_ip_object(name, location, public_ip_allocation_method, idle_timeout_in_minutes, domain_name_label)
21
+ def get_public_ip_object(name, location, public_ip_allocation_method, idle_timeout_in_minutes, domain_name_label, tags)
22
22
  public_ip = Azure::ARM::Network::Models::PublicIPAddress.new
23
23
  public_ip.name = name
24
24
  public_ip.location = location
25
25
  public_ip.public_ipallocation_method = public_ip_allocation_method unless public_ip_allocation_method.nil?
26
26
  public_ip.idle_timeout_in_minutes = idle_timeout_in_minutes unless idle_timeout_in_minutes.nil?
27
+ public_ip.tags = tags
28
+
27
29
  unless domain_name_label.nil?
28
30
  public_ip.dns_settings = Azure::ARM::Network::Models::PublicIPAddressDnsSettings.new
29
31
  public_ip.dns_settings.domain_name_label = domain_name_label
@@ -3,8 +3,8 @@ module Fog
3
3
  class AzureRM
4
4
  # Real class for Network Request
5
5
  class Real
6
- def create_or_update_virtual_network(resource_group_name, virtual_network_name, location, dns_servers, subnets, address_prefixes)
7
- virtual_network = define_vnet_object(location, address_prefixes, dns_servers, subnets)
6
+ def create_or_update_virtual_network(resource_group_name, virtual_network_name, location, dns_servers, subnets, address_prefixes, tags)
7
+ virtual_network = define_vnet_object(location, address_prefixes, dns_servers, subnets, tags)
8
8
  create_or_update_vnet(resource_group_name, virtual_network_name, virtual_network)
9
9
  end
10
10
 
@@ -22,9 +22,10 @@ module Fog
22
22
  virtual_network
23
23
  end
24
24
 
25
- def define_vnet_object(location, address_prefixes, dns_servers, subnets)
25
+ def define_vnet_object(location, address_prefixes, dns_servers, subnets, tags)
26
26
  virtual_network = Azure::ARM::Network::Models::VirtualNetwork.new
27
27
  virtual_network.location = location
28
+ virtual_network.tags = tags
28
29
 
29
30
  if address_prefixes.nil? || !address_prefixes.any?
30
31
  address_space = Azure::ARM::Network::Models::AddressSpace.new
@@ -26,7 +26,7 @@ module Fog
26
26
 
27
27
  gateway_connection.name = gateway_connection_params[:name]
28
28
  gateway_connection.location = gateway_connection_params[:location]
29
- gateway_connection.tags = gateway_connection_params[:tags] if gateway_connection.tags.nil?
29
+ gateway_connection.tags = gateway_connection_params[:tags]
30
30
 
31
31
  if gateway_connection_params[:virtual_network_gateway1]
32
32
  gateway_connection.virtual_network_gateway1 = get_virtual_network_gateway(gateway_connection_params[:virtual_network_gateway1][:resource_group], gateway_connection_params[:virtual_network_gateway1][:name])