fog-azure-rm-temp 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/fog-azure-rm.gemspec +2 -2
- data/lib/fog/azurerm/constants.rb +3 -1
- data/lib/fog/azurerm/docs/compute.md +10 -4
- data/lib/fog/azurerm/models/compute/availability_set.rb +22 -1
- data/lib/fog/azurerm/models/key_vault/access_policy_entry.rb +0 -4
- data/lib/fog/azurerm/models/network/network_interface.rb +0 -2
- data/lib/fog/azurerm/models/traffic_manager/traffic_manager_profile.rb +1 -1
- data/lib/fog/azurerm/requests/compute/create_availability_set.rb +25 -11
- data/lib/fog/azurerm/utilities/general.rb +1 -1
- data/lib/fog/azurerm/version.rb +1 -1
- data/test/api_stub/models/compute/availability_set.rb +24 -5
- data/test/api_stub/requests/compute/availability_set.rb +60 -3
- data/test/integration/application_gateway.rb +1 -1
- data/test/integration/availability_set.rb +103 -16
- data/test/integration/blob.rb +1 -1
- data/test/integration/container.rb +1 -1
- data/test/integration/data_disk.rb +1 -1
- data/test/integration/deployment.rb +1 -1
- data/test/integration/express_route_circuit.rb +1 -1
- data/test/integration/external_load_balancer.rb +1 -1
- data/test/integration/internal_load_balancer.rb +1 -1
- data/test/integration/key_vault.rb +1 -1
- data/test/integration/local_network_gateway.rb +1 -1
- data/test/integration/managed_disk.rb +1 -1
- data/test/integration/network_interface.rb +1 -1
- data/test/integration/network_security_group.rb +1 -1
- data/test/integration/network_security_rule.rb +1 -1
- data/test/integration/public_ip.rb +1 -1
- data/test/integration/record_set.rb +1 -1
- data/test/integration/resource_group.rb +1 -1
- data/test/integration/resource_tag.rb +1 -1
- data/test/integration/server.rb +1 -1
- data/test/integration/server_custom_image.rb +2 -2
- data/test/integration/sql_server.rb +1 -1
- data/test/integration/storage_account.rb +1 -1
- data/test/integration/subnet.rb +1 -1
- data/test/integration/traffic_manager.rb +1 -1
- data/test/integration/virtual_machine_extension.rb +2 -2
- data/test/integration/virtual_network.rb +1 -1
- data/test/integration/virtual_network_gateway.rb +3 -9
- data/test/integration/{Virtual_network_gateway_connection.rb → virtual_network_gateway_connection.rb} +3 -2
- data/test/integration/virtual_network_gateway_connection_to_express_route.rb +3 -3
- data/test/integration/zone.rb +1 -1
- data/test/models/compute/test_availability_set.rb +4 -2
- data/test/models/key_vault/test_vault.rb +1 -1
- data/test/requests/compute/test_attach_data_disk_to_vm.rb +6 -6
- data/test/requests/compute/test_check_vm_exists.rb +3 -3
- data/test/requests/compute/test_create_availability_set.rb +87 -3
- data/test/requests/compute/test_detach_data_disk_from_vm.rb +2 -2
- data/test/requests/compute/test_get_virtual_machine.rb +2 -2
- data/test/requests/compute/test_get_vm_status.rb +2 -2
- data/test/test_helper.rb +23 -0
- metadata +10 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a20d559af2750fa5accf144e58bfaed3066f527b
|
4
|
+
data.tar.gz: 697b8f3ccf1afe6692add47b3c95ea1fa48cf6de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 563047f630231789c7178dd53c74a71959db9d6ecfb919b1fe0d4291caa8af53f03af922364071ba1543135c88a146542002b19e26d2b565129a625d446f1b59
|
7
|
+
data.tar.gz: e7feaca9e8386910c7025a1abb25000acebbf5e4df79cd97a1d7548e9556e062fc88fe43f104d700407cf0210595cf4ebe0f4b296ebc209f7f3bf7de5fcf3004
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
## 0.3.3
|
2
|
+
|
3
|
+
**Added:**
|
4
|
+
- Compute Service - Added support to create Managed Availability Set
|
5
|
+
|
6
|
+
**Changed:**
|
7
|
+
- Compute Service - Updated default values for fault and update domains
|
8
|
+
- Compute Service - Provided option to configure fault and update domains with reasonable default values
|
9
|
+
|
10
|
+
## 0.3.2
|
11
|
+
|
12
|
+
**Added:**
|
13
|
+
- Compute Service - Made remaining server(virtual machine) methods async
|
14
|
+
|
1
15
|
## 0.3.1
|
2
16
|
|
3
17
|
**Changed:**
|
data/fog-azure-rm.gemspec
CHANGED
@@ -5,7 +5,7 @@ require 'fog/azurerm/version'
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'fog-azure-rm-temp'
|
7
7
|
spec.version = Fog::AzureRM::VERSION
|
8
|
-
spec.authors = ['Shaffan Chaudhry', 'Samawia Moin', 'Adnan Khalil', 'Zeeshan Arshad', 'Haider Ali', 'Waqar Haider', 'Bilal Naeem']
|
8
|
+
spec.authors = ['Shaffan Chaudhry', 'Samawia Moin', 'Adnan Khalil', 'Zeeshan Arshad', 'Haider Ali', 'Waqar Haider', 'Bilal Naeem', 'Muhammad Asad', 'Azeem Sajid', 'Maham Nazir', 'Abbas Sheikh']
|
9
9
|
spec.summary = "Module for the 'fog' gem to support Azure Resource Manager cloud services."
|
10
10
|
spec.description = "This library can be used as a module for 'fog' or as standalone provider
|
11
11
|
to use the Azure Resource Manager cloud services in applications.."
|
@@ -32,6 +32,6 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.add_dependency 'azure_mgmt_traffic_manager', '~> 0.9.0'
|
33
33
|
spec.add_dependency 'azure_mgmt_sql', '~> 0.9.0'
|
34
34
|
spec.add_dependency 'azure_mgmt_key_vault', '~> 0.9.0'
|
35
|
-
spec.add_dependency 'azure-storage', '
|
35
|
+
spec.add_dependency 'azure-storage', '= 0.11.5.preview'
|
36
36
|
spec.add_dependency 'vhd', '0.0.4'
|
37
37
|
end
|
@@ -7,7 +7,7 @@ STANDARD_STORAGE = 'Standard'.freeze
|
|
7
7
|
PREMIUM_STORAGE = 'Premium'.freeze
|
8
8
|
ALLOWED_STANDARD_REPLICATION = %w(LRS ZRS GRS RAGRS).freeze
|
9
9
|
API_VERSION = '2016-06-01'.freeze
|
10
|
-
FAULT_DOMAIN_COUNT =
|
10
|
+
FAULT_DOMAIN_COUNT = 2
|
11
11
|
UPDATE_DOMAIN_COUNT = 5
|
12
12
|
WINDOWS = 'windows'.freeze
|
13
13
|
VPN = 'Vpn'.freeze
|
@@ -59,3 +59,5 @@ MAXIMUM_CHUNK_SIZE = 4 * 1024 * 1024
|
|
59
59
|
# The hash value of 4MB empty content
|
60
60
|
HASH_OF_4MB_EMPTY_CONTENT = 'b5cfa9d6c8febd618f91ac2843d50a1c'.freeze
|
61
61
|
REST_CLIENT_API_VERSION = %w(2014-04-01-preview 2016-05-01).freeze
|
62
|
+
AS_SKU_CLASSIC = 'Classic'.freeze
|
63
|
+
AS_SKU_ALIGNED = 'Aligned'.freeze
|
@@ -52,6 +52,7 @@ When using **managed_disk_storage_type** you should not pass the **vhd_path** as
|
|
52
52
|
password: '<Password for VM>', # Optional, if 'platform' partameter is 'Linux'.
|
53
53
|
disable_password_authentication: false,
|
54
54
|
network_interface_card_ids: ['/subscriptions/{Subscription-Id}/resourceGroups/{Resource-Group-Name}/providers/Microsoft.Network/networkInterfaces/{Network-Interface-Id}'],
|
55
|
+
availability_set_id: '<availability_set_id>', # Optional
|
55
56
|
publisher: 'Canonical', # Not required if custom image is being used
|
56
57
|
offer: 'UbuntuServer', # Not required if custom image is being used
|
57
58
|
sku: '14.04.2-LTS', # Not required if custom image is being used
|
@@ -77,6 +78,7 @@ Create a new windows server
|
|
77
78
|
password: '<Password for VM>',
|
78
79
|
disable_password_authentication: false,
|
79
80
|
network_interface_card_ids: ['/subscriptions/{Subscription-Id}/resourceGroups/{Resource-Group-Name}/providers/Microsoft.Network/networkInterfaces/{Network-Interface-Id}'],
|
81
|
+
availability_set_id: '<availability_set_id>', # Optional
|
80
82
|
publisher: 'MicrosoftWindowsServerEssentials', # Not required if custom image is being used
|
81
83
|
offer: 'WindowsServerEssentials', # Not required if custom image is being used
|
82
84
|
sku: 'WindowsServerEssentials', # Not required if custom image is being used
|
@@ -103,6 +105,7 @@ Create a new linux server asynchronously
|
|
103
105
|
password: '<Password for VM>', # Optional, if 'platform' partameter is 'Linux'.
|
104
106
|
disable_password_authentication: false,
|
105
107
|
network_interface_card_ids: ['/subscriptions/{Subscription-Id}/resourceGroups/{Resource-Group-Name}/providers/Microsoft.Network/networkInterfaces/{Network-Interface-Id}'],
|
108
|
+
availability_set_id: '<availability_set_id>', # Optional
|
106
109
|
publisher: 'Canonical', # Not required if custom image is being used
|
107
110
|
offer: 'UbuntuServer', # Not required if custom image is being used
|
108
111
|
sku: '14.04.2-LTS', # Not required if custom image is being used
|
@@ -216,10 +219,13 @@ azure_compute_service.availability_sets.check_availability_set_exists(<Resource
|
|
216
219
|
Create a new availability set
|
217
220
|
|
218
221
|
```ruby
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
222
|
+
azure_compute_service.availability_sets.create(
|
223
|
+
name: '<Availability Set name>',
|
224
|
+
location: '<Location>',
|
225
|
+
resource_group: '<Resource Group name>'
|
226
|
+
platform_fault_domain_count: <No of Fault Domains>, # [Optional] Default => { Managed: 2, Unmanaged: 3 }
|
227
|
+
platform_update_domain_count: <No of Update Domains>, # [Optional] Default => { Managed: 5, Unmanaged: 5 }
|
228
|
+
is_managed: true # [Optional] Possible values true or false
|
223
229
|
)
|
224
230
|
```
|
225
231
|
## List Availability Sets
|
@@ -11,6 +11,8 @@ module Fog
|
|
11
11
|
attribute :resource_group
|
12
12
|
attribute :platform_update_domain_count
|
13
13
|
attribute :platform_fault_domain_count
|
14
|
+
attribute :is_managed
|
15
|
+
attribute :sku_name
|
14
16
|
|
15
17
|
def self.parse(availability_set)
|
16
18
|
hash = {}
|
@@ -21,6 +23,12 @@ module Fog
|
|
21
23
|
hash['resource_group'] = get_resource_group_from_id(availability_set.id)
|
22
24
|
hash['platform_update_domain_count'] = availability_set.platform_update_domain_count
|
23
25
|
hash['platform_fault_domain_count'] = availability_set.platform_fault_domain_count
|
26
|
+
|
27
|
+
unless availability_set.sku.nil?
|
28
|
+
hash['sku_name'] = availability_set.sku.name
|
29
|
+
hash['is_managed'] = availability_set.sku.name.eql?(AS_SKU_ALIGNED)
|
30
|
+
end
|
31
|
+
|
24
32
|
hash
|
25
33
|
end
|
26
34
|
|
@@ -29,7 +37,7 @@ module Fog
|
|
29
37
|
requires :location
|
30
38
|
requires :resource_group
|
31
39
|
# need to create the availability set
|
32
|
-
as = service.create_availability_set(
|
40
|
+
as = service.create_availability_set(avail_set_params(platform_fault_domain_count, platform_update_domain_count, is_managed))
|
33
41
|
hash = Fog::Compute::AzureRM::AvailabilitySet.parse(as)
|
34
42
|
merge_attributes(hash)
|
35
43
|
end
|
@@ -37,6 +45,19 @@ module Fog
|
|
37
45
|
def destroy
|
38
46
|
service.delete_availability_set(resource_group, name)
|
39
47
|
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def avail_set_params(platform_fault_domain_count, platform_update_domain_count, is_managed)
|
52
|
+
{
|
53
|
+
name: name,
|
54
|
+
location: location,
|
55
|
+
resource_group: resource_group,
|
56
|
+
platform_fault_domain_count: platform_fault_domain_count,
|
57
|
+
platform_update_domain_count: platform_update_domain_count,
|
58
|
+
is_managed: is_managed
|
59
|
+
}
|
60
|
+
end
|
40
61
|
end
|
41
62
|
end
|
42
63
|
end
|
@@ -22,7 +22,6 @@ module Fog
|
|
22
22
|
attribute :applied_dns_servers
|
23
23
|
attribute :internal_dns_name_label
|
24
24
|
attribute :internal_fqd
|
25
|
-
attribute :type
|
26
25
|
|
27
26
|
def self.parse(nic)
|
28
27
|
hash = {}
|
@@ -34,7 +33,6 @@ module Fog
|
|
34
33
|
hash['mac_address'] = nic.mac_address unless nic.mac_address.nil?
|
35
34
|
hash['network_security_group_id'] = nil
|
36
35
|
hash['network_security_group_id'] = nic.network_security_group.id unless nic.network_security_group.nil?
|
37
|
-
hash['type'] = nic.type
|
38
36
|
ip_configuration = nic.ip_configurations[0] unless nic.ip_configurations.nil?
|
39
37
|
unless ip_configuration.nil?
|
40
38
|
hash['ip_configuration_name'] = ip_configuration.name
|
@@ -55,7 +55,7 @@ module Fog
|
|
55
55
|
|
56
56
|
def update(profile_params)
|
57
57
|
validate_input(profile_params)
|
58
|
-
profile_params[:endpoints] = endpoints.map { |endpoint| get_hash_from_object(endpoint)['attributes'] }
|
58
|
+
profile_params[:endpoints] = endpoints.map { |endpoint| get_hash_from_object(endpoint)['attributes'] } unless endpoints.nil?
|
59
59
|
merge_attributes(profile_params)
|
60
60
|
profile = service.create_or_update_traffic_manager_profile(traffic_manager_profile_hash)
|
61
61
|
merge_attributes(Fog::TrafficManager::AzureRM::TrafficManagerProfile.parse(profile))
|
@@ -3,10 +3,18 @@ module Fog
|
|
3
3
|
class AzureRM
|
4
4
|
# This class provides the actual implementation for service calls.
|
5
5
|
class Real
|
6
|
-
def create_availability_set(
|
6
|
+
def create_availability_set(availability_set_params)
|
7
|
+
name = availability_set_params[:name]
|
8
|
+
location = availability_set_params[:location]
|
9
|
+
resource_group = availability_set_params[:resource_group]
|
10
|
+
fault_domain_count = availability_set_params[:platform_fault_domain_count]
|
11
|
+
update_domain_count = availability_set_params[:platform_update_domain_count]
|
12
|
+
is_managed = availability_set_params[:is_managed].nil? ? false : availability_set_params[:is_managed]
|
13
|
+
|
7
14
|
msg = "Creating Availability Set '#{name}' in #{location} region."
|
8
15
|
Fog::Logger.debug msg
|
9
|
-
avail_set_params = get_availability_set_properties(location)
|
16
|
+
avail_set_params = get_availability_set_properties(location, fault_domain_count, update_domain_count, is_managed)
|
17
|
+
|
10
18
|
begin
|
11
19
|
availability_set = @compute_mgmt_client.availability_sets.create_or_update(resource_group, name, avail_set_params)
|
12
20
|
rescue MsRestAzure::AzureOperationError => e
|
@@ -17,23 +25,29 @@ module Fog
|
|
17
25
|
end
|
18
26
|
|
19
27
|
# create the properties object for creating availability sets
|
20
|
-
def get_availability_set_properties(location)
|
28
|
+
def get_availability_set_properties(location, fault_domain_count, update_domain_count, is_managed)
|
21
29
|
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 = []
|
26
30
|
avail_set.location = location
|
31
|
+
avail_set.sku = create_availability_set_sku(is_managed)
|
32
|
+
avail_set.platform_fault_domain_count = fault_domain_count.nil? ? FAULT_DOMAIN_COUNT : fault_domain_count
|
33
|
+
avail_set.platform_update_domain_count = update_domain_count.nil? ? UPDATE_DOMAIN_COUNT : update_domain_count
|
27
34
|
avail_set
|
28
35
|
end
|
36
|
+
|
37
|
+
def create_availability_set_sku(is_managed)
|
38
|
+
sku = Azure::ARM::Compute::Models::Sku.new
|
39
|
+
sku.name = is_managed ? AS_SKU_ALIGNED : AS_SKU_CLASSIC
|
40
|
+
sku
|
41
|
+
end
|
29
42
|
end
|
43
|
+
|
30
44
|
# This class provides the mock implementation for unit tests.
|
31
45
|
class Mock
|
32
|
-
def create_availability_set(
|
46
|
+
def create_availability_set(availability_set_params)
|
33
47
|
{
|
34
|
-
'location' => location,
|
35
|
-
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group}/providers/Microsoft.Compute/availabilitySets/#{name}",
|
36
|
-
'name' => name,
|
48
|
+
'location' => availability_set_params[:location],
|
49
|
+
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{availability_set_params[:resource_group]}/providers/Microsoft.Compute/availabilitySets/#{availability_set_params[:name]}",
|
50
|
+
'name' => availability_set_params[:name],
|
37
51
|
'type' => 'Microsoft.Compute/availabilitySets',
|
38
52
|
'properties' =>
|
39
53
|
{
|
@@ -55,7 +55,7 @@ def raise_azure_exception(exception, msg)
|
|
55
55
|
end
|
56
56
|
exception_message = "Exception in #{msg} #{message} Type: #{exception.class}\n#{exception.backtrace.join("\n")}"
|
57
57
|
else
|
58
|
-
"#{exception.inspect}\n#{exception.backtrace.join("\n")}"
|
58
|
+
exception_message = "#{exception.inspect}\n#{exception.backtrace.join("\n")}"
|
59
59
|
end
|
60
60
|
|
61
61
|
Fog::Logger.debug exception.backtrace
|
data/lib/fog/azurerm/version.rb
CHANGED
@@ -3,15 +3,33 @@ module ApiStub
|
|
3
3
|
module Compute
|
4
4
|
# Mock class for Availability Set Model
|
5
5
|
class AvailabilitySet
|
6
|
-
def self.
|
6
|
+
def self.create_unmanaged_availability_set_response(sdk_compute_client)
|
7
7
|
avail_set = {
|
8
8
|
'id' => '/subscriptions/########-####-####-####-############/resourceGroups/fog-test-rg/providers/Microsoft.Compute/availabilitySets/fog-test-availability-set',
|
9
9
|
'name' => 'fog-test-availability-set',
|
10
10
|
'type' => 'Microsoft.Compute/availabilitySets',
|
11
11
|
'location' => 'westus',
|
12
12
|
'platformUpdateDomainCount' => UPDATE_DOMAIN_COUNT,
|
13
|
-
'platformFaultDomainCount' => FAULT_DOMAIN_COUNT
|
13
|
+
'platformFaultDomainCount' => FAULT_DOMAIN_COUNT,
|
14
|
+
'sku' => {
|
15
|
+
'name' => 'Classic'
|
16
|
+
}
|
17
|
+
}
|
18
|
+
result_mapper = Azure::ARM::Compute::Models::AvailabilitySet.mapper
|
19
|
+
sdk_compute_client.deserialize(result_mapper, avail_set, 'result.body')
|
20
|
+
end
|
14
21
|
|
22
|
+
def self.create_managed_availability_set_response(sdk_compute_client)
|
23
|
+
avail_set = {
|
24
|
+
'id' => '/subscriptions/########-####-####-####-############/resourceGroups/fog-test-rg/providers/Microsoft.Compute/availabilitySets/fog-test-availability-set',
|
25
|
+
'name' => 'fog-test-availability-set',
|
26
|
+
'type' => 'Microsoft.Compute/availabilitySets',
|
27
|
+
'location' => 'westus',
|
28
|
+
'platformUpdateDomainCount' => UPDATE_DOMAIN_COUNT,
|
29
|
+
'platformFaultDomainCount' => FAULT_DOMAIN_COUNT,
|
30
|
+
'sku' => {
|
31
|
+
'name' => 'Aligned'
|
32
|
+
}
|
15
33
|
}
|
16
34
|
result_mapper = Azure::ARM::Compute::Models::AvailabilitySet.mapper
|
17
35
|
sdk_compute_client.deserialize(result_mapper, avail_set, 'result.body')
|
@@ -25,7 +43,6 @@ module ApiStub
|
|
25
43
|
'location' => 'westus',
|
26
44
|
'platformUpdateDomainCount' => UPDATE_DOMAIN_COUNT,
|
27
45
|
'platformFaultDomainCount' => FAULT_DOMAIN_COUNT
|
28
|
-
|
29
46
|
}
|
30
47
|
result_mapper = Azure::ARM::Compute::Models::AvailabilitySet.mapper
|
31
48
|
sdk_compute_client.deserialize(result_mapper, avail_set, 'result.body')
|
@@ -38,8 +55,10 @@ module ApiStub
|
|
38
55
|
'type' => 'Microsoft.Compute/availabilitySets',
|
39
56
|
'location' => 'westus',
|
40
57
|
'platformUpdateDomainCount' => UPDATE_DOMAIN_COUNT,
|
41
|
-
'platformFaultDomainCount' => FAULT_DOMAIN_COUNT
|
42
|
-
|
58
|
+
'platformFaultDomainCount' => FAULT_DOMAIN_COUNT,
|
59
|
+
'sku' => {
|
60
|
+
'name' => 'Classic'
|
61
|
+
}
|
43
62
|
}
|
44
63
|
result_mapper = Azure::ARM::Compute::Models::AvailabilitySet.mapper
|
45
64
|
sdk_compute_client.deserialize(result_mapper, avail_set, 'result.body')
|
@@ -3,6 +3,42 @@ module ApiStub
|
|
3
3
|
module Compute
|
4
4
|
# Mock class for Availability Set Requests
|
5
5
|
class AvailabilitySet
|
6
|
+
def self.create_unmanaged_availability_set_response(compute_client)
|
7
|
+
body = '{
|
8
|
+
"id":"/subscriptions/{subscription-id}/resourceGroups/myrg1/providers/Microsoft.Compute/availabilitySets/avset1",
|
9
|
+
"name":"myavset1",
|
10
|
+
"type":"Microsoft.Compute/availabilitySets",
|
11
|
+
"location":"westus",
|
12
|
+
"tags": {},
|
13
|
+
"platformUpdateDomainCount": 5,
|
14
|
+
"platformFaultDomainCount": 3,
|
15
|
+
"virtualMachines":[],
|
16
|
+
"sku":{
|
17
|
+
"name":"Classic"
|
18
|
+
}
|
19
|
+
}'
|
20
|
+
availability_set_mapper = Azure::ARM::Compute::Models::AvailabilitySet.mapper
|
21
|
+
compute_client.deserialize(availability_set_mapper, Fog::JSON.decode(body), 'result.body')
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.create_managed_availability_set_response(compute_client)
|
25
|
+
body = '{
|
26
|
+
"id":"/subscriptions/{subscription-id}/resourceGroups/myrg1/providers/Microsoft.Compute/availabilitySets/avset1",
|
27
|
+
"name":"myavset1",
|
28
|
+
"type":"Microsoft.Compute/availabilitySets",
|
29
|
+
"location":"westus",
|
30
|
+
"tags": {},
|
31
|
+
"platformUpdateDomainCount": 5,
|
32
|
+
"platformFaultDomainCount": 2,
|
33
|
+
"virtualMachines":[],
|
34
|
+
"sku":{
|
35
|
+
"name":"Aligned"
|
36
|
+
}
|
37
|
+
}'
|
38
|
+
availability_set_mapper = Azure::ARM::Compute::Models::AvailabilitySet.mapper
|
39
|
+
compute_client.deserialize(availability_set_mapper, Fog::JSON.decode(body), 'result.body')
|
40
|
+
end
|
41
|
+
|
6
42
|
def self.create_availability_set_response(compute_client)
|
7
43
|
body = '{
|
8
44
|
"id":"/subscriptions/{subscription-id}/resourceGroups/myrg1/providers/Microsoft.Compute/availabilitySets/avset1",
|
@@ -11,7 +47,22 @@ module ApiStub
|
|
11
47
|
"location":"westus",
|
12
48
|
"tags": {},
|
13
49
|
"platformUpdateDomainCount": 5,
|
14
|
-
"platformFaultDomainCount":3,
|
50
|
+
"platformFaultDomainCount": 3,
|
51
|
+
"virtualMachines":[]
|
52
|
+
}'
|
53
|
+
availability_set_mapper = Azure::ARM::Compute::Models::AvailabilitySet.mapper
|
54
|
+
compute_client.deserialize(availability_set_mapper, Fog::JSON.decode(body), 'result.body')
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.create_custom_availability_set_response(compute_client)
|
58
|
+
body = '{
|
59
|
+
"id":"/subscriptions/{subscription-id}/resourceGroups/myrg1/providers/Microsoft.Compute/availabilitySets/avset1",
|
60
|
+
"name":"myavset1",
|
61
|
+
"type":"Microsoft.Compute/availabilitySets",
|
62
|
+
"location":"westus",
|
63
|
+
"tags": {},
|
64
|
+
"platformUpdateDomainCount": 10,
|
65
|
+
"platformFaultDomainCount": 3,
|
15
66
|
"virtualMachines":[]
|
16
67
|
}'
|
17
68
|
availability_set_mapper = Azure::ARM::Compute::Models::AvailabilitySet.mapper
|
@@ -28,7 +79,10 @@ module ApiStub
|
|
28
79
|
"tags": {},
|
29
80
|
"platformUpdateDomainCount":5,
|
30
81
|
"platformFaultDomainCount":3,
|
31
|
-
"virtualMachines":[]
|
82
|
+
"virtualMachines":[],
|
83
|
+
"sku":{
|
84
|
+
"name":"Classic"
|
85
|
+
}
|
32
86
|
} ]
|
33
87
|
}'
|
34
88
|
availability_set_mapper = Azure::ARM::Compute::Models::AvailabilitySetListResult.mapper
|
@@ -45,7 +99,10 @@ module ApiStub
|
|
45
99
|
"tags": {},
|
46
100
|
"platformUpdateDomainCount":5,
|
47
101
|
"platformFaultDomainCount":3,
|
48
|
-
"virtualMachines":[]
|
102
|
+
"virtualMachines":[],
|
103
|
+
"sku":{
|
104
|
+
"name":"Classic"
|
105
|
+
}
|
49
106
|
} ]
|
50
107
|
}'
|
51
108
|
availability_set_mapper = Azure::ARM::Compute::Models::AvailabilitySet.mapper
|
@@ -6,7 +6,7 @@ require 'yaml'
|
|
6
6
|
###################### Keep it Uncommented! ######################
|
7
7
|
########################################################################################################################
|
8
8
|
|
9
|
-
azure_credentials = YAML.load_file('credentials/azure.yml')
|
9
|
+
azure_credentials = YAML.load_file(File.expand_path('credentials/azure.yml', __dir__))
|
10
10
|
|
11
11
|
resource = Fog::Resources::AzureRM.new(
|
12
12
|
tenant_id: azure_credentials['tenant_id'],
|
@@ -6,7 +6,7 @@ require 'yaml'
|
|
6
6
|
###################### Keep it Uncommented! ######################
|
7
7
|
########################################################################################################################
|
8
8
|
|
9
|
-
azure_credentials = YAML.load_file('credentials/azure.yml')
|
9
|
+
azure_credentials = YAML.load_file(File.expand_path('credentials/azure.yml', __dir__))
|
10
10
|
|
11
11
|
rs = Fog::Resources::AzureRM.new(
|
12
12
|
tenant_id: azure_credentials['tenant_id'],
|
@@ -29,41 +29,114 @@ compute = Fog::Compute::AzureRM.new(
|
|
29
29
|
########################################################################################################################
|
30
30
|
|
31
31
|
time = current_time
|
32
|
-
resource_group_name
|
33
|
-
|
32
|
+
resource_group_name = "AS-RG-#{time}"
|
33
|
+
unmanaged_as_name_default = "ASUnmanagedDefault#{time}"
|
34
|
+
unmanaged_as_name_custom = "ASUnmanagedCustom#{time}"
|
35
|
+
managed_as_name_default = "ASManagedDefault#{time}"
|
36
|
+
managed_as_name_custom = "ASManagedCustom#{time}"
|
34
37
|
|
35
38
|
########################################################################################################################
|
36
39
|
###################### Prerequisites ######################
|
37
40
|
########################################################################################################################
|
38
41
|
|
39
42
|
begin
|
43
|
+
puts 'Running integration test for availability set...'
|
44
|
+
|
45
|
+
puts "Create resource group (#{resource_group_name}):"
|
40
46
|
resource_group = rs.resource_groups.create(
|
41
47
|
name: resource_group_name,
|
42
48
|
location: LOCATION
|
43
49
|
)
|
44
|
-
|
50
|
+
puts "Created resource group! [#{resource_group.name}]"
|
45
51
|
|
46
52
|
########################################################################################################################
|
47
|
-
###################### Check for Availability set
|
53
|
+
###################### Check for Availability set ######################
|
48
54
|
########################################################################################################################
|
49
55
|
|
50
|
-
|
51
|
-
|
56
|
+
puts 'Check for existing availability sets:'
|
57
|
+
|
58
|
+
is_exists = compute.availability_sets.check_availability_set_exists(resource_group_name, unmanaged_as_name_default)
|
59
|
+
puts "Availability set does NOT exist! [#{unmanaged_as_name_default}] " unless is_exists
|
60
|
+
|
61
|
+
is_exists = compute.availability_sets.check_availability_set_exists(resource_group_name, unmanaged_as_name_custom)
|
62
|
+
puts "Availability set does NOT exist! [#{unmanaged_as_name_custom}] " unless is_exists
|
63
|
+
|
64
|
+
is_exists = compute.availability_sets.check_availability_set_exists(resource_group_name, managed_as_name_default)
|
65
|
+
puts "Availability set does NOT exist! [#{managed_as_name_default}] " unless is_exists
|
66
|
+
|
67
|
+
is_exists = compute.availability_sets.check_availability_set_exists(resource_group_name, managed_as_name_custom)
|
68
|
+
puts "Availability set does NOT exist! [#{managed_as_name_default}] " unless is_exists
|
52
69
|
|
53
70
|
########################################################################################################################
|
54
|
-
######################
|
71
|
+
###################### Create Unmanaged Availability Set (Default) ######################
|
55
72
|
########################################################################################################################
|
56
73
|
|
74
|
+
puts "Create unmanaged default availability set (#{unmanaged_as_name_default}):"
|
57
75
|
avail_set = compute.availability_sets.create(
|
58
|
-
name:
|
76
|
+
name: unmanaged_as_name_default,
|
59
77
|
location: LOCATION,
|
60
78
|
resource_group: resource_group_name
|
61
79
|
)
|
62
|
-
|
80
|
+
name = avail_set.name
|
81
|
+
fault_domains = avail_set.platform_fault_domain_count
|
82
|
+
update_domains = avail_set.platform_update_domain_count
|
83
|
+
puts "Created availability set! [#{name}] => { fd: #{fault_domains}, ud: #{update_domains} }"
|
84
|
+
|
85
|
+
########################################################################################################################
|
86
|
+
###################### Create Unmanaged Availability Set (Custom) ######################
|
87
|
+
########################################################################################################################
|
88
|
+
|
89
|
+
puts "Create unmanaged custom availability set (#{unmanaged_as_name_custom}):"
|
90
|
+
avail_set = compute.availability_sets.create(
|
91
|
+
name: unmanaged_as_name_custom,
|
92
|
+
location: LOCATION,
|
93
|
+
resource_group: resource_group_name,
|
94
|
+
platform_fault_domain_count: 3,
|
95
|
+
platform_update_domain_count: 10
|
96
|
+
)
|
97
|
+
name = avail_set.name
|
98
|
+
fault_domains = avail_set.platform_fault_domain_count
|
99
|
+
update_domains = avail_set.platform_update_domain_count
|
100
|
+
puts "Created availability set! [#{name}] => { fd: #{fault_domains}, ud: #{update_domains} }"
|
101
|
+
|
102
|
+
########################################################################################################################
|
103
|
+
###################### Create Managed Availability Set (Default) ######################
|
104
|
+
########################################################################################################################
|
105
|
+
|
106
|
+
puts "Create managed default availability set (#{managed_as_name_default}):"
|
107
|
+
avail_set = compute.availability_sets.create(
|
108
|
+
name: managed_as_name_default,
|
109
|
+
location: LOCATION,
|
110
|
+
resource_group: resource_group_name,
|
111
|
+
is_managed: true
|
112
|
+
)
|
113
|
+
name = avail_set.name
|
114
|
+
fault_domains = avail_set.platform_fault_domain_count
|
115
|
+
update_domains = avail_set.platform_update_domain_count
|
116
|
+
puts "Created availability set! [#{name}] => { fd: #{fault_domains}, ud: #{update_domains} }"
|
117
|
+
|
118
|
+
########################################################################################################################
|
119
|
+
###################### Create Managed Availability Set (Custom) ######################
|
120
|
+
########################################################################################################################
|
121
|
+
|
122
|
+
puts "Create managed custom availability set (#{managed_as_name_custom}):"
|
123
|
+
avail_set = compute.availability_sets.create(
|
124
|
+
name: managed_as_name_custom,
|
125
|
+
location: LOCATION,
|
126
|
+
resource_group: resource_group_name,
|
127
|
+
platform_fault_domain_count: 2,
|
128
|
+
platform_update_domain_count: 10,
|
129
|
+
is_managed: true
|
130
|
+
)
|
131
|
+
name = avail_set.name
|
132
|
+
fault_domains = avail_set.platform_fault_domain_count
|
133
|
+
update_domains = avail_set.platform_update_domain_count
|
134
|
+
puts "Created availability set! [#{name}] => { fd: #{fault_domains}, ud: #{update_domains} }"
|
63
135
|
|
64
136
|
########################################################################################################################
|
65
137
|
###################### List Availability Sets ######################
|
66
138
|
########################################################################################################################
|
139
|
+
|
67
140
|
puts 'List availability sets:'
|
68
141
|
compute.availability_sets(resource_group: resource_group_name).each do |availability_set|
|
69
142
|
puts availability_set.name
|
@@ -73,18 +146,32 @@ begin
|
|
73
146
|
###################### Get and Delete Availability Set ######################
|
74
147
|
########################################################################################################################
|
75
148
|
|
76
|
-
|
77
|
-
|
78
|
-
|
149
|
+
puts 'Get and delete availability sets:'
|
150
|
+
|
151
|
+
avail_set = compute.availability_sets.get(resource_group_name, unmanaged_as_name_default)
|
152
|
+
puts "Get availability set : #{avail_set.name}"
|
153
|
+
puts "Deleted availability set : #{avail_set.destroy}"
|
154
|
+
|
155
|
+
avail_set = compute.availability_sets.get(resource_group_name, unmanaged_as_name_custom)
|
156
|
+
puts "Get availability set : #{avail_set.name}"
|
157
|
+
puts "Deleted availability set : #{avail_set.destroy}"
|
158
|
+
|
159
|
+
avail_set = compute.availability_sets.get(resource_group_name, managed_as_name_default)
|
160
|
+
puts "Get availability set : #{avail_set.name}"
|
161
|
+
puts "Deleted availability set : #{avail_set.destroy}"
|
162
|
+
|
163
|
+
avail_set = compute.availability_sets.get(resource_group_name, managed_as_name_custom)
|
164
|
+
puts "Get availability set : #{avail_set.name}"
|
165
|
+
puts "Deleted availability set : #{avail_set.destroy}"
|
79
166
|
|
80
167
|
########################################################################################################################
|
81
|
-
######################
|
168
|
+
###################### Clean Up ######################
|
82
169
|
########################################################################################################################
|
83
170
|
|
84
171
|
rg = rs.resource_groups.get(resource_group_name)
|
85
172
|
rg.destroy
|
86
|
-
puts 'Integration
|
173
|
+
puts 'Integration test for availability set ran successfully!'
|
87
174
|
rescue
|
88
|
-
puts 'Integration Test for availability set is failing'
|
175
|
+
puts 'Integration Test for availability set is failing!!!'
|
89
176
|
resource_group.destroy unless resource_group.nil?
|
90
177
|
end
|