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
@@ -57,7 +57,8 @@ begin
57
57
  access: Fog::ARM::Network::Models::SecurityRuleAccess::Allow,
58
58
  priority: '100',
59
59
  direction: Fog::ARM::Network::Models::SecurityRuleDirection::Inbound
60
- }]
60
+ }],
61
+ tags: { key: 'value' }
61
62
  )
62
63
  puts "Created network security group: #{network_security_group.name}"
63
64
 
@@ -47,7 +47,8 @@ begin
47
47
  name: 'mypubip',
48
48
  resource_group: 'TestRG-PB',
49
49
  location: LOCATION,
50
- public_ip_allocation_method: Fog::ARM::Network::Models::IPAllocationMethod::Dynamic
50
+ public_ip_allocation_method: Fog::ARM::Network::Models::IPAllocationMethod::Dynamic,
51
+ tags: { key: 'value' }
51
52
  )
52
53
  puts "Created public ip: #{public_ip.name}"
53
54
 
@@ -57,13 +57,13 @@ begin
57
57
  type: 'CNAME',
58
58
  ttl: 60
59
59
  )
60
- puts "Created CNAME type record set: #{record_set.name}"
60
+ puts "Created CNAME type record set: #{record_set.inspect}"
61
61
 
62
62
  ########################################################################################################################
63
63
  ###################### Create A Type Record Set in a Zone ######################
64
64
  ########################################################################################################################
65
65
 
66
- dns.record_sets.create(
66
+ record_set = dns.record_sets.create(
67
67
  name: 'TestRS2',
68
68
  resource_group: 'TestRG-RS',
69
69
  zone_name: 'test-zone.com',
@@ -71,14 +71,14 @@ begin
71
71
  type: 'A',
72
72
  ttl: 60
73
73
  )
74
- puts "Created A type record set: #{record_set.name}"
74
+ puts "Created A type record set: #{record_set.inspect}"
75
75
 
76
76
  ########################################################################################################################
77
77
  ###################### Get And Destroy CNAME Type Record Set in a Zone ######################
78
78
  ########################################################################################################################
79
79
 
80
80
  record_set = dns.record_sets.get('TestRG-RS', 'TestRS1', 'test-zone.com', 'CNAME')
81
- puts "Get CNAME Type record set: #{record_set.name}"
81
+ puts "Get CNAME Type record set: #{record_set.inspect}"
82
82
  record_set.destroy
83
83
 
84
84
  ########################################################################################################################
@@ -86,7 +86,7 @@ begin
86
86
  ########################################################################################################################
87
87
 
88
88
  record_set = dns.record_sets.get('TestRG-RS', 'TestRS2', 'test-zone.com', 'A')
89
- puts "Get A Type record set: #{record_set.name}"
89
+ puts "Get A Type record set: #{record_set.inspect}"
90
90
 
91
91
  ########################################################################################################################
92
92
  ###################### Update a Record Set ######################
@@ -29,12 +29,15 @@ begin
29
29
  ###################### Create Resource Group ######################
30
30
  ########################################################################################################################
31
31
 
32
+ tags = { key1: 'value1', key2: 'value2' }
33
+
32
34
  resource_group = resource.resource_groups.create(
33
35
  name: resource_group_name,
34
- location: 'eastus'
36
+ location: 'eastus',
37
+ tags: tags
35
38
  )
36
-
37
39
  puts "Created resource group #{resource_group.name}"
40
+
38
41
  ########################################################################################################################
39
42
  ###################### Get All Resource Groups in a Subscription ######################
40
43
  ########################################################################################################################
@@ -53,7 +53,8 @@ begin
53
53
  tag_resource = resources.tag_resource(
54
54
  resource_id,
55
55
  'test-key',
56
- 'test-value'
56
+ 'test-value',
57
+ '2016-06-01'
57
58
  )
58
59
  puts "Tagged resource: #{tag_resource}"
59
60
 
@@ -77,7 +78,8 @@ begin
77
78
  resource = resources.delete_resource_tag(
78
79
  resource_id,
79
80
  'test-key',
80
- 'test-value'
81
+ 'test-value',
82
+ '2016-06-01'
81
83
  )
82
84
  puts "Removed tag from a resource: #{resource}"
83
85
  ########################################################################################################################
@@ -57,10 +57,10 @@ begin
57
57
  )
58
58
 
59
59
  network.virtual_networks.create(
60
- name: 'testVnet',
61
- location: LOCATION,
62
- resource_group: 'TestRG-VM',
63
- network_address_list: '10.1.0.0/16,10.2.0.0/16'
60
+ name: 'testVnet',
61
+ location: LOCATION,
62
+ resource_group: 'TestRG-VM',
63
+ network_address_list: '10.1.0.0/16,10.2.0.0/16'
64
64
  )
65
65
 
66
66
  network.subnets.create(
@@ -79,21 +79,35 @@ begin
79
79
  private_ip_allocation_method: Fog::ARM::Network::Models::IPAllocationMethod::Dynamic
80
80
  )
81
81
 
82
+ network.network_interfaces.create(
83
+ name: 'NetInt2',
84
+ resource_group: 'TestRG-VM',
85
+ location: LOCATION,
86
+ subnet_id: "/subscriptions/#{azure_credentials['subscription_id']}/resourceGroups/TestRG-VM/providers/Microsoft.Network/virtualNetworks/testVnet/subnets/mysubnet",
87
+ ip_configuration_name: 'testIpConfiguration',
88
+ private_ip_allocation_method: Fog::ARM::Network::Models::IPAllocationMethod::Dynamic
89
+ )
90
+
82
91
  ########################################################################################################################
83
92
  ###################### Check for Virtual Machine ######################
84
93
  ########################################################################################################################
85
94
 
86
95
  flag = compute.servers.check_vm_exists('TestRG-VM', 'TestVM')
87
- puts "Virtual Machine doesn't exist." unless flag
96
+ puts 'Virtual Machine does NOT exist!' unless flag
88
97
 
89
98
  ########################################################################################################################
90
- ###################### Create Server ######################
99
+ ###################### Create Server ######################
91
100
  ########################################################################################################################
92
101
 
102
+ puts 'Creating un-managed Virtual Machine...'
103
+
104
+ tags = { key1: 'value1', key2: 'value2' }
105
+
93
106
  virtual_machine = compute.servers.create(
94
107
  name: 'TestVM',
95
108
  location: LOCATION,
96
109
  resource_group: 'TestRG-VM',
110
+ tags: tags,
97
111
  vm_size: 'Basic_A0',
98
112
  storage_account_name: storage_account_name,
99
113
  username: 'testuser',
@@ -108,16 +122,46 @@ begin
108
122
  custom_data: 'echo customData',
109
123
  os_disk_caching: Fog::ARM::Compute::Models::CachingTypes::None
110
124
  )
111
- puts "Created virtual machine: #{virtual_machine.name}"
125
+ puts "Created un-managed virtual machine: #{virtual_machine.name}"
126
+
127
+ ########################################################################################################################
128
+ ###################### Create Managed Server ######################
129
+ ########################################################################################################################
130
+
131
+ puts 'Creating managed Virtual Machine...'
132
+
133
+ managed_vm = compute.servers.create(
134
+ name: 'TestVM-Managed',
135
+ location: LOCATION,
136
+ resource_group: 'TestRG-VM',
137
+ vm_size: 'Basic_A0',
138
+ storage_account_name: nil,
139
+ username: 'testuser',
140
+ password: 'Confiz=123',
141
+ disable_password_authentication: false,
142
+ network_interface_card_ids: ["/subscriptions/#{azure_credentials['subscription_id']}/resourceGroups/TestRG-VM/providers/Microsoft.Network/networkInterfaces/NetInt2"],
143
+ publisher: 'Canonical',
144
+ offer: 'UbuntuServer',
145
+ sku: '14.04.2-LTS',
146
+ version: 'latest',
147
+ platform: 'linux',
148
+ custom_data: 'echo customData',
149
+ os_disk_caching: Fog::ARM::Compute::Models::CachingTypes::None,
150
+ managed_disk_storage_type: Azure::ARM::Compute::Models::StorageAccountTypes::StandardLRS
151
+ )
152
+ puts "Created managed virtual machine: #{managed_vm.name}"
112
153
 
113
154
  ########################################################################################################################
114
155
  ###################### Create Server Async ####################
115
156
  ########################################################################################################################
116
157
 
158
+ print 'Creating Virtual Machine asynchronously...'
159
+
117
160
  async_response = compute.servers.create_async(
118
161
  name: 'TestVM',
119
162
  location: LOCATION,
120
163
  resource_group: 'TestRG-VM',
164
+ tags: tags,
121
165
  vm_size: 'Basic_A0',
122
166
  storage_account_name: storage_account_name,
123
167
  username: 'testuser',
@@ -132,18 +176,20 @@ begin
132
176
  custom_data: 'echo customData',
133
177
  os_disk_caching: Fog::ARM::Compute::Models::CachingTypes::None
134
178
  )
135
- loop do
136
- puts async_response.state
137
179
 
138
- sleep(2) if async_response.pending?
180
+ loop do
181
+ if async_response.pending?
182
+ sleep(2)
183
+ print '.'
184
+ end
139
185
 
140
186
  if async_response.fulfilled?
141
- puts async_response.value.inspect
187
+ puts "\nCreated VM asynchronously! [#{async_response.value.name}]"
142
188
  break
143
189
  end
144
190
 
145
191
  if async_response.rejected?
146
- puts async_response.reason.inspect
192
+ puts "\nERROR: Async VM creation failed!\n#{async_response.reason.inspect}"
147
193
  break
148
194
  end
149
195
  end
@@ -154,15 +200,15 @@ begin
154
200
 
155
201
  virtual_machine = compute.servers.get('TestRG-VM', 'TestVM')
156
202
  virtual_machine.attach_data_disk('datadisk1', 10, storage_account_name)
157
- puts 'Attached Data Disk to VM'
203
+ puts 'Attached Data Disk to VM!'
158
204
 
159
205
  ########################################################################################################################
160
- ###################### Detach Data Disk from VM ######################
206
+ ###################### Detach Data Disk from VM ######################
161
207
  ########################################################################################################################
162
208
 
163
209
  virtual_machine = compute.servers.get('TestRG-VM', 'TestVM')
164
210
  virtual_machine.detach_data_disk('datadisk1')
165
- puts 'Detached Data Disk from VM'
211
+ puts 'Detached Data Disk from VM!'
166
212
 
167
213
  ########################################################################################################################
168
214
  ###################### Delete Data Disk ######################
@@ -176,14 +222,51 @@ begin
176
222
  )
177
223
  puts "Deleted data disk: #{storage_data.delete_disk('datadisk1')}"
178
224
 
225
+ ########################################################################################################################
226
+ ###################### Create a Managed Data Disk ######################
227
+ ########################################################################################################################
228
+
229
+ managed_disk = compute.managed_disks.create(
230
+ name: 'ManagedDataDisk',
231
+ location: LOCATION,
232
+ resource_group_name: 'TestRG-VM',
233
+ account_type: 'Standard_LRS',
234
+ disk_size_gb: 100,
235
+ creation_data: {
236
+ create_option: 'Empty'
237
+ }
238
+ )
239
+ puts "Created Managed Disk: #{managed_disk.name}"
240
+
241
+ ########################################################################################################################
242
+ ###################### Attach Managed Data Disk to VM ######################
243
+ ########################################################################################################################
244
+
245
+ managed_vm.attach_managed_disk('ManagedDataDisk', 'TestRG-VM')
246
+ puts 'Attached Managed Data Disk to VM!'
247
+
248
+ ########################################################################################################################
249
+ ###################### Detach Data Disk from VM ######################
250
+ ########################################################################################################################
251
+
252
+ managed_vm.detach_managed_disk('ManagedDataDisk')
253
+ puts 'Detached Managed Data Disk from VM!'
254
+
255
+ ########################################################################################################################
256
+ ###################### Delete Managed Data Disk ######################
257
+ ########################################################################################################################
258
+
259
+ managed_disk.destroy
260
+ puts 'Deleted managed data disk!'
261
+
179
262
  ########################################################################################################################
180
263
  ###################### List VM in a resource group ######################
181
264
  ########################################################################################################################
182
265
 
183
266
  virtual_machines = compute.servers(resource_group: 'TestRG-VM')
184
- puts 'List virtual machines ina resource group:'
185
- virtual_machines.each do |a_virtual_machine|
186
- puts a_virtual_machine.name
267
+ puts 'List virtual machines in a resource group:'
268
+ virtual_machines.each do |vm|
269
+ puts "- #{vm.name}"
187
270
  end
188
271
 
189
272
  #######################################################################################################################
@@ -197,10 +280,10 @@ begin
197
280
  ###################### List available sizes in VM ######################
198
281
  ########################################################################################################################
199
282
 
283
+ puts 'List of available sizes for Virtual Machine:'
200
284
  available_sizes_for_vm = virtual_machine.list_available_sizes
201
- puts 'List available sizes in virtual machines:'
202
285
  available_sizes_for_vm.each do |available_size|
203
- puts available_size.inspect
286
+ puts "- #{available_size.name}"
204
287
  end
205
288
 
206
289
  ########################################################################################################################
@@ -222,7 +305,7 @@ begin
222
305
  ########################################################################################################################
223
306
 
224
307
  virtual_machine.deallocate
225
- puts 'Virtual machine deallocated!'
308
+ puts 'Virtual machine de-allocated!'
226
309
 
227
310
  ########################################################################################################################
228
311
  ###################### Start VM ######################
@@ -243,14 +326,20 @@ begin
243
326
  ########################################################################################################################
244
327
 
245
328
  puts "Deleted virtual machine: #{virtual_machine.destroy}"
329
+ puts "Deleted virtual machine: #{managed_vm.destroy}"
246
330
 
247
331
  ########################################################################################################################
248
332
  ###################### CleanUp ######################
249
333
  ########################################################################################################################
250
334
 
335
+ puts 'Cleaning up...'
336
+
251
337
  nic = network.network_interfaces.get('TestRG-VM', 'NetInt')
252
338
  nic.destroy
253
339
 
340
+ nic = network.network_interfaces.get('TestRG-VM', 'NetInt2')
341
+ nic.destroy
342
+
254
343
  vnet = network.virtual_networks.get('TestRG-VM', 'testVnet')
255
344
  vnet.destroy
256
345
 
@@ -259,8 +348,9 @@ begin
259
348
 
260
349
  resource_group = rs.resource_groups.get('TestRG-VM')
261
350
  resource_group.destroy
262
- puts 'Integration Test for virtual machine ran successfully'
351
+
352
+ puts 'Integration Test for virtual machine ran successfully!'
263
353
  rescue
264
- puts 'Integration Test for virtual machine is failing'
354
+ puts 'Integration Test for virtual machine is failing!'
265
355
  resource_group.destroy unless resource_group.nil?
266
356
  end
@@ -40,9 +40,11 @@ network = Fog::Network::AzureRM.new(
40
40
  ###################### Prerequisites ######################
41
41
  ########################################################################################################################
42
42
 
43
+ RG_NAME = 'TestRG-CustomVM'.freeze
44
+
43
45
  begin
44
46
  resource_group = rs.resource_groups.create(
45
- name: 'TestRG-CustomVM',
47
+ name: RG_NAME,
46
48
  location: LOCATION
47
49
  )
48
50
 
@@ -51,30 +53,48 @@ begin
51
53
  storage.storage_accounts.create(
52
54
  name: storage_account_name,
53
55
  location: LOCATION,
54
- resource_group: 'TestRG-CustomVM',
56
+ resource_group: RG_NAME,
55
57
  account_type: 'Standard',
56
58
  replication: 'LRS'
57
59
  )
58
60
 
59
61
  network.virtual_networks.create(
60
- name: 'testVnet',
61
- location: LOCATION,
62
- resource_group: 'TestRG-CustomVM',
63
- network_address_list: '10.1.0.0/16,10.2.0.0/16'
62
+ name: 'testVnet',
63
+ location: LOCATION,
64
+ resource_group: RG_NAME,
65
+ network_address_list: '10.1.0.0/16,10.2.0.0/16'
64
66
  )
65
67
 
66
68
  network.subnets.create(
67
69
  name: 'mysubnet',
68
- resource_group: 'TestRG-CustomVM',
70
+ resource_group: RG_NAME,
69
71
  virtual_network_name: 'testVnet',
70
72
  address_prefix: '10.2.0.0/24'
71
73
  )
72
74
 
73
75
  network.network_interfaces.create(
74
76
  name: 'NetInt',
75
- resource_group: 'TestRG-CustomVM',
77
+ resource_group: RG_NAME,
78
+ location: LOCATION,
79
+ subnet_id: "/subscriptions/#{azure_credentials['subscription_id']}/resourceGroups/#{RG_NAME}/providers/Microsoft.Network/virtualNetworks/testVnet/subnets/mysubnet",
80
+ ip_configuration_name: 'testIpConfiguration',
81
+ private_ip_allocation_method: Fog::ARM::Network::Models::IPAllocationMethod::Dynamic
82
+ )
83
+
84
+ network.network_interfaces.create(
85
+ name: 'NetInt2',
86
+ resource_group: RG_NAME,
87
+ location: LOCATION,
88
+ subnet_id: "/subscriptions/#{azure_credentials['subscription_id']}/resourceGroups/#{RG_NAME}/providers/Microsoft.Network/virtualNetworks/testVnet/subnets/mysubnet",
89
+ ip_configuration_name: 'testIpConfiguration',
90
+ private_ip_allocation_method: Fog::ARM::Network::Models::IPAllocationMethod::Dynamic
91
+ )
92
+
93
+ network.network_interfaces.create(
94
+ name: 'NetInt3',
95
+ resource_group: RG_NAME,
76
96
  location: LOCATION,
77
- subnet_id: "/subscriptions/#{azure_credentials['subscription_id']}/resourceGroups/TestRG-CustomVM/providers/Microsoft.Network/virtualNetworks/testVnet/subnets/mysubnet",
97
+ subnet_id: "/subscriptions/#{azure_credentials['subscription_id']}/resourceGroups/#{RG_NAME}/providers/Microsoft.Network/virtualNetworks/testVnet/subnets/mysubnet",
78
98
  ip_configuration_name: 'testIpConfiguration',
79
99
  private_ip_allocation_method: Fog::ARM::Network::Models::IPAllocationMethod::Dynamic
80
100
  )
@@ -83,44 +103,124 @@ begin
83
103
  ###################### Create Server ######################
84
104
  ########################################################################################################################
85
105
 
106
+ vhd_path = 'https://myblob.blob.core.windows.net/vhds/my_vhd.vhd'.freeze
107
+
86
108
  custom_image_virtual_machine = compute.servers.create(
87
109
  name: 'TestVM',
88
110
  location: LOCATION,
89
- resource_group: 'TestRG-CustomVM',
111
+ resource_group: RG_NAME,
112
+ storage_account_name: storage_account_name,
90
113
  vm_size: 'Basic_A0',
114
+ username: 'testuser',
115
+ password: 'Confiz=123',
116
+ disable_password_authentication: false,
117
+ network_interface_card_ids: ["/subscriptions/#{azure_credentials['subscription_id']}/resourceGroups/#{RG_NAME}/providers/Microsoft.Network/networkInterfaces/NetInt"],
118
+ platform: 'linux',
119
+ vhd_path: vhd_path
120
+ )
121
+
122
+ puts "Created custom image un-managed virtual machine: #{custom_image_virtual_machine.name}"
123
+
124
+ ########################################################################################################################
125
+ ################# Create Managed Server ###################
126
+ ########################################################################################################################
127
+
128
+ custom_image_virtual_machine_managed = compute.servers.create(
129
+ name: 'TestVM-Managed',
130
+ location: LOCATION,
131
+ resource_group: RG_NAME,
91
132
  storage_account_name: storage_account_name,
133
+ vm_size: 'Basic_A0',
134
+ username: 'testuser',
135
+ password: 'Confiz=123',
136
+ disable_password_authentication: false,
137
+ network_interface_card_ids: ["/subscriptions/#{azure_credentials['subscription_id']}/resourceGroups/#{RG_NAME}/providers/Microsoft.Network/networkInterfaces/NetInt2"],
138
+ platform: 'linux',
139
+ vhd_path: vhd_path,
140
+ managed_disk_storage_type: Azure::ARM::Compute::Models::StorageAccountTypes::StandardLRS
141
+ )
142
+
143
+ puts "Created custom image managed virtual machine: #{custom_image_virtual_machine_managed.name}"
144
+
145
+ ########################################################################################################################
146
+ ############## Create Managed Server Async ################
147
+ ########################################################################################################################
148
+
149
+ print 'Creating Virtual Machine asynchronously...'
150
+
151
+ async_response = compute.servers.create_async(
152
+ name: 'TestVM-ManagedAsync',
153
+ location: LOCATION,
154
+ resource_group: RG_NAME,
155
+ storage_account_name: storage_account_name,
156
+ vm_size: 'Basic_A0',
92
157
  username: 'testuser',
93
158
  password: 'Confiz=123',
94
159
  disable_password_authentication: false,
95
- network_interface_card_ids: ["/subscriptions/#{azure_credentials['subscription_id']}/resourceGroups/TestRG-CustomVM/providers/Microsoft.Network/networkInterfaces/NetInt"],
160
+ network_interface_card_ids: ["/subscriptions/#{azure_credentials['subscription_id']}/resourceGroups/#{RG_NAME}/providers/Microsoft.Network/networkInterfaces/NetInt3"],
96
161
  platform: 'linux',
97
- vhd_path: 'https://custimagestorage.blob.core.windows.net/newcustomvhd/trusty-server-cloudimg-amd64-disk1-zeeshan.vhd'
162
+ vhd_path: vhd_path,
163
+ managed_disk_storage_type: Azure::ARM::Compute::Models::StorageAccountTypes::StandardLRS
98
164
  )
99
- puts "Created custom image virtual machine: #{custom_image_virtual_machine.name}"
165
+
166
+ loop do
167
+ if async_response.pending?
168
+ sleep(2)
169
+ print '.'
170
+ end
171
+
172
+ if async_response.fulfilled?
173
+ puts "\nCreated custom image managed virtual machine: #{async_response.value.name}"
174
+ break
175
+ end
176
+
177
+ if async_response.rejected?
178
+ puts "\nERROR: Async VM creation failed!\n#{async_response.reason.inspect}"
179
+ break
180
+ end
181
+ end
100
182
 
101
183
  ########################################################################################################################
102
184
  ###################### Get and Delete Server ######################
103
185
  ########################################################################################################################
104
186
 
105
- custom_image_virtual_machine = compute.servers.get('TestRG-CustomVM', 'TestVM')
106
- puts "Get custom image virtual machine: #{custom_image_virtual_machine.name}"
107
- puts "Deleted custom image virtual machine: #{custom_image_virtual_machine.destroy}"
187
+ custom_image_virtual_machine = compute.servers.get(RG_NAME, 'TestVM')
188
+ puts "Get custom image un-managed virtual machine: #{custom_image_virtual_machine.name}"
189
+ puts "Deleted custom image un-managed virtual machine: #{custom_image_virtual_machine.destroy}"
190
+
191
+ custom_image_virtual_machine_managed = compute.servers.get(RG_NAME, 'TestVM-Managed')
192
+ puts "Get custom image managed virtual machine: #{custom_image_virtual_machine_managed.name}"
193
+ puts "Deleted custom image managed virtual machine: #{custom_image_virtual_machine_managed.destroy}"
194
+
195
+ custom_image_virtual_machine_managed_async = compute.servers.get(RG_NAME, 'TestVM-ManagedAsync')
196
+ puts "Get custom image managed virtual machine async: #{custom_image_virtual_machine_managed_async.name}"
197
+ puts "Deleted custom image managed virtual machine async: #{custom_image_virtual_machine_managed_async.destroy}"
108
198
 
109
199
  ########################################################################################################################
110
200
  ###################### CleanUp ######################
111
201
  ########################################################################################################################
112
202
 
113
- nic = network.network_interfaces.get('TestRG-CustomVM', 'NetInt')
203
+ puts 'Cleaning up...'
204
+
205
+ nic = network.network_interfaces.get(RG_NAME, 'NetInt')
206
+ nic.destroy
207
+
208
+ nic = network.network_interfaces.get(RG_NAME, 'NetInt2')
114
209
  nic.destroy
115
210
 
116
- vnet = network.virtual_networks.get('TestRG-CustomVM', 'testVnet')
211
+ nic = network.network_interfaces.get(RG_NAME, 'NetInt3')
212
+ nic.destroy
213
+
214
+ vnet = network.virtual_networks.get(RG_NAME, 'testVnet')
117
215
  vnet.destroy
118
216
 
119
- storage = storage.storage_accounts.get('TestRG-CustomVM', storage_account_name)
217
+ storage = storage.storage_accounts.get(RG_NAME, storage_account_name)
120
218
  storage.destroy
121
219
 
122
- resource_group = rs.resource_groups.get('TestRG-CustomVM')
220
+ resource_group = rs.resource_groups.get(RG_NAME)
123
221
  resource_group.destroy
222
+
223
+ puts 'Integration Test for virtual machine ran successfully!'
124
224
  rescue
125
225
  puts 'Integration Test for custom image virtual machine is failing'
126
226
  resource_group.destroy unless resource_group.nil?