fog-azure-rm 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +64 -0
- data/README.md +5 -0
- data/lib/fog/azurerm.rb +10 -10
- data/lib/fog/azurerm/compute.rb +9 -1
- data/lib/fog/azurerm/config.rb +1 -1
- data/lib/fog/azurerm/core.rb +1 -0
- data/lib/fog/azurerm/credentials.rb +4 -4
- data/lib/fog/azurerm/dns.rb +9 -5
- data/lib/fog/azurerm/models/compute/availability_set.rb +0 -2
- data/lib/fog/azurerm/models/compute/availability_sets.rb +0 -1
- data/lib/fog/azurerm/models/compute/data_disk.rb +26 -0
- data/lib/fog/azurerm/models/compute/server.rb +46 -9
- data/lib/fog/azurerm/models/compute/servers.rb +4 -4
- data/lib/fog/azurerm/models/dns/record_set.rb +13 -13
- data/lib/fog/azurerm/models/network/application_gateway.rb +456 -0
- data/lib/fog/azurerm/models/network/application_gateway_backend_address_pool.rb +24 -0
- data/lib/fog/azurerm/models/network/application_gateway_backend_http_setting.rb +30 -0
- data/lib/fog/azurerm/models/network/application_gateway_frontend_ip_configuration.rb +30 -0
- data/lib/fog/azurerm/models/network/application_gateway_frontend_port.rb +22 -0
- data/lib/fog/azurerm/models/network/application_gateway_http_listener.rb +37 -0
- data/lib/fog/azurerm/models/network/application_gateway_ip_configuration.rb +21 -0
- data/lib/fog/azurerm/models/network/application_gateway_probe.rb +32 -0
- data/lib/fog/azurerm/models/network/application_gateway_request_routing_rule.rb +35 -0
- data/lib/fog/azurerm/models/network/application_gateway_ssl_certificate.rb +26 -0
- data/lib/fog/azurerm/models/network/application_gateway_url_path_map.rb +32 -0
- data/lib/fog/azurerm/models/network/application_gateways.rb +27 -0
- data/lib/fog/azurerm/models/network/load_balancer.rb +2 -2
- data/lib/fog/azurerm/models/network/network_interface.rb +3 -3
- data/lib/fog/azurerm/models/network/path_rule.rb +30 -0
- data/lib/fog/azurerm/models/network/subnet.rb +1 -1
- data/lib/fog/azurerm/models/network/virtual_network.rb +2 -0
- data/lib/fog/azurerm/models/network/virtual_networks.rb +2 -0
- data/lib/fog/azurerm/models/resources/resource_group.rb +2 -0
- data/lib/fog/azurerm/models/resources/resource_groups.rb +2 -0
- data/lib/fog/azurerm/models/storage/storage_accounts.rb +1 -1
- data/lib/fog/azurerm/network.rb +16 -0
- data/lib/fog/azurerm/requests/compute/attach_data_disk_to_vm.rb +160 -0
- data/lib/fog/azurerm/requests/compute/check_vm_status.rb +40 -0
- data/lib/fog/azurerm/requests/compute/create_availability_set.rb +5 -8
- data/lib/fog/azurerm/requests/compute/create_virtual_machine.rb +78 -59
- data/lib/fog/azurerm/requests/compute/deallocate_virtual_machine.rb +1 -1
- data/lib/fog/azurerm/requests/compute/delete_availability_set.rb +1 -1
- data/lib/fog/azurerm/requests/compute/delete_virtual_machine.rb +1 -1
- data/lib/fog/azurerm/requests/compute/detach_data_disk_from_vm.rb +94 -0
- data/lib/fog/azurerm/requests/compute/generalize_virtual_machine.rb +1 -1
- data/lib/fog/azurerm/requests/compute/get_virtual_machine.rb +53 -54
- data/lib/fog/azurerm/requests/compute/list_availability_sets.rb +11 -11
- data/lib/fog/azurerm/requests/compute/list_available_sizes_for_virtual_machine.rb +20 -20
- data/lib/fog/azurerm/requests/compute/list_virtual_machines.rb +3 -3
- data/lib/fog/azurerm/requests/compute/power_off_virtual_machine.rb +1 -1
- data/lib/fog/azurerm/requests/compute/redeploy_virtual_machine.rb +1 -1
- data/lib/fog/azurerm/requests/compute/restart_virtual_machine.rb +1 -1
- data/lib/fog/azurerm/requests/compute/start_virtual_machine.rb +1 -1
- data/lib/fog/azurerm/requests/dns/check_for_zone.rb +6 -5
- data/lib/fog/azurerm/requests/dns/create_record_set.rb +29 -28
- data/lib/fog/azurerm/requests/dns/create_zone.rb +18 -17
- data/lib/fog/azurerm/requests/dns/delete_record_set.rb +3 -3
- data/lib/fog/azurerm/requests/dns/delete_zone.rb +5 -4
- data/lib/fog/azurerm/requests/dns/get_records_from_record_set.rb +3 -3
- data/lib/fog/azurerm/requests/dns/list_record_sets.rb +33 -32
- data/lib/fog/azurerm/requests/dns/list_zones.rb +41 -40
- data/lib/fog/azurerm/requests/network/check_for_public_ip.rb +1 -1
- data/lib/fog/azurerm/requests/network/check_for_virtual_network.rb +1 -1
- data/lib/fog/azurerm/requests/network/create_application_gateway.rb +371 -0
- data/lib/fog/azurerm/requests/network/create_network_interface.rb +17 -9
- data/lib/fog/azurerm/requests/network/create_network_security_group.rb +15 -23
- data/lib/fog/azurerm/requests/network/create_public_ip.rb +1 -2
- data/lib/fog/azurerm/requests/network/create_subnet.rb +10 -11
- data/lib/fog/azurerm/requests/network/create_traffic_manager_endpoint.rb +2 -2
- data/lib/fog/azurerm/requests/network/create_traffic_manager_profile.rb +5 -5
- data/lib/fog/azurerm/requests/network/create_virtual_network.rb +9 -9
- data/lib/fog/azurerm/requests/network/delete_application_gateway.rb +27 -0
- data/lib/fog/azurerm/requests/network/delete_network_interface.rb +1 -1
- data/lib/fog/azurerm/requests/network/delete_network_security_group.rb +1 -1
- data/lib/fog/azurerm/requests/network/delete_public_ip.rb +2 -2
- data/lib/fog/azurerm/requests/network/delete_subnet.rb +1 -1
- data/lib/fog/azurerm/requests/network/delete_virtual_network.rb +1 -1
- data/lib/fog/azurerm/requests/network/list_application_gateways.rb +31 -0
- data/lib/fog/azurerm/requests/network/list_network_interfaces.rb +3 -5
- data/lib/fog/azurerm/requests/network/list_network_security_groups.rb +29 -37
- data/lib/fog/azurerm/requests/network/list_public_ips.rb +1 -3
- data/lib/fog/azurerm/requests/network/list_subnets.rb +4 -6
- data/lib/fog/azurerm/requests/network/list_traffic_manager_profiles.rb +1 -1
- data/lib/fog/azurerm/requests/network/list_virtual_networks.rb +7 -8
- data/lib/fog/azurerm/requests/resources/create_resource_group.rb +9 -7
- data/lib/fog/azurerm/requests/resources/delete_resource_group.rb +3 -1
- data/lib/fog/azurerm/requests/resources/list_resource_groups.rb +16 -14
- data/lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb +3 -3
- data/lib/fog/azurerm/requests/storage/create_storage_account.rb +6 -6
- data/lib/fog/azurerm/requests/storage/delete_storage_account.rb +5 -5
- data/lib/fog/azurerm/requests/storage/list_storage_account_for_rg.rb +20 -21
- data/lib/fog/azurerm/requests/storage/list_storage_accounts.rb +21 -21
- data/lib/fog/azurerm/resources.rb +4 -1
- data/lib/fog/azurerm/storage.rb +1 -2
- data/lib/fog/azurerm/version.rb +1 -1
- metadata +54 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35da447cf146705b309a9b239e0d42b543622911
|
4
|
+
data.tar.gz: 07eb2ced5d952e43d6542d13a1770796efaaff76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6d6f19416f13e123f54bd38a294356be5d953a16064720e4d417065fa829f96a8803d6812dbfab6a0c94510e420732d8a287a5f5c1c2710fa76c354e16b4ac6
|
7
|
+
data.tar.gz: bee84fdd1d9dd9f99eae7330309ec14e509b73dbd660d6d5af1c21f61a02bc9a01b9d7b78e75058b86b9b8e62c1ea3dee733ea760098be664d61d290bdd27c52
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
## 0.0.3
|
2
|
+
|
3
|
+
**Added:**
|
4
|
+
- Compute Service: Support for Attach Data Disk & Detach Data Disk in Server
|
5
|
+
- Compute Service: Support for Windows VM in create Server
|
6
|
+
- Network Service - Application Gateway
|
7
|
+
- Compute Service- check_vm_status method in Server as per: https://github.com/fog/fog-azure-rm/issues/38
|
8
|
+
- Badges in Readme.md file
|
9
|
+
|
10
|
+
**Fixed:**
|
11
|
+
- Code Climate Issues
|
12
|
+
- Rubocop Offences
|
13
|
+
- Compute service - Bug in Sever model as per: https://github.com/fog/fog-azure-rm/issues/36
|
14
|
+
- Network Service - Bug in Network Interface as per: https://github.com/fog/fog-azure-rm/issues/65
|
15
|
+
|
16
|
+
**Removed:**
|
17
|
+
- Shindo Unit Tests
|
18
|
+
|
19
|
+
**Integrated:**
|
20
|
+
- Code Climate
|
21
|
+
- Travis CI
|
22
|
+
- Hound CI
|
23
|
+
- Gemnasium
|
24
|
+
- Waffle
|
25
|
+
|
26
|
+
|
27
|
+
## 0.0.2
|
28
|
+
|
29
|
+
**Added:**
|
30
|
+
- Network Service - Network Security Group
|
31
|
+
- Network Service - Load Balancer
|
32
|
+
- Network Service - Traffic Manager
|
33
|
+
- Minitest Unit Tests - DNS Requests
|
34
|
+
- Response Parser: Compute, Network, DNS, Storage
|
35
|
+
- Mock class implementation in all services
|
36
|
+
|
37
|
+
**Changed:**
|
38
|
+
- Response related changes in all services
|
39
|
+
- Network Service - Subnet attributes names
|
40
|
+
- Code standardization in all services
|
41
|
+
|
42
|
+
|
43
|
+
## 0.0.1
|
44
|
+
|
45
|
+
**Fixed:**
|
46
|
+
- Network Service - Network Interface Card
|
47
|
+
|
48
|
+
|
49
|
+
## 0.0.0
|
50
|
+
|
51
|
+
**Added:**
|
52
|
+
- Shindo Unit Tests - All
|
53
|
+
- Minitest Unit Tests - Compute, Storage, Network, Resources, DNS Models
|
54
|
+
- Documentation - All Services
|
55
|
+
- Compute Service - Server
|
56
|
+
- Compute Service - Availability Set
|
57
|
+
- Network Service - Network Interface
|
58
|
+
- Network Service - Subnet
|
59
|
+
- Network Service - Virtual Network
|
60
|
+
- Network Service - Public IP
|
61
|
+
- Storage Service - Storage Account
|
62
|
+
- Resource Service - Resource Manager
|
63
|
+
- DNS Service - Record Set
|
64
|
+
- DNS Service - Zone
|
data/README.md
CHANGED
@@ -1,4 +1,9 @@
|
|
1
1
|
[![Gem Version](https://badge.fury.io/rb/fog-azure-rm.svg)](https://badge.fury.io/rb/fog-azure-rm)
|
2
|
+
[![Build Status](https://travis-ci.org/fog/fog-azure-rm.svg?branch=master)](https://travis-ci.org/fog/fog-azure-rm)
|
3
|
+
[![Dependency Status](https://gemnasium.com/badges/github.com/fog/fog-azure-rm.svg)](https://gemnasium.com/github.com/fog/fog-azure-rm)
|
4
|
+
[![Test Coverage](https://codeclimate.com/github/fog/fog-azure-rm/badges/coverage.svg)](https://codeclimate.com/github/fog/fog-azure-rm/coverage)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/fog/fog-azure-rm/badges/gpa.svg)](https://codeclimate.com/github/fog/fog-azure-rm)
|
6
|
+
[![Stories in Ready](https://badge.waffle.io/fog/fog-azure-rm.svg?label=ready&title=Ready)](http://waffle.io/fog/fog-azure-rm)
|
2
7
|
|
3
8
|
# Fog Azure Resource Manager
|
4
9
|
|
data/lib/fog/azurerm.rb
CHANGED
@@ -10,24 +10,24 @@ require 'fog/azurerm/storage'
|
|
10
10
|
require 'fog/azurerm/network'
|
11
11
|
require 'fog/azurerm/compute'
|
12
12
|
|
13
|
-
|
14
13
|
module Fog
|
14
|
+
# Main AzureRM fog Provider Module
|
15
15
|
module AzureRM
|
16
16
|
def self.services
|
17
17
|
begin
|
18
18
|
array_of_services = []
|
19
19
|
ENV['BUNDLE_GEM'] = File.expand_path('../../lib', File.dirname(__FILE__))
|
20
20
|
gem_path = ENV['BUNDLE_GEM']
|
21
|
-
files = Dir.entries(File.join(gem_path,'/fog/azurerm')).select {|f| !File.directory? f}
|
21
|
+
files = Dir.entries(File.join(gem_path, '/fog/azurerm')).select { |f| !File.directory? f }
|
22
22
|
files.each do |file|
|
23
|
-
next if file ==
|
24
|
-
next if file ==
|
25
|
-
next if file ==
|
26
|
-
next if file ==
|
27
|
-
next if file ==
|
28
|
-
next if file ==
|
29
|
-
next if file ==
|
30
|
-
array_of_services.push(
|
23
|
+
next if file == 'config.rb'
|
24
|
+
next if file == 'core.rb'
|
25
|
+
next if file == 'credentials.rb'
|
26
|
+
next if file == 'docs'
|
27
|
+
next if file == 'models'
|
28
|
+
next if file == 'requests'
|
29
|
+
next if file == 'version.rb'
|
30
|
+
array_of_services.push(file.split('.').first.upcase)
|
31
31
|
end
|
32
32
|
array_of_services
|
33
33
|
rescue => e
|
data/lib/fog/azurerm/compute.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'fog/azurerm/core'
|
2
|
-
# rubocop:disable LineLength
|
3
2
|
module Fog
|
4
3
|
module Compute
|
5
4
|
# This class registers models, requests and collections
|
@@ -24,12 +23,17 @@ module Fog
|
|
24
23
|
request :redeploy_virtual_machine
|
25
24
|
request :restart_virtual_machine
|
26
25
|
request :start_virtual_machine
|
26
|
+
request :check_vm_status
|
27
|
+
request :attach_data_disk_to_vm
|
28
|
+
request :detach_data_disk_from_vm
|
27
29
|
|
28
30
|
model_path 'fog/azurerm/models/compute'
|
29
31
|
model :availability_set
|
30
32
|
collection :availability_sets
|
31
33
|
model :server
|
32
34
|
collection :servers
|
35
|
+
model :data_disk
|
36
|
+
|
33
37
|
# This class provides the mock implementation for unit tests.
|
34
38
|
class Mock
|
35
39
|
def initialize(_options = {})
|
@@ -46,6 +50,8 @@ module Fog
|
|
46
50
|
def initialize(options)
|
47
51
|
begin
|
48
52
|
require 'azure_mgmt_compute'
|
53
|
+
require 'azure_mgmt_storage'
|
54
|
+
require 'azure/storage'
|
49
55
|
rescue LoadError => e
|
50
56
|
retry if require('rubygems')
|
51
57
|
raise e.message
|
@@ -54,6 +60,8 @@ module Fog
|
|
54
60
|
credentials = Fog::Credentials::AzureRM.get_credentials(options[:tenant_id], options[:client_id], options[:client_secret])
|
55
61
|
@compute_mgmt_client = ::Azure::ARM::Compute::ComputeManagementClient.new(credentials)
|
56
62
|
@compute_mgmt_client.subscription_id = options[:subscription_id]
|
63
|
+
@storage_mgmt_client = ::Azure::ARM::Storage::StorageManagementClient.new(credentials)
|
64
|
+
@storage_mgmt_client.subscription_id = options[:subscription_id]
|
57
65
|
end
|
58
66
|
end
|
59
67
|
end
|
data/lib/fog/azurerm/config.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
AZURE_RESOURCE = 'https://management.azure.com'
|
1
|
+
AZURE_RESOURCE = 'https://management.azure.com'.freeze
|
data/lib/fog/azurerm/core.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Fog
|
2
2
|
module Credentials
|
3
|
+
# This class is managing credentials token
|
3
4
|
class AzureRM
|
4
|
-
|
5
5
|
def self.get_credentials(tenant_id, client_id, client_secret)
|
6
6
|
if @credentials.nil? || new_client(tenant_id, client_id, client_secret)
|
7
7
|
get_new_credentials(tenant_id, client_id, client_secret)
|
@@ -26,12 +26,12 @@ module Fog
|
|
26
26
|
|
27
27
|
def self.new_client(tenant_id, client_id, client_secret)
|
28
28
|
@tenant_id != tenant_id ||
|
29
|
-
|
30
|
-
|
29
|
+
@client_id != client_id ||
|
30
|
+
@client_secret != client_secret
|
31
31
|
end
|
32
32
|
|
33
33
|
private_class_method :get_new_credentials
|
34
34
|
private_class_method :new_client
|
35
35
|
end
|
36
36
|
end
|
37
|
-
end
|
37
|
+
end
|
data/lib/fog/azurerm/dns.rb
CHANGED
@@ -3,6 +3,7 @@ require 'fog/azurerm/credentials'
|
|
3
3
|
|
4
4
|
module Fog
|
5
5
|
module DNS
|
6
|
+
# This class registers models, requests and collections
|
6
7
|
class AzureRM < Fog::Service
|
7
8
|
requires :tenant_id
|
8
9
|
requires :client_id
|
@@ -25,11 +26,13 @@ module Fog
|
|
25
26
|
model :record_set
|
26
27
|
collection :record_sets
|
27
28
|
|
29
|
+
# This class provides the mock implementation for unit tests.
|
28
30
|
class Mock
|
29
|
-
def initialize(
|
31
|
+
def initialize(_options = {})
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
35
|
+
# This class provides the actual implemention for service calls.
|
33
36
|
class Real
|
34
37
|
def initialize(options)
|
35
38
|
@tenant_id = options[:tenant_id]
|
@@ -37,10 +40,11 @@ module Fog
|
|
37
40
|
@client_secret = options[:client_secret]
|
38
41
|
@subscription_id = options[:subscription_id]
|
39
42
|
@resources = Fog::Resources::AzureRM.new(
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
43
|
+
tenant_id: options[:tenant_id],
|
44
|
+
client_id: options[:client_id],
|
45
|
+
client_secret: options[:client_secret],
|
46
|
+
subscription_id: options[:subscription_id]
|
47
|
+
)
|
44
48
|
end
|
45
49
|
end
|
46
50
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class AzureRM
|
4
|
+
# DataDisk Model for Compute Service
|
5
|
+
class DataDisk < Fog::Model
|
6
|
+
identity :name
|
7
|
+
attribute :disk_size_gb
|
8
|
+
attribute :lun
|
9
|
+
attribute :vhd_uri
|
10
|
+
attribute :caching
|
11
|
+
attribute :create_option
|
12
|
+
|
13
|
+
def self.parse(vm)
|
14
|
+
hash = {}
|
15
|
+
hash['name'] = vm['name']
|
16
|
+
hash['disk_size_gb'] = vm['diskSizeGB']
|
17
|
+
hash['lun'] = vm['lun']
|
18
|
+
hash['vhd_uri'] = vm['vhd']['uri']
|
19
|
+
hash['caching'] = vm['caching'] unless vm['caching'].nil?
|
20
|
+
hash['create_option'] = vm['createOption']
|
21
|
+
hash
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -11,16 +11,20 @@ module Fog
|
|
11
11
|
attribute :vm_size
|
12
12
|
attribute :storage_account_name
|
13
13
|
attribute :os_disk_name
|
14
|
-
attribute :
|
14
|
+
attribute :os_disk_vhd_uri
|
15
15
|
attribute :publisher
|
16
16
|
attribute :offer
|
17
17
|
attribute :sku
|
18
18
|
attribute :version
|
19
19
|
attribute :username
|
20
20
|
attribute :password
|
21
|
+
attribute :data_disks
|
21
22
|
attribute :disable_password_authentication
|
22
23
|
attribute :ssh_key_path
|
23
24
|
attribute :ssh_key_data
|
25
|
+
attribute :platform
|
26
|
+
attribute :provision_vm_agent
|
27
|
+
attribute :enable_automatic_updates
|
24
28
|
attribute :network_interface_card_id
|
25
29
|
attribute :availability_set_id
|
26
30
|
|
@@ -32,13 +36,29 @@ module Fog
|
|
32
36
|
hash['resource_group'] = vm['id'].split('/')[4]
|
33
37
|
hash['vm_size'] = vm['properties']['hardwareProfile']['vmSize']
|
34
38
|
hash['os_disk_name'] = vm['properties']['storageProfile']['osDisk']['name']
|
35
|
-
hash['
|
39
|
+
hash['os_disk_vhd_uri'] = vm['properties']['storageProfile']['osDisk']['vhd']['uri']
|
36
40
|
hash['publisher'] = vm['properties']['storageProfile']['imageReference']['publisher']
|
37
41
|
hash['offer'] = vm['properties']['storageProfile']['imageReference']['offer']
|
38
42
|
hash['sku'] = vm['properties']['storageProfile']['imageReference']['sku']
|
39
43
|
hash['version'] = vm['properties']['storageProfile']['imageReference']['version']
|
40
44
|
hash['username'] = vm['properties']['osProfile']['adminUsername']
|
41
|
-
hash['
|
45
|
+
hash['data_disks'] = []
|
46
|
+
|
47
|
+
vm['properties']['storageProfile']['dataDisks'].each do |disk|
|
48
|
+
data_disk = Fog::Compute::AzureRM::DataDisk.new
|
49
|
+
hash['data_disks'] << data_disk.merge_attributes(Fog::Compute::AzureRM::DataDisk.parse(disk))
|
50
|
+
end unless vm['properties']['storageProfile']['dataDisks'].nil?
|
51
|
+
|
52
|
+
hash['disable_password_authentication'] =
|
53
|
+
if vm['properties']['osProfile']['linuxConfiguration'].nil?
|
54
|
+
false
|
55
|
+
else
|
56
|
+
vm['properties']['osProfile']['linuxConfiguration']['disablePasswordAuthentication']
|
57
|
+
end
|
58
|
+
if vm['properties']['osProfile']['windowsConfiguration']
|
59
|
+
hash['provision_vm_agent'] = vm['properties']['osProfile']['windowsConfiguration']['provisionVMAgent']
|
60
|
+
hash['enable_automatic_updates'] = vm['properties']['osProfile']['windowsConfiguration']['enableAutomaticUpdates']
|
61
|
+
end
|
42
62
|
hash['network_interface_card_id'] = vm['properties']['networkProfile']['networkInterfaces'][0]['id']
|
43
63
|
hash['availability_set_id'] = vm['properties']['availabilitySet']['id'] unless vm['properties']['availabilitySet'].nil?
|
44
64
|
hash
|
@@ -46,14 +66,17 @@ module Fog
|
|
46
66
|
|
47
67
|
def save
|
48
68
|
requires :name, :location, :resource_group, :vm_size, :storage_account_name,
|
49
|
-
:username, :password, :
|
50
|
-
|
69
|
+
:username, :password, :network_interface_card_id, :publisher, :offer, :sku, :version
|
70
|
+
requires :disable_password_authentication if platform.casecmp('linux') == 0
|
51
71
|
|
52
72
|
ssh_key_path = "/home/#{username}/.ssh/authorized_keys" unless ssh_key_data.nil?
|
53
|
-
vm = service.create_virtual_machine(
|
54
|
-
|
55
|
-
|
56
|
-
|
73
|
+
vm = service.create_virtual_machine(
|
74
|
+
resource_group, name, location, vm_size, storage_account_name,
|
75
|
+
username, password, disable_password_authentication,
|
76
|
+
ssh_key_path, ssh_key_data, network_interface_card_id,
|
77
|
+
availability_set_id, publisher, offer, sku, version,
|
78
|
+
platform, provision_vm_agent, enable_automatic_updates
|
79
|
+
)
|
57
80
|
merge_attributes(Fog::Compute::AzureRM::Server.parse(vm))
|
58
81
|
end
|
59
82
|
|
@@ -88,6 +111,20 @@ module Fog
|
|
88
111
|
def list_available_sizes
|
89
112
|
service.list_available_sizes_for_virtual_machine(resource_group, name)
|
90
113
|
end
|
114
|
+
|
115
|
+
def vm_status
|
116
|
+
service.check_vm_status(resource_group, name)
|
117
|
+
end
|
118
|
+
|
119
|
+
def attach_data_disk(disk_name, disk_size, storage_account_name)
|
120
|
+
vm = service.attach_data_disk_to_vm(resource_group, name, disk_name, disk_size, storage_account_name)
|
121
|
+
merge_attributes(Fog::Compute::AzureRM::Server.parse(vm))
|
122
|
+
end
|
123
|
+
|
124
|
+
def detach_data_disk(disk_name)
|
125
|
+
vm = service.detach_data_disk_from_vm(resource_group, name, disk_name)
|
126
|
+
merge_attributes(Fog::Compute::AzureRM::Server.parse(vm))
|
127
|
+
end
|
91
128
|
end
|
92
129
|
end
|
93
130
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'fog/core/collection'
|
2
|
+
require 'fog/azurerm/models/compute/server'
|
3
3
|
|
4
4
|
module Fog
|
5
5
|
module Compute
|
@@ -19,8 +19,8 @@ module Fog
|
|
19
19
|
load(virtual_machines)
|
20
20
|
end
|
21
21
|
|
22
|
-
def get(
|
23
|
-
all.find { |s| s.name == identity
|
22
|
+
def get(identity)
|
23
|
+
all.find { |s| s.name == identity }
|
24
24
|
end
|
25
25
|
|
26
26
|
def get_from_remote(resource_group, name)
|
@@ -17,19 +17,19 @@ module Fog
|
|
17
17
|
attribute :a_record
|
18
18
|
|
19
19
|
def self.parse(recordset)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
20
|
+
hash = {}
|
21
|
+
hash['id'] = recordset['id']
|
22
|
+
hash['name'] = recordset['name']
|
23
|
+
hash['resource_group'] = recordset['id'].split('/')[4]
|
24
|
+
hash['location'] = recordset['location']
|
25
|
+
hash['zone_name'] = recordset['id'].split('/')[8]
|
26
|
+
hash['type'] = recordset['type']
|
27
|
+
type = recordset['type'].split('/')[2]
|
28
|
+
hash['a_record'] = recordset['properties']['ARecords'] if type == 'A'
|
29
|
+
hash['cname_record'] = recordset['properties']['CNAMERecord'] if type == 'CNAME'
|
30
|
+
hash['ttl'] = recordset['properties']['TTL']
|
31
|
+
hash['fqdn'] = recordset['properties']['fqdn']
|
32
|
+
hash
|
33
33
|
end
|
34
34
|
|
35
35
|
def save
|
@@ -0,0 +1,456 @@
|
|
1
|
+
module Fog
|
2
|
+
module Network
|
3
|
+
class AzureRM
|
4
|
+
# Application Gateway model class for Network Service
|
5
|
+
class ApplicationGateway < Fog::Model
|
6
|
+
identity :name
|
7
|
+
attribute :id
|
8
|
+
attribute :location
|
9
|
+
attribute :resource_group
|
10
|
+
attribute :provisioning_state
|
11
|
+
attribute :sku_name
|
12
|
+
attribute :sku_tier
|
13
|
+
attribute :sku_capacity
|
14
|
+
attribute :operational_state
|
15
|
+
attribute :gateway_ip_configurations
|
16
|
+
attribute :ssl_certificates
|
17
|
+
attribute :frontend_ip_configurations
|
18
|
+
attribute :frontend_ports
|
19
|
+
attribute :probes
|
20
|
+
attribute :backend_address_pools
|
21
|
+
attribute :backend_http_settings_list
|
22
|
+
attribute :http_listeners
|
23
|
+
attribute :url_path_maps
|
24
|
+
attribute :request_routing_rules
|
25
|
+
|
26
|
+
def self.parse(gateway)
|
27
|
+
gateway_properties = gateway['properties']
|
28
|
+
|
29
|
+
hash = {}
|
30
|
+
hash['name'] = gateway['name']
|
31
|
+
hash['id'] = gateway['id']
|
32
|
+
hash['location'] = gateway['location']
|
33
|
+
hash['resource_group'] = gateway['id'].split('/')[4]
|
34
|
+
unless gateway_properties.nil?
|
35
|
+
hash['provisioning_state'] = gateway_properties['provisioningState']
|
36
|
+
unless gateway_properties['sku'].nil?
|
37
|
+
hash['sku_name'] = gateway_properties['sku']['name']
|
38
|
+
hash['sku_tier'] = gateway_properties['sku']['tier']
|
39
|
+
hash['sku_capacity'] = gateway_properties['sku']['capacity']
|
40
|
+
end
|
41
|
+
hash['operational_state'] = gateway_properties['operationalState']
|
42
|
+
|
43
|
+
hash['gateway_ip_configurations'] = []
|
44
|
+
gateway_properties['gatewayIpConfigurations'].each do |ip_configuration|
|
45
|
+
gateway_ip_configuration = Fog::Network::AzureRM::ApplicationGatewayIPConfiguration.new
|
46
|
+
hash['gateway_ip_configurations'] << gateway_ip_configuration.merge_attributes(Fog::Network::AzureRM::ApplicationGatewayIPConfiguration.parse(ip_configuration))
|
47
|
+
end unless gateway_properties['gatewayIpConfigurations'].nil?
|
48
|
+
|
49
|
+
hash['ssl_certificates'] = []
|
50
|
+
gateway_properties['sslCertificates'].each do |certificate|
|
51
|
+
ssl_certificate = Fog::Network::AzureRM::ApplicationGatewaySslCertificate.new
|
52
|
+
hash['ssl_certificates'] << ssl_certificate.merge_attributes(Fog::Network::AzureRM::ApplicationGatewaySslCertificate.parse(certificate))
|
53
|
+
end unless gateway_properties['sslCertificates'].nil?
|
54
|
+
|
55
|
+
hash['frontend_ip_configurations'] = []
|
56
|
+
gateway_properties['frontendIpConfigurations'].each do |frontend_ip_config|
|
57
|
+
frontend_ip_configuration = Fog::Network::AzureRM::ApplicationGatewayFrontendIPConfiguration.new
|
58
|
+
hash['frontend_ip_configurations'] << frontend_ip_configuration.merge_attributes(Fog::Network::AzureRM::ApplicationGatewayFrontendIPConfiguration.parse(frontend_ip_config))
|
59
|
+
end unless gateway_properties['frontendIpConfigurations'].nil?
|
60
|
+
|
61
|
+
hash['frontend_ports'] = []
|
62
|
+
gateway_properties['frontendPorts'].each do |port|
|
63
|
+
frontend_port = Fog::Network::AzureRM::ApplicationGatewayFrontendPort.new
|
64
|
+
hash['frontend_ports'] << frontend_port.merge_attributes(Fog::Network::AzureRM::ApplicationGatewayFrontendPort.parse(port))
|
65
|
+
end unless gateway_properties['frontendPorts'].nil?
|
66
|
+
|
67
|
+
hash['probes'] = []
|
68
|
+
gateway_properties['probes'].each do |probe|
|
69
|
+
gateway_probe = Fog::Network::AzureRM::ApplicationGatewayProbe.new
|
70
|
+
hash['probes'] << gateway_probe.merge_attributes(Fog::Network::AzureRM::ApplicationGatewayProbe.parse(probe))
|
71
|
+
end unless gateway_properties['probes'].nil?
|
72
|
+
|
73
|
+
hash['backend_address_pools'] = []
|
74
|
+
gateway_properties['backendAddressPools'].each do |address|
|
75
|
+
backend_address_pool = Fog::Network::AzureRM::ApplicationGatewayBackendAddressPool.new
|
76
|
+
hash['backend_address_pools'] << backend_address_pool.merge_attributes(Fog::Network::AzureRM::ApplicationGatewayBackendAddressPool.parse(address))
|
77
|
+
end unless gateway_properties['backendAddressPools'].nil?
|
78
|
+
|
79
|
+
hash['backend_http_settings_list'] = []
|
80
|
+
gateway_properties['backendHttpSettingsCollection'].each do |http_setting|
|
81
|
+
backend_http_setting = Fog::Network::AzureRM::ApplicationGatewayBackendHttpSetting.new
|
82
|
+
hash['backend_http_settings_list'] << backend_http_setting.merge_attributes(Fog::Network::AzureRM::ApplicationGatewayBackendHttpSetting.parse(http_setting))
|
83
|
+
end unless gateway_properties['backendHttpSettingsCollection'].nil?
|
84
|
+
|
85
|
+
hash['http_listeners'] = []
|
86
|
+
gateway_properties['httpListeners'].each do |listener|
|
87
|
+
http_listener = Fog::Network::AzureRM::ApplicationGatewayHttpListener.new
|
88
|
+
hash['http_listeners'] << http_listener.merge_attributes(Fog::Network::AzureRM::ApplicationGatewayHttpListener.parse(listener))
|
89
|
+
end unless gateway_properties['httpListeners'].nil?
|
90
|
+
|
91
|
+
hash['url_path_maps'] = []
|
92
|
+
gateway_properties['urlPathMaps'].each do |map|
|
93
|
+
url_path_map = Fog::Network::AzureRM::ApplicationGatewayUrlPathMap.new
|
94
|
+
hash['url_path_maps'] << url_path_map.merge_attributes(Fog::Network::AzureRM::ApplicationGatewayUrlPathMap.parse(map))
|
95
|
+
end unless gateway_properties['urlPathMaps'].nil?
|
96
|
+
|
97
|
+
hash['request_routing_rules'] = []
|
98
|
+
gateway_properties['requestRoutingRules'].each do |rule|
|
99
|
+
request_routing_rule = Fog::Network::AzureRM::ApplicationGatewayRequestRoutingRule.new
|
100
|
+
hash['request_routing_rules'] << request_routing_rule.merge_attributes(Fog::Network::AzureRM::ApplicationGatewayRequestRoutingRule.parse(rule))
|
101
|
+
end unless gateway_properties['requestRoutingRules'].nil?
|
102
|
+
end
|
103
|
+
hash
|
104
|
+
end
|
105
|
+
|
106
|
+
def save
|
107
|
+
requires :name, :location, :resource_group, :sku_name, :sku_tier, :sku_capacity, :gateway_ip_configurations, :frontend_ip_configurations, :frontend_ports, :backend_address_pools, :backend_http_settings_list, :http_listeners, :request_routing_rules
|
108
|
+
|
109
|
+
validate_gateway_ip_configurations(gateway_ip_configurations) unless gateway_ip_configurations.nil?
|
110
|
+
validate_ssl_certificates(ssl_certificates) unless ssl_certificates.nil?
|
111
|
+
validate_frontend_ip_configurations(frontend_ip_configurations) unless frontend_ip_configurations.nil?
|
112
|
+
validate_frontend_ports(frontend_ports) unless frontend_ports.nil?
|
113
|
+
validate_probes(probes) unless probes.nil?
|
114
|
+
validate_backend_address_pools(backend_address_pools) unless backend_address_pools.nil?
|
115
|
+
validate_backend_http_settings_list(backend_http_settings_list) unless backend_http_settings_list.nil?
|
116
|
+
validate_http_listeners(http_listeners) unless http_listeners.nil?
|
117
|
+
validate_url_path_maps(url_path_maps) unless url_path_maps.nil?
|
118
|
+
validate_request_routing_rules(request_routing_rules) unless request_routing_rules.nil?
|
119
|
+
|
120
|
+
gateway = service.create_application_gateway(name, location, resource_group, sku_name, sku_tier, sku_capacity, gateway_ip_configurations, ssl_certificates, frontend_ip_configurations, frontend_ports, probes, backend_address_pools, backend_http_settings_list, http_listeners, url_path_maps, request_routing_rules)
|
121
|
+
merge_attributes(Fog::Network::AzureRM::ApplicationGateway.parse(gateway))
|
122
|
+
end
|
123
|
+
|
124
|
+
def validate_gateway_ip_configurations(gateway_ip_configurations)
|
125
|
+
if gateway_ip_configurations.is_a?(Array)
|
126
|
+
if gateway_ip_configurations.any?
|
127
|
+
gateway_ip_configurations.each do |gateway_ip_configuration|
|
128
|
+
if gateway_ip_configuration.is_a?(Hash)
|
129
|
+
validate_gateway_ip_configuration_params(gateway_ip_configuration)
|
130
|
+
else
|
131
|
+
raise(ArgumentError, ':gateway_ip_configurations must be an Array of Hashes')
|
132
|
+
end
|
133
|
+
end
|
134
|
+
else
|
135
|
+
raise(ArgumentError, ':gateway_ip_configurations must not be an empty Array')
|
136
|
+
end
|
137
|
+
else
|
138
|
+
raise(ArgumentError, ':gateway_ip_configurations must be an Array')
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
def validate_gateway_ip_configuration_params(gateway_ip_configuration)
|
143
|
+
required_params = [
|
144
|
+
:name,
|
145
|
+
:subnet_id
|
146
|
+
]
|
147
|
+
missing = required_params.select { |p| p unless gateway_ip_configuration.key?(p) }
|
148
|
+
if missing.length == 1
|
149
|
+
raise(ArgumentError, "#{missing.first} is required for this operation")
|
150
|
+
elsif missing.any?
|
151
|
+
raise(ArgumentError, "#{missing[0...-1].join(', ')} and #{missing[-1]} are required for this operation")
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
def validate_ssl_certificates(ssl_certificates)
|
156
|
+
if ssl_certificates.is_a?(Array)
|
157
|
+
if ssl_certificates.any?
|
158
|
+
ssl_certificates.each do |ssl_certificate|
|
159
|
+
if ssl_certificate.is_a?(Hash)
|
160
|
+
validate_ssl_certificate_params(ssl_certificate)
|
161
|
+
else
|
162
|
+
raise(ArgumentError, ':ssl_certificates must be an Array of Hashes')
|
163
|
+
end
|
164
|
+
end
|
165
|
+
else
|
166
|
+
raise(ArgumentError, ':ssl_certificates must not be an empty Array')
|
167
|
+
end
|
168
|
+
else
|
169
|
+
raise(ArgumentError, ':ssl_certificates must be an Array')
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
def validate_ssl_certificate_params(ssl_certificate)
|
174
|
+
required_params = [
|
175
|
+
:name,
|
176
|
+
:data,
|
177
|
+
:password,
|
178
|
+
:public_cert_data
|
179
|
+
]
|
180
|
+
missing = required_params.select { |p| p unless ssl_certificate.key?(p) }
|
181
|
+
if missing.length == 1
|
182
|
+
raise(ArgumentError, "#{missing.first} is required for this operation")
|
183
|
+
elsif missing.any?
|
184
|
+
raise(ArgumentError, "#{missing[0...-1].join(', ')} and #{missing[-1]} are required for this operation")
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
def validate_frontend_ip_configurations(frontend_ip_configurations)
|
189
|
+
if frontend_ip_configurations.is_a?(Array)
|
190
|
+
if frontend_ip_configurations.any?
|
191
|
+
frontend_ip_configurations.each do |frontend_ip_configuration|
|
192
|
+
if frontend_ip_configuration.is_a?(Hash)
|
193
|
+
validate_frontend_ip_configuration_params(frontend_ip_configuration)
|
194
|
+
else
|
195
|
+
raise(ArgumentError, ':frontend_ip_configurations must be an Array of Hashes')
|
196
|
+
end
|
197
|
+
end
|
198
|
+
else
|
199
|
+
raise(ArgumentError, ':frontend_ip_configurations must not be an empty Array')
|
200
|
+
end
|
201
|
+
else
|
202
|
+
raise(ArgumentError, ':frontend_ip_configurations must be an Array')
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
def validate_frontend_ip_configuration_params(frontend_ip_configuration)
|
207
|
+
required_params = [
|
208
|
+
:name,
|
209
|
+
:public_ip_address_id,
|
210
|
+
:private_ip_allocation_method,
|
211
|
+
:private_ip_address
|
212
|
+
]
|
213
|
+
missing = required_params.select { |p| p unless frontend_ip_configuration.key?(p) }
|
214
|
+
if missing.length == 1
|
215
|
+
raise(ArgumentError, "#{missing.first} is required for this operation")
|
216
|
+
elsif missing.any?
|
217
|
+
raise(ArgumentError, "#{missing[0...-1].join(', ')} and #{missing[-1]} are required for this operation")
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
def validate_frontend_ports(frontend_ports)
|
222
|
+
if frontend_ports.is_a?(Array)
|
223
|
+
if frontend_ports.any?
|
224
|
+
frontend_ports.each do |frontend_port|
|
225
|
+
if frontend_port.is_a?(Hash)
|
226
|
+
validate_frontend_port_params(frontend_port)
|
227
|
+
else
|
228
|
+
raise(ArgumentError, ':frontend_ports must be an Array of Hashes')
|
229
|
+
end
|
230
|
+
end
|
231
|
+
else
|
232
|
+
raise(ArgumentError, ':frontend_ports must not be an empty Array')
|
233
|
+
end
|
234
|
+
else
|
235
|
+
raise(ArgumentError, ':frontend_ports must be an Array')
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
def validate_frontend_port_params(frontend_port)
|
240
|
+
required_params = [
|
241
|
+
:name,
|
242
|
+
:port
|
243
|
+
]
|
244
|
+
missing = required_params.select { |p| p unless frontend_port.key?(p) }
|
245
|
+
if missing.length == 1
|
246
|
+
raise(ArgumentError, "#{missing.first} is required for this operation")
|
247
|
+
elsif missing.any?
|
248
|
+
raise(ArgumentError, "#{missing[0...-1].join(', ')} and #{missing[-1]} are required for this operation")
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
def validate_probes(probes)
|
253
|
+
if probes.is_a?(Array)
|
254
|
+
if probes.any?
|
255
|
+
probes.each do |probe|
|
256
|
+
if probe.is_a?(Hash)
|
257
|
+
validate_probe_params(probe)
|
258
|
+
else
|
259
|
+
raise(ArgumentError, ':probes must be an Array of Hashes')
|
260
|
+
end
|
261
|
+
end
|
262
|
+
else
|
263
|
+
raise(ArgumentError, ':probes must not be an empty Array')
|
264
|
+
end
|
265
|
+
else
|
266
|
+
raise(ArgumentError, ':probes must be an Array')
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
def validate_probe_params(probe)
|
271
|
+
required_params = [
|
272
|
+
:name,
|
273
|
+
:protocol,
|
274
|
+
:host,
|
275
|
+
:path,
|
276
|
+
:interval,
|
277
|
+
:timeout,
|
278
|
+
:unhealthy_threshold
|
279
|
+
]
|
280
|
+
missing = required_params.select { |p| p unless probe.key?(p) }
|
281
|
+
if missing.length == 1
|
282
|
+
raise(ArgumentError, "#{missing.first} is required for this operation")
|
283
|
+
elsif missing.any?
|
284
|
+
raise(ArgumentError, "#{missing[0...-1].join(', ')} and #{missing[-1]} are required for this operation")
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
def validate_backend_address_pools(backend_address_pools)
|
289
|
+
if backend_address_pools.is_a?(Array)
|
290
|
+
if backend_address_pools.any?
|
291
|
+
backend_address_pools.each do |backend_address_pool|
|
292
|
+
if backend_address_pool.is_a?(Hash)
|
293
|
+
validate_backend_address_pool_params(backend_address_pool)
|
294
|
+
else
|
295
|
+
raise(ArgumentError, ':backend_address_pools must be an Array of Hashes')
|
296
|
+
end
|
297
|
+
end
|
298
|
+
else
|
299
|
+
raise(ArgumentError, ':backend_address_pools must not be an empty Array')
|
300
|
+
end
|
301
|
+
else
|
302
|
+
raise(ArgumentError, ':backend_address_pools must be an Array')
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
306
|
+
def validate_backend_address_pool_params(backend_address_pool)
|
307
|
+
required_params = [
|
308
|
+
:name,
|
309
|
+
:ip_addresses
|
310
|
+
]
|
311
|
+
missing = required_params.select { |p| p unless backend_address_pool.key?(p) }
|
312
|
+
if missing.length == 1
|
313
|
+
raise(ArgumentError, "#{missing.first} is required for this operation")
|
314
|
+
elsif missing.any?
|
315
|
+
raise(ArgumentError, "#{missing[0...-1].join(', ')} and #{missing[-1]} are required for this operation")
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
def validate_backend_http_settings_list(backend_http_settings_list)
|
320
|
+
if backend_http_settings_list.is_a?(Array)
|
321
|
+
if backend_http_settings_list.any?
|
322
|
+
backend_http_settings_list.each do |backend_http_settings|
|
323
|
+
if backend_http_settings.is_a?(Hash)
|
324
|
+
validate_backend_http_settings_params(backend_http_settings)
|
325
|
+
else
|
326
|
+
raise(ArgumentError, ':backend_http_settings_list must be an Array of Hashes')
|
327
|
+
end
|
328
|
+
end
|
329
|
+
else
|
330
|
+
raise(ArgumentError, ':backend_http_settings_list must not be an empty Array')
|
331
|
+
end
|
332
|
+
else
|
333
|
+
raise(ArgumentError, ':backend_http_settings_list must be an Array')
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
def validate_backend_http_settings_params(backend_http_settings)
|
338
|
+
required_params = [
|
339
|
+
:name,
|
340
|
+
:port,
|
341
|
+
:protocol,
|
342
|
+
:cookie_based_affinity,
|
343
|
+
:request_timeout
|
344
|
+
]
|
345
|
+
missing = required_params.select { |p| p unless backend_http_settings.key?(p) }
|
346
|
+
if missing.length == 1
|
347
|
+
raise(ArgumentError, "#{missing.first} is required for this operation")
|
348
|
+
elsif missing.any?
|
349
|
+
raise(ArgumentError, "#{missing[0...-1].join(', ')} and #{missing[-1]} are required for this operation")
|
350
|
+
end
|
351
|
+
end
|
352
|
+
|
353
|
+
def validate_http_listeners(http_listeners)
|
354
|
+
if http_listeners.is_a?(Array)
|
355
|
+
if http_listeners.any?
|
356
|
+
http_listeners.each do |http_listener|
|
357
|
+
if http_listener.is_a?(Hash)
|
358
|
+
validate_http_listener_params(http_listener)
|
359
|
+
else
|
360
|
+
raise(ArgumentError, ':http_listeners must be an Array of Hashes')
|
361
|
+
end
|
362
|
+
end
|
363
|
+
else
|
364
|
+
raise(ArgumentError, ':http_listeners must not be an empty Array')
|
365
|
+
end
|
366
|
+
else
|
367
|
+
raise(ArgumentError, ':http_listeners must be an Array')
|
368
|
+
end
|
369
|
+
end
|
370
|
+
|
371
|
+
def validate_http_listener_params(http_listener)
|
372
|
+
required_params = [
|
373
|
+
:name,
|
374
|
+
:frontend_ip_config_id,
|
375
|
+
:frontend_port_id,
|
376
|
+
:protocol
|
377
|
+
]
|
378
|
+
missing = required_params.select { |p| p unless http_listener.key?(p) }
|
379
|
+
if missing.length == 1
|
380
|
+
raise(ArgumentError, "#{missing.first} is required for this operation")
|
381
|
+
elsif missing.any?
|
382
|
+
raise(ArgumentError, "#{missing[0...-1].join(', ')} and #{missing[-1]} are required for this operation")
|
383
|
+
end
|
384
|
+
end
|
385
|
+
|
386
|
+
def validate_url_path_maps(url_path_maps)
|
387
|
+
if url_path_maps.is_a?(Array)
|
388
|
+
if url_path_maps.any?
|
389
|
+
url_path_maps.each do |url_path_map|
|
390
|
+
if url_path_map.is_a?(Hash)
|
391
|
+
validate_url_path_map_params(url_path_map)
|
392
|
+
else
|
393
|
+
raise(ArgumentError, ':url_path_maps must be an Array of Hashes')
|
394
|
+
end
|
395
|
+
end
|
396
|
+
else
|
397
|
+
raise(ArgumentError, ':url_path_maps must not be an empty Array')
|
398
|
+
end
|
399
|
+
else
|
400
|
+
raise(ArgumentError, ':url_path_maps must be an Array')
|
401
|
+
end
|
402
|
+
end
|
403
|
+
|
404
|
+
def validate_url_path_map_params(url_path_map)
|
405
|
+
required_params = [
|
406
|
+
:name,
|
407
|
+
:default_backend_address_pool_id,
|
408
|
+
:default_backend_http_settings_id,
|
409
|
+
:path_rules
|
410
|
+
]
|
411
|
+
missing = required_params.select { |p| p unless url_path_map.key?(p) }
|
412
|
+
if missing.length == 1
|
413
|
+
raise(ArgumentError, "#{missing.first} is required for this operation")
|
414
|
+
elsif missing.any?
|
415
|
+
raise(ArgumentError, "#{missing[0...-1].join(', ')} and #{missing[-1]} are required for this operation")
|
416
|
+
end
|
417
|
+
end
|
418
|
+
|
419
|
+
def validate_request_routing_rules(request_routing_rules)
|
420
|
+
if request_routing_rules.is_a?(Array)
|
421
|
+
if request_routing_rules.any?
|
422
|
+
request_routing_rules.each do |request_routing_rule|
|
423
|
+
if request_routing_rule.is_a?(Hash)
|
424
|
+
validate_request_routing_rule_params(request_routing_rule)
|
425
|
+
else
|
426
|
+
raise(ArgumentError, ':request_routing_rules must be an Array of Hashes')
|
427
|
+
end
|
428
|
+
end
|
429
|
+
else
|
430
|
+
raise(ArgumentError, ':request_routing_rules must not be an empty Array')
|
431
|
+
end
|
432
|
+
else
|
433
|
+
raise(ArgumentError, ':request_routing_rules must be an Array')
|
434
|
+
end
|
435
|
+
end
|
436
|
+
|
437
|
+
def validate_request_routing_rule_params(request_routing_rule)
|
438
|
+
required_params = [
|
439
|
+
:type,
|
440
|
+
:http_listener_id
|
441
|
+
]
|
442
|
+
missing = required_params.select { |p| p unless request_routing_rule.key?(p) }
|
443
|
+
if missing.length == 1
|
444
|
+
raise(ArgumentError, "#{missing.first} is required for this operation")
|
445
|
+
elsif missing.any?
|
446
|
+
raise(ArgumentError, "#{missing[0...-1].join(', ')} and #{missing[-1]} are required for this operation")
|
447
|
+
end
|
448
|
+
end
|
449
|
+
|
450
|
+
def destroy
|
451
|
+
service.delete_application_gateway(resource_group, name)
|
452
|
+
end
|
453
|
+
end
|
454
|
+
end
|
455
|
+
end
|
456
|
+
end
|