fog-azure-rm 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +17 -0
- data/.gitignore +6 -0
- data/.hound.yml +2 -0
- data/.rubocop.yml +36 -0
- data/.travis.yml +14 -0
- data/CHANGELOG.md +28 -0
- data/CONTRIBUTING.md +2 -0
- data/CONTRIBUTORS.md +2 -0
- data/Gemfile +3 -0
- data/fog-azure-rm.gemspec +34 -0
- data/lib/fog/azurerm.rb +1 -0
- data/lib/fog/azurerm/compute.rb +0 -1
- data/lib/fog/azurerm/config.rb +4 -0
- data/lib/fog/azurerm/credentials.rb +10 -3
- data/lib/fog/azurerm/docs/compute.md +172 -0
- data/lib/fog/azurerm/docs/dns.md +112 -0
- data/lib/fog/azurerm/docs/network.md +794 -0
- data/lib/fog/azurerm/docs/resources.md +155 -0
- data/lib/fog/azurerm/docs/storage.md +222 -0
- data/lib/fog/azurerm/docs/structure.md +53 -0
- data/lib/fog/azurerm/models/compute/server.rb +3 -2
- data/lib/fog/azurerm/models/network/frontend_ip_configuration.rb +5 -1
- data/lib/fog/azurerm/models/network/network_interface.rb +49 -4
- data/lib/fog/azurerm/models/network/network_interfaces.rb +4 -2
- data/lib/fog/azurerm/models/network/network_security_group.rb +27 -4
- data/lib/fog/azurerm/models/network/network_security_groups.rb +4 -2
- data/lib/fog/azurerm/models/network/network_security_rule.rb +1 -1
- data/lib/fog/azurerm/models/network/subnet.rb +26 -6
- data/lib/fog/azurerm/models/network/subnets.rb +4 -2
- data/lib/fog/azurerm/models/network/virtual_network.rb +72 -10
- data/lib/fog/azurerm/models/network/virtual_networks.rb +4 -2
- data/lib/fog/azurerm/models/resources/azure_resource.rb +25 -0
- data/lib/fog/azurerm/models/resources/azure_resources.rb +31 -0
- data/lib/fog/azurerm/models/resources/dependency.rb +27 -0
- data/lib/fog/azurerm/models/resources/deployment.rb +65 -0
- data/lib/fog/azurerm/models/resources/deployments.rb +27 -0
- data/lib/fog/azurerm/models/resources/provider.rb +27 -0
- data/lib/fog/azurerm/models/resources/provider_resource_type.rb +22 -0
- data/lib/fog/azurerm/models/storage/blob.rb +13 -0
- data/lib/fog/azurerm/models/storage/blobs.rb +22 -0
- data/lib/fog/azurerm/models/storage/container.rb +65 -0
- data/lib/fog/azurerm/models/storage/containers.rb +44 -0
- data/lib/fog/azurerm/models/storage/data_disk.rb +26 -0
- data/lib/fog/azurerm/models/storage/storage_account.rb +4 -0
- data/lib/fog/azurerm/network.rb +21 -3
- data/lib/fog/azurerm/requests/network/add_address_prefixes_in_virtual_network.rb +68 -0
- data/lib/fog/azurerm/requests/network/add_dns_servers_in_virtual_network.rb +74 -0
- data/lib/fog/azurerm/requests/network/add_security_rules.rb +152 -0
- data/lib/fog/azurerm/requests/network/add_subnets_in_virtual_network.rb +69 -0
- data/lib/fog/azurerm/requests/network/attach_network_security_group_to_subnet.rb +59 -0
- data/lib/fog/azurerm/requests/network/attach_resource_to_nic.rb +88 -0
- data/lib/fog/azurerm/requests/network/attach_route_table_to_subnet.rb +59 -0
- data/lib/fog/azurerm/requests/network/create_load_balancer.rb +4 -4
- data/lib/fog/azurerm/requests/network/{create_network_interface.rb → create_or_update_network_interface.rb} +14 -13
- data/lib/fog/azurerm/requests/network/{create_network_security_group.rb → create_or_update_network_security_group.rb} +17 -35
- data/lib/fog/azurerm/requests/network/create_or_update_virtual_network.rb +116 -0
- data/lib/fog/azurerm/requests/network/create_subnet.rb +28 -14
- data/lib/fog/azurerm/requests/network/detach_network_security_group_from_subnet.rb +53 -0
- data/lib/fog/azurerm/requests/network/detach_resource_from_nic.rb +80 -0
- data/lib/fog/azurerm/requests/network/detach_route_table_from_subnet.rb +53 -0
- data/lib/fog/azurerm/requests/network/get_network_interface.rb +60 -0
- data/lib/fog/azurerm/requests/network/get_network_security_group.rb +161 -0
- data/lib/fog/azurerm/requests/network/get_subnet.rb +36 -0
- data/lib/fog/azurerm/requests/network/get_virtual_network.rb +64 -0
- data/lib/fog/azurerm/requests/network/remove_address_prefixes_from_virtual_network.rb +67 -0
- data/lib/fog/azurerm/requests/network/remove_dns_servers_from_virtual_network.rb +67 -0
- data/lib/fog/azurerm/requests/network/remove_security_rule.rb +155 -0
- data/lib/fog/azurerm/requests/network/remove_subnets_from_virtual_network.rb +57 -0
- data/lib/fog/azurerm/requests/resources/create_deployment.rb +90 -0
- data/lib/fog/azurerm/requests/resources/delete_deployment.rb +28 -0
- data/lib/fog/azurerm/requests/resources/delete_resource_tag.rb +48 -0
- data/lib/fog/azurerm/requests/resources/list_deployments.rb +75 -0
- data/lib/fog/azurerm/requests/resources/list_tagged_resources.rb +46 -0
- data/lib/fog/azurerm/requests/resources/tag_resource.rb +46 -0
- data/lib/fog/azurerm/requests/storage/create_container.rb +37 -0
- data/lib/fog/azurerm/requests/storage/delete_container.rb +26 -0
- data/lib/fog/azurerm/requests/storage/delete_disk.rb +36 -0
- data/lib/fog/azurerm/requests/storage/get_blob_metadata.rb +30 -0
- data/lib/fog/azurerm/requests/storage/get_container_access_control_list.rb +29 -0
- data/lib/fog/azurerm/requests/storage/get_container_metadata.rb +31 -0
- data/lib/fog/azurerm/requests/storage/get_container_properties.rb +36 -0
- data/lib/fog/azurerm/requests/storage/get_storage_access_keys.rb +31 -0
- data/lib/fog/azurerm/requests/storage/list_containers.rb +49 -0
- data/lib/fog/azurerm/requests/storage/list_storage_account_for_rg.rb +0 -1
- data/lib/fog/azurerm/requests/storage/set_blob_metadata.rb +26 -0
- data/lib/fog/azurerm/requests/storage/set_container_metadata.rb +26 -0
- data/lib/fog/azurerm/resources.rb +13 -0
- data/lib/fog/azurerm/storage.rb +46 -6
- data/lib/fog/azurerm/utilities/general.rb +18 -0
- data/lib/fog/azurerm/version.rb +1 -1
- data/rakefile +21 -0
- data/test/api_stub.rb +44 -0
- data/test/api_stub/models/compute/availability_set.rb +21 -0
- data/test/api_stub/models/compute/server.rb +191 -0
- data/test/api_stub/models/dns/record_set.rb +59 -0
- data/test/api_stub/models/dns/zone.rb +47 -0
- data/test/api_stub/models/network/application_gateway.rb +135 -0
- data/test/api_stub/models/network/load_balancer.rb +132 -0
- data/test/api_stub/models/network/network_interface.rb +71 -0
- data/test/api_stub/models/network/network_security_group.rb +94 -0
- data/test/api_stub/models/network/public_ip.rb +35 -0
- data/test/api_stub/models/network/subnet.rb +35 -0
- data/test/api_stub/models/network/traffic_manager_end_point.rb +26 -0
- data/test/api_stub/models/network/traffic_manager_profile.rb +74 -0
- data/test/api_stub/models/network/virtual_network.rb +61 -0
- data/test/api_stub/models/resources/deployment.rb +110 -0
- data/test/api_stub/models/resources/resource.rb +40 -0
- data/test/api_stub/models/resources/resource_group.rb +38 -0
- data/test/api_stub/models/storage/blob.rb +17 -0
- data/test/api_stub/models/storage/container.rb +92 -0
- data/test/api_stub/models/storage/data_disk.rb +30 -0
- data/test/api_stub/models/storage/storageaccount.rb +29 -0
- data/test/api_stub/requests/compute/availability_set.rb +46 -0
- data/test/api_stub/requests/compute/virtual_machine.rb +654 -0
- data/test/api_stub/requests/dns/record_set.rb +105 -0
- data/test/api_stub/requests/dns/zone.rb +67 -0
- data/test/api_stub/requests/network/application_gateway.rb +433 -0
- data/test/api_stub/requests/network/load_balancer.rb +366 -0
- data/test/api_stub/requests/network/network_interface.rb +268 -0
- data/test/api_stub/requests/network/network_security_group.rb +240 -0
- data/test/api_stub/requests/network/public_ip.rb +73 -0
- data/test/api_stub/requests/network/subnet.rb +73 -0
- data/test/api_stub/requests/network/traffic_manager_endpoint.rb +25 -0
- data/test/api_stub/requests/network/traffic_manager_profile.rb +140 -0
- data/test/api_stub/requests/network/virtual_network.rb +127 -0
- data/test/api_stub/requests/resources/deployment.rb +23 -0
- data/test/api_stub/requests/resources/resource.rb +47 -0
- data/test/api_stub/requests/resources/resource_group.rb +53 -0
- data/test/api_stub/requests/storage/blob.rb +24 -0
- data/test/api_stub/requests/storage/container.rb +95 -0
- data/test/api_stub/requests/storage/storageaccount.rb +112 -0
- data/test/integration/README.md +14 -0
- data/test/integration/application_gateway.rb +129 -0
- data/test/integration/availability_set.rb +56 -0
- data/test/integration/container.rb +81 -0
- data/test/integration/credentials/azure.yml +4 -0
- data/test/integration/external_load_balancer.rb +119 -0
- data/test/integration/internal_load_balancer.rb +126 -0
- data/test/integration/network_interface.rb +135 -0
- data/test/integration/network_security_group.rb +104 -0
- data/test/integration/public_ip.rb +63 -0
- data/test/integration/record_set.rb +88 -0
- data/test/integration/server.rb +139 -0
- data/test/integration/storage_account.rb +62 -0
- data/test/integration/subnet.rb +91 -0
- data/test/integration/traffic_manager.rb +81 -0
- data/test/integration/virtual_network.rb +124 -0
- data/test/integration/zone.rb +64 -0
- data/test/models/compute/test_availability_set.rb +53 -0
- data/test/models/compute/test_availability_sets.rb +41 -0
- data/test/models/compute/test_server.rb +143 -0
- data/test/models/compute/test_servers.rb +49 -0
- data/test/models/dns/test_record_set.rb +59 -0
- data/test/models/dns/test_record_sets.rb +51 -0
- data/test/models/dns/test_zone.rb +49 -0
- data/test/models/dns/test_zones.rb +49 -0
- data/test/models/network/test_application_gateway.rb +62 -0
- data/test/models/network/test_application_gateways.rb +42 -0
- data/test/models/network/test_load_balancer.rb +56 -0
- data/test/models/network/test_load_balancers.rb +42 -0
- data/test/models/network/test_network_interface.rb +106 -0
- data/test/models/network/test_network_interfaces.rb +41 -0
- data/test/models/network/test_network_security_group.rb +88 -0
- data/test/models/network/test_network_security_groups.rb +40 -0
- data/test/models/network/test_network_security_rule.rb +30 -0
- data/test/models/network/test_public_ip.rb +58 -0
- data/test/models/network/test_public_ips.rb +55 -0
- data/test/models/network/test_subnet.rb +84 -0
- data/test/models/network/test_subnets.rb +42 -0
- data/test/models/network/test_traffic_manager_end_point.rb +53 -0
- data/test/models/network/test_traffic_manager_end_points.rb +42 -0
- data/test/models/network/test_traffic_manager_profile.rb +54 -0
- data/test/models/network/test_traffic_manager_profiles.rb +41 -0
- data/test/models/network/test_virtual_network.rb +112 -0
- data/test/models/network/test_virtual_networks.rb +54 -0
- data/test/models/resources/test_deployment.rb +54 -0
- data/test/models/resources/test_deployments.rb +37 -0
- data/test/models/resources/test_resource.rb +22 -0
- data/test/models/resources/test_resource_group.rb +43 -0
- data/test/models/resources/test_resource_groups.rb +37 -0
- data/test/models/resources/test_resources.rb +38 -0
- data/test/models/storage/test_blobs.rb +32 -0
- data/test/models/storage/test_container.rb +67 -0
- data/test/models/storage/test_containers.rb +56 -0
- data/test/models/storage/test_data_disk.rb +29 -0
- data/test/models/storage/test_storage_account.rb +62 -0
- data/test/models/storage/test_storage_accounts.rb +65 -0
- data/test/requests/compute/test_attach_data_disk_to_vm.rb +175 -0
- data/test/requests/compute/test_create_availability_set.rb +30 -0
- data/test/requests/compute/test_create_virtual_machine.rb +50 -0
- data/test/requests/compute/test_deallocate_virtual_machine.rb +29 -0
- data/test/requests/compute/test_delete_availability_set.rb +29 -0
- data/test/requests/compute/test_delete_virtual_machine.rb +29 -0
- data/test/requests/compute/test_detach_data_disk_from_vm.rb +53 -0
- data/test/requests/compute/test_generalize_virtual_machine.rb +29 -0
- data/test/requests/compute/test_get_virtual_machine.rb +31 -0
- data/test/requests/compute/test_get_vm_status.rb +31 -0
- data/test/requests/compute/test_list_availability_sets.rb +30 -0
- data/test/requests/compute/test_list_available_sizes_for_virtual_machine.rb +31 -0
- data/test/requests/compute/test_list_virtual_machines.rb +30 -0
- data/test/requests/compute/test_power_off_virtual_machine.rb +29 -0
- data/test/requests/compute/test_redeploy_virtual_machine.rb +29 -0
- data/test/requests/compute/test_restart_virtual_machine.rb +29 -0
- data/test/requests/compute/test_start_virtual_machine.rb +29 -0
- data/test/requests/dns/test_check_for_zone.rb +52 -0
- data/test/requests/dns/test_create_record_set.rb +45 -0
- data/test/requests/dns/test_create_zone.rb +36 -0
- data/test/requests/dns/test_delete_record_set.rb +35 -0
- data/test/requests/dns/test_delete_zone.rb +35 -0
- data/test/requests/dns/test_get_records_from_record_set.rb +55 -0
- data/test/requests/dns/test_list_record_sets.rb +36 -0
- data/test/requests/dns/test_list_zones.rb +40 -0
- data/test/requests/network/test_add_address_prefixes_in_virtual_network.rb +45 -0
- data/test/requests/network/test_add_dns_servers_in_virtual_network.rb +45 -0
- data/test/requests/network/test_add_security_rules.rb +63 -0
- data/test/requests/network/test_add_subnets_in_virtual_network.rb +45 -0
- data/test/requests/network/test_attach_network_security_group_to_subnet.rb +33 -0
- data/test/requests/network/test_attach_resource_to_nic.rb +65 -0
- data/test/requests/network/test_attach_route_table_to_subnet.rb +33 -0
- data/test/requests/network/test_check_for_public_ip.rb +38 -0
- data/test/requests/network/test_check_for_virtual_network.rb +38 -0
- data/test/requests/network/test_create_application_gateway.rb +61 -0
- data/test/requests/network/test_create_load_balancer.rb +56 -0
- data/test/requests/network/test_create_network_interface.rb +54 -0
- data/test/requests/network/test_create_network_security_group.rb +45 -0
- data/test/requests/network/test_create_or_update_virtual_network.rb +63 -0
- data/test/requests/network/test_create_public_ip.rb +44 -0
- data/test/requests/network/test_create_subnet.rb +44 -0
- data/test/requests/network/test_create_traffic_manager_endpoint.rb +32 -0
- data/test/requests/network/test_create_traffic_manager_profile.rb +32 -0
- data/test/requests/network/test_delete_application_gateway.rb +30 -0
- data/test/requests/network/test_delete_load_balancer.rb +30 -0
- data/test/requests/network/test_delete_network_interface.rb +30 -0
- data/test/requests/network/test_delete_network_security_group.rb +32 -0
- data/test/requests/network/test_delete_public_ip.rb +30 -0
- data/test/requests/network/test_delete_subnet.rb +30 -0
- data/test/requests/network/test_delete_traffic_manager_endpoint.rb +28 -0
- data/test/requests/network/test_delete_traffic_manager_profile.rb +28 -0
- data/test/requests/network/test_delete_virtual_network.rb +30 -0
- data/test/requests/network/test_detach_network_security_group_from_subnet.rb +33 -0
- data/test/requests/network/test_detach_resource_from_nic.rb +60 -0
- data/test/requests/network/test_detach_route_table_from_subnet.rb +33 -0
- data/test/requests/network/test_get_network_interface.rb +31 -0
- data/test/requests/network/test_get_network_security_group.rb +33 -0
- data/test/requests/network/test_get_subnet.rb +33 -0
- data/test/requests/network/test_get_traffic_manager_profile.rb +29 -0
- data/test/requests/network/test_list_application_gateways.rb +31 -0
- data/test/requests/network/test_list_load_balancers.rb +31 -0
- data/test/requests/network/test_list_network_interfaces.rb +31 -0
- data/test/requests/network/test_list_network_security_groups.rb +33 -0
- data/test/requests/network/test_list_public_ips.rb +31 -0
- data/test/requests/network/test_list_subnets.rb +31 -0
- data/test/requests/network/test_list_traffic_manager_profiles.rb +29 -0
- data/test/requests/network/test_list_virtual_networks.rb +31 -0
- data/test/requests/network/test_remove_address_prefixes_from_virtual_network.rb +45 -0
- data/test/requests/network/test_remove_dns_servers_from_virtual_network.rb +45 -0
- data/test/requests/network/test_remove_security_rule.rb +49 -0
- data/test/requests/network/test_remove_subnets_from_virtual_network.rb +45 -0
- data/test/requests/resources/test_create_deployment.rb +49 -0
- data/test/requests/resources/test_create_resource_group.rb +31 -0
- data/test/requests/resources/test_delete_deployment.rb +31 -0
- data/test/requests/resources/test_delete_resource_group.rb +30 -0
- data/test/requests/resources/test_delete_resource_tag.rb +51 -0
- data/test/requests/resources/test_list_deployments.rb +32 -0
- data/test/requests/resources/test_list_resource_groups.rb +31 -0
- data/test/requests/resources/test_list_tagged_resources.rb +31 -0
- data/test/requests/resources/test_tag_resource.rb +51 -0
- data/test/requests/storage/test_check_storage_account_name_availability.rb +59 -0
- data/test/requests/storage/test_create_container.rb +31 -0
- data/test/requests/storage/test_create_storage_account.rb +56 -0
- data/test/requests/storage/test_delete_container.rb +30 -0
- data/test/requests/storage/test_delete_storage_account.rb +34 -0
- data/test/requests/storage/test_get_blob_metadata.rb +18 -0
- data/test/requests/storage/test_get_container_access_control_list.rb +31 -0
- data/test/requests/storage/test_get_container_metadata.rb +18 -0
- data/test/requests/storage/test_get_container_properties.rb +31 -0
- data/test/requests/storage/test_get_storage_access_keys.rb +31 -0
- data/test/requests/storage/test_list_containers.rb +23 -0
- data/test/requests/storage/test_list_storage_accounts.rb +47 -0
- data/test/requests/storage/test_list_storage_accounts_for_rg.rb +51 -0
- data/test/requests/storage/test_set_blob_metadata.rb +17 -0
- data/test/requests/storage/test_set_container_metadata.rb +17 -0
- data/test/test_credentials.rb +39 -0
- data/test/test_helper.rb +428 -0
- metadata +273 -14
- data/lib/fog/azurerm/models/compute/data_disk.rb +0 -26
- data/lib/fog/azurerm/requests/network/create_virtual_network.rb +0 -115
@@ -0,0 +1,67 @@
|
|
1
|
+
module Fog
|
2
|
+
module Network
|
3
|
+
class AzureRM
|
4
|
+
# Real class for Network Request
|
5
|
+
class Real
|
6
|
+
def remove_address_prefixes_from_virtual_network(resource_group_name, virtual_network_name, address_prefixes)
|
7
|
+
Fog::Logger.debug "Removing Address Prefixes: #{address_prefixes.join(', ')} from Virtual Network: #{virtual_network_name}"
|
8
|
+
virtual_network = get_virtual_network_object_for_remove_address_prefixes!(resource_group_name, virtual_network_name, address_prefixes)
|
9
|
+
virtual_network = create_or_update_vnet(resource_group_name, virtual_network_name, virtual_network)
|
10
|
+
Fog::Logger.debug "Address Prefixes: #{address_prefixes.join(', ')} removed successfully."
|
11
|
+
Azure::ARM::Network::Models::VirtualNetwork.serialize_object(virtual_network)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def get_virtual_network_object_for_remove_address_prefixes!(resource_group_name, virtual_network_name, address_prefixes)
|
17
|
+
virtual_network = get_vnet(resource_group_name, virtual_network_name)
|
18
|
+
attached_address_prefixes = virtual_network.properties.address_space.address_prefixes
|
19
|
+
virtual_network.properties.address_space.address_prefixes = attached_address_prefixes - address_prefixes
|
20
|
+
virtual_network
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Mock class for Network Request
|
25
|
+
class Mock
|
26
|
+
def remove_address_prefixes_from_virtual_network(*)
|
27
|
+
{
|
28
|
+
'id' => '/subscriptions/########-####-####-####-############/resourceGroups/fog-rg/providers/Microsoft.Network/virtualNetworks/fog-vnet',
|
29
|
+
'name' => 'fog-vnet',
|
30
|
+
'type' => 'Microsoft.Network/virtualNetworks',
|
31
|
+
'location' => 'westus',
|
32
|
+
'properties' =>
|
33
|
+
{
|
34
|
+
'addressSpace' =>
|
35
|
+
{
|
36
|
+
'addressPrefixes' =>
|
37
|
+
[
|
38
|
+
'10.1.0.0/16'
|
39
|
+
]
|
40
|
+
},
|
41
|
+
'dhcpOptions' => {
|
42
|
+
'dnsServers' => [
|
43
|
+
'10.1.0.5',
|
44
|
+
'10.1.0.6'
|
45
|
+
]
|
46
|
+
},
|
47
|
+
'subnets' =>
|
48
|
+
[
|
49
|
+
{
|
50
|
+
'id' => '/subscriptions/########-####-####-####-############/resourceGroups/fog-rg/providers/Microsoft.Network/virtualNetworks/fog-vnet/subnets/fog-subnet',
|
51
|
+
'properties' =>
|
52
|
+
{
|
53
|
+
'addressPrefix' => '10.1.0.0/24',
|
54
|
+
'provisioningState' => 'Succeeded'
|
55
|
+
},
|
56
|
+
'name' => 'fog-subnet'
|
57
|
+
}
|
58
|
+
],
|
59
|
+
'resourceGuid' => 'c573f8e2-d916-493f-8b25-a681c31269ef',
|
60
|
+
'provisioningState' => 'Succeeded'
|
61
|
+
}
|
62
|
+
}
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Fog
|
2
|
+
module Network
|
3
|
+
class AzureRM
|
4
|
+
# Real class for Network Request
|
5
|
+
class Real
|
6
|
+
def remove_dns_servers_from_virtual_network(resource_group_name, virtual_network_name, dns_servers)
|
7
|
+
Fog::Logger.debug "Removing DNS Servers: #{dns_servers.join(', ')} from Virtual Network: #{virtual_network_name}"
|
8
|
+
virtual_network = get_virtual_network_object_for_remove_dns_servers!(resource_group_name, virtual_network_name, dns_servers)
|
9
|
+
virtual_network = create_or_update_vnet(resource_group_name, virtual_network_name, virtual_network)
|
10
|
+
Fog::Logger.debug "DNS Servers: #{dns_servers.join(', ')} removed successfully."
|
11
|
+
Azure::ARM::Network::Models::VirtualNetwork.serialize_object(virtual_network)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def get_virtual_network_object_for_remove_dns_servers!(resource_group_name, virtual_network_name, dns_servers)
|
17
|
+
virtual_network = get_vnet(resource_group_name, virtual_network_name)
|
18
|
+
attached_dns_servers = virtual_network.properties.dhcp_options.dns_servers
|
19
|
+
virtual_network.properties.dhcp_options.dns_servers = attached_dns_servers - dns_servers
|
20
|
+
virtual_network
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Mock class for Network Request
|
25
|
+
class Mock
|
26
|
+
def remove_dns_servers_from_virtual_network(*)
|
27
|
+
{
|
28
|
+
'id' => '/subscriptions/########-####-####-####-############/resourceGroups/fog-rg/providers/Microsoft.Network/virtualNetworks/fog-vnet',
|
29
|
+
'name' => 'fog-vnet',
|
30
|
+
'type' => 'Microsoft.Network/virtualNetworks',
|
31
|
+
'location' => 'westus',
|
32
|
+
'properties' =>
|
33
|
+
{
|
34
|
+
'addressSpace' =>
|
35
|
+
{
|
36
|
+
'addressPrefixes' =>
|
37
|
+
[
|
38
|
+
'10.1.0.0/16',
|
39
|
+
'10.2.0.0/16'
|
40
|
+
]
|
41
|
+
},
|
42
|
+
'dhcpOptions' => {
|
43
|
+
'dnsServers' => [
|
44
|
+
'10.1.0.5'
|
45
|
+
]
|
46
|
+
},
|
47
|
+
'subnets' =>
|
48
|
+
[
|
49
|
+
{
|
50
|
+
'id' => '/subscriptions/########-####-####-####-############/resourceGroups/fog-rg/providers/Microsoft.Network/virtualNetworks/fog-vnet/subnets/fog-subnet',
|
51
|
+
'properties' =>
|
52
|
+
{
|
53
|
+
'addressPrefix' => '10.1.0.0/24',
|
54
|
+
'provisioningState' => 'Succeeded'
|
55
|
+
},
|
56
|
+
'name' => 'fog-subnet'
|
57
|
+
}
|
58
|
+
],
|
59
|
+
'resourceGuid' => 'c573f8e2-d916-493f-8b25-a681c31269ef',
|
60
|
+
'provisioningState' => 'Succeeded'
|
61
|
+
}
|
62
|
+
}
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,155 @@
|
|
1
|
+
module Fog
|
2
|
+
module Network
|
3
|
+
class AzureRM
|
4
|
+
# Real class for Network Request
|
5
|
+
class Real
|
6
|
+
def remove_security_rule(resource_group_name, security_group_name, security_rule_name)
|
7
|
+
Fog::Logger.debug "Deleting security rule #{security_rule_name} from Network Security Group #{security_group_name}."
|
8
|
+
promise = @network_client.network_security_groups.get(resource_group_name, security_group_name)
|
9
|
+
result = promise.value!
|
10
|
+
nsg = result.body
|
11
|
+
updated_security_rule_list = remove_security_rule_from_list(nsg.properties.security_rules, security_rule_name)
|
12
|
+
nsg.properties.security_rules = updated_security_rule_list
|
13
|
+
begin
|
14
|
+
promise = @network_client.network_security_groups.begin_create_or_update(resource_group_name, security_group_name, nsg)
|
15
|
+
result = promise.value!
|
16
|
+
Fog::Logger.debug "Security Rule #{security_rule_name} deleted from Network Security Group #{security_group_name} successfully!"
|
17
|
+
Azure::ARM::Network::Models::NetworkSecurityGroup.serialize_object(result.body)
|
18
|
+
rescue MsRestAzure::AzureOperationError => e
|
19
|
+
msg = "Exception in deleting Security Rule #{security_rule_name} from Network Security Group #{security_group_name} . #{e.body['error']['message']}"
|
20
|
+
raise msg
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def remove_security_rule_from_list(security_rule_list, rule_name)
|
25
|
+
unless security_rule_list.nil?
|
26
|
+
return security_rule_list.select { |sr| sr.name != rule_name }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# Mock class for Network Request
|
32
|
+
class Mock
|
33
|
+
def remove_security_rule(resource_group_name, security_group_name, _security_rule_name)
|
34
|
+
{
|
35
|
+
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group_name}/providers/Microsoft.Network/networkSecurityGroups/#{name}",
|
36
|
+
'name' => security_group_name,
|
37
|
+
'type' => 'Microsoft.Network/networkSecurityGroups',
|
38
|
+
'location' => 'location',
|
39
|
+
'properties' =>
|
40
|
+
{
|
41
|
+
'securityRules' => [],
|
42
|
+
'defaultSecurityRules' =>
|
43
|
+
[
|
44
|
+
{
|
45
|
+
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group_name}/providers/Microsoft.Network/networkSecurityGroups/#{security_group_name}/defaultSecurityRules/AllowVnetInBound",
|
46
|
+
'properties' =>
|
47
|
+
{
|
48
|
+
'protocol' => '*',
|
49
|
+
'sourceAddressPrefix' => 'VirtualNetwork',
|
50
|
+
'destinationAddressPrefix' => 'VirtualNetwork',
|
51
|
+
'access' => 'Allow',
|
52
|
+
'direction' => 'Inbound',
|
53
|
+
'description' => 'Allow inbound traffic from all VMs in VNET',
|
54
|
+
'sourcePortRange' => '*',
|
55
|
+
'destinationPortRange' => '*',
|
56
|
+
'priority' => 65_000,
|
57
|
+
'provisioningState' => 'Updating'
|
58
|
+
},
|
59
|
+
'name' => 'AllowVnetInBound'
|
60
|
+
},
|
61
|
+
{
|
62
|
+
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group_name}/providers/Microsoft.Network/networkSecurityGroups/#{security_group_name}/defaultSecurityRules/AllowAzureLoadBalancerInBound",
|
63
|
+
'properties' =>
|
64
|
+
{
|
65
|
+
'protocol' => '*',
|
66
|
+
'sourceAddressPrefix' => 'AzureLoadBalancer',
|
67
|
+
'destinationAddressPrefix' => '*',
|
68
|
+
'access' => 'Allow',
|
69
|
+
'direction' => 'Inbound',
|
70
|
+
'description' => 'Allow inbound traffic from azure load balancer',
|
71
|
+
'sourcePortRange' => '*',
|
72
|
+
'destinationPortRange' => '*',
|
73
|
+
'priority' => 65_001,
|
74
|
+
'provisioningState' => 'Updating'
|
75
|
+
},
|
76
|
+
'name' => 'AllowAzureLoadBalancerInBound'
|
77
|
+
},
|
78
|
+
{
|
79
|
+
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group_name}/providers/Microsoft.Network/networkSecurityGroups/#{security_group_name}/defaultSecurityRules/DenyAllInBound",
|
80
|
+
'properties' =>
|
81
|
+
{
|
82
|
+
'protocol' => '*',
|
83
|
+
'sourceAddressPrefix' => '*',
|
84
|
+
'destinationAddressPrefix' => '*',
|
85
|
+
'access' => 'Deny',
|
86
|
+
'direction' => 'Inbound',
|
87
|
+
'description' => 'Deny all inbound traffic',
|
88
|
+
'sourcePortRange' => '*',
|
89
|
+
'destinationPortRange' => '*',
|
90
|
+
'priority' => 65_500,
|
91
|
+
'provisioningState' => 'Updating'
|
92
|
+
},
|
93
|
+
'name' => 'DenyAllInBound'
|
94
|
+
},
|
95
|
+
{
|
96
|
+
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group_name}/providers/Microsoft.Network/networkSecurityGroups/#{security_group_name}/defaultSecurityRules/AllowVnetOutBound",
|
97
|
+
'properties' =>
|
98
|
+
{
|
99
|
+
'protocol' => '*',
|
100
|
+
'sourceAddressPrefix' => 'VirtualNetwork',
|
101
|
+
'destinationAddressPrefix' => 'VirtualNetwork',
|
102
|
+
'access' => 'Allow',
|
103
|
+
'direction' => 'Outbound',
|
104
|
+
'description' => 'Allow outbound traffic from all VMs to all VMs in VNET',
|
105
|
+
'sourcePortRange' => '*',
|
106
|
+
'destinationPortRange' => '*',
|
107
|
+
'priority' => 65_000,
|
108
|
+
'provisioningState' => 'Updating'
|
109
|
+
},
|
110
|
+
'name' => 'AllowVnetOutBound'
|
111
|
+
},
|
112
|
+
{
|
113
|
+
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group_name}/providers/Microsoft.Network/networkSecurityGroups/#{security_group_name}/defaultSecurityRules/AllowInternetOutBound",
|
114
|
+
'properties' =>
|
115
|
+
{
|
116
|
+
'protocol' => '*',
|
117
|
+
'sourceAddressPrefix' => '*',
|
118
|
+
'destinationAddressPrefix' => 'Internet',
|
119
|
+
'access' => 'Allow',
|
120
|
+
'direction' => 'Outbound',
|
121
|
+
'description' => 'Allow outbound traffic from all VMs to Internet',
|
122
|
+
'sourcePortRange' => '*',
|
123
|
+
'destinationPortRange' => '*',
|
124
|
+
'priority' => 65_001,
|
125
|
+
'provisioningState' => 'Updating'
|
126
|
+
},
|
127
|
+
'name' => 'AllowInternetOutBound'
|
128
|
+
},
|
129
|
+
{
|
130
|
+
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group_name}/providers/Microsoft.Network/networkSecurityGroups/#{security_group_name}/defaultSecurityRules/DenyAllOutBound",
|
131
|
+
'properties' =>
|
132
|
+
{
|
133
|
+
'protocol' => '*',
|
134
|
+
'sourceAddressPrefix' => '*',
|
135
|
+
'destinationAddressPrefix' => '*',
|
136
|
+
'access' => 'Deny',
|
137
|
+
'direction' => 'Outbound',
|
138
|
+
'description' => 'Deny all outbound traffic',
|
139
|
+
'sourcePortRange' => '*',
|
140
|
+
'destinationPortRange' => '*',
|
141
|
+
'priority' => 65_500,
|
142
|
+
'provisioningState' => 'Updating'
|
143
|
+
},
|
144
|
+
'name' => 'DenyAllOutBound'
|
145
|
+
}
|
146
|
+
],
|
147
|
+
'resourceGuid' => '9dca97e6-4789-4ebd-86e3-52b8b0da6cd4',
|
148
|
+
'provisioningState' => 'Updating'
|
149
|
+
}
|
150
|
+
}
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Fog
|
2
|
+
module Network
|
3
|
+
class AzureRM
|
4
|
+
# Real class for Network Request
|
5
|
+
class Real
|
6
|
+
def remove_subnets_from_virtual_network(resource_group_name, virtual_network_name, subnet_names)
|
7
|
+
Fog::Logger.debug "Removing Subnets:#{subnet_names.join(', ')} from Virtual Network: #{virtual_network_name}"
|
8
|
+
virtual_network = get_virtual_network_object_for_remove_subnets!(resource_group_name, virtual_network_name, subnet_names)
|
9
|
+
result = create_or_update_vnet(resource_group_name, virtual_network_name, virtual_network)
|
10
|
+
Fog::Logger.debug "Subnets:#{subnet_names.join(', ')} removed successfully."
|
11
|
+
Azure::ARM::Network::Models::VirtualNetwork.serialize_object(result)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def get_virtual_network_object_for_remove_subnets!(resource_group_name, virtual_network_name, subnet_names)
|
17
|
+
virtual_network = get_vnet(resource_group_name, virtual_network_name)
|
18
|
+
old_subnet_objects = virtual_network.properties.subnets
|
19
|
+
virtual_network.properties.subnets = old_subnet_objects.reject { |subnet| subnet_names.include?(subnet.name) }
|
20
|
+
virtual_network
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Mock class for Network Request
|
25
|
+
class Mock
|
26
|
+
def remove_subnets_from_virtual_network(*)
|
27
|
+
{
|
28
|
+
'id' => '/subscriptions/########-####-####-####-############/resourceGroups/fog-rg/providers/Microsoft.Network/virtualNetworks/fog-vnet',
|
29
|
+
'name' => 'fog-vnet',
|
30
|
+
'type' => 'Microsoft.Network/virtualNetworks',
|
31
|
+
'location' => 'westus',
|
32
|
+
'properties' =>
|
33
|
+
{
|
34
|
+
'addressSpace' =>
|
35
|
+
{
|
36
|
+
'addressPrefixes' =>
|
37
|
+
[
|
38
|
+
'10.1.0.0/16',
|
39
|
+
'10.2.0.0/16'
|
40
|
+
]
|
41
|
+
},
|
42
|
+
'dhcpOptions' => {
|
43
|
+
'dnsServers' => [
|
44
|
+
'10.1.0.5',
|
45
|
+
'10.1.0.6'
|
46
|
+
]
|
47
|
+
},
|
48
|
+
'subnets' => [],
|
49
|
+
'resourceGuid' => 'c573f8e2-d916-493f-8b25-a681c31269ef',
|
50
|
+
'provisioningState' => 'Succeeded'
|
51
|
+
}
|
52
|
+
}
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
module Fog
|
2
|
+
module Resources
|
3
|
+
class AzureRM
|
4
|
+
# This class provides the actual implemention for service calls.
|
5
|
+
class Real
|
6
|
+
def create_deployment(resource_group, deployment_name, template_link, parameters_link)
|
7
|
+
begin
|
8
|
+
Fog::Logger.debug "Creating Deployment: #{deployment_name} in Resource Group: #{resource_group}"
|
9
|
+
deployment = Azure::ARM::Resources::Models::Deployment.new
|
10
|
+
deployment_properties = Azure::ARM::Resources::Models::DeploymentProperties.new
|
11
|
+
|
12
|
+
template_link_obj = Azure::ARM::Resources::Models::TemplateLink.new
|
13
|
+
template_link_obj.uri = template_link
|
14
|
+
|
15
|
+
parameters_link_obj = Azure::ARM::Resources::Models::ParametersLink.new
|
16
|
+
parameters_link_obj.uri = parameters_link
|
17
|
+
|
18
|
+
deployment_properties.template_link = template_link_obj
|
19
|
+
deployment_properties.parameters_link = parameters_link_obj
|
20
|
+
deployment_properties.mode = 'Incremental'
|
21
|
+
|
22
|
+
deployment.properties = deployment_properties
|
23
|
+
|
24
|
+
@rmc.deployments.validate(resource_group, deployment_name, deployment)
|
25
|
+
promise = @rmc.deployments.create_or_update(resource_group, deployment_name, deployment)
|
26
|
+
result = promise.value!
|
27
|
+
Fog::Logger.debug "Deployment: #{deployment_name} in Resource Group: #{resource_group} created successfully."
|
28
|
+
Azure::ARM::Resources::Models::DeploymentExtended.serialize_object(result.body)
|
29
|
+
rescue MsRestAzure::AzureOperationError => e
|
30
|
+
msg = "Exception creating Deployment: #{deployment_name} in Resource Group: #{resource_group}. #{e.body['error']['message']}"
|
31
|
+
raise msg
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# This class provides the mock implementation
|
37
|
+
class Mock
|
38
|
+
def create_deployment(resource_group, deployment_name, template_link, parameters_link)
|
39
|
+
{
|
40
|
+
id: "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group}/providers/microsoft.resources/deployments/#{deployment_name}",
|
41
|
+
name: deployment_name,
|
42
|
+
properties: {
|
43
|
+
templateLink: {
|
44
|
+
uri: template_link,
|
45
|
+
contentVersion: '1.0.0.0'
|
46
|
+
},
|
47
|
+
parametersLink: {
|
48
|
+
uri: parameters_link,
|
49
|
+
contentVersion: '1.0.0.0'
|
50
|
+
},
|
51
|
+
parameters: {
|
52
|
+
parameter1: {
|
53
|
+
type: 'string',
|
54
|
+
value: 'parameter1'
|
55
|
+
}
|
56
|
+
},
|
57
|
+
mode: 'Incremental',
|
58
|
+
provisioningState: 'Accepted',
|
59
|
+
timestamp: '2015-01-01T18:26:20.6229141Z',
|
60
|
+
correlationId: 'd5062e45-6e9f-4fd3-a0a0-6b2c56b15757',
|
61
|
+
outputs: {
|
62
|
+
key1: {
|
63
|
+
type: 'string',
|
64
|
+
value: 'output1'
|
65
|
+
}
|
66
|
+
},
|
67
|
+
providers: [{
|
68
|
+
namespace: 'namespace1',
|
69
|
+
resourceTypes: [{
|
70
|
+
resourceType: 'resourceType1',
|
71
|
+
locations: ['westus']
|
72
|
+
}]
|
73
|
+
}],
|
74
|
+
dependencies: [{
|
75
|
+
dependsOn: [{
|
76
|
+
id: 'resourceid1',
|
77
|
+
resourceType: 'namespace1/resourcetype1',
|
78
|
+
resourceName: 'resourcename1'
|
79
|
+
}],
|
80
|
+
id: 'resourceid2',
|
81
|
+
resourceType: 'namespace1/resourcetype2',
|
82
|
+
resourceName: 'resourcename2'
|
83
|
+
}]
|
84
|
+
}
|
85
|
+
}
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Fog
|
2
|
+
module Resources
|
3
|
+
class AzureRM
|
4
|
+
# This class provides the actual implemention for service calls.
|
5
|
+
class Real
|
6
|
+
def delete_deployment(resource_group, deployment_name)
|
7
|
+
begin
|
8
|
+
Fog::Logger.debug "Deleting Deployment: #{deployment_name} in Resource Group: #{resource_group}"
|
9
|
+
@rmc.deployments.delete(resource_group, deployment_name).value!
|
10
|
+
Fog::Logger.debug "Deployment: #{deployment_name} in Resource Group: #{resource_group} deleted successfully."
|
11
|
+
true
|
12
|
+
rescue MsRestAzure::AzureOperationError => e
|
13
|
+
msg = "Exception deleting Deployment: #{deployment_name} in Resource Group: #{resource_group}. #{e.body['error']['message']}"
|
14
|
+
raise msg
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# This class provides the mock implementation
|
20
|
+
class Mock
|
21
|
+
def delete_deployment(_resource_group, deployment_name)
|
22
|
+
Fog::Logger.debug "Deployment: #{deployment_name} deleted successfully."
|
23
|
+
true
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|