test/integration/server_custom_image.rb in fog-azure-rm-0.3.9 vs test/integration/server_custom_image.rb in fog-azure-rm-0.4.0
- old
+ new
@@ -57,14 +57,14 @@
account_type: 'Standard',
replication: 'LRS'
)
network.virtual_networks.create(
- name: 'testVnet',
- location: LOCATION,
- resource_group: RG_NAME,
- network_address_list: '10.1.0.0/16,10.2.0.0/16'
+ name: 'testVnet',
+ location: LOCATION,
+ resource_group: RG_NAME,
+ network_address_list: '10.1.0.0/16,10.2.0.0/16'
)
network.subnets.create(
name: 'mysubnet',
resource_group: RG_NAME,
@@ -101,10 +101,12 @@
########################################################################################################################
###################### Create Server ######################
########################################################################################################################
+ vhd_path = 'https://myblob.blob.core.windows.net/vhds/my_vhd.vhd'.freeze
+
custom_image_virtual_machine = compute.servers.create(
name: 'TestVM',
location: LOCATION,
resource_group: RG_NAME,
storage_account_name: storage_account_name,
@@ -112,11 +114,11 @@
username: 'testuser',
password: 'Confiz=123',
disable_password_authentication: false,
network_interface_card_ids: ["/subscriptions/#{azure_credentials['subscription_id']}/resourceGroups/#{RG_NAME}/providers/Microsoft.Network/networkInterfaces/NetInt"],
platform: 'linux',
- vhd_path: 'https://myblob.blob.core.windows.net/vhds/my_vhd.vhd'
+ vhd_path: vhd_path
)
puts "Created custom image un-managed virtual machine: #{custom_image_virtual_machine.name}"
########################################################################################################################
@@ -132,20 +134,22 @@
username: 'testuser',
password: 'Confiz=123',
disable_password_authentication: false,
network_interface_card_ids: ["/subscriptions/#{azure_credentials['subscription_id']}/resourceGroups/#{RG_NAME}/providers/Microsoft.Network/networkInterfaces/NetInt2"],
platform: 'linux',
- vhd_path: 'https://myblob.blob.core.windows.net/vhds/my_vhd.vhd',
+ vhd_path: vhd_path,
managed_disk_storage_type: Azure::ARM::Compute::Models::StorageAccountTypes::StandardLRS
)
puts "Created custom image managed virtual machine: #{custom_image_virtual_machine_managed.name}"
########################################################################################################################
############## Create Managed Server Async ################
########################################################################################################################
+ print 'Creating Virtual Machine asynchronously...'
+
async_response = compute.servers.create_async(
name: 'TestVM-ManagedAsync',
location: LOCATION,
resource_group: RG_NAME,
storage_account_name: storage_account_name,
@@ -153,26 +157,27 @@
username: 'testuser',
password: 'Confiz=123',
disable_password_authentication: false,
network_interface_card_ids: ["/subscriptions/#{azure_credentials['subscription_id']}/resourceGroups/#{RG_NAME}/providers/Microsoft.Network/networkInterfaces/NetInt3"],
platform: 'linux',
- vhd_path: 'https://myblob.blob.core.windows.net/vhds/my_vhd.vhd',
+ vhd_path: vhd_path,
managed_disk_storage_type: Azure::ARM::Compute::Models::StorageAccountTypes::StandardLRS
)
loop do
- puts async_response.state
+ if async_response.pending?
+ sleep(2)
+ print '.'
+ end
- sleep(2) if async_response.pending?
-
if async_response.fulfilled?
- puts "Created custom image managed virtual machine: #{async_response.value.name}"
+ puts "\nCreated custom image managed virtual machine: #{async_response.value.name}"
break
end
if async_response.rejected?
- puts async_response.reason.inspect
+ puts "\nERROR: Async VM creation failed!\n#{async_response.reason.inspect}"
break
end
end
########################################################################################################################
@@ -193,10 +198,12 @@
########################################################################################################################
###################### CleanUp ######################
########################################################################################################################
+ puts 'Cleaning up...'
+
nic = network.network_interfaces.get(RG_NAME, 'NetInt')
nic.destroy
nic = network.network_interfaces.get(RG_NAME, 'NetInt2')
nic.destroy
@@ -210,9 +217,11 @@
storage = storage.storage_accounts.get(RG_NAME, storage_account_name)
storage.destroy
resource_group = rs.resource_groups.get(RG_NAME)
resource_group.destroy
+
+ puts 'Integration Test for virtual machine ran successfully!'
rescue
puts 'Integration Test for custom image virtual machine is failing'
resource_group.destroy unless resource_group.nil?
end