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.
- checksums.yaml +4 -4
- data/.arclint +8 -0
- data/.travis.yml +28 -14
- data/CHANGELOG.md +77 -0
- data/CONTRIBUTORS.md +4 -0
- data/fog-azure-rm.gemspec +3 -2
- data/lib/fog/azurerm.rb +1 -0
- data/lib/fog/azurerm/async_response.rb +9 -1
- data/lib/fog/azurerm/compute.rb +3 -1
- data/lib/fog/azurerm/constants.rb +11 -3
- data/lib/fog/azurerm/dns.rb +3 -1
- data/lib/fog/azurerm/docs/application_gateway.md +119 -117
- data/lib/fog/azurerm/docs/compute.md +299 -202
- data/lib/fog/azurerm/docs/dns.md +44 -43
- data/lib/fog/azurerm/docs/key_vault.md +31 -28
- data/lib/fog/azurerm/docs/network.md +407 -404
- data/lib/fog/azurerm/docs/resources.md +52 -49
- data/lib/fog/azurerm/docs/sql.md +56 -54
- data/lib/fog/azurerm/docs/storage.md +92 -157
- data/lib/fog/azurerm/docs/traffic_manager.md +55 -53
- data/lib/fog/azurerm/models/application_gateway/gateway.rb +5 -1
- data/lib/fog/azurerm/models/compute/availability_set.rb +4 -1
- data/lib/fog/azurerm/models/compute/managed_disk.rb +0 -1
- data/lib/fog/azurerm/models/compute/server.rb +61 -11
- data/lib/fog/azurerm/models/compute/servers.rb +2 -2
- data/lib/fog/azurerm/models/dns/a_record.rb +15 -0
- data/lib/fog/azurerm/models/dns/cname_record.rb +15 -0
- data/lib/fog/azurerm/models/dns/record_set.rb +20 -8
- data/lib/fog/azurerm/models/key_vault/vault.rb +3 -1
- data/lib/fog/azurerm/models/network/load_balancer.rb +3 -1
- data/lib/fog/azurerm/models/network/local_network_gateway.rb +3 -1
- data/lib/fog/azurerm/models/network/network_interface.rb +3 -1
- data/lib/fog/azurerm/models/network/network_security_group.rb +4 -2
- data/lib/fog/azurerm/models/network/public_ip.rb +4 -2
- data/lib/fog/azurerm/models/network/virtual_network.rb +4 -2
- data/lib/fog/azurerm/models/resources/resource_group.rb +3 -1
- data/lib/fog/azurerm/models/sql/sql_database.rb +3 -3
- data/lib/fog/azurerm/models/sql/sql_server.rb +3 -2
- data/lib/fog/azurerm/models/storage/directories.rb +6 -1
- data/lib/fog/azurerm/models/storage/file.rb +2 -0
- data/lib/fog/azurerm/models/storage/storage_account.rb +4 -1
- data/lib/fog/azurerm/models/storage/storage_accounts.rb +7 -0
- data/lib/fog/azurerm/models/traffic_manager/traffic_manager_profile.rb +3 -1
- data/lib/fog/azurerm/requests/application_gateway/check_ag_exists.rb +1 -1
- data/lib/fog/azurerm/requests/application_gateway/create_or_update_application_gateway.rb +1 -0
- data/lib/fog/azurerm/requests/compute/attach_data_disk_to_vm.rb +2 -2
- data/lib/fog/azurerm/requests/compute/check_availability_set_exists.rb +1 -1
- data/lib/fog/azurerm/requests/compute/check_managed_disk_exists.rb +1 -1
- data/lib/fog/azurerm/requests/compute/check_vm_exists.rb +1 -1
- data/lib/fog/azurerm/requests/compute/check_vm_extension_exists.rb +2 -2
- data/lib/fog/azurerm/requests/compute/create_availability_set.rb +4 -2
- data/lib/fog/azurerm/requests/compute/create_image.rb +68 -0
- data/lib/fog/azurerm/requests/compute/create_virtual_machine.rb +302 -135
- data/lib/fog/azurerm/requests/compute/delete_image.rb +29 -0
- data/lib/fog/azurerm/requests/compute/get_image.rb +45 -0
- data/lib/fog/azurerm/requests/compute/get_virtual_machine.rb +4 -2
- data/lib/fog/azurerm/requests/dns/check_record_set_exists.rb +1 -1
- data/lib/fog/azurerm/requests/dns/check_zone_exists.rb +3 -2
- data/lib/fog/azurerm/requests/dns/create_or_update_record_set.rb +3 -2
- data/lib/fog/azurerm/requests/dns/create_or_update_zone.rb +1 -2
- data/lib/fog/azurerm/requests/key_vault/check_vault_exists.rb +1 -1
- data/lib/fog/azurerm/requests/key_vault/create_or_update_vault.rb +1 -0
- data/lib/fog/azurerm/requests/network/check_express_route_cir_auth_exists.rb +1 -1
- data/lib/fog/azurerm/requests/network/check_express_route_circuit_exists.rb +1 -1
- data/lib/fog/azurerm/requests/network/check_load_balancer_exists.rb +1 -1
- data/lib/fog/azurerm/requests/network/check_local_net_gateway_exists.rb +1 -1
- data/lib/fog/azurerm/requests/network/check_net_sec_group_exists.rb +1 -1
- data/lib/fog/azurerm/requests/network/check_net_sec_rule_exists.rb +1 -1
- data/lib/fog/azurerm/requests/network/check_network_interface_exists.rb +1 -1
- data/lib/fog/azurerm/requests/network/check_public_ip_exists.rb +1 -1
- data/lib/fog/azurerm/requests/network/check_subnet_exists.rb +1 -1
- data/lib/fog/azurerm/requests/network/check_virtual_network_exists.rb +1 -1
- data/lib/fog/azurerm/requests/network/check_vnet_gateway_connection_exists.rb +1 -1
- data/lib/fog/azurerm/requests/network/check_vnet_gateway_exists.rb +1 -1
- data/lib/fog/azurerm/requests/network/create_load_balancer.rb +4 -4
- data/lib/fog/azurerm/requests/network/create_or_update_express_route_circuit.rb +1 -1
- data/lib/fog/azurerm/requests/network/create_or_update_local_network_gateway.rb +1 -2
- data/lib/fog/azurerm/requests/network/create_or_update_network_interface.rb +4 -3
- data/lib/fog/azurerm/requests/network/create_or_update_network_security_group.rb +4 -3
- data/lib/fog/azurerm/requests/network/create_or_update_public_ip.rb +5 -3
- data/lib/fog/azurerm/requests/network/create_or_update_virtual_network.rb +4 -3
- data/lib/fog/azurerm/requests/network/create_or_update_virtual_network_gateway_connection.rb +1 -1
- data/lib/fog/azurerm/requests/resources/check_azure_resource_exists.rb +4 -4
- data/lib/fog/azurerm/requests/resources/create_resource_group.rb +2 -1
- data/lib/fog/azurerm/requests/resources/delete_resource_tag.rb +4 -4
- data/lib/fog/azurerm/requests/resources/tag_resource.rb +4 -4
- data/lib/fog/azurerm/requests/sql/create_or_update_database.rb +13 -10
- data/lib/fog/azurerm/requests/sql/create_or_update_sql_server.rb +8 -5
- data/lib/fog/azurerm/requests/storage/check_storage_account_exists.rb +1 -1
- data/lib/fog/azurerm/requests/storage/create_storage_account.rb +4 -2
- data/lib/fog/azurerm/requests/traffic_manager/check_traffic_manager_endpoint_exists.rb +1 -1
- data/lib/fog/azurerm/requests/traffic_manager/check_traffic_manager_profile_exists.rb +1 -1
- data/lib/fog/azurerm/requests/traffic_manager/create_or_update_traffic_manager_profile.rb +13 -3
- data/lib/fog/azurerm/storage.rb +0 -18
- data/lib/fog/azurerm/utilities/general.rb +21 -10
- data/lib/fog/azurerm/version.rb +1 -1
- data/rake-script.sh +7 -1
- data/rakefile +1 -1
- data/test/api_stub.rb +19 -2
- data/test/api_stub/models/compute/server.rb +21 -5
- data/test/api_stub/requests/compute/image.rb +41 -0
- data/test/api_stub/requests/compute/virtual_machine.rb +60 -62
- data/test/api_stub/requests/resources/resource_group.rb +1 -1
- data/test/integration/application_gateway.rb +8 -1
- data/test/integration/availability_set.rb +9 -2
- data/test/integration/external_load_balancer.rb +2 -1
- data/test/integration/internal_load_balancer.rb +2 -1
- data/test/integration/key_vault.rb +2 -1
- data/test/integration/managed_disk.rb +10 -5
- data/test/integration/network_interface.rb +2 -1
- data/test/integration/network_security_group.rb +2 -1
- data/test/integration/public_ip.rb +2 -1
- data/test/integration/record_set.rb +5 -5
- data/test/integration/resource_group.rb +5 -2
- data/test/integration/resource_tag.rb +4 -2
- data/test/integration/server.rb +113 -23
- data/test/integration/server_custom_image.rb +120 -20
- data/test/integration/sql_server.rb +10 -2
- data/test/integration/storage_account.rb +32 -20
- data/test/integration/traffic_manager.rb +6 -1
- data/test/integration/virtual_network.rb +2 -1
- data/test/integration/virtual_network_gateway_connection.rb +3 -3
- data/test/models/application_gateway/test_gateway.rb +2 -1
- data/test/models/compute/test_availability_set.rb +2 -1
- data/test/models/compute/test_managed_disk.rb +2 -1
- data/test/models/compute/test_server.rb +13 -4
- data/test/models/dns/test_zone.rb +2 -1
- data/test/models/key_vault/test_vault.rb +2 -1
- data/test/models/network/test_load_balancer.rb +2 -1
- data/test/models/network/test_network_interface.rb +2 -1
- data/test/models/network/test_network_security_group.rb +2 -1
- data/test/models/network/test_public_ip.rb +2 -1
- data/test/models/network/test_virtual_network.rb +2 -1
- data/test/models/resources/test_resource_group.rb +2 -1
- data/test/models/sql/test_database.rb +2 -1
- data/test/models/sql/test_sql_server.rb +2 -1
- data/test/models/storage/test_storage_account.rb +2 -1
- data/test/models/traffic_manager/test_traffic_manager_profile.rb +2 -1
- data/test/requests/application_gateway/test_check_ag_exists.rb +11 -4
- data/test/requests/compute/test_attach_data_disk_to_vm.rb +2 -2
- data/test/requests/compute/test_check_availability_set_exists.rb +9 -2
- data/test/requests/compute/test_check_managed_disk_exists.rb +9 -2
- data/test/requests/compute/test_check_vm_exists.rb +9 -2
- data/test/requests/compute/test_check_vm_extension_exists.rb +9 -2
- data/test/requests/compute/test_create_image.rb +27 -0
- data/test/requests/compute/test_create_virtual_machine.rb +41 -17
- data/test/requests/compute/test_delete_image.rb +23 -0
- data/test/requests/compute/test_get_image.rb +23 -0
- data/test/requests/dns/test_check_record_set_exists.rb +9 -2
- data/test/requests/dns/test_check_zone_exists.rb +16 -2
- data/test/requests/key_vault/test_check_vault_exists.rb +9 -2
- data/test/requests/network/test_check_express_route_cir_auth_exists.rb +9 -2
- data/test/requests/network/test_check_express_route_circuit_exists.rb +9 -2
- data/test/requests/network/test_check_load_balancer_exists.rb +9 -2
- data/test/requests/network/test_check_local_net_gateway_exists.rb +11 -4
- data/test/requests/network/test_check_net_sec_group_exists.rb +9 -2
- data/test/requests/network/test_check_net_sec_rule_exists.rb +9 -2
- data/test/requests/network/test_check_network_interface_exists.rb +9 -2
- data/test/requests/network/test_check_public_ip_exists.rb +9 -2
- data/test/requests/network/test_check_subnet_exists.rb +9 -2
- data/test/requests/network/test_check_virtual_network_exists.rb +10 -4
- data/test/requests/network/test_check_vnet_gateway_connection_exists.rb +9 -2
- data/test/requests/network/test_check_vnet_gateway_exists.rb +9 -2
- data/test/requests/network/test_create_load_balancer.rb +3 -2
- data/test/requests/network/test_create_network_interface.rb +4 -3
- data/test/requests/network/test_create_or_update_network_security_group.rb +3 -2
- data/test/requests/network/test_create_or_update_virtual_network.rb +5 -3
- data/test/requests/network/test_create_public_ip.rb +3 -2
- data/test/requests/network/test_update_public_ip.rb +3 -2
- data/test/requests/resources/test_create_resource_group.rb +3 -2
- data/test/requests/resources/test_delete_resource_tag.rb +3 -3
- data/test/requests/resources/test_tag_resource.rb +3 -3
- data/test/requests/storage/test_check_storage_account_exists.rb +8 -1
- data/test/requests/traffic_manager/test_check_traffic_manager_endpoint_exists.rb +9 -2
- data/test/requests/traffic_manager/test_check_traffic_manager_profile_exists.rb +9 -2
- data/test/test_helper.rb +5 -14
- metadata +67 -75
- data/lib/fog/azurerm/models/storage/recovery_vault.rb +0 -50
- data/lib/fog/azurerm/models/storage/recovery_vaults.rb +0 -27
- data/lib/fog/azurerm/requests/storage/create_or_update_recovery_vault.rb +0 -54
- data/lib/fog/azurerm/requests/storage/delete_recovery_vault.rb +0 -35
- data/lib/fog/azurerm/requests/storage/disable_backup_protection.rb +0 -60
- data/lib/fog/azurerm/requests/storage/enable_backup_protection.rb +0 -61
- data/lib/fog/azurerm/requests/storage/get_all_backup_jobs.rb +0 -56
- data/lib/fog/azurerm/requests/storage/get_backup_container.rb +0 -53
- data/lib/fog/azurerm/requests/storage/get_backup_item.rb +0 -58
- data/lib/fog/azurerm/requests/storage/get_backup_job_for_vm.rb +0 -53
- data/lib/fog/azurerm/requests/storage/get_backup_protection_policy.rb +0 -64
- data/lib/fog/azurerm/requests/storage/get_recovery_vault.rb +0 -49
- data/lib/fog/azurerm/requests/storage/list_recovery_vaults.rb +0 -48
- data/lib/fog/azurerm/requests/storage/set_recovery_vault_context.rb +0 -36
- data/lib/fog/azurerm/requests/storage/start_backup.rb +0 -54
- data/test/api_stub/models/storage/recovery_vault.rb +0 -23
- data/test/api_stub/requests/storage/recovery_vault.rb +0 -189
- data/test/models/storage/test_recovery_vault.rb +0 -61
- data/test/models/storage/test_recovery_vaults.rb +0 -47
- data/test/requests/storage/test_create_recovery_vault.rb +0 -35
- data/test/requests/storage/test_delete_recovery_vault.rb +0 -34
- data/test/requests/storage/test_disable_backup_protection.rb +0 -52
- data/test/requests/storage/test_enable_backup_protection.rb +0 -66
- data/test/requests/storage/test_get_all_backup_jobs.rb +0 -35
- data/test/requests/storage/test_get_backup_container.rb +0 -35
- data/test/requests/storage/test_get_backup_item.rb +0 -35
- data/test/requests/storage/test_get_backup_job_for_vm.rb +0 -26
- data/test/requests/storage/test_get_backup_protection_policy.rb +0 -35
- data/test/requests/storage/test_get_recovery_vault.rb +0 -35
- data/test/requests/storage/test_list_recovery_vault.rb +0 -35
- data/test/requests/storage/test_set_recovery_vault_context.rb +0 -34
- 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.
|
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.
|
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.
|
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.
|
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
|
########################################################################################################################
|
data/test/integration/server.rb
CHANGED
@@ -57,10 +57,10 @@ begin
|
|
57
57
|
)
|
58
58
|
|
59
59
|
network.virtual_networks.create(
|
60
|
-
name:
|
61
|
-
location:
|
62
|
-
resource_group:
|
63
|
-
network_address_list:
|
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
|
96
|
+
puts 'Virtual Machine does NOT exist!' unless flag
|
88
97
|
|
89
98
|
########################################################################################################################
|
90
|
-
######################
|
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
|
-
|
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.
|
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
|
185
|
-
virtual_machines.each do |
|
186
|
-
puts
|
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.
|
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
|
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
|
-
|
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:
|
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:
|
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:
|
61
|
-
location:
|
62
|
-
resource_group:
|
63
|
-
network_address_list:
|
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:
|
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:
|
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/
|
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:
|
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/
|
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:
|
162
|
+
vhd_path: vhd_path,
|
163
|
+
managed_disk_storage_type: Azure::ARM::Compute::Models::StorageAccountTypes::StandardLRS
|
98
164
|
)
|
99
|
-
|
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(
|
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
|
-
|
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
|
-
|
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(
|
217
|
+
storage = storage.storage_accounts.get(RG_NAME, storage_account_name)
|
120
218
|
storage.destroy
|
121
219
|
|
122
|
-
resource_group = rs.resource_groups.get(
|
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?
|