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,80 @@
|
|
1
|
+
module Fog
|
2
|
+
module Network
|
3
|
+
class AzureRM
|
4
|
+
# Real class for Network Request
|
5
|
+
class Real
|
6
|
+
def detach_resource_from_nic(resource_group_name, nic_name, resource_type)
|
7
|
+
Fog::Logger.debug "Removing #{resource_type} from Network Interface #{nic_name}."
|
8
|
+
begin
|
9
|
+
nic = get_network_interface_with_detached_resource(nic_name, resource_group_name, resource_type)
|
10
|
+
|
11
|
+
promise = @network_client.network_interfaces.create_or_update(resource_group_name, nic_name, nic)
|
12
|
+
result = promise.value!
|
13
|
+
Fog::Logger.debug "#{resource_type} deleted from Network Interface #{nic_name} successfully!"
|
14
|
+
Azure::ARM::Network::Models::NetworkInterface.serialize_object(result.body)
|
15
|
+
rescue MsRestAzure::AzureOperationError => e
|
16
|
+
msg = "Exception removing #{resource_type} from Network Interface #{nic_name} . #{e.body['error']['message']}"
|
17
|
+
raise msg
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_network_interface_with_detached_resource(nic_name, resource_group_name, resource_type)
|
22
|
+
promise = @network_client.network_interfaces.get(resource_group_name, nic_name)
|
23
|
+
result = promise.value!
|
24
|
+
nic = result.body
|
25
|
+
case resource_type
|
26
|
+
when PUBLIC_IP
|
27
|
+
nic.properties.ip_configurations[0].properties.public_ipaddress = nil unless nic.properties.ip_configurations.empty?
|
28
|
+
when NETWORK_SECURITY_GROUP
|
29
|
+
nic.properties.network_security_group = nil
|
30
|
+
end
|
31
|
+
nic
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Mock class for Network Request
|
36
|
+
class Mock
|
37
|
+
def detach_resource_from_nic(resource_group_name, nic_name, _resource_type)
|
38
|
+
{
|
39
|
+
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group_name}/providers/Microsoft.Network/networkInterfaces/#{nic_name}",
|
40
|
+
'name' => nic_name,
|
41
|
+
'type' => 'Microsoft.Network/networkInterfaces',
|
42
|
+
'location' => location,
|
43
|
+
'properties' =>
|
44
|
+
{
|
45
|
+
'ipConfigurations' =>
|
46
|
+
[
|
47
|
+
{
|
48
|
+
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group_name}/providers/Microsoft.Network/networkInterfaces/#{nic_name}/ipConfigurations/#{ip_configs_name}",
|
49
|
+
'properties' =>
|
50
|
+
{
|
51
|
+
'privateIPAddress' => '10.0.0.5',
|
52
|
+
'privateIPAllocationMethod' => prv_ip_alloc_method,
|
53
|
+
'subnet' =>
|
54
|
+
{
|
55
|
+
'id' => subnet_id
|
56
|
+
},
|
57
|
+
'publicIPAddress' =>
|
58
|
+
{
|
59
|
+
'id' => public_ip_address_id
|
60
|
+
},
|
61
|
+
'provisioningState' => 'Succeeded'
|
62
|
+
},
|
63
|
+
'name' => ip_configs_name
|
64
|
+
}
|
65
|
+
],
|
66
|
+
'dnsSettings' =>
|
67
|
+
{
|
68
|
+
'dnsServers' => [],
|
69
|
+
'appliedDnsServers' => []
|
70
|
+
},
|
71
|
+
'enableIPForwarding' => false,
|
72
|
+
'resourceGuid' => '2bff0fad-623b-4773-82b8-dc875f3aacd2',
|
73
|
+
'provisioningState' => 'Succeeded'
|
74
|
+
}
|
75
|
+
}
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Fog
|
2
|
+
module Network
|
3
|
+
class AzureRM
|
4
|
+
# Real class for Network Request
|
5
|
+
class Real
|
6
|
+
def detach_route_table_from_subnet(resource_group, subnet_name, virtual_network_name, address_prefix, network_security_group_id)
|
7
|
+
Fog::Logger.debug "Detaching Route Table from Subnet: #{subnet_name}."
|
8
|
+
|
9
|
+
subnet = define_subnet_object_for_detach_route_table(address_prefix, network_security_group_id)
|
10
|
+
begin
|
11
|
+
promise = @network_client.subnets.create_or_update(resource_group, virtual_network_name, subnet_name, subnet)
|
12
|
+
result = promise.value!
|
13
|
+
Fog::Logger.debug 'Route Table detached successfully.'
|
14
|
+
Azure::ARM::Network::Models::Subnet.serialize_object(result.body)
|
15
|
+
rescue MsRestAzure::AzureOperationError => e
|
16
|
+
msg = "Exception detaching Route Table from Subnet: #{subnet_name}. #{e.body['error']['message']}"
|
17
|
+
raise msg
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def define_subnet_object_for_detach_route_table(address_prefix, network_security_group_id)
|
24
|
+
subnet = Azure::ARM::Network::Models::Subnet.new
|
25
|
+
subnet_properties = Azure::ARM::Network::Models::SubnetPropertiesFormat.new
|
26
|
+
network_security_group = Azure::ARM::Network::Models::NetworkSecurityGroup.new
|
27
|
+
|
28
|
+
network_security_group.id = network_security_group_id
|
29
|
+
subnet_properties.address_prefix = address_prefix
|
30
|
+
subnet_properties.network_security_group = network_security_group unless network_security_group_id.nil?
|
31
|
+
subnet_properties.route_table = nil
|
32
|
+
subnet.properties = subnet_properties
|
33
|
+
subnet
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# Mock class for Network Request
|
38
|
+
class Mock
|
39
|
+
def detach_route_table_from_subnet(*)
|
40
|
+
{
|
41
|
+
'id' => '/subscriptions/########-####-####-####-############/resourceGroups/fog-rg/providers/Microsoft.Network/virtualNetworks/fog-vnet/subnets/fog-subnet',
|
42
|
+
'properties' =>
|
43
|
+
{
|
44
|
+
'addressPrefix' => '10.1.0.0/24',
|
45
|
+
'provisioningState' => 'Succeeded'
|
46
|
+
},
|
47
|
+
'name' => 'fog-subnet'
|
48
|
+
}
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Fog
|
2
|
+
module Network
|
3
|
+
class AzureRM
|
4
|
+
# Real class for Network Interface Request
|
5
|
+
class Real
|
6
|
+
def get_network_interface(resource_group_name, nic_name)
|
7
|
+
Fog::Logger.debug "Getting Network Interface#{nic_name} from Resource Group #{resource_group_name}."
|
8
|
+
begin
|
9
|
+
promise = @network_client.network_interfaces.get(resource_group_name, nic_name)
|
10
|
+
result = promise.value!
|
11
|
+
Azure::ARM::Network::Models::NetworkInterface.serialize_object(result.body)
|
12
|
+
rescue MsRestAzure::AzureOperationError => e
|
13
|
+
msg = "Exception getting Network Interface #{nic_name} from Resource Group '#{resource_group_name}'. #{e.body['error']['message']}."
|
14
|
+
raise msg
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# Mock class for Network Interface Request
|
20
|
+
class Mock
|
21
|
+
def get_network_interface(resource_group_name, nic_name)
|
22
|
+
{
|
23
|
+
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group_name}/providers/Microsoft.Network/networkInterfaces/#{nic_name}",
|
24
|
+
'name' => nic_name,
|
25
|
+
'type' => 'Microsoft.Network/networkInterfaces',
|
26
|
+
'location' => 'westus',
|
27
|
+
'properties' =>
|
28
|
+
{
|
29
|
+
'ipConfigurations' =>
|
30
|
+
[
|
31
|
+
{
|
32
|
+
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group_name}/providers/Microsoft.Network/networkInterfaces/test-NIC/ipConfigurations/ipconfig1",
|
33
|
+
'properties' =>
|
34
|
+
{
|
35
|
+
'privateIPAddress' => '10.2.0.4',
|
36
|
+
'privateIPAllocationMethod' => 'Dynamic',
|
37
|
+
'subnet' =>
|
38
|
+
{
|
39
|
+
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group_name}/providers/Microsoft.Network/virtualNetworks/testVnet/subnets/fog-test-subnet"
|
40
|
+
},
|
41
|
+
'provisioningState' => 'Succeeded'
|
42
|
+
},
|
43
|
+
'name' => 'ipconfig1'
|
44
|
+
}
|
45
|
+
],
|
46
|
+
'dnsSettings' =>
|
47
|
+
{
|
48
|
+
'dnsServers' => [],
|
49
|
+
'appliedDnsServers' => []
|
50
|
+
},
|
51
|
+
'enableIPForwarding' => false,
|
52
|
+
'resourceGuid' => '51e01337-fb15-4b04-b9de-e91537c764fd',
|
53
|
+
'provisioningState' => 'Succeeded'
|
54
|
+
}
|
55
|
+
}
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,161 @@
|
|
1
|
+
module Fog
|
2
|
+
module Network
|
3
|
+
class AzureRM
|
4
|
+
# Real class for Network Security Group Request
|
5
|
+
class Real
|
6
|
+
def get_network_security_group(resource_group_name, security_group_name)
|
7
|
+
Fog::Logger.debug "Getting Network Security Group #{security_group_name} from Resource Group #{resource_group_name}."
|
8
|
+
begin
|
9
|
+
promise = @network_client.network_security_groups.get(resource_group_name, security_group_name)
|
10
|
+
result = promise.value!
|
11
|
+
Azure::ARM::Network::Models::NetworkSecurityGroup.serialize_object(result.body)
|
12
|
+
rescue MsRestAzure::AzureOperationError => e
|
13
|
+
msg = "Exception getting Network Security Group #{security_group_name} from Resource Group '#{resource_group_name}'. #{e.body['error']['message']}."
|
14
|
+
raise msg
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# Mock class for Network Security Group Request
|
20
|
+
class Mock
|
21
|
+
def get_network_security_group(resource_group_name, security_group_name)
|
22
|
+
{
|
23
|
+
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group_name}/providers/Microsoft.Network/networkSecurityGroups/#{security_group_name}",
|
24
|
+
'name' => security_group_name,
|
25
|
+
'type' => 'Microsoft.Network/networkSecurityGroups',
|
26
|
+
'location' => 'westus',
|
27
|
+
'properties' =>
|
28
|
+
{
|
29
|
+
'securityRules' =>
|
30
|
+
[
|
31
|
+
{
|
32
|
+
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group_name}/providers/Microsoft.Network/networkSecurityGroups/#{security_group_name}/securityRules/testRule",
|
33
|
+
'properties' =>
|
34
|
+
{
|
35
|
+
'protocol' => 'tcp',
|
36
|
+
'sourceAddressPrefix' => '0.0.0.0/0',
|
37
|
+
'destinationAddressPrefix' => '0.0.0.0/0',
|
38
|
+
'access' => 'Allow',
|
39
|
+
'direction' => 'Inbound',
|
40
|
+
'sourcePortRange' => '22',
|
41
|
+
'destinationPortRange' => '22',
|
42
|
+
'priority' => 100,
|
43
|
+
'provisioningState' => 'Succeeded'
|
44
|
+
},
|
45
|
+
'name' => 'testRule'
|
46
|
+
}
|
47
|
+
],
|
48
|
+
'defaultSecurityRules' =>
|
49
|
+
[
|
50
|
+
{
|
51
|
+
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group_name}/providers/Microsoft.Network/networkSecurityGroups/#{security_group_name}/defaultSecurityRules/AllowVnetInBound",
|
52
|
+
'properties' =>
|
53
|
+
{
|
54
|
+
'protocol' => '*',
|
55
|
+
'sourceAddressPrefix' => 'VirtualNetwork',
|
56
|
+
'destinationAddressPrefix' => 'VirtualNetwork',
|
57
|
+
'access' => 'Allow',
|
58
|
+
'direction' => 'Inbound',
|
59
|
+
'description' => 'Allow inbound traffic from all VMs in VNET',
|
60
|
+
'sourcePortRange' => '*',
|
61
|
+
'destinationPortRange' => '*',
|
62
|
+
'priority' => 65_000,
|
63
|
+
'provisioningState' => 'Succeeded'
|
64
|
+
},
|
65
|
+
'name' => 'AllowVnetInBound'
|
66
|
+
},
|
67
|
+
{
|
68
|
+
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group_name}/providers/Microsoft.Network/networkSecurityGroups/#{security_group_name}/defaultSecurityRules/AllowAzureLoadBalancerInBound",
|
69
|
+
'properties' =>
|
70
|
+
{
|
71
|
+
'protocol' => '*',
|
72
|
+
'sourceAddressPrefix' => 'AzureLoadBalancer',
|
73
|
+
'destinationAddressPrefix' => '*',
|
74
|
+
'access' => 'Allow',
|
75
|
+
'direction' => 'Inbound',
|
76
|
+
'description' => 'Allow inbound traffic from azure load balancer',
|
77
|
+
'sourcePortRange' => '*',
|
78
|
+
'destinationPortRange' => '*',
|
79
|
+
'priority' => 65_001,
|
80
|
+
'provisioningState' => 'Succeeded'
|
81
|
+
},
|
82
|
+
'name' => 'AllowAzureLoadBalancerInBound'
|
83
|
+
},
|
84
|
+
{
|
85
|
+
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group_name}/providers/Microsoft.Network/networkSecurityGroups/#{security_group_name}/defaultSecurityRules/DenyAllInBound",
|
86
|
+
'properties' =>
|
87
|
+
{
|
88
|
+
'protocol' => '*',
|
89
|
+
'sourceAddressPrefix' => '*',
|
90
|
+
'destinationAddressPrefix' => '*',
|
91
|
+
'access' => 'Deny',
|
92
|
+
'direction' => 'Inbound',
|
93
|
+
'description' => 'Deny all inbound traffic',
|
94
|
+
'sourcePortRange' => '*',
|
95
|
+
'destinationPortRange' => '*',
|
96
|
+
'priority' => 65_500,
|
97
|
+
'provisioningState' => 'Succeeded'
|
98
|
+
},
|
99
|
+
'name' => 'DenyAllInBound'
|
100
|
+
},
|
101
|
+
{
|
102
|
+
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group_name}/providers/Microsoft.Network/networkSecurityGroups/#{security_group_name}/defaultSecurityRules/AllowVnetOutBound",
|
103
|
+
'properties' =>
|
104
|
+
{
|
105
|
+
'protocol' => '*',
|
106
|
+
'sourceAddressPrefix' => 'VirtualNetwork',
|
107
|
+
'destinationAddressPrefix' => 'VirtualNetwork',
|
108
|
+
'access' => 'Allow',
|
109
|
+
'direction' => 'Outbound',
|
110
|
+
'description' => 'Allow outbound traffic from all VMs to all VMs in VNET',
|
111
|
+
'sourcePortRange' => '*',
|
112
|
+
'destinationPortRange' => '*',
|
113
|
+
'priority' => 65_000,
|
114
|
+
'provisioningState' => 'Succeeded'
|
115
|
+
},
|
116
|
+
'name' => 'AllowVnetOutBound'
|
117
|
+
},
|
118
|
+
{
|
119
|
+
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group_name}/providers/Microsoft.Network/networkSecurityGroups/#{security_group_name}/defaultSecurityRules/AllowInternetOutBound",
|
120
|
+
'properties' =>
|
121
|
+
{
|
122
|
+
'protocol' => '*',
|
123
|
+
'sourceAddressPrefix' => '*',
|
124
|
+
'destinationAddressPrefix' => 'Internet',
|
125
|
+
'access' => 'Allow',
|
126
|
+
'direction' => 'Outbound',
|
127
|
+
'description' => 'Allow outbound traffic from all VMs to Internet',
|
128
|
+
'sourcePortRange' => '*',
|
129
|
+
'destinationPortRange' => '*',
|
130
|
+
'priority' => 65_001,
|
131
|
+
'provisioningState' => 'Succeeded'
|
132
|
+
},
|
133
|
+
'name' => 'AllowInternetOutBound'
|
134
|
+
},
|
135
|
+
{
|
136
|
+
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group_name}/providers/Microsoft.Network/networkSecurityGroups/#{security_group_name}/defaultSecurityRules/DenyAllOutBound",
|
137
|
+
'properties' =>
|
138
|
+
{
|
139
|
+
'protocol' => '*',
|
140
|
+
'sourceAddressPrefix' => '*',
|
141
|
+
'destinationAddressPrefix' => '*',
|
142
|
+
'access' => 'Deny',
|
143
|
+
'direction' => 'Outbound',
|
144
|
+
'description' => 'Deny all outbound traffic',
|
145
|
+
'sourcePortRange' => '*',
|
146
|
+
'destinationPortRange' => '*',
|
147
|
+
'priority' => 65_500,
|
148
|
+
'provisioningState' => 'Succeeded'
|
149
|
+
},
|
150
|
+
'name' => 'DenyAllOutBound'
|
151
|
+
}
|
152
|
+
],
|
153
|
+
'resourceGuid' => '9dca97e6-4789-4ebd-86e3-52b8b0da6cd4',
|
154
|
+
'provisioningState' => 'Succeeded'
|
155
|
+
}
|
156
|
+
}
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Fog
|
2
|
+
module Network
|
3
|
+
class AzureRM
|
4
|
+
# Real class for Network Request
|
5
|
+
class Real
|
6
|
+
def get_subnet(resource_group, virtual_network_name, subnet_name)
|
7
|
+
Fog::Logger.debug "Getting Subnet: #{subnet_name}."
|
8
|
+
begin
|
9
|
+
promise = @network_client.subnets.get(resource_group, virtual_network_name, subnet_name)
|
10
|
+
result = promise.value!
|
11
|
+
Fog::Logger.debug "Subnet #{subnet_name} retrieved successfully."
|
12
|
+
Azure::ARM::Network::Models::Subnet.serialize_object(result.body)
|
13
|
+
rescue MsRestAzure::AzureOperationError => e
|
14
|
+
msg = "Exception getting Subnet #{subnet_name} in Resource Group: #{resource_group}. #{e.body['error']['message']}"
|
15
|
+
raise msg
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# Mock class for Network Request
|
21
|
+
class Mock
|
22
|
+
def get_subnet(*)
|
23
|
+
{
|
24
|
+
'id' => '/subscriptions/########-####-####-####-############/resourceGroups/fog-rg/providers/Microsoft.Network/virtualNetworks/fog-vnet/subnets/fog-subnet',
|
25
|
+
'properties' =>
|
26
|
+
{
|
27
|
+
'addressPrefix' => '10.1.0.0/24',
|
28
|
+
'provisioningState' => 'Succeeded'
|
29
|
+
},
|
30
|
+
'name' => 'fog-subnet'
|
31
|
+
}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Fog
|
2
|
+
module Network
|
3
|
+
class AzureRM
|
4
|
+
# Real class for Network Request
|
5
|
+
class Real
|
6
|
+
def get_virtual_network(resource_group_name, virtual_network_name)
|
7
|
+
vnet = get_vnet(resource_group_name, virtual_network_name)
|
8
|
+
Azure::ARM::Network::Models::VirtualNetwork.serialize_object(vnet)
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def get_vnet(resource_group_name, virtual_network_name)
|
14
|
+
Fog::Logger.debug "Getting Virtual Network: #{virtual_network_name}."
|
15
|
+
begin
|
16
|
+
response = @network_client.virtual_networks.get(resource_group_name, virtual_network_name).value!
|
17
|
+
Fog::Logger.debug "Virtual Network #{virtual_network_name} retrieved successfully."
|
18
|
+
response.body
|
19
|
+
rescue MsRestAzure::AzureOperationError => e
|
20
|
+
msg = "Exception getting Virtual Network #{virtual_network_name} in Resource Group: #{resource_group_name}. #{e.body['error']['message']}"
|
21
|
+
raise msg
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Mock class for Network Request
|
27
|
+
class Mock
|
28
|
+
def get_virtual_network(*)
|
29
|
+
{
|
30
|
+
'id' => '/subscriptions/########-####-####-####-############/resourceGroups/fog-rg/providers/Microsoft.Network/virtualNetworks/fog-vnet',
|
31
|
+
'name' => 'fog-vnet',
|
32
|
+
'type' => 'Microsoft.Network/virtualNetworks',
|
33
|
+
'location' => 'westus',
|
34
|
+
'properties' =>
|
35
|
+
{
|
36
|
+
'addressSpace' =>
|
37
|
+
{
|
38
|
+
'addressPrefixes' =>
|
39
|
+
[
|
40
|
+
'10.1.0.0/16',
|
41
|
+
'10.2.0.0/16'
|
42
|
+
]
|
43
|
+
},
|
44
|
+
'subnets' =>
|
45
|
+
[
|
46
|
+
{
|
47
|
+
'id' => '/subscriptions/########-####-####-####-############/resourceGroups/fog-rg/providers/Microsoft.Network/virtualNetworks/fog-vnet/subnets/fog-subnet',
|
48
|
+
'properties' =>
|
49
|
+
{
|
50
|
+
'addressPrefix' => '10.1.0.0/24',
|
51
|
+
'provisioningState' => 'Succeeded'
|
52
|
+
},
|
53
|
+
'name' => 'fog-subnet'
|
54
|
+
}
|
55
|
+
],
|
56
|
+
'resourceGuid' => 'c573f8e2-d916-493f-8b25-a681c31269ef',
|
57
|
+
'provisioningState' => 'Succeeded'
|
58
|
+
}
|
59
|
+
}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|