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
@@ -25,7 +25,7 @@ module Fog
|
|
25
25
|
|
26
26
|
def self.parse(nic)
|
27
27
|
nic_properties = nic['properties']
|
28
|
-
nic_ip_configuration =
|
28
|
+
nic_ip_configuration = nic_properties['ipConfigurations'][0]
|
29
29
|
hash = {}
|
30
30
|
hash['id'] = nic['id']
|
31
31
|
hash['name'] = nic['name']
|
@@ -33,8 +33,8 @@ module Fog
|
|
33
33
|
hash['resource_group'] = nic['id'].split('/')[4]
|
34
34
|
hash['virtual_machine_id'] = nic_properties['virtualMachine']['id'] unless nic_properties['virtualMachine'].nil?
|
35
35
|
hash['mac_address'] = nic_properties['macAddress'] unless nic_properties['macAddress'].nil?
|
36
|
+
hash['network_security_group_id'] = nil
|
36
37
|
hash['network_security_group_id'] = nic_properties['networkSecurityGroup']['id'] unless nic_properties['networkSecurityGroup'].nil?
|
37
|
-
|
38
38
|
unless nic_ip_configuration.nil?
|
39
39
|
nic_ip_configuration_properties = nic_ip_configuration['properties']
|
40
40
|
hash['ip_configuration_name'] = nic_ip_configuration['name']
|
@@ -42,6 +42,7 @@ module Fog
|
|
42
42
|
hash['subnet_id'] = nic_ip_configuration_properties['subnet']['id'] unless nic_ip_configuration_properties['subnet'].nil?
|
43
43
|
hash['private_ip_allocation_method'] = nic_ip_configuration_properties['privateIPAllocationMethod']
|
44
44
|
hash['private_ip_address'] = nic_ip_configuration_properties['privateIPAddress']
|
45
|
+
hash['public_ip_address_id'] = nil
|
45
46
|
hash['public_ip_address_id'] = nic_ip_configuration_properties['publicIPAddress']['id'] unless nic_ip_configuration_properties['publicIPAddress'].nil?
|
46
47
|
hash['load_balancer_backend_address_pools_ids'] = nic_ip_configuration_properties['loadBalancerBackendAddressPools'].map { |item| item['id'] } unless nic_ip_configuration_properties['loadBalancerBackendAddressPools'].nil?
|
47
48
|
hash['load_balancer_inbound_nat_rules_ids'] = nic_ip_configuration_properties['loadBalancerInboundNatRules'].map { |item| item['id'] } unless nic_ip_configuration_properties['loadBalancerInboundNatRules'].nil?
|
@@ -61,13 +62,57 @@ module Fog
|
|
61
62
|
requires :subnet_id
|
62
63
|
requires :ip_configuration_name
|
63
64
|
requires :private_ip_allocation_method
|
64
|
-
|
65
|
-
merge_attributes(Fog::Network::AzureRM::NetworkInterface.parse(
|
65
|
+
nic = service.create_or_update_network_interface(resource_group, name, location, subnet_id, public_ip_address_id, ip_configuration_name, private_ip_allocation_method, private_ip_address)
|
66
|
+
merge_attributes(Fog::Network::AzureRM::NetworkInterface.parse(nic))
|
67
|
+
end
|
68
|
+
|
69
|
+
def update(updated_attributes = {})
|
70
|
+
validate_update_attributes!(updated_attributes)
|
71
|
+
merge_attributes(updated_attributes)
|
72
|
+
nic = service.create_or_update_network_interface(resource_group, name, location, subnet_id, public_ip_address_id, ip_configuration_name, private_ip_allocation_method, private_ip_address)
|
73
|
+
merge_attributes(Fog::Network::AzureRM::NetworkInterface.parse(nic))
|
74
|
+
end
|
75
|
+
|
76
|
+
def attach_subnet(subnet_id)
|
77
|
+
raise 'Subnet ID can not be nil.' if subnet_id.nil?
|
78
|
+
nic = service.attach_resource_to_nic(resource_group, name, SUBNET, subnet_id)
|
79
|
+
merge_attributes(Fog::Network::AzureRM::NetworkInterface.parse(nic))
|
80
|
+
end
|
81
|
+
|
82
|
+
def attach_public_ip(public_ip_id)
|
83
|
+
raise 'Public-IP ID can not be nil.' if public_ip_id.nil?
|
84
|
+
nic = service.attach_resource_to_nic(resource_group, name, PUBLIC_IP, public_ip_id)
|
85
|
+
merge_attributes(Fog::Network::AzureRM::NetworkInterface.parse(nic))
|
86
|
+
end
|
87
|
+
|
88
|
+
def attach_network_security_group(network_security_group_id)
|
89
|
+
raise 'Network-Security-Group ID can not be nil.' if network_security_group_id.nil?
|
90
|
+
nic = service.attach_resource_to_nic(resource_group, name, NETWORK_SECURITY_GROUP, network_security_group_id)
|
91
|
+
merge_attributes(Fog::Network::AzureRM::NetworkInterface.parse(nic))
|
92
|
+
end
|
93
|
+
|
94
|
+
def detach_public_ip
|
95
|
+
raise "Error detaching Public IP. No Public IP is attached to Network Interface #{name}" if public_ip_address_id.nil?
|
96
|
+
nic = service.detach_resource_from_nic(resource_group, name, PUBLIC_IP)
|
97
|
+
merge_attributes(Fog::Network::AzureRM::NetworkInterface.parse(nic))
|
98
|
+
end
|
99
|
+
|
100
|
+
def detach_network_security_group
|
101
|
+
raise "Error detaching Network Security Group. No Security Group is attached to Network Interface #{name}" if network_security_group_id.nil?
|
102
|
+
nic = service.detach_resource_from_nic(resource_group, name, NETWORK_SECURITY_GROUP)
|
103
|
+
merge_attributes(Fog::Network::AzureRM::NetworkInterface.parse(nic))
|
66
104
|
end
|
67
105
|
|
68
106
|
def destroy
|
69
107
|
service.delete_network_interface(resource_group, name)
|
70
108
|
end
|
109
|
+
|
110
|
+
def validate_update_attributes!(hash)
|
111
|
+
restricted_attributes = [:name, :id, :resource_group, :location, :ip_configuration_name, :ip_configuration_id]
|
112
|
+
hash_keys = hash.keys
|
113
|
+
invalid_attributes = restricted_attributes & hash_keys
|
114
|
+
raise "Attributes #{invalid_attributes.join(', ')} can not be updated." unless invalid_attributes.empty?
|
115
|
+
end
|
71
116
|
end
|
72
117
|
end
|
73
118
|
end
|
@@ -18,8 +18,10 @@ module Fog
|
|
18
18
|
load(network_interfaces)
|
19
19
|
end
|
20
20
|
|
21
|
-
def get(
|
22
|
-
|
21
|
+
def get(resource_group_name, name)
|
22
|
+
nic = service.get_network_interface(resource_group_name, name)
|
23
|
+
network_interface_card = Fog::Network::AzureRM::NetworkInterface.new(service: service)
|
24
|
+
network_interface_card.merge_attributes(Fog::Network::AzureRM::NetworkInterface.parse(nic))
|
23
25
|
end
|
24
26
|
end
|
25
27
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Fog
|
2
2
|
module Network
|
3
3
|
class AzureRM
|
4
|
-
#
|
4
|
+
# Network Security Group model for Network Service
|
5
5
|
class NetworkSecurityGroup < Fog::Model
|
6
6
|
identity :name
|
7
7
|
attribute :id
|
@@ -40,7 +40,7 @@ module Fog
|
|
40
40
|
requires :name, :location, :resource_group
|
41
41
|
|
42
42
|
validate_security_rules(security_rules) unless security_rules.nil?
|
43
|
-
nsg = service.
|
43
|
+
nsg = service.create_or_update_network_security_group(resource_group, name, location, security_rules)
|
44
44
|
merge_attributes(Fog::Network::AzureRM::NetworkSecurityGroup.parse(nsg))
|
45
45
|
end
|
46
46
|
|
@@ -48,6 +48,29 @@ module Fog
|
|
48
48
|
service.delete_network_security_group(resource_group, name)
|
49
49
|
end
|
50
50
|
|
51
|
+
def update_security_rules(security_rule_hash = {})
|
52
|
+
raise('Provided hash can not be empty.') if security_rule_hash.empty? || security_rule_hash.nil?
|
53
|
+
|
54
|
+
if !security_rule_hash[:security_rules].nil? && security_rule_hash.length == 1
|
55
|
+
validate_security_rules(security_rule_hash[:security_rules])
|
56
|
+
merge_attributes(security_rule_hash)
|
57
|
+
nsg = service.create_or_update_network_security_group(resource_group, name, location, security_rules)
|
58
|
+
return merge_attributes(Fog::Network::AzureRM::NetworkSecurityGroup.parse(nsg))
|
59
|
+
end
|
60
|
+
raise 'Invalid hash key.'
|
61
|
+
end
|
62
|
+
|
63
|
+
def add_security_rules(security_rules)
|
64
|
+
validate_security_rules(security_rules)
|
65
|
+
nsg = service.add_security_rules(resource_group, name, security_rules)
|
66
|
+
merge_attributes(Fog::Network::AzureRM::NetworkSecurityGroup.parse(nsg))
|
67
|
+
end
|
68
|
+
|
69
|
+
def remove_security_rule(security_rule_name)
|
70
|
+
nsg = service.remove_security_rule(resource_group, name, security_rule_name)
|
71
|
+
merge_attributes(Fog::Network::AzureRM::NetworkSecurityGroup.parse(nsg))
|
72
|
+
end
|
73
|
+
|
51
74
|
private
|
52
75
|
|
53
76
|
def validate_security_rules(security_rules)
|
@@ -56,11 +79,11 @@ module Fog
|
|
56
79
|
if sr.is_a?(Hash)
|
57
80
|
validate_security_rule_params(sr)
|
58
81
|
else
|
59
|
-
raise(ArgumentError, '
|
82
|
+
raise(ArgumentError, 'Parameter security_rules must be an Array of Hashes')
|
60
83
|
end
|
61
84
|
end
|
62
85
|
else
|
63
|
-
raise(ArgumentError, '
|
86
|
+
raise(ArgumentError, 'Parameter security_rules must be an Array')
|
64
87
|
end
|
65
88
|
end
|
66
89
|
|
@@ -18,8 +18,10 @@ module Fog
|
|
18
18
|
load(network_security_groups)
|
19
19
|
end
|
20
20
|
|
21
|
-
def get(
|
22
|
-
|
21
|
+
def get(resource_group, name)
|
22
|
+
nsg = service.get_network_security_group(resource_group, name)
|
23
|
+
network_security_group = Fog::Network::AzureRM::NetworkSecurityGroup.new(service: service)
|
24
|
+
network_security_group.merge_attributes(Fog::Network::AzureRM::NetworkSecurityGroup.parse(nsg))
|
23
25
|
end
|
24
26
|
end
|
25
27
|
end
|
@@ -16,20 +16,40 @@ module Fog
|
|
16
16
|
hash = {}
|
17
17
|
hash['id'] = subnet['id']
|
18
18
|
hash['name'] = subnet['name']
|
19
|
-
hash['resource_group'] = subnet['id']
|
20
|
-
hash['virtual_network_name'] = subnet['id']
|
19
|
+
hash['resource_group'] = get_resource_group_from_id(subnet['id'])
|
20
|
+
hash['virtual_network_name'] = get_virtual_network_from_id(subnet['id'])
|
21
21
|
hash['address_prefix'] = subnet['properties']['addressPrefix']
|
22
|
+
hash['network_security_group_id'] = nil
|
22
23
|
hash['network_security_group_id'] = subnet['properties']['networkSecurityGroup']['id'] unless subnet['properties']['networkSecurityGroup'].nil?
|
24
|
+
hash['route_table_id'] = nil
|
23
25
|
hash['route_table_id'] = subnet['properties']['routeTable']['id'] unless subnet['properties']['routeTable'].nil?
|
24
26
|
hash['ip_configurations_ids'] = subnet['properties']['ipConfigurations'].map { |item| item['id'] } unless subnet['properties']['ipConfigurations'].nil?
|
25
27
|
hash
|
26
28
|
end
|
27
29
|
|
28
30
|
def save
|
29
|
-
requires :name
|
30
|
-
|
31
|
-
|
32
|
-
|
31
|
+
requires :name, :resource_group, :virtual_network_name, :address_prefix
|
32
|
+
subnet = service.create_subnet(resource_group, name, virtual_network_name, address_prefix, network_security_group_id, route_table_id)
|
33
|
+
merge_attributes(Fog::Network::AzureRM::Subnet.parse(subnet))
|
34
|
+
end
|
35
|
+
|
36
|
+
def attach_network_security_group(network_security_group_id)
|
37
|
+
subnet = service.attach_network_security_group_to_subnet(resource_group, name, virtual_network_name, address_prefix, route_table_id, network_security_group_id)
|
38
|
+
merge_attributes(Fog::Network::AzureRM::Subnet.parse(subnet))
|
39
|
+
end
|
40
|
+
|
41
|
+
def detach_network_security_group
|
42
|
+
subnet = service.detach_network_security_group_from_subnet(resource_group, name, virtual_network_name, address_prefix, route_table_id)
|
43
|
+
merge_attributes(Fog::Network::AzureRM::Subnet.parse(subnet))
|
44
|
+
end
|
45
|
+
|
46
|
+
def attach_route_table(route_table_id)
|
47
|
+
subnet = service.attach_route_table_to_subnet(resource_group, name, virtual_network_name, address_prefix, network_security_group_id, route_table_id)
|
48
|
+
merge_attributes(Fog::Network::AzureRM::Subnet.parse(subnet))
|
49
|
+
end
|
50
|
+
|
51
|
+
def detach_route_table
|
52
|
+
subnet = service.detach_route_table_from_subnet(resource_group, name, virtual_network_name, address_prefix, network_security_group_id)
|
33
53
|
merge_attributes(Fog::Network::AzureRM::Subnet.parse(subnet))
|
34
54
|
end
|
35
55
|
|
@@ -20,8 +20,10 @@ module Fog
|
|
20
20
|
load(subnets)
|
21
21
|
end
|
22
22
|
|
23
|
-
def get(
|
24
|
-
|
23
|
+
def get(resource_group, virtual_network_name, subnet_name)
|
24
|
+
subnet = service.get_subnet(resource_group, virtual_network_name, subnet_name)
|
25
|
+
subnet_object = Fog::Network::AzureRM::Subnet.new(service: service)
|
26
|
+
subnet_object.merge_attributes(Fog::Network::AzureRM::Subnet.parse(subnet))
|
25
27
|
end
|
26
28
|
end
|
27
29
|
end
|
@@ -8,23 +8,25 @@ module Fog
|
|
8
8
|
attribute :id
|
9
9
|
attribute :location
|
10
10
|
attribute :resource_group
|
11
|
-
attribute :
|
12
|
-
attribute :
|
13
|
-
attribute :
|
11
|
+
attribute :dns_servers
|
12
|
+
attribute :subnets
|
13
|
+
attribute :address_prefixes
|
14
14
|
|
15
15
|
def self.parse(vnet)
|
16
16
|
hash = {}
|
17
17
|
hash['id'] = vnet['id']
|
18
18
|
hash['name'] = vnet['name']
|
19
|
-
hash['resource_group'] = vnet['id']
|
19
|
+
hash['resource_group'] = get_resource_group_from_id(vnet['id'])
|
20
20
|
hash['location'] = vnet['location']
|
21
|
-
hash['
|
22
|
-
hash['
|
23
|
-
|
21
|
+
hash['dns_servers'] = vnet['properties']['dhcpOptions']['dnsServers'] unless vnet['properties']['dhcpOptions'].nil?
|
22
|
+
hash['address_prefixes'] = vnet['properties']['addressSpace']['addressPrefixes'] unless vnet['properties']['addressSpace']['addressPrefixes'].nil?
|
23
|
+
|
24
|
+
subnets = []
|
24
25
|
vnet['properties']['subnets'].each do |subnet|
|
25
|
-
|
26
|
+
subnet_object = Fog::Network::AzureRM::Subnet.new
|
27
|
+
subnets.push(subnet_object.merge_attributes(Fog::Network::AzureRM::Subnet.parse(subnet)))
|
26
28
|
end
|
27
|
-
hash['
|
29
|
+
hash['subnets'] = subnets
|
28
30
|
hash
|
29
31
|
end
|
30
32
|
|
@@ -32,13 +34,73 @@ module Fog
|
|
32
34
|
requires :name
|
33
35
|
requires :location
|
34
36
|
requires :resource_group
|
35
|
-
|
37
|
+
validate_subnets!(subnets) unless subnets.nil?
|
38
|
+
|
39
|
+
vnet = service.create_or_update_virtual_network(resource_group, name, location, dns_servers, subnets, address_prefixes)
|
36
40
|
merge_attributes(Fog::Network::AzureRM::VirtualNetwork.parse(vnet))
|
37
41
|
end
|
38
42
|
|
43
|
+
def add_dns_servers(dns_servers_list)
|
44
|
+
virtual_network = service.add_dns_servers_in_virtual_network(resource_group, name, dns_servers_list)
|
45
|
+
merge_attributes(Fog::Network::AzureRM::VirtualNetwork.parse(virtual_network))
|
46
|
+
end
|
47
|
+
|
48
|
+
def remove_dns_servers(dns_servers_list)
|
49
|
+
virtual_network = service.remove_dns_servers_from_virtual_network(resource_group, name, dns_servers_list)
|
50
|
+
merge_attributes(Fog::Network::AzureRM::VirtualNetwork.parse(virtual_network))
|
51
|
+
end
|
52
|
+
|
53
|
+
def add_address_prefixes(address_prefixes_list)
|
54
|
+
virtual_network = service.add_address_prefixes_in_virtual_network(resource_group, name, address_prefixes_list)
|
55
|
+
merge_attributes(Fog::Network::AzureRM::VirtualNetwork.parse(virtual_network))
|
56
|
+
end
|
57
|
+
|
58
|
+
def remove_address_prefixes(address_prefixes_list)
|
59
|
+
virtual_network = service.remove_address_prefixes_from_virtual_network(resource_group, name, address_prefixes_list)
|
60
|
+
merge_attributes(Fog::Network::AzureRM::VirtualNetwork.parse(virtual_network))
|
61
|
+
end
|
62
|
+
|
63
|
+
def add_subnets(subnets_list)
|
64
|
+
validate_subnets!(subnets_list)
|
65
|
+
virtual_network = service.add_subnets_in_virtual_network(resource_group, name, subnets_list)
|
66
|
+
merge_attributes(Fog::Network::AzureRM::VirtualNetwork.parse(virtual_network))
|
67
|
+
end
|
68
|
+
|
69
|
+
def remove_subnets(subnet_names_list)
|
70
|
+
virtual_network = service.remove_subnets_from_virtual_network(resource_group, name, subnet_names_list)
|
71
|
+
merge_attributes(Fog::Network::AzureRM::VirtualNetwork.parse(virtual_network))
|
72
|
+
end
|
73
|
+
|
74
|
+
def update(vnet_hash)
|
75
|
+
raise('Provided hash can not be empty.') if vnet_hash.empty? || vnet_hash.nil?
|
76
|
+
validate_update_attributes!(vnet_hash)
|
77
|
+
merge_attributes(vnet_hash)
|
78
|
+
virtual_network = service.create_or_update_virtual_network(resource_group, name, location, dns_servers, subnets, address_prefixes)
|
79
|
+
merge_attributes(Fog::Network::AzureRM::VirtualNetwork.parse(virtual_network))
|
80
|
+
end
|
81
|
+
|
39
82
|
def destroy
|
40
83
|
service.delete_virtual_network(resource_group, name)
|
41
84
|
end
|
85
|
+
|
86
|
+
private
|
87
|
+
|
88
|
+
def validate_update_attributes!(vnet_hash)
|
89
|
+
forbidden_attributes = [:id, :name, :location, :resource_group]
|
90
|
+
invalid_attributes = forbidden_attributes & vnet_hash.keys
|
91
|
+
raise "#{invalid_attributes.join(', ')} cannot be changed." if invalid_attributes.any?
|
92
|
+
validate_subnets!(vnet_hash[:subnets]) if vnet_hash.key?(:subnets)
|
93
|
+
end
|
94
|
+
|
95
|
+
def validate_subnets!(subnets)
|
96
|
+
raise ':subnets must be an Array' unless subnets.is_a?(Array)
|
97
|
+
raise ':subnets must not be an empty Array' if subnets.empty?
|
98
|
+
|
99
|
+
subnets.each do |subnet|
|
100
|
+
raise ':subnets must be an Array of Hashes' unless subnet.is_a?(Hash)
|
101
|
+
validate_params([:name, :address_prefix], subnet)
|
102
|
+
end
|
103
|
+
end
|
42
104
|
end
|
43
105
|
end
|
44
106
|
end
|
@@ -19,8 +19,10 @@ module Fog
|
|
19
19
|
load(virtual_networks)
|
20
20
|
end
|
21
21
|
|
22
|
-
def get(
|
23
|
-
|
22
|
+
def get(resource_group_name, virtual_network_name)
|
23
|
+
virtual_network = service.get_virtual_network(resource_group_name, virtual_network_name)
|
24
|
+
virtual_network_object = Fog::Network::AzureRM::VirtualNetwork.new(service: service)
|
25
|
+
virtual_network_object.merge_attributes(Fog::Network::AzureRM::VirtualNetwork.parse(virtual_network))
|
24
26
|
end
|
25
27
|
|
26
28
|
def check_if_exists(resource_group, name)
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Fog
|
2
|
+
module Resources
|
3
|
+
class AzureRM
|
4
|
+
# This class is giving implementation of create/save and
|
5
|
+
# delete/destroy for resources.
|
6
|
+
class AzureResource < Fog::Model
|
7
|
+
attribute :id
|
8
|
+
attribute :name
|
9
|
+
attribute :type
|
10
|
+
attribute :location
|
11
|
+
attribute :tags
|
12
|
+
|
13
|
+
def self.parse(resource)
|
14
|
+
hash = {}
|
15
|
+
hash['id'] = resource['id']
|
16
|
+
hash['name'] = resource['name']
|
17
|
+
hash['type'] = resource['type']
|
18
|
+
hash['location'] = resource['location']
|
19
|
+
hash['tags'] = resource['tags']
|
20
|
+
hash
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'fog/core/collection'
|
2
|
+
require 'fog/azurerm/models/resources/azure_resource'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Resources
|
6
|
+
class AzureRM
|
7
|
+
# This class is giving implementation of all/list and get.
|
8
|
+
class AzureResources < Fog::Collection
|
9
|
+
attribute :tag_name
|
10
|
+
attribute :tag_value
|
11
|
+
model Fog::Resources::AzureRM::AzureResource
|
12
|
+
|
13
|
+
def all
|
14
|
+
unless tag_name.nil? && tag_value.nil?
|
15
|
+
resources = []
|
16
|
+
service.list_tagged_resources(tag_name, tag_value).each do |resource|
|
17
|
+
resources << Fog::Resources::AzureRM::AzureResource.parse(resource)
|
18
|
+
end
|
19
|
+
resources.inspect
|
20
|
+
return load(resources)
|
21
|
+
end
|
22
|
+
nil
|
23
|
+
end
|
24
|
+
|
25
|
+
def get(resource_id)
|
26
|
+
all.find { |f| f.id == resource_id }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Fog
|
2
|
+
module Resources
|
3
|
+
class AzureRM
|
4
|
+
# Dependency model class
|
5
|
+
class Dependency < Fog::Model
|
6
|
+
attribute :id
|
7
|
+
attribute :resource_name
|
8
|
+
attribute :resource_type
|
9
|
+
attribute :depends_on
|
10
|
+
|
11
|
+
def self.parse(dependency)
|
12
|
+
hash = {}
|
13
|
+
hash['id'] = dependency['id']
|
14
|
+
hash['resource_name'] = dependency['resourceName']
|
15
|
+
hash['resource_type'] = dependency['resourceType']
|
16
|
+
|
17
|
+
hash['depends_on'] = []
|
18
|
+
dependency['dependsOn'].each do |sub_dependency|
|
19
|
+
dependency_obj = Fog::Resources::AzureRM::Dependency.new
|
20
|
+
hash['depends_on'] << dependency_obj.merge_attributes(Fog::Resources::AzureRM::Dependency.parse(sub_dependency))
|
21
|
+
end unless dependency['dependsOn'].nil?
|
22
|
+
hash
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|