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
@@ -3,7 +3,7 @@ module Fog
3
3
  class AzureRM
4
4
  # This class provides the actual implementation for service calls.
5
5
  class Real
6
- def check_azure_resource_exists(resource_id, api_version)
6
+ def check_azure_resource_exists(resource_id, api_version = API_VERSION)
7
7
  split_resource = resource_id.split('/') unless resource_id.nil?
8
8
  raise 'Invalid Resource Id' if split_resource.count != 9
9
9
 
@@ -16,9 +16,9 @@ module Fog
16
16
  msg = "Checking Resource #{resource_name}"
17
17
  Fog::Logger.debug msg
18
18
  begin
19
- @rmc.resources.check_existence(resource_group_name, resource_provider_namespace, parent_resource_id, resource_type, resource_name, api_version)
20
- Fog::Logger.debug "Resource #{resource_name} exists."
21
- true
19
+ resource_exists = @rmc.resources.check_existence(resource_group_name, resource_provider_namespace, parent_resource_id, resource_type, resource_name, api_version)
20
+ Fog::Logger.debug "Resource #{resource_name} exists." if resource_exists
21
+ resource_exists
22
22
  rescue MsRestAzure::AzureOperationError => e
23
23
  if e.response.status == 405
24
24
  Fog::Logger.debug "Resource #{resource_name} doesn't exist."
@@ -3,11 +3,12 @@ module Fog
3
3
  class AzureRM
4
4
  # This class provides the actual implementation for service calls.
5
5
  class Real
6
- def create_resource_group(name, location)
6
+ def create_resource_group(name, location, tags)
7
7
  msg = "Creating Resource Group: #{name}."
8
8
  Fog::Logger.debug msg
9
9
  resource_group = Azure::ARM::Resources::Models::ResourceGroup.new
10
10
  resource_group.location = location
11
+ resource_group.tags = tags
11
12
  begin
12
13
  resource_group = @rmc.resource_groups.create_or_update(name, resource_group)
13
14
  rescue MsRestAzure::AzureOperationError => e
@@ -3,7 +3,7 @@ module Fog
3
3
  class AzureRM
4
4
  # This class provides the actual implementation for service calls.
5
5
  class Real
6
- def delete_resource_tag(resource_id, tag_name, tag_value)
6
+ def delete_resource_tag(resource_id, tag_name, tag_value, api_version = API_VERSION)
7
7
  split_resource = resource_id.split('/') unless resource_id.nil?
8
8
  if split_resource.count != 9
9
9
  raise 'Invalid Resource Id'
@@ -18,12 +18,12 @@ module Fog
18
18
  Fog::Logger.debug msg
19
19
 
20
20
  begin
21
- resource = @rmc.resources.get(resource_group_name, resource_provider_namespace, '', resource_type, resource_name, API_VERSION)
21
+ resource = @rmc.resources.get(resource_group_name, resource_provider_namespace, '', resource_type, resource_name, api_version)
22
22
 
23
23
  if resource.tags.key?(tag_name)
24
24
  resource.tags.delete_if { |key, value| key == tag_name && value == tag_value }
25
25
  end
26
- @rmc.resources.create_or_update(resource_group_name, resource_provider_namespace, '', resource_type, resource_name, API_VERSION, resource)
26
+ @rmc.resources.create_or_update(resource_group_name, resource_provider_namespace, '', resource_type, resource_name, api_version, resource)
27
27
  rescue MsRestAzure::AzureOperationError => e
28
28
  raise_azure_exception(e, msg)
29
29
  end
@@ -34,7 +34,7 @@ module Fog
34
34
 
35
35
  # This class provides the mock implementation for unit tests.
36
36
  class Mock
37
- def delete_resource_tag(_resource_id, tag_name, _tag_value)
37
+ def delete_resource_tag(_resource_id, tag_name, _tag_value, _api_version)
38
38
  Fog::Logger.debug "Tag #{tag_name} deleted successfully from Resource your-resource-name"
39
39
  true
40
40
  end
@@ -3,7 +3,7 @@ module Fog
3
3
  class AzureRM
4
4
  # This class provides the actual implementation for service calls.
5
5
  class Real
6
- def tag_resource(resource_id, tag_name, tag_value)
6
+ def tag_resource(resource_id, tag_name, tag_value, api_version = API_VERSION)
7
7
  split_resource = resource_id.split('/') unless resource_id.nil?
8
8
  if split_resource.count != 9
9
9
  raise 'Invalid Resource Id'
@@ -19,10 +19,10 @@ module Fog
19
19
  Fog::Logger.debug msg
20
20
 
21
21
  begin
22
- resource = @rmc.resources.get(resource_group_name, resource_provider_namespace, parent_resource_id, resource_type, resource_name, API_VERSION)
22
+ resource = @rmc.resources.get(resource_group_name, resource_provider_namespace, parent_resource_id, resource_type, resource_name, api_version)
23
23
  resource.tags = {} if resource.tags.nil?
24
24
  resource.tags[tag_name] = tag_value
25
- @rmc.resources.create_or_update(resource_group_name, resource_provider_namespace, parent_resource_id, resource_type, resource_name, API_VERSION, resource)
25
+ @rmc.resources.create_or_update(resource_group_name, resource_provider_namespace, parent_resource_id, resource_type, resource_name, api_version, resource)
26
26
  rescue MsRestAzure::AzureOperationError => e
27
27
  raise_azure_exception(e, msg)
28
28
  end
@@ -33,7 +33,7 @@ module Fog
33
33
 
34
34
  # This class provides the mock implementation for unit tests.
35
35
  class Mock
36
- def tag_resource(_resource_id, tag_name, _tag_value)
36
+ def tag_resource(_resource_id, tag_name, _tag_value, _api_version)
37
37
  Fog::Logger.debug "Tag #{tag_name} created successfully for Resource 'resource_name'"
38
38
  true
39
39
  end
@@ -6,19 +6,21 @@ module Fog
6
6
  def create_or_update_database(database_hash)
7
7
  msg = "Creating SQL Database: #{database_hash[:name]}."
8
8
  Fog::Logger.debug msg
9
+ formatted_database_params = format_database_parameters(database_hash[:location],
10
+ database_hash[:create_mode],
11
+ database_hash[:edition],
12
+ database_hash[:source_database_id],
13
+ database_hash[:collation],
14
+ database_hash[:max_size_bytes],
15
+ database_hash[:requested_service_objective_name],
16
+ database_hash[:elastic_pool_name],
17
+ database_hash[:requested_service_objective_id],
18
+ database_hash[:tags])
9
19
  begin
10
20
  sql_database = @sql_mgmt_client.databases.create_or_update(database_hash[:resource_group],
11
21
  database_hash[:server_name],
12
22
  database_hash[:name],
13
- format_database_parameters(database_hash[:location],
14
- database_hash[:create_mode],
15
- database_hash[:edition],
16
- database_hash[:source_database_id],
17
- database_hash[:collation],
18
- database_hash[:max_size_bytes],
19
- database_hash[:requested_service_objective_name],
20
- database_hash[:elastic_pool_name],
21
- database_hash[:requested_service_objective_id]))
23
+ formatted_database_params)
22
24
  rescue MsRestAzure::AzureOperationError => e
23
25
  raise_azure_exception(e, msg)
24
26
  end
@@ -28,7 +30,7 @@ module Fog
28
30
 
29
31
  private
30
32
 
31
- def format_database_parameters(location, create_mode, edition, source_database_id, collation, max_size_bytes, requested_service_objective_name, elastic_pool_name, requested_service_objective_id)
33
+ def format_database_parameters(location, create_mode, edition, source_database_id, collation, max_size_bytes, requested_service_objective_name, elastic_pool_name, requested_service_objective_id, tags)
32
34
  database = Azure::ARM::SQL::Models::Database.new
33
35
  database.location = location
34
36
  database.edition = edition unless edition.nil?
@@ -39,6 +41,7 @@ module Fog
39
41
  database.source_database_id = source_database_id unless source_database_id.nil?
40
42
  database.requested_service_objective_id = requested_service_objective_id unless requested_service_objective_id.nil?
41
43
  database.requested_service_objective_name = requested_service_objective_name unless requested_service_objective_name.nil?
44
+ database.tags = tags
42
45
  database
43
46
  end
44
47
  end
@@ -6,13 +6,15 @@ module Fog
6
6
  def create_or_update_sql_server(server_hash)
7
7
  msg = "Creating SQL Server: #{server_hash[:name]}."
8
8
  Fog::Logger.debug msg
9
+ formatted_server_params = format_server_parameters(server_hash[:location],
10
+ server_hash[:version],
11
+ server_hash[:administrator_login],
12
+ server_hash[:administrator_login_password],
13
+ server_hash[:tags])
9
14
  begin
10
15
  sql_server = @sql_mgmt_client.servers.create_or_update(server_hash[:resource_group],
11
16
  server_hash[:name],
12
- format_server_parameters(server_hash[:location],
13
- server_hash[:version],
14
- server_hash[:administrator_login],
15
- server_hash[:administrator_login_password]))
17
+ formatted_server_params)
16
18
  rescue MsRestAzure::AzureOperationError => e
17
19
  raise_azure_exception(e, msg)
18
20
  end
@@ -22,12 +24,13 @@ module Fog
22
24
 
23
25
  private
24
26
 
25
- def format_server_parameters(location, version, admin_login, admin_password)
27
+ def format_server_parameters(location, version, admin_login, admin_password, tags)
26
28
  server = Azure::ARM::SQL::Models::Server.new
27
29
  server.version = version
28
30
  server.location = location
29
31
  server.administrator_login = admin_login
30
32
  server.administrator_login_password = admin_password
33
+ server.tags = tags
31
34
  server
32
35
  end
33
36
  end
@@ -9,7 +9,7 @@ module Fog
9
9
  begin
10
10
  storage_account = @storage_mgmt_client.storage_accounts.get_properties(resource_group_name, storage_account_name)
11
11
  rescue MsRestAzure::AzureOperationError => e
12
- if e.body['error']['code'] == 'ResourceNotFound'
12
+ if resource_not_found?(e)
13
13
  Fog::Logger.debug "Storage Account #{storage_account_name} doesn't exist."
14
14
  return false
15
15
  else
@@ -9,7 +9,8 @@ module Fog
9
9
  storage_account_params = get_storage_account_params(storage_account_hash[:sku_name],
10
10
  storage_account_hash[:location],
11
11
  storage_account_hash[:replication],
12
- storage_account_hash[:encryption])
12
+ storage_account_hash[:encryption],
13
+ storage_account_hash[:tags])
13
14
  begin
14
15
  storage_account = @storage_mgmt_client.storage_accounts.create(storage_account_hash[:resource_group],
15
16
  storage_account_hash[:name],
@@ -23,7 +24,7 @@ module Fog
23
24
 
24
25
  private
25
26
 
26
- def get_storage_account_params(sku_name, location, replication, encryption_enabled)
27
+ def get_storage_account_params(sku_name, location, replication, encryption_enabled, tags)
27
28
  params = Azure::ARM::Storage::Models::StorageAccountCreateParameters.new
28
29
  sku = Azure::ARM::Storage::Models::Sku.new
29
30
  sku.name = "#{sku_name}_#{replication}"
@@ -40,6 +41,7 @@ module Fog
40
41
  encryption.services = encryption_services
41
42
  params.encryption = encryption
42
43
  end
44
+ params.tags = tags
43
45
  params
44
46
  end
45
47
  end
@@ -11,7 +11,7 @@ module Fog
11
11
  Fog::Logger.debug "Traffic Manager Endpoint #{traffic_manager_end_point} 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 "Traffic Manager Endpoint #{traffic_manager_end_point} doesn't exist."
16
16
  false
17
17
  else
@@ -11,7 +11,7 @@ module Fog
11
11
  Fog::Logger.debug "Traffic Manager Profile #{traffic_manager_profile_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 "Traffic Manager Profile #{traffic_manager_profile_name} doesn't exist."
16
16
  false
17
17
  else
@@ -6,9 +6,18 @@ module Fog
6
6
  def create_or_update_traffic_manager_profile(profile_hash)
7
7
  msg = "Creating Traffic Manager Profile: #{profile_hash[:name]}."
8
8
  Fog::Logger.debug msg
9
- profile_parameters = get_profile_object(profile_hash[:traffic_routing_method], profile_hash[:relative_name], profile_hash[:ttl], profile_hash[:protocol], profile_hash[:port], profile_hash[:path], profile_hash[:endpoints])
9
+ profile_parameters = get_profile_object(profile_hash[:traffic_routing_method],
10
+ profile_hash[:relative_name],
11
+ profile_hash[:ttl],
12
+ profile_hash[:protocol],
13
+ profile_hash[:port],
14
+ profile_hash[:path],
15
+ profile_hash[:endpoints],
16
+ profile_hash[:tags])
10
17
  begin
11
- traffic_manager_profile = @traffic_mgmt_client.profiles.create_or_update(profile_hash[:resource_group], profile_hash[:name], profile_parameters)
18
+ traffic_manager_profile = @traffic_mgmt_client.profiles.create_or_update(profile_hash[:resource_group],
19
+ profile_hash[:name],
20
+ profile_parameters)
12
21
  rescue MsRestAzure::AzureOperationError => e
13
22
  raise_azure_exception(e, msg)
14
23
  end
@@ -18,7 +27,7 @@ module Fog
18
27
 
19
28
  private
20
29
 
21
- def get_profile_object(traffic_routing_method, relative_name, ttl, protocol, port, path, endpoints)
30
+ def get_profile_object(traffic_routing_method, relative_name, ttl, protocol, port, path, endpoints, tags)
22
31
  traffic_manager_profile = Azure::ARM::TrafficManager::Models::Profile.new
23
32
  traffic_manager_profile.traffic_routing_method = traffic_routing_method
24
33
  traffic_manager_profile.location = GLOBAL
@@ -26,6 +35,7 @@ module Fog
26
35
  traffic_manager_profile.dns_config = get_traffic_manager_dns_config(relative_name, ttl)
27
36
  traffic_manager_profile.monitor_config = get_traffic_manager_monitor_config(protocol, port, path)
28
37
  traffic_manager_profile.endpoints = get_endpoints(endpoints) unless endpoints.nil?
38
+ traffic_manager_profile.tags = tags
29
39
  traffic_manager_profile
30
40
  end
31
41
 
@@ -64,22 +64,6 @@ module Fog
64
64
  request :save_page_blob
65
65
  request :multipart_save_block_blob
66
66
 
67
- # Azure Recovery Vault requests
68
- request :create_or_update_recovery_vault
69
- request :get_recovery_vault
70
- request :list_recovery_vaults
71
- request :delete_recovery_vault
72
- request :enable_backup_protection
73
- request :set_recovery_vault_context
74
- request :get_backup_protection_policy
75
- request :start_backup
76
- request :get_backup_item
77
- request :get_backup_container
78
- request :disable_backup_protection
79
- request :get_all_backup_jobs
80
- request :get_all_backup_jobs
81
- request :get_backup_job_for_vm
82
-
83
67
  model_path 'fog/azurerm/models/storage'
84
68
  model :storage_account
85
69
  collection :storage_accounts
@@ -87,8 +71,6 @@ module Fog
87
71
  collection :directories
88
72
  model :file
89
73
  collection :files
90
- model :recovery_vault
91
- collection :recovery_vaults
92
74
 
93
75
  # This class provides the mock implementation for unit tests.
94
76
  class Mock
@@ -47,16 +47,8 @@ def get_record_type(type)
47
47
  end
48
48
 
49
49
  def raise_azure_exception(exception, msg)
50
- if exception.respond_to? 'body'
51
- message = if exception.body['error'].nil?
52
- exception.body['message']
53
- else
54
- exception.body['error']['message']
55
- end
56
- exception_message = "Exception in #{msg} #{message} Type: #{exception.class}\n#{exception.backtrace.join("\n")}"
57
- else
58
- exception_message = "#{exception.inspect}\n#{exception.backtrace.join("\n")}"
59
- end
50
+ description = exception.is_a?(Azure::Core::Http::HTTPError) ? exception.description : exception.error_message
51
+ exception_message = "Exception in #{msg} #{description} Type: #{exception.class}\n#{exception.backtrace.join('\n')}"
60
52
 
61
53
  Fog::Logger.debug exception.backtrace
62
54
  raise exception_message
@@ -166,3 +158,22 @@ def parse_storage_object(object)
166
158
  data['etag'].delete!('"')
167
159
  data
168
160
  end
161
+
162
+ def resource_not_found?(azure_operation_error)
163
+ is_found = false
164
+ if azure_operation_error.response.status == HTTP_NOT_FOUND
165
+ if azure_operation_error.body['code']
166
+ is_found = azure_operation_error.body['code'] == ERROR_CODE_NOT_FOUND
167
+ elsif azure_operation_error.body['error']
168
+ is_found = azure_operation_error.body['error']['code'] == ERROR_CODE_NOT_FOUND ||
169
+ azure_operation_error.body['error']['code'] == ERROR_CODE_RESOURCE_GROUP_NOT_FOUND ||
170
+ azure_operation_error.body['error']['code'] == ERROR_CODE_RESOURCE_NOT_FOUND ||
171
+ azure_operation_error.body['error']['code'] == ERROR_CODE_PARENT_RESOURCE_NOT_FOUND
172
+ end
173
+ end
174
+ is_found
175
+ end
176
+
177
+ def get_image_name(id)
178
+ id.split('/').last
179
+ end
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module AzureRM
3
- VERSION = '0.0.4'.freeze
3
+ VERSION = '0.0.5'.freeze
4
4
  end
5
5
  end
@@ -1,4 +1,10 @@
1
1
  #!/bin/bash
2
2
  rake cc_coverage
3
+ R=$?
3
4
  export CODECLIMATE_REPO_TOKEN="b1401494baa004d90402414cb33a7fc6420fd3693e60c677a120ddefd7d84cfd"
4
- codeclimate-test-reporter
5
+ codeclimate-test-reporter
6
+ if [ $R == 1 ]; then
7
+ exit 1
8
+ else
9
+ exit 0
10
+ fi
data/rakefile CHANGED
@@ -26,4 +26,4 @@ end
26
26
  desc 'Generates a coverage report for integration tests'
27
27
  task :integration_tests do
28
28
  Dir.glob('test/smoke_tests/**/test_*.rb').each { |file| require File.expand_path file, __dir__ }
29
- end
29
+ end
@@ -1,6 +1,7 @@
1
1
  # Module for API Stub
2
2
  module ApiStub
3
3
  module Models
4
+ # Load test Compute models
4
5
  module Compute
5
6
  autoload :Server, File.expand_path('api_stub/models/compute/server', __dir__)
6
7
  autoload :AvailabilitySet, File.expand_path('api_stub/models/compute/availability_set', __dir__)
@@ -8,19 +9,21 @@ module ApiStub
8
9
  autoload :ManagedDisk, File.expand_path('api_stub/models/compute/managed_disk', __dir__)
9
10
  end
10
11
 
12
+ # Load test Resources models
11
13
  module Resources
12
14
  autoload :ResourceGroup, File.expand_path('api_stub/models/resources/resource_group', __dir__)
13
15
  autoload :Deployment, File.expand_path('api_stub/models/resources/deployment', __dir__)
14
16
  autoload :Resource, File.expand_path('api_stub/models/resources/resource', __dir__)
15
17
  end
16
18
 
19
+ # Load test Storage models
17
20
  module Storage
18
21
  autoload :StorageAccount, File.expand_path('api_stub/models/storage/storageaccount', __dir__)
19
22
  autoload :File, ::File.expand_path('api_stub/models/storage/file', __dir__)
20
23
  autoload :Directory, ::File.expand_path('api_stub/models/storage/directory', __dir__)
21
- autoload :RecoveryVault, ::File.expand_path('api_stub/models/storage/recovery_vault', __dir__)
22
24
  end
23
25
 
26
+ # Load test Network models
24
27
  module Network
25
28
  autoload :PublicIp, File.expand_path('api_stub/models/network/public_ip', __dir__)
26
29
  autoload :Subnet, File.expand_path('api_stub/models/network/subnet', __dir__)
@@ -38,52 +41,61 @@ module ApiStub
38
41
  autoload :LocalNetworkGateway, File.expand_path('api_stub/models/network/local_network_gateway', __dir__)
39
42
  end
40
43
 
44
+ # Load test ApplicationGateway models
41
45
  module ApplicationGateway
42
46
  autoload :Gateway, File.expand_path('api_stub/models/application_gateway/gateway', __dir__)
43
47
  end
44
48
 
49
+ # Load test TrafficManager models
45
50
  module TrafficManager
46
51
  autoload :TrafficManagerEndPoint, File.expand_path('api_stub/models/traffic_manager/traffic_manager_end_point', __dir__)
47
52
  autoload :TrafficManagerProfile, File.expand_path('api_stub/models/traffic_manager/traffic_manager_profile', __dir__)
48
53
  end
49
54
 
55
+ # Load test DNS models
50
56
  module DNS
51
57
  autoload :Zone, File.expand_path('api_stub/models/dns/zone', __dir__)
52
58
  autoload :RecordSet, File.expand_path('api_stub/models/dns/record_set', __dir__)
53
59
  end
54
60
 
61
+ # Load test Sql models
55
62
  module Sql
56
63
  autoload :SqlServer, File.expand_path('api_stub/models/sql/sql_server', __dir__)
57
64
  autoload :SqlDatabase, File.expand_path('api_stub/models/sql/sql_database', __dir__)
58
65
  autoload :SqlFirewallRule, File.expand_path('api_stub/models/sql/sql_firewall_rule', __dir__)
59
66
  end
60
67
 
68
+ # Load test KeyVault models
61
69
  module KeyVault
62
70
  autoload :Vault, File.expand_path('api_stub/models/key_vault/vault', __dir__)
63
71
  end
64
72
  end
65
73
 
66
74
  module Requests
75
+ # Load test Compute requests
67
76
  module Compute
68
77
  autoload :AvailabilitySet, File.expand_path('api_stub/requests/compute/availability_set', __dir__)
69
78
  autoload :VirtualMachine, File.expand_path('api_stub/requests/compute/virtual_machine', __dir__)
70
79
  autoload :VirtualMachineExtension, File.expand_path('api_stub/requests/compute/virtual_machine_extension', __dir__)
71
80
  autoload :ManagedDisk, File.expand_path('api_stub/requests/compute/managed_disk', __dir__)
81
+ autoload :Image, File.expand_path('api_stub/requests/compute/image', __dir__)
72
82
  end
73
83
 
84
+ # Load test Resources requests
74
85
  module Resources
75
86
  autoload :ResourceGroup, File.expand_path('api_stub/requests/resources/resource_group', __dir__)
76
87
  autoload :Deployment, File.expand_path('api_stub/requests/resources/deployment', __dir__)
77
88
  autoload :AzureResource, File.expand_path('api_stub/requests/resources/resource', __dir__)
78
89
  end
79
90
 
91
+ # Load test Storage requests
80
92
  module Storage
81
93
  autoload :StorageAccount, File.expand_path('api_stub/requests/storage/storageaccount', __dir__)
82
94
  autoload :File, ::File.expand_path('api_stub/requests/storage/file', __dir__)
83
95
  autoload :Directory, ::File.expand_path('api_stub/requests/storage/directory', __dir__)
84
- autoload :RecoveryVault, ::File.expand_path('api_stub/requests/storage/recovery_vault', __dir__)
85
96
  end
86
97
 
98
+ # Load test Network requests
87
99
  module Network
88
100
  autoload :PublicIp, File.expand_path('api_stub/requests/network/public_ip', __dir__)
89
101
  autoload :Subnet, File.expand_path('api_stub/requests/network/subnet', __dir__)
@@ -101,26 +113,31 @@ module ApiStub
101
113
  autoload :LocalNetworkGateway, File.expand_path('api_stub/requests/network/local_network_gateway', __dir__)
102
114
  end
103
115
 
116
+ # Load test ApplicationGateway requests
104
117
  module ApplicationGateway
105
118
  autoload :Gateway, File.expand_path('api_stub/requests/application_gateway/gateway', __dir__)
106
119
  end
107
120
 
121
+ # Load test TrafficManager requests
108
122
  module TrafficManager
109
123
  autoload :TrafficManagerEndPoint, File.expand_path('api_stub/requests/traffic_manager/traffic_manager_endpoint', __dir__)
110
124
  autoload :TrafficManagerProfile, File.expand_path('api_stub/requests/traffic_manager/traffic_manager_profile', __dir__)
111
125
  end
112
126
 
127
+ # Load test DNS requests
113
128
  module DNS
114
129
  autoload :Zone, File.expand_path('api_stub/requests/dns/zone', __dir__)
115
130
  autoload :RecordSet, File.expand_path('api_stub/requests/dns/record_set', __dir__)
116
131
  end
117
132
 
133
+ # Load test Sql requests
118
134
  module Sql
119
135
  autoload :SqlServer, File.expand_path('api_stub/requests/sql/sql_server', __dir__)
120
136
  autoload :SqlDatabase, File.expand_path('api_stub/requests/sql/database', __dir__)
121
137
  autoload :FirewallRule, File.expand_path('api_stub/requests/sql/firewall_rule', __dir__)
122
138
  end
123
139
 
140
+ # Load test KeyVault requests
124
141
  module KeyVault
125
142
  autoload :Vault, File.expand_path('api_stub/requests/key_vault/vault', __dir__)
126
143
  end