fog-azure-rm 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/Gemfile +1 -1
- data/README.md +0 -1
- data/fog-azure-rm.gemspec +4 -1
- data/lib/fog/azurerm.rb +7 -0
- data/lib/fog/azurerm/application_gateway.rb +10 -2
- data/lib/fog/azurerm/compute.rb +14 -4
- data/lib/fog/azurerm/config.rb +0 -51
- data/lib/fog/azurerm/constants.rb +51 -0
- data/lib/fog/azurerm/dns.rb +12 -4
- data/lib/fog/azurerm/docs/application_gateway.md +38 -4
- data/lib/fog/azurerm/docs/compute.md +23 -4
- data/lib/fog/azurerm/docs/dns.md +18 -4
- data/lib/fog/azurerm/docs/key_vault.md +88 -0
- data/lib/fog/azurerm/docs/network.md +98 -9
- data/lib/fog/azurerm/docs/resources.md +24 -4
- data/lib/fog/azurerm/docs/sql.md +5 -6
- data/lib/fog/azurerm/docs/storage.md +12 -0
- data/lib/fog/azurerm/docs/traffic_manager.md +22 -4
- data/lib/fog/azurerm/key_vault.rb +51 -0
- data/lib/fog/azurerm/models/application_gateway/backend_address_pool.rb +2 -0
- data/lib/fog/azurerm/models/application_gateway/backend_http_setting.rb +2 -0
- data/lib/fog/azurerm/models/application_gateway/frontend_ip_configuration.rb +4 -0
- data/lib/fog/azurerm/models/application_gateway/frontend_port.rb +2 -0
- data/lib/fog/azurerm/models/application_gateway/gateway.rb +2 -6
- data/lib/fog/azurerm/models/application_gateway/gateways.rb +4 -0
- data/lib/fog/azurerm/models/application_gateway/http_listener.rb +2 -0
- data/lib/fog/azurerm/models/application_gateway/ip_configuration.rb +3 -0
- data/lib/fog/azurerm/models/application_gateway/probe.rb +2 -0
- data/lib/fog/azurerm/models/application_gateway/request_routing_rule.rb +2 -0
- data/lib/fog/azurerm/models/application_gateway/ssl_certificate.rb +2 -0
- data/lib/fog/azurerm/models/application_gateway/url_path_map.rb +2 -0
- data/lib/fog/azurerm/models/compute/availability_sets.rb +4 -0
- data/lib/fog/azurerm/models/compute/servers.rb +4 -0
- data/lib/fog/azurerm/models/compute/virtual_machine_extensions.rb +4 -0
- data/lib/fog/azurerm/models/dns/record_sets.rb +4 -0
- data/lib/fog/azurerm/models/dns/zones.rb +2 -2
- data/lib/fog/azurerm/models/key_vault/access_policy_entry.rb +31 -0
- data/lib/fog/azurerm/models/key_vault/vault.rb +76 -0
- data/lib/fog/azurerm/models/key_vault/vaults.rb +27 -0
- data/lib/fog/azurerm/models/network/express_route_circuit_authorizations.rb +4 -0
- data/lib/fog/azurerm/models/network/express_route_circuits.rb +4 -0
- data/lib/fog/azurerm/models/network/load_balancers.rb +12 -2
- data/lib/fog/azurerm/models/network/local_network_gateways.rb +4 -0
- data/lib/fog/azurerm/models/network/network_interfaces.rb +4 -0
- data/lib/fog/azurerm/models/network/network_security_groups.rb +4 -0
- data/lib/fog/azurerm/models/network/network_security_rules.rb +4 -0
- data/lib/fog/azurerm/models/network/public_ips.rb +2 -9
- data/lib/fog/azurerm/models/network/subnets.rb +4 -0
- data/lib/fog/azurerm/models/network/virtual_network_gateway_connections.rb +4 -0
- data/lib/fog/azurerm/models/network/virtual_network_gateways.rb +4 -0
- data/lib/fog/azurerm/models/network/virtual_networks.rb +9 -11
- data/lib/fog/azurerm/models/resources/azure_resources.rb +4 -0
- data/lib/fog/azurerm/models/resources/deployments.rb +4 -0
- data/lib/fog/azurerm/models/resources/resource_groups.rb +4 -0
- data/lib/fog/azurerm/models/sql/firewall_rule.rb +5 -17
- data/lib/fog/azurerm/models/sql/firewall_rules.rb +4 -0
- data/lib/fog/azurerm/models/sql/sql_database.rb +4 -21
- data/lib/fog/azurerm/models/sql/sql_databases.rb +4 -0
- data/lib/fog/azurerm/models/sql/sql_server.rb +5 -18
- data/lib/fog/azurerm/models/sql/sql_servers.rb +4 -0
- data/lib/fog/azurerm/models/storage/directories.rb +4 -0
- data/lib/fog/azurerm/models/storage/storage_accounts.rb +4 -0
- data/lib/fog/azurerm/models/traffic_manager/traffic_manager_end_points.rb +4 -0
- data/lib/fog/azurerm/models/traffic_manager/traffic_manager_profiles.rb +4 -0
- data/lib/fog/azurerm/network.rb +22 -4
- data/lib/fog/azurerm/requests/application_gateway/check_ag_exists.rb +31 -0
- data/lib/fog/azurerm/requests/application_gateway/create_or_update_application_gateway.rb +6 -0
- data/lib/fog/azurerm/requests/compute/check_availability_set_exists.rb +31 -0
- data/lib/fog/azurerm/requests/compute/check_vm_exists.rb +31 -0
- data/lib/fog/azurerm/requests/compute/check_vm_extension_exists.rb +31 -0
- data/lib/fog/azurerm/requests/dns/check_record_set_exists.rb +31 -0
- data/lib/fog/azurerm/requests/dns/{check_for_zone.rb → check_zone_exists.rb} +4 -2
- data/lib/fog/azurerm/requests/dns/list_record_sets.rb +1 -1
- data/lib/fog/azurerm/requests/dns/list_zones.rb +2 -2
- data/lib/fog/azurerm/requests/key_vault/check_vault_exists.rb +31 -0
- data/lib/fog/azurerm/requests/key_vault/create_or_update_vault.rb +105 -0
- data/lib/fog/azurerm/requests/key_vault/delete_vault.rb +28 -0
- data/lib/fog/azurerm/requests/key_vault/get_vault.rb +54 -0
- data/lib/fog/azurerm/requests/key_vault/list_vaults.rb +56 -0
- data/lib/fog/azurerm/requests/network/check_express_route_cir_auth_exists.rb +31 -0
- data/lib/fog/azurerm/requests/network/check_express_route_circuit_exists.rb +31 -0
- data/lib/fog/azurerm/requests/network/check_load_balancer_exists.rb +31 -0
- data/lib/fog/azurerm/requests/network/check_local_net_gateway_exists.rb +31 -0
- data/lib/fog/azurerm/requests/network/check_net_sec_group_exists.rb +31 -0
- data/lib/fog/azurerm/requests/network/check_net_sec_rule_exists.rb +31 -0
- data/lib/fog/azurerm/requests/network/check_network_interface_exists.rb +31 -0
- data/lib/fog/azurerm/requests/network/{check_for_public_ip.rb → check_public_ip_exists.rb} +12 -5
- data/lib/fog/azurerm/requests/network/check_subnet_exists.rb +32 -0
- data/lib/fog/azurerm/requests/network/{check_for_virtual_network.rb → check_virtual_network_exists.rb} +11 -6
- data/lib/fog/azurerm/requests/network/check_vnet_gateway_connection_exists.rb +32 -0
- data/lib/fog/azurerm/requests/network/check_vnet_gateway_exists.rb +32 -0
- data/lib/fog/azurerm/requests/network/list_load_balancers_in_subscription.rb +31 -0
- data/lib/fog/azurerm/requests/network/list_virtual_networks_in_subscription.rb +74 -0
- data/lib/fog/azurerm/requests/resources/check_azure_resource_exists.rb +40 -0
- data/lib/fog/azurerm/requests/resources/check_deployment_exists.rb +30 -0
- data/lib/fog/azurerm/requests/resources/check_resource_group_exists.rb +30 -0
- data/lib/fog/azurerm/requests/sql/check_database_exists.rb +21 -0
- data/lib/fog/azurerm/requests/sql/check_firewall_rule_exists.rb +21 -0
- data/lib/fog/azurerm/requests/sql/check_sql_server_exists.rb +21 -0
- data/lib/fog/azurerm/requests/sql/create_or_update_database.rb +26 -32
- data/lib/fog/azurerm/requests/sql/create_or_update_firewall_rule.rb +8 -22
- data/lib/fog/azurerm/requests/sql/create_or_update_sql_server.rb +14 -24
- data/lib/fog/azurerm/requests/sql/delete_database.rb +2 -9
- data/lib/fog/azurerm/requests/sql/delete_firewall_rule.rb +2 -9
- data/lib/fog/azurerm/requests/sql/delete_sql_server.rb +3 -9
- data/lib/fog/azurerm/requests/sql/get_database.rb +4 -10
- data/lib/fog/azurerm/requests/sql/get_firewall_rule.rb +4 -10
- data/lib/fog/azurerm/requests/sql/get_sql_server.rb +3 -10
- data/lib/fog/azurerm/requests/sql/list_databases.rb +3 -10
- data/lib/fog/azurerm/requests/sql/list_firewall_rules.rb +4 -10
- data/lib/fog/azurerm/requests/sql/list_sql_servers.rb +3 -10
- data/lib/fog/azurerm/requests/storage/check_container_exists.rb +30 -0
- data/lib/fog/azurerm/requests/storage/check_storage_account_exists.rb +31 -0
- data/lib/fog/azurerm/requests/storage/create_or_update_recovery_vault.rb +1 -1
- data/lib/fog/azurerm/requests/storage/delete_recovery_vault.rb +1 -1
- data/lib/fog/azurerm/requests/storage/disable_backup_protection.rb +1 -1
- data/lib/fog/azurerm/requests/storage/enable_backup_protection.rb +1 -1
- data/lib/fog/azurerm/requests/storage/get_all_backup_jobs.rb +1 -1
- data/lib/fog/azurerm/requests/storage/get_backup_container.rb +1 -1
- data/lib/fog/azurerm/requests/storage/get_backup_item.rb +1 -1
- data/lib/fog/azurerm/requests/storage/get_backup_protection_policy.rb +1 -1
- data/lib/fog/azurerm/requests/storage/get_recovery_vault.rb +1 -1
- data/lib/fog/azurerm/requests/storage/list_recovery_vaults.rb +1 -1
- data/lib/fog/azurerm/requests/storage/set_recovery_vault_context.rb +1 -1
- data/lib/fog/azurerm/requests/storage/start_backup.rb +1 -1
- data/lib/fog/azurerm/requests/traffic_manager/check_traffic_manager_endpoint_exists.rb +31 -0
- data/lib/fog/azurerm/requests/traffic_manager/check_traffic_manager_profile_exists.rb +31 -0
- data/lib/fog/azurerm/resources.rb +10 -2
- data/lib/fog/azurerm/sql.rb +18 -10
- data/lib/fog/azurerm/storage.rb +4 -0
- data/lib/fog/azurerm/traffic_manager.rb +9 -2
- data/lib/fog/azurerm/version.rb +1 -1
- data/rake-script.sh +3 -10
- data/test/api_stub.rb +8 -0
- data/test/api_stub/models/key_vault/vault.rb +39 -0
- data/test/api_stub/models/sql/sql_database.rb +18 -16
- data/test/api_stub/models/sql/sql_firewall_rule.rb +12 -10
- data/test/api_stub/models/sql/sql_server.rb +12 -10
- data/test/api_stub/requests/key_vault/vault.rb +95 -0
- data/test/api_stub/requests/sql/database.rb +8 -6
- data/test/api_stub/requests/sql/firewall_rule.rb +8 -4
- data/test/api_stub/requests/sql/sql_server.rb +8 -4
- data/test/integration/Virtual_network_gateway_connection.rb +7 -0
- data/test/integration/application_gateway.rb +8 -0
- data/test/integration/availability_set.rb +13 -2
- data/test/integration/blob.rb +0 -6
- data/test/integration/container.rb +7 -0
- data/test/integration/deployment.rb +7 -0
- data/test/integration/express_route_circuit.rb +16 -0
- data/test/integration/external_load_balancer.rb +18 -0
- data/test/integration/key_vault.rb +98 -0
- data/test/integration/local_network_gateway.rb +8 -0
- data/test/integration/network_interface.rb +8 -0
- data/test/integration/network_security_group.rb +8 -0
- data/test/integration/network_security_rule.rb +8 -0
- data/test/integration/public_ip.rb +3 -2
- data/test/integration/record_set.rb +8 -0
- data/test/integration/resource_group.rb +12 -4
- data/test/integration/resource_tag.rb +7 -0
- data/test/integration/server.rb +8 -0
- data/test/integration/sql_server.rb +23 -3
- data/test/integration/storage_account.rb +8 -1
- data/test/integration/subnet.rb +7 -0
- data/test/integration/traffic_manager.rb +14 -0
- data/test/integration/virtual_machine_extension.rb +8 -0
- data/test/integration/virtual_network.rb +13 -4
- data/test/integration/virtual_network_gateway.rb +7 -0
- data/test/integration/zone.rb +8 -0
- data/test/models/application_gateway/test_gateway.rb +1 -0
- data/test/models/application_gateway/test_gateways.rb +14 -1
- data/test/models/compute/test_availability_sets.rb +14 -1
- data/test/models/compute/test_servers.rb +14 -1
- data/test/models/compute/test_virtual_machine_extensions.rb +14 -1
- data/test/models/dns/test_record_sets.rb +14 -1
- data/test/models/dns/test_zones.rb +7 -7
- data/test/models/key_vault/test_vault.rb +39 -0
- data/test/models/key_vault/test_vaults.rb +55 -0
- data/test/models/network/test_express_route_circuit_authorizations.rb +14 -1
- data/test/models/network/test_express_route_circuits.rb +14 -1
- data/test/models/network/test_load_balancers.rb +14 -1
- data/test/models/network/test_local_network_gateways.rb +14 -1
- data/test/models/network/test_network_interfaces.rb +14 -1
- data/test/models/network/test_network_security_groups.rb +14 -1
- data/test/models/network/test_network_security_rules.rb +14 -1
- data/test/models/network/test_public_ips.rb +6 -6
- data/test/models/network/test_subnets.rb +14 -1
- data/test/models/network/test_virtual_network_gateway_connections.rb +14 -1
- data/test/models/network/test_virtual_network_gateways.rb +14 -1
- data/test/models/network/test_virtual_networks.rb +20 -8
- data/test/models/resources/test_deployments.rb +14 -1
- data/test/models/resources/test_resource_groups.rb +14 -1
- data/test/models/resources/test_resources.rb +16 -3
- data/test/models/sql/test_database.rb +3 -4
- data/test/models/sql/test_databases.rb +5 -5
- data/test/models/sql/test_firewall_rule.rb +2 -1
- data/test/models/sql/test_firewall_rules.rb +3 -2
- data/test/models/sql/test_sql_server.rb +2 -1
- data/test/models/sql/test_sql_servers.rb +5 -5
- data/test/models/storage/test_directories.rb +14 -1
- data/test/models/storage/test_storage_accounts.rb +14 -1
- data/test/models/traffic_manager/test_traffic_manager_end_points.rb +14 -1
- data/test/models/traffic_manager/test_traffic_manager_profiles.rb +14 -1
- data/test/requests/application_gateway/test_check_ag_exists.rb +31 -0
- data/test/requests/compute/test_check_availability_set_exists.rb +31 -0
- data/test/requests/compute/test_check_vm_exists.rb +31 -0
- data/test/requests/compute/test_check_vm_extension_exists.rb +31 -0
- data/test/requests/dns/test_check_record_set_exists.rb +31 -0
- data/test/requests/dns/test_check_zone_exists.rb +35 -0
- data/test/requests/dns/test_list_record_sets.rb +35 -0
- data/test/requests/dns/{test_check_for_zone.rb → test_list_zones.rb} +10 -8
- data/test/requests/key_vault/test_check_vault_exists.rb +31 -0
- data/test/requests/key_vault/test_create_or_update_vault.rb +25 -0
- data/test/requests/key_vault/test_delete_vault.rb +23 -0
- data/test/requests/key_vault/test_get_vault.rb +24 -0
- data/test/requests/key_vault/test_list_vaults.rb +24 -0
- data/test/requests/network/test_check_express_route_cir_auth_exists.rb +31 -0
- data/test/requests/network/test_check_express_route_circuit_exists.rb +31 -0
- data/test/requests/network/test_check_load_balancer_exists.rb +31 -0
- data/test/requests/network/test_check_local_net_gateway_exists.rb +31 -0
- data/test/requests/network/test_check_net_sec_group_exists.rb +31 -0
- data/test/requests/network/test_check_net_sec_rule_exists.rb +31 -0
- data/test/requests/network/test_check_network_interface_exists.rb +31 -0
- data/test/requests/network/{test_check_for_public_ip.rb → test_check_public_ip_exists.rb} +8 -8
- data/test/requests/network/test_check_subnet_exists.rb +31 -0
- data/test/requests/network/{test_check_for_virtual_network.rb → test_check_virtual_network_exists.rb} +8 -8
- data/test/requests/network/test_check_vnet_gateway_connection_exists.rb +31 -0
- data/test/requests/network/test_check_vnet_gateway_exists.rb +31 -0
- data/test/requests/network/test_list_virtual_networks_in_subscription.rb +24 -0
- data/test/requests/resources/test_check_azure_resource_exists.rb +22 -0
- data/test/requests/resources/test_check_deployment_exists.rb +29 -0
- data/test/requests/resources/test_check_resource_group_exists.rb +29 -0
- data/test/requests/sql/test_create_or_update_database.rb +9 -12
- data/test/requests/sql/test_create_or_update_firewall_rule.rb +9 -11
- data/test/requests/sql/test_create_or_update_sql_server.rb +9 -12
- data/test/requests/sql/test_delete_database.rb +6 -17
- data/test/requests/sql/test_delete_firewall_rule.rb +6 -17
- data/test/requests/sql/test_delete_sql_server.rb +6 -17
- data/test/requests/sql/test_get_database.rb +7 -18
- data/test/requests/sql/test_get_firewall_rule.rb +7 -18
- data/test/requests/sql/test_get_sql_server.rb +7 -18
- data/test/requests/sql/test_list_databases.rb +7 -18
- data/test/requests/sql/test_list_firewall_rules.rb +7 -18
- data/test/requests/sql/test_list_sql_servers.rb +7 -18
- data/test/requests/storage/test_check_container_exists.rb +18 -0
- data/test/requests/storage/test_check_storage_account_exists.rb +32 -0
- data/test/requests/traffic_manager/test_check_traffic_manager_endpoint_exists.rb +31 -0
- data/test/requests/traffic_manager/test_check_traffic_manager_profile_exists.rb +31 -0
- data/test/test_helper.rb +39 -4
- metadata +125 -10
@@ -0,0 +1,31 @@
|
|
1
|
+
module Fog
|
2
|
+
module Network
|
3
|
+
class AzureRM
|
4
|
+
# Real class for Network Request
|
5
|
+
class Real
|
6
|
+
def list_load_balancers_in_subscription
|
7
|
+
msg = 'Getting list of Load-Balancers in subscription'
|
8
|
+
Fog::Logger.debug msg
|
9
|
+
begin
|
10
|
+
load_balancers = @network_client.load_balancers.list_all
|
11
|
+
rescue MsRestAzure::AzureOperationError => e
|
12
|
+
raise_azure_exception(e, msg)
|
13
|
+
end
|
14
|
+
Fog::Logger.debug 'Successfully retrieved load balancers in subscription'
|
15
|
+
load_balancers
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# Mock class for Network Request
|
20
|
+
class Mock
|
21
|
+
def list_load_balancers_in_subscription
|
22
|
+
lb = Azure::ARM::Network::Models::LoadBalancer.new
|
23
|
+
lb.name = 'fogtestloadbalancer'
|
24
|
+
lb.location = 'West US'
|
25
|
+
lb.properties = Azure::ARM::Network::Models::LoadBalancerPropertiesFormat.new
|
26
|
+
[lb]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module Fog
|
2
|
+
module Network
|
3
|
+
class AzureRM
|
4
|
+
# This class provides the actual implementation for service calls.
|
5
|
+
class Real
|
6
|
+
def list_virtual_networks_in_subscription
|
7
|
+
msg = 'Listing Virtual Networks in a subscription'
|
8
|
+
Fog::Logger.debug msg
|
9
|
+
begin
|
10
|
+
virtual_networks = @network_client.virtual_networks.list_all
|
11
|
+
rescue MsRestAzure::AzureOperationError => e
|
12
|
+
raise_azure_exception(e, msg)
|
13
|
+
end
|
14
|
+
virtual_networks
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# This class provides the mock implementation for unit tests.
|
19
|
+
class Mock
|
20
|
+
def list_virtual_networks_in_subscription
|
21
|
+
virtual_network = {
|
22
|
+
'value' => [
|
23
|
+
{
|
24
|
+
'id' => '/subscriptions/########-####-####-####-############/resourceGroups/TestRG/providers/Microsoft.Network/virtualNetworks/testVnet',
|
25
|
+
'name' => 'testVnet',
|
26
|
+
'type' => 'Microsoft.Network/virtualNetworks',
|
27
|
+
'location' => 'westus',
|
28
|
+
'properties' =>
|
29
|
+
{
|
30
|
+
'addressSpace' =>
|
31
|
+
{
|
32
|
+
'addressPrefixes' =>
|
33
|
+
%w(10.1.0.0/16 10.2.0.0/16)
|
34
|
+
},
|
35
|
+
'subnets' =>
|
36
|
+
[
|
37
|
+
{
|
38
|
+
'id' => '/subscriptions/########-####-####-####-############/resourceGroups/TestRG/providers/Microsoft.Network/virtualNetworks/testVnet/subnets/subnet_0_testVnet',
|
39
|
+
'properties' =>
|
40
|
+
{
|
41
|
+
'addressPrefix' => '10.1.0.0/24',
|
42
|
+
'provisioningState' => 'Succeeded'
|
43
|
+
},
|
44
|
+
'name' => 'subnet_0_testVnet'
|
45
|
+
},
|
46
|
+
{
|
47
|
+
'id' => '/subscriptions/########-####-####-####-############/resourceGroups/TestRG/providers/Microsoft.Network/virtualNetworks/testVnet/subnets/fog-test-subnet',
|
48
|
+
'properties' =>
|
49
|
+
{
|
50
|
+
'addressPrefix' => '10.2.0.0/16',
|
51
|
+
'ipConfigurations' =>
|
52
|
+
[
|
53
|
+
{
|
54
|
+
'id' => '/subscriptions/########-####-####-####-############/resourceGroups/TestRG/providers/Microsoft.Network/networkInterfaces/test-NIC/ipConfigurations/ipconfig1'
|
55
|
+
}
|
56
|
+
],
|
57
|
+
'provisioningState' => 'Succeeded'
|
58
|
+
},
|
59
|
+
'name' => 'fog-test-subnet'
|
60
|
+
}
|
61
|
+
],
|
62
|
+
'resourceGuid' => 'c573f8e2-d916-493f-8b25-a681c31269ef',
|
63
|
+
'provisioningState' => 'Succeeded'
|
64
|
+
}
|
65
|
+
}
|
66
|
+
]
|
67
|
+
}
|
68
|
+
vnet_mapper = Azure::ARM::Network::Models::VirtualNetworkListResult.mapper
|
69
|
+
@network_client.deserialize(vnet_mapper, virtual_network, 'result.body')
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Fog
|
2
|
+
module Resources
|
3
|
+
class AzureRM
|
4
|
+
# This class provides the actual implementation for service calls.
|
5
|
+
class Real
|
6
|
+
def check_azure_resource_exists(resource_id, api_version)
|
7
|
+
split_resource = resource_id.split('/') unless resource_id.nil?
|
8
|
+
raise 'Invalid Resource Id' if split_resource.count != 9
|
9
|
+
|
10
|
+
resource_group_name = get_resource_from_resource_id(resource_id, RESOURCE_GROUP_NAME)
|
11
|
+
resource_provider_namespace = get_resource_from_resource_id(resource_id, RESOURCE_PROVIDER_NAMESPACE)
|
12
|
+
resource_type = get_resource_from_resource_id(resource_id, RESOURCE_TYPE)
|
13
|
+
resource_name = get_resource_from_resource_id(resource_id, RESOURCE_NAME)
|
14
|
+
parent_resource_id = ''
|
15
|
+
|
16
|
+
msg = "Checking Resource #{resource_name}"
|
17
|
+
Fog::Logger.debug msg
|
18
|
+
begin
|
19
|
+
@rmc.resources.check_existence(resource_group_name, resource_provider_namespace, parent_resource_id, resource_type, resource_name, api_version)
|
20
|
+
Fog::Logger.debug "Resource #{resource_name} exists."
|
21
|
+
true
|
22
|
+
rescue MsRestAzure::AzureOperationError => e
|
23
|
+
if e.response.status == 405
|
24
|
+
Fog::Logger.debug "Resource #{resource_name} doesn't exist."
|
25
|
+
false
|
26
|
+
else
|
27
|
+
raise_azure_exception(e, msg)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
# This class provides the mock implementation for unit tests.
|
33
|
+
class Mock
|
34
|
+
def check_azure_resource_exists(*)
|
35
|
+
true
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Fog
|
2
|
+
module Resources
|
3
|
+
class AzureRM
|
4
|
+
# This class provides the actual implementation for service calls.
|
5
|
+
class Real
|
6
|
+
def check_deployment_exists(resource_group_name, deployment_name)
|
7
|
+
msg = "Checking Deployment #{deployment_name}"
|
8
|
+
Fog::Logger.debug msg
|
9
|
+
begin
|
10
|
+
flag = @rmc.deployments.check_existence(resource_group_name, deployment_name)
|
11
|
+
if flag
|
12
|
+
Fog::Logger.debug "Deployment #{deployment_name} exists."
|
13
|
+
else
|
14
|
+
Fog::Logger.debug "Deployment #{deployment_name} doesn't exist."
|
15
|
+
end
|
16
|
+
flag
|
17
|
+
rescue MsRestAzure::AzureOperationError => e
|
18
|
+
raise_azure_exception(e, msg)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
# This class provides the mock implementation for unit tests.
|
23
|
+
class Mock
|
24
|
+
def check_deployment_exists(*)
|
25
|
+
true
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Fog
|
2
|
+
module Resources
|
3
|
+
class AzureRM
|
4
|
+
# This class provides the actual implementation for service calls.
|
5
|
+
class Real
|
6
|
+
def check_resource_group_exists(resource_group_name)
|
7
|
+
msg = "Checking Resource Group #{resource_group_name}"
|
8
|
+
Fog::Logger.debug msg
|
9
|
+
begin
|
10
|
+
flag = @rmc.resource_groups.check_existence(resource_group_name)
|
11
|
+
if flag
|
12
|
+
Fog::Logger.debug "Resource Group #{resource_group_name} exists."
|
13
|
+
else
|
14
|
+
Fog::Logger.debug "Resource Group #{resource_group_name} doesn't exist."
|
15
|
+
end
|
16
|
+
flag
|
17
|
+
rescue MsRestAzure::AzureOperationError => e
|
18
|
+
raise_azure_exception(e, msg)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
# This class provides the mock implementation for unit tests.
|
23
|
+
class Mock
|
24
|
+
def check_resource_group_exists(*)
|
25
|
+
true
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Fog
|
2
|
+
module Sql
|
3
|
+
class AzureRM
|
4
|
+
# Mock class for Sql Request
|
5
|
+
class Real
|
6
|
+
def check_database_exists(resource_group, server_name, name)
|
7
|
+
msg = "Checking SQL Database #{name}"
|
8
|
+
Fog::Logger.debug msg
|
9
|
+
# This module needs to be updated to azure sdk
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# Mock class for Sql Request
|
14
|
+
class Mock
|
15
|
+
def check_database_exists(*)
|
16
|
+
true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Fog
|
2
|
+
module Sql
|
3
|
+
class AzureRM
|
4
|
+
# Mock class for Sql Request
|
5
|
+
class Real
|
6
|
+
def check_firewall_rule_exists(resource_group, server_name, rule_name)
|
7
|
+
msg = "Checking Firewall Rule #{rule_name}"
|
8
|
+
Fog::Logger.debug msg
|
9
|
+
# This module needs to be updated to azure sdk
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# Mock class for Sql Request
|
14
|
+
class Mock
|
15
|
+
def check_firewall_rule_exists(*)
|
16
|
+
true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Fog
|
2
|
+
module Sql
|
3
|
+
class AzureRM
|
4
|
+
# Mock class for Sql Request
|
5
|
+
class Real
|
6
|
+
def check_sql_server_exists(resource_group, server_name)
|
7
|
+
msg = "Checking SQL Server #{server_name}"
|
8
|
+
Fog::Logger.debug msg
|
9
|
+
# This module needs to be updated to azure sdk
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# Mock class for Sql Request
|
14
|
+
class Mock
|
15
|
+
def check_sql_server_exists(*)
|
16
|
+
true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -6,46 +6,40 @@ module Fog
|
|
6
6
|
def create_or_update_database(database_hash)
|
7
7
|
msg = "Creating SQL Database: #{database_hash[:name]}."
|
8
8
|
Fog::Logger.debug msg
|
9
|
-
resource_url = "#{resource_manager_endpoint_url}/subscriptions/#{@subscription_id}/resourceGroups/#{database_hash[:resource_group]}/providers/Microsoft.Sql/servers/#{database_hash[:server_name]}/databases/#{database_hash[:name]}?api-version=2014-04-01-preview"
|
10
|
-
request_parameters = format_database_parameters(database_hash[:location], database_hash[:create_mode], database_hash[:edition], database_hash[:source_database_id], database_hash[:collation], database_hash[:max_size_bytes], database_hash[:requested_service_objective_name], database_hash[:restore_point_in_time], database_hash[:source_database_deletion_date], database_hash[:elastic_pool_name], database_hash[:requested_service_objective_id])
|
11
9
|
begin
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
10
|
+
sql_database = @sql_mgmt_client.databases.create_or_update(database_hash[:resource_group],
|
11
|
+
database_hash[:server_name],
|
12
|
+
database_hash[:name],
|
13
|
+
format_database_parameters(database_hash[:location],
|
14
|
+
database_hash[:create_mode],
|
15
|
+
database_hash[:edition],
|
16
|
+
database_hash[:source_database_id],
|
17
|
+
database_hash[:collation],
|
18
|
+
database_hash[:max_size_bytes],
|
19
|
+
database_hash[:requested_service_objective_name],
|
20
|
+
database_hash[:elastic_pool_name],
|
21
|
+
database_hash[:requested_service_objective_id]))
|
22
|
+
rescue MsRestAzure::AzureOperationError => e
|
21
23
|
raise_azure_exception(e, msg)
|
22
24
|
end
|
23
25
|
Fog::Logger.debug "SQL Database: #{database_hash[:name]} created successfully."
|
24
|
-
|
26
|
+
sql_database
|
25
27
|
end
|
26
28
|
|
27
29
|
private
|
28
30
|
|
29
|
-
def format_database_parameters(location, create_mode, edition, source_database_id, collation, max_size_bytes, requested_service_objective_name,
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
properties['requestedServiceObjectiveId'] = requested_service_objective_id unless requested_service_objective_id.nil?
|
42
|
-
properties['requestedServiceObjectiveName'] = requested_service_objective_name unless requested_service_objective_name.nil?
|
43
|
-
|
44
|
-
parameters['tags'] = {}
|
45
|
-
parameters['location'] = location
|
46
|
-
parameters['properties'] = properties
|
47
|
-
|
48
|
-
parameters
|
31
|
+
def format_database_parameters(location, create_mode, edition, source_database_id, collation, max_size_bytes, requested_service_objective_name, elastic_pool_name, requested_service_objective_id)
|
32
|
+
database = Azure::ARM::SQL::Models::Database.new
|
33
|
+
database.location = location
|
34
|
+
database.edition = edition unless edition.nil?
|
35
|
+
database.collation = collation unless collation.nil?
|
36
|
+
database.create_mode = create_mode unless create_mode.nil?
|
37
|
+
database.max_size_bytes = max_size_bytes unless max_size_bytes.nil?
|
38
|
+
database.elastic_pool_name = elastic_pool_name unless elastic_pool_name.nil?
|
39
|
+
database.source_database_id = source_database_id unless source_database_id.nil?
|
40
|
+
database.requested_service_objective_id = requested_service_objective_id unless requested_service_objective_id.nil?
|
41
|
+
database.requested_service_objective_name = requested_service_objective_name unless requested_service_objective_name.nil?
|
42
|
+
database
|
49
43
|
end
|
50
44
|
end
|
51
45
|
|
@@ -7,36 +7,22 @@ module Fog
|
|
7
7
|
msg = "Creating SQL Firewall Rule : #{firewall_hash[:name]}."
|
8
8
|
Fog::Logger.debug msg
|
9
9
|
|
10
|
-
resource_url = "#{resource_manager_endpoint_url}/subscriptions/#{@subscription_id}/resourceGroups/#{firewall_hash[:resource_group]}/providers/Microsoft.Sql/servers/#{firewall_hash[:server_name]}/firewallRules/#{firewall_hash[:name]}?api-version=2014-04-01-preview"
|
11
|
-
request_parameters = get_server_firewall_parameters(firewall_hash[:start_ip], firewall_hash[:end_ip])
|
12
10
|
begin
|
13
|
-
|
14
|
-
|
15
|
-
resource_url,
|
16
|
-
request_parameters.to_json,
|
17
|
-
accept: :json,
|
18
|
-
content_type: :json,
|
19
|
-
authorization: token
|
20
|
-
)
|
21
|
-
rescue RestClient::Exception => e
|
11
|
+
server_firewall_rule = @sql_mgmt_client.servers.create_or_update_firewall_rule(firewall_hash[:resource_group], firewall_hash[:server_name], firewall_hash[:name], format_server_firewall_parameters(firewall_hash[:start_ip], firewall_hash[:end_ip]))
|
12
|
+
rescue MsRestAzure::AzureOperationError => e
|
22
13
|
raise_azure_exception(e, msg)
|
23
14
|
end
|
24
15
|
Fog::Logger.debug "SQL Firewall Rule : #{firewall_hash[:name]} created successfully."
|
25
|
-
|
16
|
+
server_firewall_rule
|
26
17
|
end
|
27
18
|
|
28
19
|
private
|
29
20
|
|
30
|
-
def
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
properties['endIpAddress'] = end_ip
|
36
|
-
|
37
|
-
parameters['properties'] = properties
|
38
|
-
|
39
|
-
parameters
|
21
|
+
def format_server_firewall_parameters(start_ip, end_ip)
|
22
|
+
firewall_rule = Azure::ARM::SQL::Models::ServerFirewallRule.new
|
23
|
+
firewall_rule.start_ip_address = start_ip
|
24
|
+
firewall_rule.end_ip_address = end_ip
|
25
|
+
firewall_rule
|
40
26
|
end
|
41
27
|
end
|
42
28
|
|
@@ -6,39 +6,29 @@ module Fog
|
|
6
6
|
def create_or_update_sql_server(server_hash)
|
7
7
|
msg = "Creating SQL Server: #{server_hash[:name]}."
|
8
8
|
Fog::Logger.debug msg
|
9
|
-
resource_url = "#{resource_manager_endpoint_url}/subscriptions/#{@subscription_id}/resourceGroups/#{server_hash[:resource_group]}/providers/Microsoft.Sql/servers/#{server_hash[:name]}?api-version=2014-04-01-preview"
|
10
|
-
request_parameters = format_server_parameters(server_hash[:location], server_hash[:version], server_hash[:administrator_login], server_hash[:administrator_login_password])
|
11
9
|
begin
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
)
|
20
|
-
rescue RestClient::Exception => e
|
10
|
+
sql_server = @sql_mgmt_client.servers.create_or_update(server_hash[:resource_group],
|
11
|
+
server_hash[:name],
|
12
|
+
format_server_parameters(server_hash[:location],
|
13
|
+
server_hash[:version],
|
14
|
+
server_hash[:administrator_login],
|
15
|
+
server_hash[:administrator_login_password]))
|
16
|
+
rescue MsRestAzure::AzureOperationError => e
|
21
17
|
raise_azure_exception(e, msg)
|
22
18
|
end
|
23
19
|
Fog::Logger.debug "SQL Server: #{server_hash[:name]} created successfully."
|
24
|
-
|
20
|
+
sql_server
|
25
21
|
end
|
26
22
|
|
27
23
|
private
|
28
24
|
|
29
25
|
def format_server_parameters(location, version, admin_login, admin_password)
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
parameters['properties'] = properties
|
38
|
-
parameters['location'] = location
|
39
|
-
parameters['tags'] = {}
|
40
|
-
|
41
|
-
parameters
|
26
|
+
server = Azure::ARM::SQL::Models::Server.new
|
27
|
+
server.version = version
|
28
|
+
server.location = location
|
29
|
+
server.administrator_login = admin_login
|
30
|
+
server.administrator_login_password = admin_password
|
31
|
+
server
|
42
32
|
end
|
43
33
|
end
|
44
34
|
|