fog-azure-rm 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 (433) hide show
  1. checksums.yaml +4 -4
  2. data/.DS_Store +0 -0
  3. data/.travis.yml +11 -1
  4. data/CHANGELOG.md +35 -14
  5. data/fog-azure-rm.gemspec +8 -9
  6. data/lib/fog/azurerm.rb +3 -0
  7. data/lib/fog/azurerm/application_gateway.rb +64 -0
  8. data/lib/fog/azurerm/compute.rb +1 -0
  9. data/lib/fog/azurerm/config.rb +17 -0
  10. data/lib/fog/azurerm/core.rb +1 -0
  11. data/lib/fog/azurerm/dns.rb +4 -2
  12. data/lib/fog/azurerm/docs/application_gateway.md +139 -0
  13. data/lib/fog/azurerm/docs/dns.md +28 -6
  14. data/lib/fog/azurerm/docs/network.md +151 -143
  15. data/lib/fog/azurerm/docs/resources.md +3 -3
  16. data/lib/fog/azurerm/docs/storage.md +15 -3
  17. data/lib/fog/azurerm/docs/traffic_manager.md +118 -0
  18. data/lib/fog/azurerm/fog_azure_rm_exception.rb +13 -0
  19. data/lib/fog/azurerm/models/application_gateway/backend_address_pool.rb +22 -0
  20. data/lib/fog/azurerm/models/application_gateway/backend_http_setting.rb +26 -0
  21. data/lib/fog/azurerm/models/application_gateway/frontend_ip_configuration.rb +22 -0
  22. data/lib/fog/azurerm/models/application_gateway/frontend_port.rb +18 -0
  23. data/lib/fog/azurerm/models/{network/application_gateway.rb → application_gateway/gateway.rb} +74 -78
  24. data/lib/fog/azurerm/models/{network/application_gateways.rb → application_gateway/gateways.rb} +6 -6
  25. data/lib/fog/azurerm/models/application_gateway/http_listener.rb +28 -0
  26. data/lib/fog/azurerm/models/application_gateway/ip_configuration.rb +18 -0
  27. data/lib/fog/azurerm/models/application_gateway/probe.rb +28 -0
  28. data/lib/fog/azurerm/models/application_gateway/request_routing_rule.rb +25 -0
  29. data/lib/fog/azurerm/models/application_gateway/ssl_certificate.rb +22 -0
  30. data/lib/fog/azurerm/models/application_gateway/url_path_map.rb +28 -0
  31. data/lib/fog/azurerm/models/compute/availability_set.rb +8 -8
  32. data/lib/fog/azurerm/models/compute/availability_sets.rb +3 -1
  33. data/lib/fog/azurerm/models/compute/server.rb +50 -34
  34. data/lib/fog/azurerm/models/dns/record_set.rb +30 -2
  35. data/lib/fog/azurerm/models/dns/record_sets.rb +4 -2
  36. data/lib/fog/azurerm/models/dns/zone.rb +1 -1
  37. data/lib/fog/azurerm/models/dns/zones.rb +4 -2
  38. data/lib/fog/azurerm/models/network/express_route_circuit.rb +89 -0
  39. data/lib/fog/azurerm/models/network/express_route_circuit_peering.rb +93 -0
  40. data/lib/fog/azurerm/models/network/express_route_circuit_peerings.rb +31 -0
  41. data/lib/fog/azurerm/models/network/express_route_circuits.rb +29 -0
  42. data/lib/fog/azurerm/models/network/express_route_service_provider.rb +29 -0
  43. data/lib/fog/azurerm/models/network/express_route_service_providers.rb +21 -0
  44. data/lib/fog/azurerm/models/network/frontend_ip_configuration.rb +5 -15
  45. data/lib/fog/azurerm/models/network/inbound_nat_pool.rb +6 -7
  46. data/lib/fog/azurerm/models/network/inbound_nat_rule.rb +6 -9
  47. data/lib/fog/azurerm/models/network/load_balancer.rb +17 -19
  48. data/lib/fog/azurerm/models/network/load_balancing_rule.rb +11 -16
  49. data/lib/fog/azurerm/models/network/network_interface.rb +24 -24
  50. data/lib/fog/azurerm/models/network/network_security_group.rb +9 -9
  51. data/lib/fog/azurerm/models/network/network_security_rule.rb +13 -13
  52. data/lib/fog/azurerm/models/network/probe.rb +7 -8
  53. data/lib/fog/azurerm/models/network/public_ip.rb +15 -16
  54. data/lib/fog/azurerm/models/network/public_ips.rb +4 -2
  55. data/lib/fog/azurerm/models/network/subnet.rb +8 -8
  56. data/lib/fog/azurerm/models/network/virtual_network.rb +9 -9
  57. data/lib/fog/azurerm/models/network/virtual_network_gateway.rb +138 -0
  58. data/lib/fog/azurerm/models/network/virtual_network_gateways.rb +29 -0
  59. data/lib/fog/azurerm/models/network/vpn_client_configuration.rb +34 -0
  60. data/lib/fog/azurerm/models/network/vpn_client_revoked_certificates.rb +22 -0
  61. data/lib/fog/azurerm/models/network/vpn_client_root_certificates.rb +22 -0
  62. data/lib/fog/azurerm/models/resources/azure_resource.rb +5 -5
  63. data/lib/fog/azurerm/models/resources/dependency.rb +5 -5
  64. data/lib/fog/azurerm/models/resources/deployment.rb +14 -14
  65. data/lib/fog/azurerm/models/resources/provider.rb +4 -4
  66. data/lib/fog/azurerm/models/resources/provider_resource_type.rb +4 -4
  67. data/lib/fog/azurerm/models/resources/resource_group.rb +9 -1
  68. data/lib/fog/azurerm/models/resources/resource_groups.rb +5 -1
  69. data/lib/fog/azurerm/models/storage/data_disk.rb +6 -6
  70. data/lib/fog/azurerm/models/storage/storage_account.rb +41 -10
  71. data/lib/fog/azurerm/models/storage/storage_accounts.rb +1 -6
  72. data/lib/fog/azurerm/models/traffic_manager/traffic_manager_end_point.rb +75 -0
  73. data/lib/fog/azurerm/models/traffic_manager/traffic_manager_end_points.rb +31 -0
  74. data/lib/fog/azurerm/models/traffic_manager/traffic_manager_profile.rb +59 -0
  75. data/lib/fog/azurerm/models/traffic_manager/traffic_manager_profiles.rb +26 -0
  76. data/lib/fog/azurerm/network.rb +25 -25
  77. data/lib/fog/azurerm/requests/{network → application_gateway}/create_application_gateway.rb +59 -95
  78. data/lib/fog/azurerm/requests/application_gateway/delete_application_gateway.rb +26 -0
  79. data/lib/fog/azurerm/requests/application_gateway/list_application_gateways.rb +29 -0
  80. data/lib/fog/azurerm/requests/compute/attach_data_disk_to_vm.rb +38 -38
  81. data/lib/fog/azurerm/requests/compute/check_vm_status.rb +8 -10
  82. data/lib/fog/azurerm/requests/compute/create_availability_set.rb +15 -20
  83. data/lib/fog/azurerm/requests/compute/create_virtual_machine.rb +50 -45
  84. data/lib/fog/azurerm/requests/compute/deallocate_virtual_machine.rb +9 -10
  85. data/lib/fog/azurerm/requests/compute/delete_availability_set.rb +7 -8
  86. data/lib/fog/azurerm/requests/compute/delete_virtual_machine.rb +9 -10
  87. data/lib/fog/azurerm/requests/compute/detach_data_disk_from_vm.rb +20 -19
  88. data/lib/fog/azurerm/requests/compute/generalize_virtual_machine.rb +9 -10
  89. data/lib/fog/azurerm/requests/compute/get_availability_set.rb +32 -0
  90. data/lib/fog/azurerm/requests/compute/get_virtual_machine.rb +17 -14
  91. data/lib/fog/azurerm/requests/compute/list_availability_sets.rb +7 -6
  92. data/lib/fog/azurerm/requests/compute/list_available_sizes_for_virtual_machine.rb +37 -31
  93. data/lib/fog/azurerm/requests/compute/list_virtual_machines.rb +47 -42
  94. data/lib/fog/azurerm/requests/compute/power_off_virtual_machine.rb +9 -10
  95. data/lib/fog/azurerm/requests/compute/redeploy_virtual_machine.rb +9 -10
  96. data/lib/fog/azurerm/requests/compute/restart_virtual_machine.rb +9 -10
  97. data/lib/fog/azurerm/requests/compute/start_virtual_machine.rb +9 -10
  98. data/lib/fog/azurerm/requests/dns/{create_record_set.rb → create_or_update_record_set.rb} +2 -2
  99. data/lib/fog/azurerm/requests/dns/{create_zone.rb → create_or_update_zone.rb} +3 -3
  100. data/lib/fog/azurerm/requests/dns/get_record_set.rb +56 -0
  101. data/lib/fog/azurerm/requests/dns/get_zone.rb +50 -0
  102. data/lib/fog/azurerm/requests/dns/list_record_sets.rb +2 -2
  103. data/lib/fog/azurerm/requests/network/add_address_prefixes_in_virtual_network.rb +3 -3
  104. data/lib/fog/azurerm/requests/network/add_dns_servers_in_virtual_network.rb +8 -6
  105. data/lib/fog/azurerm/requests/network/add_security_rules.rb +15 -13
  106. data/lib/fog/azurerm/requests/network/add_subnets_in_virtual_network.rb +6 -4
  107. data/lib/fog/azurerm/requests/network/attach_network_security_group_to_subnet.rb +13 -15
  108. data/lib/fog/azurerm/requests/network/attach_resource_to_nic.rb +17 -16
  109. data/lib/fog/azurerm/requests/network/attach_route_table_to_subnet.rb +13 -15
  110. data/lib/fog/azurerm/requests/network/check_for_public_ip.rb +2 -4
  111. data/lib/fog/azurerm/requests/network/check_for_virtual_network.rb +5 -5
  112. data/lib/fog/azurerm/requests/network/create_load_balancer.rb +43 -62
  113. data/lib/fog/azurerm/requests/network/create_or_update_express_route_circuit.rb +98 -0
  114. data/lib/fog/azurerm/requests/network/create_or_update_express_route_circuit_peering.rb +69 -0
  115. data/lib/fog/azurerm/requests/network/create_or_update_network_interface.rb +14 -19
  116. data/lib/fog/azurerm/requests/network/create_or_update_network_security_group.rb +29 -26
  117. data/lib/fog/azurerm/requests/network/create_or_update_virtual_network.rb +19 -25
  118. data/lib/fog/azurerm/requests/network/create_or_update_virtual_network_gateway.rb +151 -0
  119. data/lib/fog/azurerm/requests/network/create_public_ip.rb +8 -10
  120. data/lib/fog/azurerm/requests/network/create_subnet.rb +13 -15
  121. data/lib/fog/azurerm/requests/network/delete_express_route_circuit.rb +28 -0
  122. data/lib/fog/azurerm/requests/network/delete_express_route_circuit_peering.rb +28 -0
  123. data/lib/fog/azurerm/requests/network/delete_load_balancer.rb +8 -7
  124. data/lib/fog/azurerm/requests/network/delete_network_interface.rb +7 -8
  125. data/lib/fog/azurerm/requests/network/delete_network_security_group.rb +8 -7
  126. data/lib/fog/azurerm/requests/network/delete_public_ip.rb +4 -6
  127. data/lib/fog/azurerm/requests/network/delete_subnet.rb +6 -7
  128. data/lib/fog/azurerm/requests/network/delete_virtual_network.rb +6 -7
  129. data/lib/fog/azurerm/requests/network/delete_virtual_network_gateway.rb +28 -0
  130. data/lib/fog/azurerm/requests/network/detach_network_security_group_from_subnet.rb +15 -17
  131. data/lib/fog/azurerm/requests/network/detach_resource_from_nic.rb +15 -14
  132. data/lib/fog/azurerm/requests/network/detach_route_table_from_subnet.rb +15 -17
  133. data/lib/fog/azurerm/requests/network/get_express_route_circuit.rb +51 -0
  134. data/lib/fog/azurerm/requests/network/get_express_route_circuit_peering.rb +48 -0
  135. data/lib/fog/azurerm/requests/network/get_network_interface.rb +7 -7
  136. data/lib/fog/azurerm/requests/network/get_network_security_group.rb +11 -7
  137. data/lib/fog/azurerm/requests/network/get_public_ip.rb +41 -0
  138. data/lib/fog/azurerm/requests/network/get_subnet.rb +10 -9
  139. data/lib/fog/azurerm/requests/network/get_virtual_network.rb +12 -14
  140. data/lib/fog/azurerm/requests/network/get_virtual_network_gateway.rb +45 -0
  141. data/lib/fog/azurerm/requests/network/list_express_route_circuit_peerings.rb +44 -0
  142. data/lib/fog/azurerm/requests/network/list_express_route_circuits.rb +53 -0
  143. data/lib/fog/azurerm/requests/network/list_express_route_service_providers.rb +37 -0
  144. data/lib/fog/azurerm/requests/network/list_load_balancers.rb +6 -6
  145. data/lib/fog/azurerm/requests/network/list_network_interfaces.rb +42 -37
  146. data/lib/fog/azurerm/requests/network/list_network_security_groups.rb +149 -143
  147. data/lib/fog/azurerm/requests/network/list_public_ips.rb +26 -22
  148. data/lib/fog/azurerm/requests/network/list_subnets.rb +35 -31
  149. data/lib/fog/azurerm/requests/network/list_virtual_network_gateways.rb +43 -0
  150. data/lib/fog/azurerm/requests/network/list_virtual_networks.rb +52 -51
  151. data/lib/fog/azurerm/requests/network/remove_address_prefixes_from_virtual_network.rb +6 -4
  152. data/lib/fog/azurerm/requests/network/remove_dns_servers_from_virtual_network.rb +6 -4
  153. data/lib/fog/azurerm/requests/network/remove_security_rule.rb +15 -13
  154. data/lib/fog/azurerm/requests/network/remove_subnets_from_virtual_network.rb +6 -4
  155. data/lib/fog/azurerm/requests/resources/create_deployment.rb +27 -21
  156. data/lib/fog/azurerm/requests/resources/create_resource_group.rb +9 -9
  157. data/lib/fog/azurerm/requests/resources/delete_deployment.rb +3 -4
  158. data/lib/fog/azurerm/requests/resources/delete_resource_group.rb +3 -5
  159. data/lib/fog/azurerm/requests/resources/delete_resource_tag.rb +14 -20
  160. data/lib/fog/azurerm/requests/resources/list_deployments.rb +8 -7
  161. data/lib/fog/azurerm/requests/resources/list_resource_groups.rb +27 -23
  162. data/lib/fog/azurerm/requests/resources/list_tagged_resources.rb +30 -27
  163. data/lib/fog/azurerm/requests/resources/tag_resource.rb +15 -20
  164. data/lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb +13 -15
  165. data/lib/fog/azurerm/requests/storage/create_container.rb +6 -5
  166. data/lib/fog/azurerm/requests/storage/create_storage_account.rb +36 -22
  167. data/lib/fog/azurerm/requests/storage/delete_container.rb +6 -5
  168. data/lib/fog/azurerm/requests/storage/delete_disk.rb +13 -12
  169. data/lib/fog/azurerm/requests/storage/delete_storage_account.rb +8 -9
  170. data/lib/fog/azurerm/requests/storage/get_blob_metadata.rb +10 -9
  171. data/lib/fog/azurerm/requests/storage/get_container_access_control_list.rb +6 -5
  172. data/lib/fog/azurerm/requests/storage/get_container_metadata.rb +8 -7
  173. data/lib/fog/azurerm/requests/storage/get_container_properties.rb +6 -5
  174. data/lib/fog/azurerm/requests/storage/get_storage_access_keys.rb +7 -7
  175. data/lib/fog/azurerm/requests/storage/list_containers.rb +6 -5
  176. data/lib/fog/azurerm/requests/storage/list_storage_account_for_rg.rb +7 -12
  177. data/lib/fog/azurerm/requests/storage/list_storage_accounts.rb +7 -13
  178. data/lib/fog/azurerm/requests/storage/set_blob_metadata.rb +8 -7
  179. data/lib/fog/azurerm/requests/storage/set_container_metadata.rb +8 -7
  180. data/lib/fog/azurerm/requests/traffic_manager/create_traffic_manager_endpoint.rb +54 -0
  181. data/lib/fog/azurerm/requests/traffic_manager/create_traffic_manager_profile.rb +107 -0
  182. data/lib/fog/azurerm/requests/traffic_manager/delete_traffic_manager_endpoint.rb +28 -0
  183. data/lib/fog/azurerm/requests/traffic_manager/delete_traffic_manager_profile.rb +26 -0
  184. data/lib/fog/azurerm/requests/traffic_manager/get_traffic_manager_endpoint.rb +39 -0
  185. data/lib/fog/azurerm/requests/traffic_manager/get_traffic_manager_profile.rb +80 -0
  186. data/lib/fog/azurerm/requests/traffic_manager/list_traffic_manager_profiles.rb +82 -0
  187. data/lib/fog/azurerm/storage.rb +1 -1
  188. data/lib/fog/azurerm/traffic_manager.rb +56 -0
  189. data/lib/fog/azurerm/utilities/general.rb +28 -0
  190. data/lib/fog/azurerm/version.rb +1 -1
  191. data/test/api_stub.rb +14 -7
  192. data/test/api_stub/models/{network/application_gateway.rb → application_gateway/gateway.rb} +8 -7
  193. data/test/api_stub/models/compute/availability_set.rb +35 -6
  194. data/test/api_stub/models/compute/server.rb +15 -16
  195. data/test/api_stub/models/dns/record_set.rb +20 -0
  196. data/test/api_stub/models/network/express_route_circuit.rb +47 -0
  197. data/test/api_stub/models/network/express_route_circuit_peering.rb +33 -0
  198. data/test/api_stub/models/network/express_route_service_provider.rb +29 -0
  199. data/test/api_stub/models/network/load_balancer.rb +137 -115
  200. data/test/api_stub/models/network/network_interface.rb +3 -2
  201. data/test/api_stub/models/network/network_security_group.rb +4 -3
  202. data/test/api_stub/models/network/public_ip.rb +5 -4
  203. data/test/api_stub/models/network/subnet.rb +3 -2
  204. data/test/api_stub/models/network/virtual_network.rb +3 -2
  205. data/test/api_stub/models/network/virtual_network_gateway.rb +26 -0
  206. data/test/api_stub/models/resources/deployment.rb +56 -50
  207. data/test/api_stub/models/resources/resource.rb +17 -14
  208. data/test/api_stub/models/resources/resource_group.rb +4 -18
  209. data/test/api_stub/models/storage/storageaccount.rb +8 -15
  210. data/test/api_stub/models/{network → traffic_manager}/traffic_manager_end_point.rb +4 -3
  211. data/test/api_stub/models/{network → traffic_manager}/traffic_manager_profile.rb +4 -3
  212. data/test/api_stub/requests/application_gateway/gateway.rb +431 -0
  213. data/test/api_stub/requests/compute/availability_set.rb +34 -23
  214. data/test/api_stub/requests/compute/virtual_machine.rb +73 -30
  215. data/test/api_stub/requests/dns/record_set.rb +6 -6
  216. data/test/api_stub/requests/dns/zone.rb +2 -2
  217. data/test/api_stub/requests/network/express_route_circuit.rb +100 -0
  218. data/test/api_stub/requests/network/express_route_circuit_peering.rb +62 -0
  219. data/test/api_stub/requests/network/express_route_service_provider.rb +30 -0
  220. data/test/api_stub/requests/network/load_balancer.rb +273 -251
  221. data/test/api_stub/requests/network/network_interface.rb +12 -16
  222. data/test/api_stub/requests/network/network_security_group.rb +12 -27
  223. data/test/api_stub/requests/network/public_ip.rb +7 -9
  224. data/test/api_stub/requests/network/subnet.rb +6 -8
  225. data/test/api_stub/requests/network/virtual_network.rb +6 -8
  226. data/test/api_stub/requests/network/virtual_network_gateway.rb +49 -0
  227. data/test/api_stub/requests/resources/deployment.rb +56 -11
  228. data/test/api_stub/requests/resources/resource.rb +6 -8
  229. data/test/api_stub/requests/resources/resource_group.rb +6 -8
  230. data/test/api_stub/requests/storage/storageaccount.rb +44 -31
  231. data/test/api_stub/requests/traffic_manager/traffic_manager_endpoint.rb +41 -0
  232. data/test/api_stub/requests/{network → traffic_manager}/traffic_manager_profile.rb +7 -5
  233. data/test/integration/application_gateway.rb +16 -8
  234. data/test/integration/availability_set.rb +1 -1
  235. data/test/integration/container.rb +2 -1
  236. data/test/integration/deployment.rb +54 -0
  237. data/test/integration/express_route_circuit.rb +80 -0
  238. data/test/integration/external_load_balancer.rb +7 -6
  239. data/test/integration/internal_load_balancer.rb +6 -5
  240. data/test/integration/network_interface.rb +2 -2
  241. data/test/integration/public_ip.rb +2 -2
  242. data/test/integration/record_set.rb +26 -8
  243. data/test/integration/resource_group.rb +39 -0
  244. data/test/integration/resource_tag.rb +62 -0
  245. data/test/integration/server.rb +6 -4
  246. data/test/integration/storage_account.rb +33 -5
  247. data/test/integration/subnet.rb +2 -2
  248. data/test/integration/traffic_manager.rb +12 -12
  249. data/test/integration/virtual_network.rb +6 -6
  250. data/test/integration/virtual_network_gateway.rb +101 -0
  251. data/test/integration/zone.rb +1 -1
  252. data/test/models/application_gateway/test_gateway.rb +57 -0
  253. data/test/models/{network/test_application_gateways.rb → application_gateway/test_gateways.rb} +10 -10
  254. data/test/models/compute/test_availability_set.rb +2 -1
  255. data/test/models/compute/test_availability_sets.rb +5 -4
  256. data/test/models/compute/test_server.rb +6 -5
  257. data/test/models/compute/test_servers.rb +3 -2
  258. data/test/models/dns/test_record_set.rb +27 -1
  259. data/test/models/dns/test_record_sets.rb +3 -2
  260. data/test/models/dns/test_zone.rb +1 -1
  261. data/test/models/dns/test_zones.rb +2 -1
  262. data/test/models/network/test_express_route_circuit.rb +58 -0
  263. data/test/models/network/test_express_route_circuit_peering.rb +59 -0
  264. data/test/models/network/test_express_route_circuit_peerings.rb +43 -0
  265. data/test/models/network/test_express_route_circuits.rb +42 -0
  266. data/test/models/network/test_express_route_service_providers.rb +30 -0
  267. data/test/models/network/test_load_balancer.rb +7 -12
  268. data/test/models/network/test_load_balancers.rb +4 -4
  269. data/test/models/network/test_network_interface.rb +10 -16
  270. data/test/models/network/test_network_interfaces.rb +3 -2
  271. data/test/models/network/test_network_security_group.rb +6 -8
  272. data/test/models/network/test_network_security_groups.rb +2 -1
  273. data/test/models/network/test_public_ip.rb +5 -6
  274. data/test/models/network/test_public_ips.rb +6 -6
  275. data/test/models/network/test_subnet.rb +9 -15
  276. data/test/models/network/test_subnets.rb +3 -2
  277. data/test/models/network/test_virtual_network.rb +10 -16
  278. data/test/models/network/test_virtual_network_gateway.rb +62 -0
  279. data/test/models/network/test_virtual_network_gateways.rb +42 -0
  280. data/test/models/network/test_virtual_networks.rb +3 -2
  281. data/test/models/resources/test_deployment.rb +2 -1
  282. data/test/models/resources/test_deployments.rb +2 -1
  283. data/test/models/resources/test_resource_group.rb +2 -1
  284. data/test/models/resources/test_resource_groups.rb +2 -1
  285. data/test/models/resources/test_resources.rb +2 -1
  286. data/test/models/storage/test_data_disk.rb +0 -6
  287. data/test/models/storage/test_storage_account.rb +29 -8
  288. data/test/models/storage/test_storage_accounts.rb +5 -5
  289. data/test/models/{network → traffic_manager}/test_traffic_manager_end_point.rb +4 -3
  290. data/test/models/traffic_manager/test_traffic_manager_end_points.rb +43 -0
  291. data/test/models/{network → traffic_manager}/test_traffic_manager_profile.rb +5 -4
  292. data/test/models/traffic_manager/test_traffic_manager_profiles.rb +42 -0
  293. data/test/requests/application_gateway/test_create_application_gateway.rb +51 -0
  294. data/test/requests/application_gateway/test_delete_application_gateway.rb +23 -0
  295. data/test/requests/application_gateway/test_list_application_gateways.rb +24 -0
  296. data/test/requests/compute/test_attach_data_disk_to_vm.rb +40 -123
  297. data/test/requests/compute/test_create_availability_set.rb +9 -11
  298. data/test/requests/compute/test_create_virtual_machine.rb +13 -29
  299. data/test/requests/compute/test_deallocate_virtual_machine.rb +7 -13
  300. data/test/requests/compute/test_delete_availability_set.rb +5 -11
  301. data/test/requests/compute/test_delete_virtual_machine.rb +7 -13
  302. data/test/requests/compute/test_detach_data_disk_from_vm.rb +13 -34
  303. data/test/requests/compute/test_generalize_virtual_machine.rb +7 -13
  304. data/test/requests/compute/test_get_availability_set.rb +24 -0
  305. data/test/requests/compute/test_get_virtual_machine.rb +8 -15
  306. data/test/requests/compute/test_get_vm_status.rb +8 -14
  307. data/test/requests/compute/test_list_availability_sets.rb +8 -14
  308. data/test/requests/compute/test_list_available_sizes_for_virtual_machine.rb +8 -15
  309. data/test/requests/compute/test_list_virtual_machines.rb +8 -14
  310. data/test/requests/compute/test_power_off_virtual_machine.rb +7 -13
  311. data/test/requests/compute/test_redeploy_virtual_machine.rb +7 -13
  312. data/test/requests/compute/test_restart_virtual_machine.rb +7 -13
  313. data/test/requests/compute/test_start_virtual_machine.rb +7 -13
  314. data/test/requests/dns/test_create_record_set.rb +8 -8
  315. data/test/requests/dns/test_create_zone.rb +6 -6
  316. data/test/requests/dns/test_delete_record_set.rb +2 -2
  317. data/test/requests/dns/test_delete_zone.rb +2 -2
  318. data/test/requests/dns/test_get_record_set.rb +46 -0
  319. data/test/requests/dns/test_get_zone.rb +46 -0
  320. data/test/requests/network/test_add_address_prefixes_in_virtual_network.rb +11 -27
  321. data/test/requests/network/test_add_dns_servers_in_virtual_network.rb +11 -27
  322. data/test/requests/network/test_add_security_rules.rb +11 -31
  323. data/test/requests/network/test_add_subnets_in_virtual_network.rb +11 -27
  324. data/test/requests/network/test_attach_network_security_group_to_subnet.rb +9 -16
  325. data/test/requests/network/test_attach_resource_to_nic.rb +15 -37
  326. data/test/requests/network/test_attach_route_table_to_subnet.rb +9 -16
  327. data/test/requests/network/test_check_for_public_ip.rb +10 -18
  328. data/test/requests/network/test_check_for_virtual_network.rb +10 -18
  329. data/test/requests/network/test_create_express_route_circuit.rb +39 -0
  330. data/test/requests/network/test_create_express_route_circuit_peering.rb +37 -0
  331. data/test/requests/network/test_create_load_balancer.rb +27 -34
  332. data/test/requests/network/test_create_network_interface.rb +16 -28
  333. data/test/requests/network/test_create_or_update_network_security_group.rb +38 -0
  334. data/test/requests/network/test_create_or_update_virtual_network.rb +20 -28
  335. data/test/requests/network/test_create_public_ip.rb +13 -22
  336. data/test/requests/network/test_create_subnet.rb +13 -22
  337. data/test/requests/network/test_create_virtual_network_gateway.rb +37 -0
  338. data/test/requests/network/test_delete_express_route_circuit.rb +24 -0
  339. data/test/requests/network/test_delete_express_route_circuit_peering.rb +24 -0
  340. data/test/requests/network/test_delete_load_balancer.rb +7 -13
  341. data/test/requests/network/test_delete_network_interface.rb +7 -13
  342. data/test/requests/network/test_delete_network_security_group.rb +6 -13
  343. data/test/requests/network/test_delete_public_ip.rb +7 -13
  344. data/test/requests/network/test_delete_subnet.rb +7 -13
  345. data/test/requests/network/test_delete_virtual_network.rb +7 -13
  346. data/test/requests/network/test_delete_virtual_network_gateway.rb +24 -0
  347. data/test/requests/network/test_detach_network_security_group_from_subnet.rb +9 -16
  348. data/test/requests/network/test_detach_resource_from_nic.rb +15 -34
  349. data/test/requests/network/test_detach_route_table_from_subnet.rb +9 -16
  350. data/test/requests/network/test_get_express_route_circuit.rb +24 -0
  351. data/test/requests/network/test_get_express_route_circuit_peering.rb +24 -0
  352. data/test/requests/network/test_get_network_interface.rb +8 -15
  353. data/test/requests/network/test_get_network_security_group.rb +9 -16
  354. data/test/requests/network/test_get_public_ip.rb +26 -0
  355. data/test/requests/network/test_get_subnet.rb +9 -16
  356. data/test/requests/network/test_get_virtual_network.rb +26 -0
  357. data/test/requests/network/test_get_virtual_network_gateway.rb +24 -0
  358. data/test/requests/network/test_list_express_route_circuit_peerings.rb +24 -0
  359. data/test/requests/network/test_list_express_route_circuits.rb +26 -0
  360. data/test/requests/network/test_list_express_route_service_providers.rb +24 -0
  361. data/test/requests/network/test_list_load_balancers.rb +8 -15
  362. data/test/requests/network/test_list_network_interfaces.rb +8 -15
  363. data/test/requests/network/test_list_network_security_groups.rb +9 -16
  364. data/test/requests/network/test_list_public_ips.rb +8 -15
  365. data/test/requests/network/test_list_subnets.rb +8 -15
  366. data/test/requests/network/test_list_virtual_network_gateways.rb +24 -0
  367. data/test/requests/network/test_list_virtual_networks.rb +8 -15
  368. data/test/requests/network/test_remove_address_prefixes_from_virtual_network.rb +11 -27
  369. data/test/requests/network/test_remove_dns_servers_from_virtual_network.rb +11 -27
  370. data/test/requests/network/test_remove_security_rule.rb +11 -31
  371. data/test/requests/network/test_remove_subnets_from_virtual_network.rb +11 -27
  372. data/test/requests/resources/test_create_deployment.rb +10 -27
  373. data/test/requests/resources/test_create_resource_group.rb +8 -15
  374. data/test/requests/resources/test_delete_deployment.rb +5 -11
  375. data/test/requests/resources/test_delete_resource_group.rb +8 -14
  376. data/test/requests/resources/test_delete_resource_tag.rb +12 -28
  377. data/test/requests/resources/test_list_deployments.rb +8 -15
  378. data/test/requests/resources/test_list_resource_groups.rb +8 -15
  379. data/test/requests/resources/test_list_tagged_resources.rb +8 -15
  380. data/test/requests/resources/test_tag_resource.rb +12 -28
  381. data/test/requests/storage/test_check_storage_account_name_availability.rb +14 -29
  382. data/test/requests/storage/test_create_storage_account.rb +13 -35
  383. data/test/requests/storage/test_delete_storage_account.rb +8 -14
  384. data/test/requests/storage/test_get_storage_access_keys.rb +7 -14
  385. data/test/requests/storage/test_list_storage_accounts.rb +12 -22
  386. data/test/requests/storage/test_list_storage_accounts_for_rg.rb +15 -29
  387. data/test/requests/traffic_manager/test_create_traffic_manager_endpoint.rb +25 -0
  388. data/test/requests/traffic_manager/test_create_traffic_manager_profile.rb +25 -0
  389. data/test/requests/traffic_manager/test_delete_traffic_manager_endpoint.rb +23 -0
  390. data/test/requests/traffic_manager/test_delete_traffic_manager_profile.rb +23 -0
  391. data/test/requests/traffic_manager/test_get_traffic_manager_endpoint.rb +24 -0
  392. data/test/requests/traffic_manager/test_get_traffic_manager_profile.rb +24 -0
  393. data/test/requests/traffic_manager/test_list_traffic_manager_profiles.rb +24 -0
  394. data/test/test_helper.rb +113 -4
  395. metadata +147 -86
  396. data/lib/fog/azurerm/models/network/application_gateway_backend_address_pool.rb +0 -24
  397. data/lib/fog/azurerm/models/network/application_gateway_backend_http_setting.rb +0 -30
  398. data/lib/fog/azurerm/models/network/application_gateway_frontend_ip_configuration.rb +0 -30
  399. data/lib/fog/azurerm/models/network/application_gateway_frontend_port.rb +0 -22
  400. data/lib/fog/azurerm/models/network/application_gateway_http_listener.rb +0 -37
  401. data/lib/fog/azurerm/models/network/application_gateway_ip_configuration.rb +0 -21
  402. data/lib/fog/azurerm/models/network/application_gateway_probe.rb +0 -32
  403. data/lib/fog/azurerm/models/network/application_gateway_request_routing_rule.rb +0 -35
  404. data/lib/fog/azurerm/models/network/application_gateway_ssl_certificate.rb +0 -26
  405. data/lib/fog/azurerm/models/network/application_gateway_url_path_map.rb +0 -32
  406. data/lib/fog/azurerm/models/network/traffic_manager_end_point.rb +0 -63
  407. data/lib/fog/azurerm/models/network/traffic_manager_end_points.rb +0 -29
  408. data/lib/fog/azurerm/models/network/traffic_manager_profile.rb +0 -59
  409. data/lib/fog/azurerm/models/network/traffic_manager_profiles.rb +0 -24
  410. data/lib/fog/azurerm/requests/network/create_traffic_manager_endpoint.rb +0 -78
  411. data/lib/fog/azurerm/requests/network/create_traffic_manager_profile.rb +0 -127
  412. data/lib/fog/azurerm/requests/network/delete_application_gateway.rb +0 -27
  413. data/lib/fog/azurerm/requests/network/delete_traffic_manager_endpoint.rb +0 -37
  414. data/lib/fog/azurerm/requests/network/delete_traffic_manager_profile.rb +0 -37
  415. data/lib/fog/azurerm/requests/network/get_traffic_manager_profile.rb +0 -96
  416. data/lib/fog/azurerm/requests/network/list_application_gateways.rb +0 -31
  417. data/lib/fog/azurerm/requests/network/list_traffic_manager_profiles.rb +0 -98
  418. data/test/api_stub/models/storage/data_disk.rb +0 -30
  419. data/test/api_stub/requests/network/application_gateway.rb +0 -433
  420. data/test/api_stub/requests/network/traffic_manager_endpoint.rb +0 -25
  421. data/test/models/network/test_application_gateway.rb +0 -62
  422. data/test/models/network/test_traffic_manager_end_points.rb +0 -42
  423. data/test/models/network/test_traffic_manager_profiles.rb +0 -41
  424. data/test/requests/network/test_create_application_gateway.rb +0 -61
  425. data/test/requests/network/test_create_network_security_group.rb +0 -45
  426. data/test/requests/network/test_create_traffic_manager_endpoint.rb +0 -32
  427. data/test/requests/network/test_create_traffic_manager_profile.rb +0 -32
  428. data/test/requests/network/test_delete_application_gateway.rb +0 -30
  429. data/test/requests/network/test_delete_traffic_manager_endpoint.rb +0 -28
  430. data/test/requests/network/test_delete_traffic_manager_profile.rb +0 -28
  431. data/test/requests/network/test_get_traffic_manager_profile.rb +0 -29
  432. data/test/requests/network/test_list_application_gateways.rb +0 -31
  433. data/test/requests/network/test_list_traffic_manager_profiles.rb +0 -29
@@ -0,0 +1,26 @@
1
+ module Fog
2
+ module ApplicationGateway
3
+ class AzureRM
4
+ # Real class for Application Gateway Request
5
+ class Real
6
+ def delete_application_gateway(resource_group, name)
7
+ msg = "Deleting Application_Gateway #{name} from Resource Group #{resource_group}."
8
+ Fog::Logger.debug msg
9
+ begin
10
+ @network_client.application_gateways.delete(resource_group, name)
11
+ rescue MsRestAzure::AzureOperationError => e
12
+ raise_azure_exception(e, msg)
13
+ end
14
+ Fog::Logger.debug "Application Gateway #{name} Deleted Successfully."
15
+ true
16
+ end
17
+ end
18
+
19
+ # Mock class for Network Request
20
+ class Mock
21
+ def delete_application_gateway(_resource_group, _name)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,29 @@
1
+ module Fog
2
+ module ApplicationGateway
3
+ class AzureRM
4
+ # Real class for Application Gateway Request
5
+ class Real
6
+ def list_application_gateways(resource_group)
7
+ msg = "Getting list of Application-Gateway from Resource Group #{resource_group}."
8
+ Fog::Logger.debug msg
9
+ begin
10
+ gateways = @network_client.application_gateways.list_as_lazy(resource_group)
11
+ rescue MsRestAzure::AzureOperationError => e
12
+ raise_azure_exception(e, msg)
13
+ end
14
+ gateways.value
15
+ end
16
+ end
17
+
18
+ # Mock class for Network Request
19
+ class Mock
20
+ def list_application_gateways(_resource_group)
21
+ ag = Azure::ARM::Network::Models::ApplicationGateway.new
22
+ ag.name = 'fogtestgateway'
23
+ ag.location = 'East US'
24
+ [ag]
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -4,35 +4,35 @@ module Fog
4
4
  # This class provides the actual implementation for service calls.
5
5
  class Real
6
6
  def attach_data_disk_to_vm(resource_group, vm_name, disk_name, disk_size, storage_account_name)
7
- Fog::Logger.debug "Attaching Data Disk #{disk_name} to Virtual Machine #{vm_name} in Resource Group #{resource_group}."
7
+ msg = "Attaching Data Disk #{disk_name} to Virtual Machine #{vm_name} in Resource Group #{resource_group}"
8
+ Fog::Logger.debug msg
8
9
  vm = get_virtual_machine_instance(resource_group, vm_name, @compute_mgmt_client)
9
- lun = get_logical_unit_number(vm.properties.storage_profile.data_disks)
10
+ lun = get_logical_unit_number(vm.storage_profile.data_disks)
10
11
  access_key = get_storage_access_key(resource_group, storage_account_name, @storage_mgmt_client)
11
- data_disk = build_storage_profile(disk_name, disk_size, lun, storage_account_name, access_key)
12
- vm.properties.storage_profile.data_disks.push(data_disk)
12
+ data_disk = get_data_disk_object(disk_name, disk_size, lun, storage_account_name, access_key)
13
+ vm.storage_profile.data_disks.push(data_disk)
13
14
  vm.resources = nil
14
15
  begin
15
- promise = @compute_mgmt_client.virtual_machines.create_or_update(resource_group, vm_name, vm)
16
- result = promise.value!
17
- Fog::Logger.debug "Data Disk #{disk_name} attached to Virtual Machine #{vm_name} successfully."
18
- Azure::ARM::Compute::Models::VirtualMachine.serialize_object(result.body)
16
+ virtual_machine = @compute_mgmt_client.virtual_machines.create_or_update(resource_group, vm_name, vm)
19
17
  rescue MsRestAzure::AzureOperationError => e
20
- msg = "Error Attaching Data Disk #{disk_name} to Virtual Machine #{vm_name} in Resource Group #{resource_group}. #{e.body['error']['message']}"
21
- raise msg
18
+ raise_azure_exception(e, msg)
22
19
  end
20
+ Fog::Logger.debug "Data Disk #{disk_name} attached to Virtual Machine #{vm_name} successfully."
21
+ virtual_machine
23
22
  end
24
23
 
25
24
  private
26
25
 
27
26
  def get_virtual_machine_instance(resource_group, vm_name, client)
27
+ msg = "Getting Virtual Machine #{vm_name} from Resource Group #{resource_group}"
28
+ Fog::Logger.debug msg
28
29
  begin
29
- promise = client.virtual_machines.get(resource_group, vm_name)
30
- result = promise.value!
31
- result.body
30
+ virtual_machine = client.virtual_machines.get(resource_group, vm_name)
32
31
  rescue MsRestAzure::AzureOperationError => e
33
- msg = "Error Attaching Data Disk to Virtual Machine. #{e.body['error']['message']}"
34
- raise msg
32
+ raise_azure_exception(e, msg)
35
33
  end
34
+ Fog::Logger.debug "Getting Virtual Machine #{vm_name} from Resource Group #{resource_group} successful"
35
+ virtual_machine
36
36
  end
37
37
 
38
38
  def get_logical_unit_number(data_disks)
@@ -49,16 +49,18 @@ module Fog
49
49
  end
50
50
 
51
51
  def get_storage_access_key(resource_group, storage_account_name, storage_client)
52
+ msg = "Getting Storage Access Keys from Resource Group #{resource_group}"
53
+ Fog::Logger.debug msg
52
54
  begin
53
- storage_account_keys = storage_client.storage_accounts.list_keys(resource_group, storage_account_name).value!
54
- storage_account_keys.body.key2
55
+ storage_account_keys = storage_client.storage_accounts.list_keys(resource_group, storage_account_name)
55
56
  rescue MsRestAzure::AzureOperationError => e
56
- msg = "Error Attaching Data Disk to Virtual Machine. #{e.body['error']['message']}"
57
- raise msg
57
+ raise_azure_exception(e, msg)
58
58
  end
59
+ Fog::Logger.debug "Getting Storage Access Keys from Resource Group #{resource_group} successful"
60
+ storage_account_keys.keys[0].value
59
61
  end
60
62
 
61
- def build_storage_profile(disk_name, disk_size, lun, storage_account_name, access_key)
63
+ def get_data_disk_object(disk_name, disk_size, lun, storage_account_name, access_key)
62
64
  data_disk = Azure::ARM::Compute::Models::DataDisk.new
63
65
  data_disk.name = disk_name
64
66
  data_disk.lun = lun
@@ -67,12 +69,9 @@ module Fog
67
69
  data_disk.vhd.uri = "https://#{storage_account_name}.blob.core.windows.net/vhds/#{disk_name}.vhd"
68
70
  data_disk.caching = Azure::ARM::Compute::Models::CachingTypes::ReadWrite
69
71
  blob_name = "#{disk_name}.vhd"
70
- is_new_disk_or_old = check_blob_exist(storage_account_name, blob_name, access_key)
71
- data_disk.create_option = if is_new_disk_or_old == true
72
- Azure::ARM::Compute::Models::DiskCreateOptionTypes::Attach
73
- else
74
- Azure::ARM::Compute::Models::DiskCreateOptionTypes::Empty
75
- end
72
+ disk_exist = check_blob_exist(storage_account_name, blob_name, access_key)
73
+ data_disk.create_option = Azure::ARM::Compute::Models::DiskCreateOptionTypes::Empty
74
+ data_disk.create_option = Azure::ARM::Compute::Models::DiskCreateOptionTypes::Attach if disk_exist
76
75
  data_disk
77
76
  end
78
77
 
@@ -84,18 +83,17 @@ module Fog
84
83
  true unless blob_prop.nil?
85
84
  rescue Azure::Core::Http::HTTPError => e
86
85
  return false if e.status_code == 404
87
- msg = "Error Attaching Data Disk to Virtual Machine. #{e.description}"
88
- raise msg
86
+ raise_azure_exception(e, 'Checking blob existence')
89
87
  end
90
88
  end
91
89
  end
92
90
  # This class provides the mock implementation for unit tests.
93
91
  class Mock
94
- def attach_data_disk_to_vm(resource_group, vm_name, disk_name, disk_size, storage_account_name)
95
- {
92
+ def attach_data_disk_to_vm(*)
93
+ vm = {
96
94
  'location' => 'West US',
97
- 'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group}/providers/Microsoft.Compute/virtualMachines/#{name}",
98
- 'name' => vm_name,
95
+ 'id' => '/subscriptions/########-####-####-####-############/resourceGroups/fog-test-rg/providers/Microsoft.Compute/virtualMachines/fog-test-server',
96
+ 'name' => 'fog-test-server',
99
97
  'type' => 'Microsoft.Compute/virtualMachines',
100
98
  'properties' =>
101
99
  {
@@ -114,10 +112,10 @@ module Fog
114
112
  },
115
113
  'osDisk' =>
116
114
  {
117
- 'name' => "#{vm_name}_os_disk",
115
+ 'name' => 'fog-test-server_os_disk',
118
116
  'vhd' =>
119
117
  {
120
- 'uri' => "http://#{storage_account_name}.blob.core.windows.net/vhds/#{vm_name}_os_disk.vhd"
118
+ 'uri' => 'http://mystorage1.blob.core.windows.net/vhds/fog-test-server_os_disk.vhd'
121
119
  },
122
120
  'createOption' => 'FromImage',
123
121
  'osType' => 'Linux',
@@ -125,10 +123,10 @@ module Fog
125
123
  },
126
124
  'dataDisks' => [{
127
125
  'lun' => 0,
128
- 'name' => disk_name,
129
- 'vhd_uri' => "https://confizrg7443.blob.core.windows.net/vhds/#{disk_name}.vhd",
126
+ 'name' => 'fog-test-server_data_disk',
127
+ 'vhd_uri' => 'https://confizrg7443.blob.core.windows.net/vhds/fog-test-server_data_disk.vhd',
130
128
  'create_option' => 'empty',
131
- 'disk_size_gb' => disk_size
129
+ 'disk_size_gb' => 1
132
130
  }]
133
131
  },
134
132
  'osProfile' =>
@@ -146,13 +144,15 @@ module Fog
146
144
  'networkInterfaces' =>
147
145
  [
148
146
  {
149
- 'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group}/providers/Microsoft.Network/networkInterfaces/fog-test-vnet"
147
+ 'id' => '/subscriptions/########-####-####-####-############/resourceGroups/fog-test-rg/providers/Microsoft.Network/networkInterfaces/fog-test-vnet'
150
148
  }
151
149
  ]
152
150
  },
153
151
  'provisioningState' => 'Succeeded'
154
152
  }
155
153
  }
154
+ vm_mapper = Azure::ARM::Compute::Models::VirtualMachine.mapper
155
+ @compute_mgmt_client.deserialize(vm_mapper, vm, 'result.body')
156
156
  end
157
157
  end
158
158
  end
@@ -1,24 +1,22 @@
1
1
  module Fog
2
2
  module Compute
3
3
  class AzureRM
4
- # This class provides the actual implemention for service calls.
4
+ # This class provides the actual implementation for service calls.
5
5
  class Real
6
6
  def check_vm_status(resource_group, name)
7
- Fog::Logger.debug "Checking Virtual Machine #{name} status."
7
+ msg = "Checking Virtual Machine #{name} status"
8
+ Fog::Logger.debug msg
8
9
  begin
9
- # Pass 'instanceView' in get method, as argument, to get Virtual Machine status.
10
- promise = @compute_mgmt_client.virtual_machines.get(resource_group, name, 'instanceView')
11
- response = promise.value!
12
- virtual_machine = response.body
13
- get_status(virtual_machine)
10
+ virtual_machine = @compute_mgmt_client.virtual_machines.get(resource_group, name, 'instanceView')
14
11
  rescue MsRestAzure::AzureOperationError => e
15
- msg = "Error in checking Virtual Machine '#{name}' status in Resource Group '#{resource_group}'. #{e.body['error']['message']}"
16
- raise msg
12
+ raise_azure_exception(e, msg)
17
13
  end
14
+ Fog::Logger.debug "Successfully returned status of Virtual Machine #{name} in Resource Group #{resource_group}"
15
+ get_status(virtual_machine)
18
16
  end
19
17
 
20
18
  def get_status(virtual_machine)
21
- vm_statuses = virtual_machine.properties.instance_view.statuses
19
+ vm_statuses = virtual_machine.instance_view.statuses
22
20
  vm_status = nil
23
21
  vm_statuses.each do |status|
24
22
  if status.code.include? 'PowerState'
@@ -1,34 +1,29 @@
1
1
  module Fog
2
2
  module Compute
3
3
  class AzureRM
4
- # This class provides the actual implemention for service calls.
4
+ # This class provides the actual implementation for service calls.
5
5
  class Real
6
6
  def create_availability_set(resource_group, name, location)
7
+ msg = "Creating Availability Set '#{name}' in #{location} region."
8
+ Fog::Logger.debug msg
9
+ avail_set_params = get_availability_set_properties(location)
7
10
  begin
8
- Fog::Logger.debug "Creating Availability Set '#{name}' in #{location} region."
9
- avail_set_props = get_avail_set_properties(location)
10
- promise = @compute_mgmt_client.availability_sets.create_or_update(resource_group, name, avail_set_props)
11
- result = promise.value!
12
- Fog::Logger.debug "Availability Set #{name} created successfully."
13
- Azure::ARM::Compute::Models::AvailabilitySet.serialize_object(result.body)
11
+ availability_set = @compute_mgmt_client.availability_sets.create_or_update(resource_group, name, avail_set_params)
14
12
  rescue MsRestAzure::AzureOperationError => e
15
- msg = "Exception creating Availability Set #{name} in Resource Group: #{resource_group}. #{e.body['error']['message']}"
16
- raise msg
13
+ raise_azure_exception(e, msg)
17
14
  end
15
+ Fog::Logger.debug "Availability Set #{name} created successfully."
16
+ availability_set
18
17
  end
19
18
 
20
19
  # create the properties object for creating availability sets
21
- def get_avail_set_properties(location)
22
- avail_set_props = Azure::ARM::Compute::Models::AvailabilitySetProperties.new
23
- # At least two domain faults
24
- avail_set_props.platform_fault_domain_count = 2
25
- avail_set_props.platform_update_domain_count = 2
26
- # At this point we do not have virtual machines to include
27
- avail_set_props.virtual_machines = []
28
- avail_set_props.statuses = []
20
+ def get_availability_set_properties(location)
29
21
  avail_set = Azure::ARM::Compute::Models::AvailabilitySet.new
22
+ avail_set.platform_fault_domain_count = FAULT_DOMAIN_COUNT
23
+ avail_set.platform_update_domain_count = UPDATE_DOMAIN_COUNT
24
+ avail_set.virtual_machines = []
25
+ avail_set.statuses = []
30
26
  avail_set.location = location
31
- avail_set.properties = avail_set_props
32
27
  avail_set
33
28
  end
34
29
  end
@@ -42,8 +37,8 @@ module Fog
42
37
  'type' => 'Microsoft.Compute/availabilitySets',
43
38
  'properties' =>
44
39
  {
45
- 'platformUpdateDomainCount' => 2,
46
- 'platformFaultDomainCount' => 2
40
+ 'platformUpdateDomainCount' => FAULT_DOMAIN_COUNT,
41
+ 'platformFaultDomainCount' => FAULT_DOMAIN_COUNT
47
42
  }
48
43
  }
49
44
  end
@@ -3,40 +3,47 @@ module Fog
3
3
  class AzureRM
4
4
  # This class provides the actual implementation for service calls.
5
5
  class Real
6
- def create_virtual_machine(resource_group, name, location, vm_size, storage_account_name,
7
- username, password, disable_password_authentication,
8
- ssh_key_path, ssh_key_data, network_interface_card_id,
9
- availability_set_id, publisher, offer, sku, version,
10
- platform, provision_vm_agent, enable_automatic_updates)
11
- Fog::Logger.debug "Creating Virtual Machine #{name} in Resource Group #{resource_group}."
12
- params = Azure::ARM::Compute::Models::VirtualMachine.new
13
- vm_properties = Azure::ARM::Compute::Models::VirtualMachineProperties.new
6
+ def create_virtual_machine(vm_hash)
7
+ msg = "Creating Virtual Machine #{vm_hash[:name]} in Resource Group #{vm_hash[:resource_group]}."
8
+ Fog::Logger.debug msg
9
+ virtual_machine = Azure::ARM::Compute::Models::VirtualMachine.new
14
10
 
15
- unless availability_set_id.nil?
11
+ unless vm_hash[:availability_set_id].nil?
16
12
  sub_resource = MsRestAzure::SubResource.new
17
- sub_resource.id = availability_set_id
18
- vm_properties.availability_set = sub_resource
13
+ sub_resource.id = vm_hash[:availability_set_id]
14
+ virtual_machine.availability_set = sub_resource
19
15
  end
20
16
 
21
- vm_properties.hardware_profile = define_hardware_profile(vm_size)
22
- vm_properties.storage_profile = define_storage_profile(name, storage_account_name, publisher, offer, sku, version)
23
- vm_properties.os_profile = if platform.casecmp('windows') == 0
24
- define_windows_os_profile(name, username, password, provision_vm_agent, enable_automatic_updates)
17
+ virtual_machine.hardware_profile = define_hardware_profile(vm_hash[:vm_size])
18
+ virtual_machine.storage_profile = define_storage_profile(vm_hash[:name],
19
+ vm_hash[:storage_account_name],
20
+ vm_hash[:publisher],
21
+ vm_hash[:offer],
22
+ vm_hash[:sku],
23
+ vm_hash[:version])
24
+ virtual_machine.os_profile = if vm_hash[:platform].casecmp(WINDOWS) == 0
25
+ define_windows_os_profile(vm_hash[:name],
26
+ vm_hash[:username],
27
+ vm_hash[:password],
28
+ vm_hash[:provision_vm_agent],
29
+ vm_hash[:enable_automatic_updates])
25
30
  else
26
- define_linux_os_profile(name, username, password, disable_password_authentication, ssh_key_path, ssh_key_data)
31
+ define_linux_os_profile(vm_hash[:name],
32
+ vm_hash[:username],
33
+ vm_hash[:password],
34
+ vm_hash[:disable_password_authentication],
35
+ vm_hash[:ssh_key_path],
36
+ vm_hash[:ssh_key_data])
27
37
  end
28
- vm_properties.network_profile = define_network_profile(network_interface_card_id)
29
- params.properties = vm_properties
30
- params.location = location
38
+ virtual_machine.network_profile = define_network_profile(vm_hash[:network_interface_card_id])
39
+ virtual_machine.location = vm_hash[:location]
31
40
  begin
32
- promise = @compute_mgmt_client.virtual_machines.create_or_update(resource_group, name, params)
33
- result = promise.value!
34
- Fog::Logger.debug "Virtual Machine #{name} Created Successfully."
35
- Azure::ARM::Compute::Models::VirtualMachine.serialize_object(result.body)
41
+ vm = @compute_mgmt_client.virtual_machines.create_or_update(vm_hash[:resource_group], vm_hash[:name], virtual_machine)
36
42
  rescue MsRestAzure::AzureOperationError => e
37
- msg = "Error Creating Virtual Machine '#{name}' in Resource Group '#{resource_group}'. #{e.body['error']['message']}"
38
- raise msg
43
+ raise_azure_exception(e, msg)
39
44
  end
45
+ Fog::Logger.debug "Virtual Machine #{vm_hash[:name]} Created Successfully."
46
+ vm
40
47
  end
41
48
 
42
49
  private
@@ -110,37 +117,33 @@ module Fog
110
117
  end
111
118
  # This class provides the mock implementation for unit tests.
112
119
  class Mock
113
- def create_virtual_machine(resource_group, name, location, vm_size, storage_account_name,
114
- username, _password, disable_password_authentication,
115
- _ssh_key_path, _ssh_key_data, network_interface_card_id,
116
- _availability_set_id, publisher, offer, sku, version,
117
- _platform, _provision_vm_agent, _enable_automatic_updates)
118
- {
119
- 'location' => location,
120
- 'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group}/providers/Microsoft.Compute/virtualMachines/#{name}",
121
- 'name' => name,
120
+ def create_virtual_machine(*)
121
+ vm = {
122
+ 'location' => 'westus',
123
+ 'id' => '/subscriptions/########-####-####-####-############/resourceGroups/fog-test-rg/providers/Microsoft.Compute/virtualMachines/fog-test-server',
124
+ 'name' => 'fog-test-server',
122
125
  'type' => 'Microsoft.Compute/virtualMachines',
123
126
  'properties' =>
124
127
  {
125
128
  'hardwareProfile' =>
126
129
  {
127
- 'vmSize' => vm_size
130
+ 'vmSize' => 'Standard_A0'
128
131
  },
129
132
  'storageProfile' =>
130
133
  {
131
134
  'imageReference' =>
132
135
  {
133
- 'publisher' => publisher,
134
- 'offer' => offer,
135
- 'sku' => sku,
136
- 'version' => version
136
+ 'publisher' => 'MicrosoftWindowsServerEssentials',
137
+ 'offer' => 'WindowsServerEssentials',
138
+ 'sku' => 'WindowsServerEssentials',
139
+ 'version' => 'latest'
137
140
  },
138
141
  'osDisk' =>
139
142
  {
140
- 'name' => "#{name}_os_disk",
143
+ 'name' => 'fog-test-server_os_disk',
141
144
  'vhd' =>
142
145
  {
143
- 'uri' => "http://#{storage_account_name}.blob.core.windows.net/vhds/#{name}_os_disk.vhd"
146
+ 'uri' => 'http://mystorage1.blob.core.windows.net/vhds/fog-test-server_os_disk.vhd'
144
147
  },
145
148
  'createOption' => 'FromImage',
146
149
  'osType' => 'Linux',
@@ -150,11 +153,11 @@ module Fog
150
153
  },
151
154
  'osProfile' =>
152
155
  {
153
- 'computerName' => name,
154
- 'adminUsername' => username,
156
+ 'computerName' => 'fog-test-server',
157
+ 'adminUsername' => 'fog',
155
158
  'linuxConfiguration' =>
156
159
  {
157
- 'disablePasswordAuthentication' => disable_password_authentication
160
+ 'disablePasswordAuthentication' => true
158
161
  },
159
162
  'secrets' => []
160
163
  },
@@ -163,13 +166,15 @@ module Fog
163
166
  'networkInterfaces' =>
164
167
  [
165
168
  {
166
- 'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group}/providers/Microsoft.Network/networkInterfaces/#{network_interface_card_id.split('/')[8]}"
169
+ 'id' => '/subscriptions/########-####-####-####-############/resourceGroups/fog-test-rg/providers/Microsoft.Network/networkInterfaces/fog-test-vnet'
167
170
  }
168
171
  ]
169
172
  },
170
173
  'provisioningState' => 'Succeeded'
171
174
  }
172
175
  }
176
+ vm_mapper = Azure::ARM::Compute::Models::VirtualMachine.mapper
177
+ @compute_mgmt_client.deserialize(vm_mapper, vm, 'result.body')
173
178
  end
174
179
  end
175
180
  end