fog-azure-rm 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/CHANGELOG.md +11 -1
- data/README.md +13 -5
- data/fog-azure-rm.gemspec +8 -7
- data/lib/fog/azurerm/application_gateway.rb +2 -0
- data/lib/fog/azurerm/dns.rb +10 -1
- data/lib/fog/azurerm/docs/sql.md +130 -0
- data/lib/fog/azurerm/docs/structure.md +1 -1
- data/lib/fog/azurerm/models/application_gateway/gateway.rb +8 -0
- data/lib/fog/azurerm/models/dns/record_set.rb +34 -27
- data/lib/fog/azurerm/models/dns/zone.rb +27 -13
- data/lib/fog/azurerm/models/network/express_route_circuit_authorization.rb +4 -12
- data/lib/fog/azurerm/models/network/express_route_circuit_authorizations.rb +2 -6
- data/lib/fog/azurerm/models/network/local_network_gateway.rb +5 -13
- data/lib/fog/azurerm/models/network/local_network_gateways.rb +2 -5
- data/lib/fog/azurerm/models/network/virtual_network_gateway_connection.rb +3 -20
- data/lib/fog/azurerm/models/network/virtual_network_gateway_connections.rb +1 -4
- data/lib/fog/azurerm/models/sql/sql_database.rb +89 -0
- data/lib/fog/azurerm/models/sql/sql_databases.rb +29 -0
- data/lib/fog/azurerm/models/sql/sql_server.rb +57 -0
- data/lib/fog/azurerm/models/sql/sql_servers.rb +27 -0
- data/lib/fog/azurerm/models/traffic_manager/traffic_manager_end_point.rb +6 -16
- data/lib/fog/azurerm/models/traffic_manager/traffic_manager_end_points.rb +6 -11
- data/lib/fog/azurerm/models/traffic_manager/traffic_manager_profile.rb +21 -20
- data/lib/fog/azurerm/models/traffic_manager/traffic_manager_profiles.rb +4 -7
- data/lib/fog/azurerm/network.rb +3 -0
- data/lib/fog/azurerm/requests/application_gateway/start_application_gateway.rb +27 -0
- data/lib/fog/azurerm/requests/application_gateway/stop_application_gateway.rb +27 -0
- data/lib/fog/azurerm/requests/dns/check_for_zone.rb +8 -20
- data/lib/fog/azurerm/requests/dns/create_or_update_record_set.rb +47 -81
- data/lib/fog/azurerm/requests/dns/create_or_update_zone.rb +27 -34
- data/lib/fog/azurerm/requests/dns/delete_record_set.rb +9 -18
- data/lib/fog/azurerm/requests/dns/delete_zone.rb +9 -17
- data/lib/fog/azurerm/requests/dns/get_record_set.rb +11 -20
- data/lib/fog/azurerm/requests/dns/get_records_from_record_set.rb +12 -38
- data/lib/fog/azurerm/requests/dns/get_zone.rb +11 -20
- data/lib/fog/azurerm/requests/dns/list_record_sets.rb +11 -19
- data/lib/fog/azurerm/requests/dns/list_zones.rb +15 -32
- data/lib/fog/azurerm/requests/network/create_or_update_express_route_circuit_authorization.rb +4 -2
- data/lib/fog/azurerm/requests/network/create_or_update_local_network_gateway.rb +3 -1
- data/lib/fog/azurerm/requests/network/create_or_update_virtual_network_gateway_connection.rb +3 -1
- data/lib/fog/azurerm/requests/network/delete_express_route_circuit_authorization.rb +2 -1
- data/lib/fog/azurerm/requests/network/delete_local_network_gateway.rb +2 -1
- data/lib/fog/azurerm/requests/network/delete_virtual_network_gateway_connection.rb +2 -1
- data/lib/fog/azurerm/requests/network/get_express_route_circuit_authorization.rb +2 -1
- data/lib/fog/azurerm/requests/network/get_load_balancer.rb +8 -7
- data/lib/fog/azurerm/requests/network/get_local_network_gateway.rb +2 -1
- data/lib/fog/azurerm/requests/network/get_virtual_network_gateway_connection.rb +2 -1
- data/lib/fog/azurerm/requests/network/list_express_route_circuit_authorizations.rb +2 -1
- data/lib/fog/azurerm/requests/network/list_local_network_gateways.rb +2 -1
- data/lib/fog/azurerm/requests/network/list_virtual_network_gateway_connections.rb +2 -1
- data/lib/fog/azurerm/requests/sql/create_or_update_database.rb +74 -0
- data/lib/fog/azurerm/requests/sql/create_or_update_sql_server.rb +61 -0
- data/lib/fog/azurerm/requests/sql/delete_database.rb +35 -0
- data/lib/fog/azurerm/requests/sql/delete_sql_server.rb +35 -0
- data/lib/fog/azurerm/requests/sql/get_database.rb +48 -0
- data/lib/fog/azurerm/requests/sql/get_sql_server.rb +41 -0
- data/lib/fog/azurerm/requests/sql/list_databases.rb +65 -0
- data/lib/fog/azurerm/requests/sql/list_sql_servers.rb +51 -0
- data/lib/fog/azurerm/requests/traffic_manager/delete_traffic_manager_profile.rb +1 -1
- data/lib/fog/azurerm/sql.rb +49 -0
- data/lib/fog/azurerm/utilities/general.rb +19 -0
- data/lib/fog/azurerm/utilities/logger_messages.yml +19 -0
- data/lib/fog/azurerm/version.rb +1 -1
- data/lib/fog/azurerm.rb +21 -0
- data/test/api_stub/models/dns/record_set.rb +34 -56
- data/test/api_stub/models/dns/zone.rb +17 -35
- data/test/api_stub/models/sql/sql_database.rb +28 -0
- data/test/api_stub/models/sql/sql_server.rb +22 -0
- data/test/api_stub/requests/dns/record_set.rb +13 -43
- data/test/api_stub/requests/dns/zone.rb +21 -36
- data/test/api_stub/requests/network/express_route_circuit_authorization.rb +1 -1
- data/test/api_stub/requests/sql/database.rb +69 -0
- data/test/api_stub/requests/sql/sql_server.rb +45 -0
- data/test/api_stub.rb +10 -0
- data/test/integration/application_gateway.rb +17 -5
- data/test/integration/credentials/azure.yml +4 -4
- data/test/integration/express_route_circuit.rb +1 -1
- data/test/integration/record_set.rb +1 -0
- data/test/integration/resource_tag.rb +14 -3
- data/test/integration/sql_server.rb +111 -0
- data/test/integration/traffic_manager.rb +1 -1
- data/test/integration/zone.rb +1 -0
- data/test/models/application_gateway/test_gateway.rb +25 -3
- data/test/models/application_gateway/test_gateways.rb +2 -2
- data/test/models/compute/test_availability_set.rb +1 -1
- data/test/models/compute/test_availability_sets.rb +2 -2
- data/test/models/compute/test_server.rb +2 -2
- data/test/models/compute/test_servers.rb +2 -2
- data/test/models/compute/test_virtual_machine_extension.rb +2 -2
- data/test/models/compute/test_virtual_machine_extensions.rb +2 -2
- data/test/models/dns/test_record_set.rb +5 -4
- data/test/models/dns/test_record_sets.rb +9 -8
- data/test/models/dns/test_zone.rb +4 -3
- data/test/models/dns/test_zones.rb +4 -3
- data/test/models/network/test_express_route_circuit.rb +2 -2
- data/test/models/network/test_express_route_circuit_authorization.rb +3 -3
- data/test/models/network/test_express_route_circuit_authorizations.rb +3 -3
- data/test/models/network/test_express_route_circuit_peering.rb +2 -2
- data/test/models/network/test_express_route_circuit_peerings.rb +3 -3
- data/test/models/network/test_express_route_circuits.rb +2 -2
- data/test/models/network/test_express_route_service_providers.rb +1 -1
- data/test/models/network/test_load_balancer.rb +2 -2
- data/test/models/network/test_load_balancers.rb +2 -2
- data/test/models/network/test_local_network_gateway.rb +2 -2
- data/test/models/network/test_local_network_gateways.rb +2 -2
- data/test/models/network/test_network_interface.rb +2 -2
- data/test/models/network/test_network_interfaces.rb +2 -2
- data/test/models/network/test_network_security_group.rb +1 -1
- data/test/models/network/test_network_security_groups.rb +2 -2
- data/test/models/network/test_network_security_rule.rb +1 -1
- data/test/models/network/test_network_security_rules.rb +3 -3
- data/test/models/network/test_public_ip.rb +2 -2
- data/test/models/network/test_public_ips.rb +2 -2
- data/test/models/network/test_subnet.rb +2 -2
- data/test/models/network/test_subnets.rb +3 -3
- data/test/models/network/test_virtual_network.rb +2 -2
- data/test/models/network/test_virtual_network_gateway.rb +2 -2
- data/test/models/network/test_virtual_network_gateway_connection.rb +2 -2
- data/test/models/network/test_virtual_network_gateway_connections.rb +2 -2
- data/test/models/network/test_virtual_network_gateways.rb +2 -2
- data/test/models/network/test_virtual_networks.rb +2 -2
- data/test/models/resources/test_deployment.rb +2 -2
- data/test/models/resources/test_deployments.rb +1 -1
- data/test/models/resources/test_resource.rb +1 -1
- data/test/models/resources/test_resource_group.rb +2 -2
- data/test/models/resources/test_resource_groups.rb +1 -1
- data/test/models/resources/test_resources.rb +1 -1
- data/test/models/sql/test_database.rb +68 -0
- data/test/models/sql/test_databases.rb +42 -0
- data/test/models/sql/test_sql_server.rb +56 -0
- data/test/models/sql/test_sql_servers.rb +41 -0
- data/test/models/storage/test_data_disk.rb +1 -1
- data/test/models/storage/test_directories.rb +1 -1
- data/test/models/storage/test_directory.rb +1 -1
- data/test/models/storage/test_file.rb +1 -1
- data/test/models/storage/test_files.rb +1 -1
- data/test/models/storage/test_storage_account.rb +1 -1
- data/test/models/storage/test_storage_accounts.rb +2 -2
- data/test/models/traffic_manager/test_traffic_manager_end_point.rb +2 -2
- data/test/models/traffic_manager/test_traffic_manager_end_points.rb +3 -3
- data/test/models/traffic_manager/test_traffic_manager_profile.rb +2 -2
- data/test/models/traffic_manager/test_traffic_manager_profiles.rb +2 -2
- data/test/requests/application_gateway/test_start_application_gateway.rb +25 -0
- data/test/requests/application_gateway/test_stop_application_gateway.rb +25 -0
- data/test/requests/dns/test_check_for_zone.rb +8 -36
- data/test/requests/dns/test_create_record_set.rb +19 -18
- data/test/requests/dns/test_create_zone.rb +14 -13
- data/test/requests/dns/test_delete_record_set.rb +8 -19
- data/test/requests/dns/test_delete_zone.rb +8 -19
- data/test/requests/dns/test_get_record_set.rb +8 -30
- data/test/requests/dns/test_get_records_from_record_set.rb +15 -28
- data/test/requests/dns/test_get_zone.rb +11 -22
- data/test/requests/dns/test_list_record_sets.rb +10 -11
- data/test/requests/dns/test_list_zones.rb +9 -23
- data/test/requests/network/{test_create_or_update_local_network_gateway.rb → test_create_local_network_gateway.rb} +2 -2
- data/test/requests/network/test_create_virtual_network_gateway_connection.rb +2 -2
- data/test/requests/sql/test_create_or_update_database.rb +28 -0
- data/test/requests/sql/test_create_or_update_sql_server.rb +28 -0
- data/test/requests/sql/test_delete_database.rb +34 -0
- data/test/requests/sql/test_delete_sql_server.rb +34 -0
- data/test/requests/sql/test_get_database.rb +35 -0
- data/test/requests/sql/test_get_sql_server.rb +35 -0
- data/test/requests/sql/test_list_databases.rb +35 -0
- data/test/requests/sql/test_list_sql_servers.rb +35 -0
- data/test/smoke_tests/compute/test_resource_group_smoke.rb +27 -0
- data/test/test_helper.rb +27 -0
- metadata +68 -17
@@ -0,0 +1,89 @@
|
|
1
|
+
module Fog
|
2
|
+
module Sql
|
3
|
+
class AzureRM
|
4
|
+
# Sql Database model for Database Service
|
5
|
+
class SqlDatabase < Fog::Model
|
6
|
+
identity :name
|
7
|
+
attribute :id
|
8
|
+
attribute :resource_group
|
9
|
+
attribute :server_name
|
10
|
+
attribute :type
|
11
|
+
attribute :collation
|
12
|
+
attribute :create_mode
|
13
|
+
attribute :creation_date
|
14
|
+
attribute :current_service_level_objective_id
|
15
|
+
attribute :database_id
|
16
|
+
attribute :default_secondary_location
|
17
|
+
attribute :edition
|
18
|
+
attribute :earliest_restore_date
|
19
|
+
attribute :elastic_pool_name
|
20
|
+
attribute :location
|
21
|
+
attribute :max_size_bytes
|
22
|
+
attribute :requested_service_objective_id
|
23
|
+
attribute :requested_service_objective_name
|
24
|
+
attribute :restore_point_in_time
|
25
|
+
attribute :service_level_objective
|
26
|
+
attribute :source_database_id
|
27
|
+
attribute :source_database_deletion_date
|
28
|
+
|
29
|
+
def self.parse(database)
|
30
|
+
{
|
31
|
+
id: database['id'],
|
32
|
+
type: database['type'],
|
33
|
+
name: database['name'],
|
34
|
+
location: database['location'],
|
35
|
+
edition: database['properties']['edition'],
|
36
|
+
elastic_pool_name: database['elasticPoolName'],
|
37
|
+
collation: database['properties']['collation'],
|
38
|
+
create_mode: database['properties']['createMode'],
|
39
|
+
database_id: database['properties']['databaseId'],
|
40
|
+
server_name: get_server_name_from_id(database['id']),
|
41
|
+
creation_date: database['properties']['creationDate'],
|
42
|
+
max_size_bytes: database['properties']['maxSizeBytes'],
|
43
|
+
resource_group: get_resource_group_from_id(database['id']),
|
44
|
+
source_database_id: database['properties']['sourceDatabaseId'],
|
45
|
+
restore_point_in_time: database['properties']['restorePointInTime'],
|
46
|
+
earliest_restore_date: database['properties']['earliestRestoreDate'],
|
47
|
+
service_level_objective: database['properties']['serviceLevelObjective'],
|
48
|
+
default_secondary_location: database['properties']['defaultSecondaryLocation'],
|
49
|
+
source_database_deletion_date: database['properties']['sourceDatabaseDeletionDate'],
|
50
|
+
requested_service_objective_id: database['properties']['requestedServiceObjectiveId'],
|
51
|
+
requested_service_objective_name: database['properties']['requestedServiceObjectiveName'],
|
52
|
+
current_service_level_objective_id: database['properties']['currentServiceLevelObjectiveId'],
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
def save
|
57
|
+
requires :resource_group, :server_name, :name, :location
|
58
|
+
sql_database = service.create_or_update_database(database_params)
|
59
|
+
merge_attributes(Fog::Sql::AzureRM::SqlDatabase.parse(sql_database))
|
60
|
+
end
|
61
|
+
|
62
|
+
def destroy
|
63
|
+
service.delete_database(resource_group, server_name, name)
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def database_params
|
69
|
+
{
|
70
|
+
resource_group: resource_group,
|
71
|
+
server_name: server_name,
|
72
|
+
name: name,
|
73
|
+
location: location,
|
74
|
+
create_mode: create_mode,
|
75
|
+
edition: edition,
|
76
|
+
source_database_id: source_database_id,
|
77
|
+
collation: collation,
|
78
|
+
max_size_bytes: max_size_bytes,
|
79
|
+
requested_service_objective_name: requested_service_objective_name,
|
80
|
+
restore_point_in_time: restore_point_in_time,
|
81
|
+
source_database_deletion_date: source_database_deletion_date,
|
82
|
+
elastic_pool_name: elastic_pool_name,
|
83
|
+
requested_service_objective_id: requested_service_objective_id
|
84
|
+
}
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Fog
|
2
|
+
module Sql
|
3
|
+
class AzureRM
|
4
|
+
# Sql Server Collection for Database Service
|
5
|
+
class SqlDatabases < Fog::Collection
|
6
|
+
attribute :resource_group
|
7
|
+
attribute :server_name
|
8
|
+
model SqlDatabase
|
9
|
+
|
10
|
+
def all
|
11
|
+
requires :resource_group
|
12
|
+
requires :server_name
|
13
|
+
|
14
|
+
databases = []
|
15
|
+
service.list_databases(resource_group, server_name).each do |database|
|
16
|
+
databases << SqlDatabase.parse(database)
|
17
|
+
end
|
18
|
+
load(databases)
|
19
|
+
end
|
20
|
+
|
21
|
+
def get(resource_group, server_name, name)
|
22
|
+
database = service.get_database(resource_group, server_name, name)
|
23
|
+
database_obj = SqlDatabase.new(service: service)
|
24
|
+
database_obj.merge_attributes(SqlDatabase.parse(database))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Fog
|
2
|
+
module Sql
|
3
|
+
class AzureRM
|
4
|
+
# Sql Server model for Server Service
|
5
|
+
class SqlServer < Fog::Model
|
6
|
+
identity :name
|
7
|
+
attribute :id
|
8
|
+
attribute :type
|
9
|
+
attribute :resource_group
|
10
|
+
attribute :location
|
11
|
+
attribute :version
|
12
|
+
attribute :state
|
13
|
+
attribute :administrator_login
|
14
|
+
attribute :administrator_login_password
|
15
|
+
attribute :fully_qualified_domain_name
|
16
|
+
|
17
|
+
def self.parse(server)
|
18
|
+
{
|
19
|
+
id: server['id'],
|
20
|
+
type: server['type'],
|
21
|
+
name: server['name'],
|
22
|
+
location: server['location'],
|
23
|
+
state: server['properties']['state'],
|
24
|
+
version: server['properties']['version'],
|
25
|
+
resource_group: get_resource_group_from_id(server['id']),
|
26
|
+
administrator_login: server['properties']['administratorLogin'],
|
27
|
+
administrator_login_password: server['properties']['administratorLoginPassword'],
|
28
|
+
fully_qualified_domain_name: server['properties']['fullyQualifiedDomainName']
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
def save
|
33
|
+
requires :name, :resource_group, :location, :version, :administrator_login, :administrator_login_password
|
34
|
+
sql_server = service.create_or_update_sql_server(database_params)
|
35
|
+
merge_attributes(Fog::Sql::AzureRM::SqlServer.parse(sql_server))
|
36
|
+
end
|
37
|
+
|
38
|
+
def destroy
|
39
|
+
service.delete_sql_server(resource_group, name)
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def database_params
|
45
|
+
{
|
46
|
+
resource_group: resource_group,
|
47
|
+
name: name,
|
48
|
+
version: version,
|
49
|
+
location: location,
|
50
|
+
administrator_login: administrator_login,
|
51
|
+
administrator_login_password: administrator_login_password
|
52
|
+
}
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Fog
|
2
|
+
module Sql
|
3
|
+
class AzureRM
|
4
|
+
# Sql Server Collection for Server Service
|
5
|
+
class SqlServers < Fog::Collection
|
6
|
+
attribute :resource_group
|
7
|
+
model SqlServer
|
8
|
+
|
9
|
+
def all
|
10
|
+
requires :resource_group
|
11
|
+
|
12
|
+
servers = []
|
13
|
+
service.list_sql_servers(resource_group).each do |server|
|
14
|
+
servers << SqlServer.parse(server)
|
15
|
+
end
|
16
|
+
load(servers)
|
17
|
+
end
|
18
|
+
|
19
|
+
def get(resource_group, server_name)
|
20
|
+
server = service.get_sql_server(resource_group, server_name)
|
21
|
+
server_obj = SqlServer.new(service: service)
|
22
|
+
server_obj.merge_attributes(SqlServer.parse(server))
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -18,21 +18,11 @@ module Fog
|
|
18
18
|
attribute :min_child_endpoints
|
19
19
|
|
20
20
|
def self.parse(endpoint)
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
hash['target_resource_id'] = endpoint.target_resource_id
|
27
|
-
hash['target'] = endpoint.target
|
28
|
-
hash['endpoint_status'] = endpoint.endpoint_status
|
29
|
-
hash['endpoint_monitor_status'] = endpoint.endpoint_monitor_status
|
30
|
-
hash['weight'] = endpoint.weight
|
31
|
-
hash['priority'] = endpoint.priority
|
32
|
-
hash['endpoint_location'] = endpoint.endpoint_location
|
33
|
-
hash['min_child_endpoints'] = endpoint.min_child_endpoints
|
34
|
-
hash['traffic_manager_profile_name'] = get_traffic_manager_profile_name_from_endpoint_id(endpoint.id)
|
35
|
-
hash
|
21
|
+
traffic_manager_endpoint = get_hash_from_object(endpoint)
|
22
|
+
traffic_manager_endpoint['type'] = get_end_point_type(endpoint.type)
|
23
|
+
traffic_manager_endpoint['resource_group'] = get_resource_group_from_id(endpoint.id)
|
24
|
+
traffic_manager_endpoint['traffic_manager_profile_name'] = get_traffic_manager_profile_name_from_endpoint_id(endpoint.id)
|
25
|
+
traffic_manager_endpoint
|
36
26
|
end
|
37
27
|
|
38
28
|
def save
|
@@ -60,7 +50,7 @@ module Fog
|
|
60
50
|
def create_or_update
|
61
51
|
if %w(azureEndpoints externalEndpoints nestedEndpoints).select { |type| type if type.eql?(type) }.any?
|
62
52
|
traffic_manager_endpoint = service.create_or_update_traffic_manager_endpoint(traffic_manager_endpoint_hash)
|
63
|
-
merge_attributes(
|
53
|
+
merge_attributes(TrafficManagerEndPoint.parse(traffic_manager_endpoint))
|
64
54
|
else
|
65
55
|
raise(ArgumentError, ":type should be '#{AZURE_ENDPOINTS}', '#{EXTERNAL_ENDPOINTS}' or '#{NESTED_ENDPOINTS}'")
|
66
56
|
end
|
@@ -5,25 +5,20 @@ module Fog
|
|
5
5
|
class TrafficManagerEndPoints < Fog::Collection
|
6
6
|
attribute :resource_group
|
7
7
|
attribute :traffic_manager_profile_name
|
8
|
-
model
|
8
|
+
model TrafficManagerEndPoint
|
9
9
|
|
10
10
|
def all
|
11
|
-
requires :resource_group
|
12
|
-
requires :traffic_manager_profile_name
|
11
|
+
requires :resource_group, :traffic_manager_profile_name
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
end_points = profile.endpoints
|
17
|
-
end_points.each do |endpoint|
|
18
|
-
traffic_manager_endpoints << Fog::TrafficManager::AzureRM::TrafficManagerEndPoint.parse(endpoint)
|
19
|
-
end
|
13
|
+
end_points = service.get_traffic_manager_profile(resource_group, traffic_manager_profile_name).endpoints
|
14
|
+
traffic_manager_endpoints = end_points.map { |endpoint| TrafficManagerEndPoint.parse(endpoint) }
|
20
15
|
load(traffic_manager_endpoints)
|
21
16
|
end
|
22
17
|
|
23
18
|
def get(resource_group, traffic_manager_profile_name, end_point_name, type)
|
24
19
|
endpoint = service.get_traffic_manager_end_point(resource_group, traffic_manager_profile_name, end_point_name, type)
|
25
|
-
endpoint_obj =
|
26
|
-
endpoint_obj.merge_attributes(
|
20
|
+
endpoint_obj = TrafficManagerEndPoint.new(service: service)
|
21
|
+
endpoint_obj.merge_attributes(TrafficManagerEndPoint.parse(endpoint))
|
27
22
|
end
|
28
23
|
end
|
29
24
|
end
|
@@ -19,33 +19,34 @@ module Fog
|
|
19
19
|
attribute :endpoints
|
20
20
|
|
21
21
|
def self.parse(profile)
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
22
|
+
traffic_manager_profile = get_hash_from_object(profile)
|
23
|
+
|
24
|
+
if profile.dns_config
|
25
|
+
traffic_manager_profile['relative_name'] = profile.dns_config.relative_name
|
26
|
+
traffic_manager_profile['fqdn'] = profile.dns_config.fqdn
|
27
|
+
traffic_manager_profile['ttl'] = profile.dns_config.ttl
|
28
|
+
end
|
29
|
+
|
30
|
+
if profile.monitor_config
|
31
|
+
traffic_manager_profile['profile_monitor_status'] = profile.monitor_config.profile_monitor_status
|
32
|
+
traffic_manager_profile['protocol'] = profile.monitor_config.protocol
|
33
|
+
traffic_manager_profile['port'] = profile.monitor_config.port
|
34
|
+
traffic_manager_profile['path'] = profile.monitor_config.path
|
35
|
+
end
|
36
|
+
traffic_manager_profile['resource_group'] = get_resource_group_from_id(profile.id)
|
37
|
+
traffic_manager_profile['endpoints'] = []
|
37
38
|
profile.endpoints.each do |endpoint|
|
38
|
-
end_point =
|
39
|
-
|
39
|
+
end_point = TrafficManagerEndPoint.new
|
40
|
+
traffic_manager_profile['endpoints'] << end_point.merge_attributes(TrafficManagerEndPoint.parse(endpoint))
|
40
41
|
end
|
41
|
-
|
42
|
+
traffic_manager_profile
|
42
43
|
end
|
43
44
|
|
44
45
|
def save
|
45
46
|
requires :name, :resource_group, :traffic_routing_method, :relative_name, :ttl,
|
46
47
|
:protocol, :port, :path
|
47
48
|
traffic_manager_profile = service.create_or_update_traffic_manager_profile(traffic_manager_profile_hash)
|
48
|
-
merge_attributes(
|
49
|
+
merge_attributes(TrafficManagerProfile.parse(traffic_manager_profile))
|
49
50
|
end
|
50
51
|
|
51
52
|
def destroy
|
@@ -56,7 +57,7 @@ module Fog
|
|
56
57
|
validate_input(profile_params)
|
57
58
|
merge_attributes(profile_params)
|
58
59
|
profile = service.create_or_update_traffic_manager_profile(traffic_manager_profile_hash)
|
59
|
-
merge_attributes(
|
60
|
+
merge_attributes(TrafficManagerProfile.parse(profile))
|
60
61
|
end
|
61
62
|
|
62
63
|
private
|
@@ -4,21 +4,18 @@ module Fog
|
|
4
4
|
# Traffic Manager Profile Collection for TrafficManager Service
|
5
5
|
class TrafficManagerProfiles < Fog::Collection
|
6
6
|
attribute :resource_group
|
7
|
-
model
|
7
|
+
model TrafficManagerProfile
|
8
8
|
|
9
9
|
def all
|
10
10
|
requires :resource_group
|
11
|
-
traffic_manager_profiles =
|
12
|
-
service.list_traffic_manager_profiles(resource_group).each do |profile|
|
13
|
-
traffic_manager_profiles << Fog::TrafficManager::AzureRM::TrafficManagerProfile.parse(profile)
|
14
|
-
end
|
11
|
+
traffic_manager_profiles = service.list_traffic_manager_profiles(resource_group).map { |profile| TrafficManagerProfile.parse(profile) }
|
15
12
|
load(traffic_manager_profiles)
|
16
13
|
end
|
17
14
|
|
18
15
|
def get(resource_group, traffic_manager_profile_name)
|
19
16
|
profile = service.get_traffic_manager_profile(resource_group, traffic_manager_profile_name)
|
20
|
-
profile_obj =
|
21
|
-
profile_obj.merge_attributes(
|
17
|
+
profile_obj = TrafficManagerProfile.new(service: service)
|
18
|
+
profile_obj.merge_attributes(TrafficManagerProfile.parse(profile))
|
22
19
|
end
|
23
20
|
end
|
24
21
|
end
|
data/lib/fog/azurerm/network.rb
CHANGED
@@ -138,6 +138,7 @@ module Fog
|
|
138
138
|
def initialize(options)
|
139
139
|
begin
|
140
140
|
require 'azure_mgmt_network'
|
141
|
+
require 'yaml'
|
141
142
|
rescue LoadError => e
|
142
143
|
retry if require('rubygems')
|
143
144
|
raise e.message
|
@@ -150,6 +151,8 @@ module Fog
|
|
150
151
|
@client_id = options[:client_id]
|
151
152
|
@client_secret = options[:client_secret]
|
152
153
|
@subscription_id = options[:subscription_id]
|
154
|
+
current_directory = File.dirname(__FILE__)
|
155
|
+
@logger_messages = YAML.load_file("#{current_directory}/utilities/logger_messages.yml")
|
153
156
|
end
|
154
157
|
end
|
155
158
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Fog
|
2
|
+
module ApplicationGateway
|
3
|
+
class AzureRM
|
4
|
+
class Real
|
5
|
+
def start_application_gateway(resource_group, name)
|
6
|
+
msg = "Starting Application Gateway #{name} in Resource Group #{resource_group}"
|
7
|
+
Fog::Logger.debug msg
|
8
|
+
|
9
|
+
begin
|
10
|
+
@network_client.application_gateways.start(resource_group, name)
|
11
|
+
rescue MsRestAzure::AzureOperationError => e
|
12
|
+
raise_azure_exception(e, msg)
|
13
|
+
end
|
14
|
+
Fog::Logger.debug "Successfully started Application Gateway #{name} in Resource Group #{resource_group}"
|
15
|
+
true
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class Mock
|
20
|
+
def start_application_gateway(*)
|
21
|
+
Fog::Logger.debug 'Successfully started Application Gateway {name} in Resource Group {resource_group}'
|
22
|
+
true
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Fog
|
2
|
+
module ApplicationGateway
|
3
|
+
class AzureRM
|
4
|
+
class Real
|
5
|
+
def stop_application_gateway(resource_group, name)
|
6
|
+
msg = "Stopping Application Gateway #{name} in Resource Group #{resource_group}"
|
7
|
+
Fog::Logger.debug msg
|
8
|
+
|
9
|
+
begin
|
10
|
+
@network_client.application_gateways.stop(resource_group, name)
|
11
|
+
rescue MsRestAzure::AzureOperationError => e
|
12
|
+
raise_azure_exception(e, msg)
|
13
|
+
end
|
14
|
+
Fog::Logger.debug "Successfully stopped Application Gateway #{name} in Resource Group #{resource_group}"
|
15
|
+
true
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class Mock
|
20
|
+
def stop_application_gateway(*)
|
21
|
+
Fog::Logger.debug 'Successfully stopped Application Gateway {name} in Resource Group {resource_group}'
|
22
|
+
true
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -4,33 +4,21 @@ module Fog
|
|
4
4
|
# Real class for DNS Request
|
5
5
|
class Real
|
6
6
|
def check_for_zone(resource_group, name)
|
7
|
-
|
7
|
+
msg = "Getting Zone #{name} from Resource Group #{resource_group}."
|
8
|
+
Fog::Logger.debug msg
|
8
9
|
begin
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
accept: 'application/json',
|
13
|
-
content_type: 'application/json',
|
14
|
-
authorization: token
|
15
|
-
)
|
16
|
-
true
|
17
|
-
rescue RestClient::Exception => e
|
18
|
-
body = JSON.parse(e.response)
|
19
|
-
if (body['error']['code']) == 'ResourceNotFound'
|
20
|
-
false
|
21
|
-
else
|
22
|
-
Fog::Logger.warning "Exception checking if the zone exists in resource group #{resource_group}"
|
23
|
-
msg = "Exception checking if the zone exists: #{body['error']['code']}, #{body['error']['message']}"
|
24
|
-
raise msg
|
25
|
-
end
|
10
|
+
zone = @dns_client.zones.get(resource_group, name)
|
11
|
+
rescue MsRestAzure::AzureOperationError => e
|
12
|
+
raise_azure_exception(e, msg)
|
26
13
|
end
|
14
|
+
!zone.nil?
|
27
15
|
end
|
28
16
|
end
|
29
17
|
|
30
18
|
# Mock class for DNS Request
|
31
19
|
class Mock
|
32
|
-
def check_for_zone(
|
33
|
-
Fog::Logger.debug
|
20
|
+
def check_for_zone(*)
|
21
|
+
Fog::Logger.debug 'Zone name name is available.'
|
34
22
|
true
|
35
23
|
end
|
36
24
|
end
|
@@ -3,101 +3,67 @@ module Fog
|
|
3
3
|
class AzureRM
|
4
4
|
# Real class for DNS Request
|
5
5
|
class Real
|
6
|
-
def create_or_update_record_set(
|
7
|
-
|
8
|
-
Fog::Logger.debug
|
6
|
+
def create_or_update_record_set(record_set_params, type)
|
7
|
+
msg = "Creating/updating Recordset #{record_set_params[:name]} in Resource Group: #{record_set_params[:resource_group]}."
|
8
|
+
Fog::Logger.debug msg
|
9
|
+
recordset_object = get_record_set_object(record_set_params, type)
|
10
|
+
begin
|
11
|
+
record_set = @dns_client.record_sets.create_or_update(record_set_params[:resource_group], record_set_params[:zone_name], record_set_params[:name], type, recordset_object)
|
12
|
+
rescue MsRestAzure::AzureOperationError => e
|
13
|
+
raise_azure_exception(e, msg)
|
14
|
+
end
|
15
|
+
Fog::Logger.debug "Record Set #{record_set_params[:name]} created/updated successfully."
|
16
|
+
record_set
|
17
|
+
end
|
9
18
|
|
10
|
-
|
19
|
+
private
|
20
|
+
|
21
|
+
def get_record_set_object(record_set_params, type)
|
22
|
+
record_set = Azure::ARM::Dns::Models::RecordSet.new
|
23
|
+
record_set.name = record_set_params[:name]
|
24
|
+
record_set.type = type
|
25
|
+
record_set.ttl = record_set_params[:ttl]
|
26
|
+
record_set.etag = record_set_params[:etag]
|
27
|
+
case type
|
11
28
|
when 'A'
|
12
29
|
a_type_records_array = []
|
13
|
-
records.each do |ip|
|
14
|
-
|
30
|
+
record_set_params[:records].each do |ip|
|
31
|
+
a_record = Azure::ARM::Dns::Models::ARecord.new
|
32
|
+
a_record.ipv4address = ip
|
33
|
+
a_type_records_array.push(a_record)
|
15
34
|
end
|
16
|
-
|
17
|
-
location: 'global',
|
18
|
-
tags: '',
|
19
|
-
properties: {
|
20
|
-
TTL: ttl,
|
21
|
-
ARecords: a_type_records_array
|
22
|
-
}
|
23
|
-
}
|
35
|
+
record_set.arecords = a_type_records_array
|
24
36
|
when 'CNAME'
|
25
|
-
|
26
|
-
location: 'global',
|
27
|
-
tags: '',
|
28
|
-
properties: {
|
29
|
-
TTL: ttl,
|
30
|
-
CNAMERecord: {
|
31
|
-
cname: records.first # because cname only has 1 value and we know the object is an array passed in.
|
32
|
-
}
|
33
|
-
}
|
34
|
-
}
|
37
|
+
record_set.cname_record = record_set_params[:records].first # because cname only has 1 value and we know the object is an array passed in.
|
35
38
|
end
|
36
39
|
|
37
|
-
|
38
|
-
token = Fog::Credentials::AzureRM.get_token(@tenant_id, @client_id, @client_secret)
|
39
|
-
response = RestClient.put(
|
40
|
-
resource_url,
|
41
|
-
body.to_json,
|
42
|
-
accept: 'application/json',
|
43
|
-
content_type: 'application/json',
|
44
|
-
authorization: token
|
45
|
-
)
|
46
|
-
Fog::Logger.debug "RecordSet #{name} Created/Updated Successfully!"
|
47
|
-
parsed_response = JSON.parse(response)
|
48
|
-
parsed_response
|
49
|
-
rescue Exception => e
|
50
|
-
Fog::Logger.warning "Exception creating recordset #{name} in zone #{zone_name}."
|
51
|
-
msg = "AzureDns::RecordSet - Exception is: #{e.message}"
|
52
|
-
raise msg
|
53
|
-
end
|
40
|
+
record_set
|
54
41
|
end
|
55
42
|
end
|
56
43
|
|
57
44
|
# Mock class for DNS Request
|
58
45
|
class Mock
|
59
|
-
def create_or_update_record_set(
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
{
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
[
|
75
|
-
{
|
76
|
-
'ipv4Address' => records[0]
|
77
|
-
}
|
78
|
-
]
|
79
|
-
}
|
80
|
-
}
|
81
|
-
elsif record_type == 'CNAME'
|
82
|
-
{
|
83
|
-
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group}/providers/Microsoft.Network/dnszones/#{zone_name}/#{record_type}/#{name}",
|
84
|
-
'name' => name,
|
85
|
-
'type' => "Microsoft.Network/dnszones/#{record_type}",
|
86
|
-
'etag' => 'cc5ceb6e-16ad-4a5f-bbd7-9bc31c12d0cf',
|
87
|
-
'location' => 'global',
|
88
|
-
'tags' => {},
|
89
|
-
'properties' =>
|
90
|
-
{
|
91
|
-
'metadata' => {},
|
92
|
-
'fqdn' => "#{name}.#{zone_name}.",
|
93
|
-
'TTL' => ttl,
|
94
|
-
'CNAMERecord' =>
|
46
|
+
def create_or_update_record_set(*)
|
47
|
+
{
|
48
|
+
'id' => '/subscriptions/########-####-####-####-############/resourceGroups/resource_group/providers/Microsoft.Network/dnszones/zone_name/record_type/name',
|
49
|
+
'name' => 'name',
|
50
|
+
'type' => 'Microsoft.Network/dnszones/record_type',
|
51
|
+
'etag' => '7f159cb1-653d-4920-bc03-153c700412a2',
|
52
|
+
'location' => 'global',
|
53
|
+
'tags' => {},
|
54
|
+
'properties' =>
|
55
|
+
{
|
56
|
+
'metadata' => {},
|
57
|
+
'fqdn' => 'name.zone_name',
|
58
|
+
'TTL' => 10,
|
59
|
+
'ARecords' =>
|
60
|
+
[
|
95
61
|
{
|
96
|
-
'
|
62
|
+
'ipv4Address' => '10.1.2.0'
|
97
63
|
}
|
98
|
-
|
99
|
-
|
100
|
-
|
64
|
+
]
|
65
|
+
}
|
66
|
+
}
|
101
67
|
end
|
102
68
|
end
|
103
69
|
end
|