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,135 @@
|
|
1
|
+
require 'fog/azurerm'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
########################################################################################################################
|
5
|
+
###################### Services object required by all actions ######################
|
6
|
+
###################### Keep it Uncommented! ######################
|
7
|
+
########################################################################################################################
|
8
|
+
|
9
|
+
azure_credentials = YAML.load_file('credentials/azure.yml')
|
10
|
+
|
11
|
+
rs = Fog::Resources::AzureRM.new(
|
12
|
+
tenant_id: azure_credentials['tenant_id'],
|
13
|
+
client_id: azure_credentials['client_id'],
|
14
|
+
client_secret: azure_credentials['client_secret'],
|
15
|
+
subscription_id: azure_credentials['subscription_id']
|
16
|
+
)
|
17
|
+
|
18
|
+
network = Fog::Network::AzureRM.new(
|
19
|
+
tenant_id: azure_credentials['tenant_id'],
|
20
|
+
client_id: azure_credentials['client_id'],
|
21
|
+
client_secret: azure_credentials['client_secret'],
|
22
|
+
subscription_id: azure_credentials['subscription_id']
|
23
|
+
)
|
24
|
+
|
25
|
+
########################################################################################################################
|
26
|
+
###################### Prerequisites ######################
|
27
|
+
########################################################################################################################
|
28
|
+
|
29
|
+
rs.resource_groups.create(
|
30
|
+
name: 'TestRG-NI',
|
31
|
+
location: 'eastus'
|
32
|
+
)
|
33
|
+
|
34
|
+
network.virtual_networks.create(
|
35
|
+
name: 'testVnet',
|
36
|
+
location: 'eastus',
|
37
|
+
resource_group: 'TestRG-NI',
|
38
|
+
network_address_list: '10.1.0.0/16,10.2.0.0/16'
|
39
|
+
)
|
40
|
+
|
41
|
+
network.subnets.create(
|
42
|
+
name: 'mysubnet',
|
43
|
+
resource_group: 'TestRG-NI',
|
44
|
+
virtual_network_name: 'testVnet',
|
45
|
+
address_prefix: '10.2.0.0/24'
|
46
|
+
)
|
47
|
+
|
48
|
+
network.subnets.create(
|
49
|
+
name: 'mysubnet1',
|
50
|
+
resource_group: 'TestRG-NI',
|
51
|
+
virtual_network_name: 'testVnet',
|
52
|
+
address_prefix: '10.2.1.0/24'
|
53
|
+
)
|
54
|
+
|
55
|
+
network.public_ips.create(
|
56
|
+
name: 'mypubip',
|
57
|
+
resource_group: 'TestRG-NI',
|
58
|
+
location: 'eastus',
|
59
|
+
public_ip_allocation_method: 'Dynamic'
|
60
|
+
)
|
61
|
+
|
62
|
+
network.public_ips.create(
|
63
|
+
name: 'mypubip1',
|
64
|
+
resource_group: 'TestRG-NI',
|
65
|
+
location: 'eastus',
|
66
|
+
public_ip_allocation_method: 'Dynamic'
|
67
|
+
)
|
68
|
+
|
69
|
+
network.network_security_groups.create(
|
70
|
+
name: 'test_nsg',
|
71
|
+
resource_group: 'TestRG-NI',
|
72
|
+
location: 'eastus',
|
73
|
+
security_rules:
|
74
|
+
[
|
75
|
+
{
|
76
|
+
name: 'testRule',
|
77
|
+
protocol: 'tcp',
|
78
|
+
source_port_range: '22',
|
79
|
+
destination_port_range: '22',
|
80
|
+
source_address_prefix: '0.0.0.0/0',
|
81
|
+
destination_address_prefix: '0.0.0.0/0',
|
82
|
+
access: 'Allow',
|
83
|
+
priority: '100',
|
84
|
+
direction: 'Inbound'
|
85
|
+
}
|
86
|
+
]
|
87
|
+
)
|
88
|
+
|
89
|
+
########################################################################################################################
|
90
|
+
###################### Create Network Interface ######################
|
91
|
+
########################################################################################################################
|
92
|
+
|
93
|
+
network.network_interfaces.create(
|
94
|
+
name: 'NetInt',
|
95
|
+
resource_group: 'TestRG-NI',
|
96
|
+
location: 'eastus',
|
97
|
+
subnet_id: "/subscriptions/#{azure_credentials['subscription_id']}/resourceGroups/TestRG-NI/providers/Microsoft.Network/virtualNetworks/testVnet/subnets/mysubnet",
|
98
|
+
public_ip_address_id: "/subscriptions/#{azure_credentials['subscription_id']}/resourceGroups/TestRG-NI/providers/Microsoft.Network/publicIPAddresses/mypubip",
|
99
|
+
ip_configuration_name: 'testIpConfiguration',
|
100
|
+
private_ip_allocation_method: 'Dynamic'
|
101
|
+
)
|
102
|
+
|
103
|
+
########################################################################################################################
|
104
|
+
###################### Get Network Interface and Update Resources ######################
|
105
|
+
########################################################################################################################
|
106
|
+
|
107
|
+
nic = network.network_interfaces.get('TestRG-NI', 'NetInt')
|
108
|
+
|
109
|
+
subnet_id = "/subscriptions/#{azure_credentials['subscription_id']}/resourceGroups/TestRG-NI/providers/Microsoft.Network/virtualNetworks/testVnet/subnets/mysubnet1"
|
110
|
+
nic.attach_subnet(subnet_id)
|
111
|
+
|
112
|
+
public_ip = "/subscriptions/#{azure_credentials['subscription_id']}/resourceGroups/TestRG-NI/providers/Microsoft.Network/publicIPAddresses/mypubip1"
|
113
|
+
nic.attach_public_ip(public_ip)
|
114
|
+
|
115
|
+
nsg_ip = "/subscriptions/#{azure_credentials['subscription_id']}/resourceGroups/TestRG-NI/providers/Microsoft.Network/networkSecurityGroups/test_nsg"
|
116
|
+
nic.attach_network_security_group(nsg_ip)
|
117
|
+
|
118
|
+
nic.detach_public_ip
|
119
|
+
|
120
|
+
nic.detach_network_security_group
|
121
|
+
|
122
|
+
########################################################################################################################
|
123
|
+
###################### CleanUp ######################
|
124
|
+
########################################################################################################################
|
125
|
+
|
126
|
+
nic.destroy
|
127
|
+
|
128
|
+
pubip = network.public_ips(resource_group: 'TestRG-NI').get('mypubip')
|
129
|
+
pubip.destroy
|
130
|
+
|
131
|
+
vnet = network.virtual_networks(resource_group: 'TestRG-NI').get('testVnet')
|
132
|
+
vnet.destroy
|
133
|
+
|
134
|
+
rg = rs.resource_groups.get('TestRG-NI')
|
135
|
+
rg.destroy
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require 'fog/azurerm'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
########################################################################################################################
|
5
|
+
###################### Services object required by all actions ######################
|
6
|
+
###################### Keep it Uncommented! ######################
|
7
|
+
########################################################################################################################
|
8
|
+
|
9
|
+
azure_credentials = YAML.load_file('credentials/azure.yml')
|
10
|
+
|
11
|
+
rs = Fog::Resources::AzureRM.new(
|
12
|
+
tenant_id: azure_credentials['tenant_id'],
|
13
|
+
client_id: azure_credentials['client_id'],
|
14
|
+
client_secret: azure_credentials['client_secret'],
|
15
|
+
subscription_id: azure_credentials['subscription_id']
|
16
|
+
)
|
17
|
+
|
18
|
+
network = Fog::Network::AzureRM.new(
|
19
|
+
tenant_id: azure_credentials['tenant_id'],
|
20
|
+
client_id: azure_credentials['client_id'],
|
21
|
+
client_secret: azure_credentials['client_secret'],
|
22
|
+
subscription_id: azure_credentials['subscription_id']
|
23
|
+
)
|
24
|
+
|
25
|
+
########################################################################################################################
|
26
|
+
###################### Prerequisites ######################
|
27
|
+
########################################################################################################################
|
28
|
+
|
29
|
+
rs.resource_groups.create(
|
30
|
+
name: 'TestRG-NSG',
|
31
|
+
location: 'eastus'
|
32
|
+
)
|
33
|
+
|
34
|
+
########################################################################################################################
|
35
|
+
###################### Create Network Security Group ######################
|
36
|
+
########################################################################################################################
|
37
|
+
|
38
|
+
network.network_security_groups.create(
|
39
|
+
name: 'testGroup',
|
40
|
+
resource_group: 'TestRG-NSG',
|
41
|
+
location: 'eastus',
|
42
|
+
security_rules: [{
|
43
|
+
name: 'testRule',
|
44
|
+
protocol: 'tcp',
|
45
|
+
source_port_range: '22',
|
46
|
+
destination_port_range: '22',
|
47
|
+
source_address_prefix: '0.0.0.0/0',
|
48
|
+
destination_address_prefix: '0.0.0.0/0',
|
49
|
+
access: 'Allow',
|
50
|
+
priority: '100',
|
51
|
+
direction: 'Inbound'
|
52
|
+
}]
|
53
|
+
)
|
54
|
+
|
55
|
+
########################################################################################################################
|
56
|
+
###################### Get and Update Network Security Group ######################
|
57
|
+
########################################################################################################################
|
58
|
+
|
59
|
+
nsg = network.network_security_groups.get('TestRG-NSG', 'testGroup')
|
60
|
+
nsg.update_security_rules(
|
61
|
+
security_rules:
|
62
|
+
[
|
63
|
+
{
|
64
|
+
name: 'testRule',
|
65
|
+
protocol: 'tcp',
|
66
|
+
source_port_range: '*',
|
67
|
+
destination_port_range: '22',
|
68
|
+
source_address_prefix: '0.0.0.0/0',
|
69
|
+
destination_address_prefix: '0.0.0.0/0',
|
70
|
+
access: 'Allow',
|
71
|
+
priority: '100',
|
72
|
+
direction: 'Inbound'
|
73
|
+
}
|
74
|
+
]
|
75
|
+
)
|
76
|
+
|
77
|
+
########################################################################################################################
|
78
|
+
###################### Add and Remove Network Security Rules ######################
|
79
|
+
########################################################################################################################
|
80
|
+
|
81
|
+
nsg.add_security_rules(
|
82
|
+
[
|
83
|
+
{
|
84
|
+
name: 'testRule2',
|
85
|
+
protocol: 'tcp',
|
86
|
+
source_port_range: '22',
|
87
|
+
destination_port_range: '22',
|
88
|
+
source_address_prefix: '0.0.0.0/0',
|
89
|
+
destination_address_prefix: '0.0.0.0/0',
|
90
|
+
access: 'Allow',
|
91
|
+
priority: '102',
|
92
|
+
direction: 'Inbound'
|
93
|
+
}
|
94
|
+
]
|
95
|
+
)
|
96
|
+
nsg.remove_security_rule('testRule')
|
97
|
+
|
98
|
+
########################################################################################################################
|
99
|
+
###################### CleanUp ######################
|
100
|
+
########################################################################################################################
|
101
|
+
|
102
|
+
nsg.destroy
|
103
|
+
rg = rs.resource_groups.get('TestRG-NSG')
|
104
|
+
rg.destroy
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'fog/azurerm'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
########################################################################################################################
|
5
|
+
###################### Services object required by all actions ######################
|
6
|
+
###################### Keep it Uncommented! ######################
|
7
|
+
########################################################################################################################
|
8
|
+
|
9
|
+
azure_credentials = YAML.load_file('credentials/azure.yml')
|
10
|
+
|
11
|
+
rs = Fog::Resources::AzureRM.new(
|
12
|
+
tenant_id: azure_credentials['tenant_id'],
|
13
|
+
client_id: azure_credentials['client_id'],
|
14
|
+
client_secret: azure_credentials['client_secret'],
|
15
|
+
subscription_id: azure_credentials['subscription_id']
|
16
|
+
)
|
17
|
+
|
18
|
+
network = Fog::Network::AzureRM.new(
|
19
|
+
tenant_id: azure_credentials['tenant_id'],
|
20
|
+
client_id: azure_credentials['client_id'],
|
21
|
+
client_secret: azure_credentials['client_secret'],
|
22
|
+
subscription_id: azure_credentials['subscription_id']
|
23
|
+
)
|
24
|
+
|
25
|
+
########################################################################################################################
|
26
|
+
###################### Prerequisites ######################
|
27
|
+
########################################################################################################################
|
28
|
+
|
29
|
+
rs.resource_groups.create(
|
30
|
+
name: 'TestRG-PB',
|
31
|
+
location: 'eastus'
|
32
|
+
)
|
33
|
+
|
34
|
+
########################################################################################################################
|
35
|
+
###################### Check if PublicIP exists ######################
|
36
|
+
########################################################################################################################
|
37
|
+
|
38
|
+
network.public_ips.check_if_exists('mypubip', 'TestRG-PB')
|
39
|
+
|
40
|
+
########################################################################################################################
|
41
|
+
###################### Create Public IP ######################
|
42
|
+
########################################################################################################################
|
43
|
+
|
44
|
+
network.public_ips.create(
|
45
|
+
name: 'mypubip',
|
46
|
+
resource_group: 'TestRG-PB',
|
47
|
+
location: 'eastus',
|
48
|
+
public_ip_allocation_method: 'Static'
|
49
|
+
)
|
50
|
+
|
51
|
+
########################################################################################################################
|
52
|
+
###################### Get and Delete Public IP ######################
|
53
|
+
########################################################################################################################
|
54
|
+
|
55
|
+
pubip = network.public_ips(resource_group: 'TestRG-PB').get('mypubip')
|
56
|
+
pubip.destroy
|
57
|
+
|
58
|
+
########################################################################################################################
|
59
|
+
###################### CleanUp ######################
|
60
|
+
########################################################################################################################
|
61
|
+
|
62
|
+
rg = rs.resource_groups.get('TestRG-PB')
|
63
|
+
rg.destroy
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'fog/azurerm'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
########################################################################################################################
|
5
|
+
###################### Services object required by all actions ######################
|
6
|
+
###################### Keep it Uncommented! ######################
|
7
|
+
########################################################################################################################
|
8
|
+
|
9
|
+
azure_credentials = YAML.load_file('credentials/azure.yml')
|
10
|
+
|
11
|
+
rs = Fog::Resources::AzureRM.new(
|
12
|
+
tenant_id: azure_credentials['tenant_id'],
|
13
|
+
client_id: azure_credentials['client_id'],
|
14
|
+
client_secret: azure_credentials['client_secret'],
|
15
|
+
subscription_id: azure_credentials['subscription_id']
|
16
|
+
)
|
17
|
+
|
18
|
+
dns = Fog::DNS.new(
|
19
|
+
provider: 'AzureRM',
|
20
|
+
tenant_id: azure_credentials['tenant_id'],
|
21
|
+
client_id: azure_credentials['client_id'],
|
22
|
+
client_secret: azure_credentials['client_secret'],
|
23
|
+
subscription_id: azure_credentials['subscription_id']
|
24
|
+
)
|
25
|
+
|
26
|
+
########################################################################################################################
|
27
|
+
###################### Prerequisites ######################
|
28
|
+
########################################################################################################################
|
29
|
+
|
30
|
+
rs.resource_groups.create(
|
31
|
+
name: 'TestRG-RS',
|
32
|
+
location: 'eastus'
|
33
|
+
)
|
34
|
+
|
35
|
+
dns.zones.create(
|
36
|
+
name: 'test-zone.com',
|
37
|
+
resource_group: 'TestRG-RS'
|
38
|
+
)
|
39
|
+
|
40
|
+
########################################################################################################################
|
41
|
+
###################### Create CNAME Type Record Set in a Zone ######################
|
42
|
+
########################################################################################################################
|
43
|
+
|
44
|
+
dns.record_sets.create(
|
45
|
+
name: 'TestRS1',
|
46
|
+
resource_group: 'TestRG-RS',
|
47
|
+
zone_name: 'test-zone.com',
|
48
|
+
records: ['test.fog.com'],
|
49
|
+
type: 'CNAME',
|
50
|
+
ttl: 60
|
51
|
+
)
|
52
|
+
|
53
|
+
########################################################################################################################
|
54
|
+
###################### Create A Type Record Set in a Zone ######################
|
55
|
+
########################################################################################################################
|
56
|
+
|
57
|
+
dns.record_sets.create(
|
58
|
+
name: 'TestRS2',
|
59
|
+
resource_group: 'TestRG-RS',
|
60
|
+
zone_name: 'test-zone.com',
|
61
|
+
records: %w(1.2.3.4 1.2.3.3),
|
62
|
+
type: 'A',
|
63
|
+
ttl: 60
|
64
|
+
)
|
65
|
+
|
66
|
+
########################################################################################################################
|
67
|
+
###################### Get And Destroy CNAME Type Record Set in a Zone ######################
|
68
|
+
########################################################################################################################
|
69
|
+
|
70
|
+
rs = dns.record_sets(resource_group: 'TestRG-RS', zone_name: 'test-zone.com').get('TestRS1', 'CNAME')
|
71
|
+
rs.destroy
|
72
|
+
|
73
|
+
########################################################################################################################
|
74
|
+
###################### Get And Destroy A Type Record Set in a Zone ######################
|
75
|
+
########################################################################################################################
|
76
|
+
|
77
|
+
rs = dns.record_sets(resource_group: 'TestRG-RS', zone_name: 'test-zone.com').get('TestRS2', 'A')
|
78
|
+
rs.destroy
|
79
|
+
|
80
|
+
########################################################################################################################
|
81
|
+
###################### CleanUp ######################
|
82
|
+
########################################################################################################################
|
83
|
+
|
84
|
+
zone = dns.zones.get('test-zone.com', 'TestRG-RS')
|
85
|
+
zone.destroy
|
86
|
+
|
87
|
+
rg = rs.resource_groups.get('TestRG-RS')
|
88
|
+
rg.destroy
|
@@ -0,0 +1,139 @@
|
|
1
|
+
require 'fog/azurerm'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
########################################################################################################################
|
5
|
+
###################### Services object required by all actions ######################
|
6
|
+
###################### Keep it Uncommented! ######################
|
7
|
+
########################################################################################################################
|
8
|
+
|
9
|
+
azure_credentials = YAML.load_file('credentials/azure.yml')
|
10
|
+
|
11
|
+
rs = Fog::Resources::AzureRM.new(
|
12
|
+
tenant_id: azure_credentials['tenant_id'],
|
13
|
+
client_id: azure_credentials['client_id'],
|
14
|
+
client_secret: azure_credentials['client_secret'],
|
15
|
+
subscription_id: azure_credentials['subscription_id']
|
16
|
+
)
|
17
|
+
|
18
|
+
compute = Fog::Compute::AzureRM.new(
|
19
|
+
tenant_id: azure_credentials['tenant_id'],
|
20
|
+
client_id: azure_credentials['client_id'],
|
21
|
+
client_secret: azure_credentials['client_secret'],
|
22
|
+
subscription_id: azure_credentials['subscription_id']
|
23
|
+
)
|
24
|
+
|
25
|
+
storage = Fog::Storage::AzureRM.new(
|
26
|
+
tenant_id: azure_credentials['tenant_id'],
|
27
|
+
client_id: azure_credentials['client_id'],
|
28
|
+
client_secret: azure_credentials['client_secret'],
|
29
|
+
subscription_id: azure_credentials['subscription_id']
|
30
|
+
)
|
31
|
+
|
32
|
+
network = Fog::Network::AzureRM.new(
|
33
|
+
tenant_id: azure_credentials['tenant_id'],
|
34
|
+
client_id: azure_credentials['client_id'],
|
35
|
+
client_secret: azure_credentials['client_secret'],
|
36
|
+
subscription_id: azure_credentials['subscription_id']
|
37
|
+
)
|
38
|
+
|
39
|
+
########################################################################################################################
|
40
|
+
###################### Prerequisites ######################
|
41
|
+
########################################################################################################################
|
42
|
+
|
43
|
+
rs.resource_groups.create(
|
44
|
+
name: 'TestRG-VM',
|
45
|
+
location: 'eastus'
|
46
|
+
)
|
47
|
+
|
48
|
+
storage.storage_accounts.create(
|
49
|
+
name: 'fogstorageac',
|
50
|
+
location: 'eastus',
|
51
|
+
resource_group: 'TestRG-VM'
|
52
|
+
)
|
53
|
+
|
54
|
+
network.virtual_networks.create(
|
55
|
+
name: 'testVnet',
|
56
|
+
location: 'eastus',
|
57
|
+
resource_group: 'TestRG-VM',
|
58
|
+
network_address_list: '10.1.0.0/16,10.2.0.0/16'
|
59
|
+
)
|
60
|
+
|
61
|
+
network.subnets.create(
|
62
|
+
name: 'mysubnet',
|
63
|
+
resource_group: 'TestRG-VM',
|
64
|
+
virtual_network_name: 'testVnet',
|
65
|
+
address_prefix: '10.1.0.0/24'
|
66
|
+
)
|
67
|
+
|
68
|
+
network.network_interfaces.create(
|
69
|
+
name: 'NetInt',
|
70
|
+
resource_group: 'TestRG-VM',
|
71
|
+
location: 'eastus',
|
72
|
+
subnet_id: "/subscriptions/#{azure_credentials['subscription_id']}/resourceGroups/TestRG-VM/providers/Microsoft.Network/virtualNetworks/testVnet/subnets/mysubnet",
|
73
|
+
ip_configuration_name: 'testIpConfiguration',
|
74
|
+
private_ip_allocation_method: 'Dynamic'
|
75
|
+
)
|
76
|
+
|
77
|
+
########################################################################################################################
|
78
|
+
###################### Create Server ######################
|
79
|
+
########################################################################################################################
|
80
|
+
|
81
|
+
compute.servers.create(
|
82
|
+
name: 'TestVM',
|
83
|
+
location: 'eastus',
|
84
|
+
resource_group: 'TestRG-VM',
|
85
|
+
vm_size: 'Basic_A0',
|
86
|
+
storage_account_name: 'fogstorageac',
|
87
|
+
username: 'testuser',
|
88
|
+
password: 'Confiz=123',
|
89
|
+
disable_password_authentication: false,
|
90
|
+
network_interface_card_id: "/subscriptions/#{azure_credentials['subscription_id']}/resourceGroups/TestRG-VM/providers/Microsoft.Network/networkInterfaces/NetInt",
|
91
|
+
publisher: 'Canonical',
|
92
|
+
offer: 'UbuntuServer',
|
93
|
+
sku: '14.04.2-LTS',
|
94
|
+
version: 'latest',
|
95
|
+
platform: 'linux'
|
96
|
+
)
|
97
|
+
|
98
|
+
########################################################################################################################
|
99
|
+
###################### Attach Data Disk to Server ######################
|
100
|
+
########################################################################################################################
|
101
|
+
|
102
|
+
server = compute.servers(resource_group: 'TestRG-VM').get('TestVM')
|
103
|
+
server.attach_data_disk('datadisk1', 10, 'fogstorageac')
|
104
|
+
|
105
|
+
########################################################################################################################
|
106
|
+
###################### Detach Data Disk to Server ######################
|
107
|
+
########################################################################################################################
|
108
|
+
|
109
|
+
server = compute.servers(resource_group: 'TestRG-VM').get('TestVM')
|
110
|
+
server.detach_data_disk('datadisk1')
|
111
|
+
|
112
|
+
########################################################################################################################
|
113
|
+
###################### Delete Data Disk ######################
|
114
|
+
########################################################################################################################
|
115
|
+
|
116
|
+
storage.delete_disk('TestRG-VM', 'fogstorageac', 'datadisk1')
|
117
|
+
|
118
|
+
########################################################################################################################
|
119
|
+
###################### Get and Delete Server ######################
|
120
|
+
########################################################################################################################
|
121
|
+
|
122
|
+
server = compute.servers(resource_group: 'TestRG-VM').get('TestVM')
|
123
|
+
server.destroy
|
124
|
+
|
125
|
+
########################################################################################################################
|
126
|
+
###################### CleanUp ######################
|
127
|
+
########################################################################################################################
|
128
|
+
|
129
|
+
nic = network.network_interfaces(resource_group: 'TestRG-VM').get('NetInt')
|
130
|
+
nic.destroy
|
131
|
+
|
132
|
+
vnet = network.virtual_networks(resource_group: 'TestRG-VM').get('testVnet')
|
133
|
+
vnet.destroy
|
134
|
+
|
135
|
+
storage = storage.storage_accounts(resource_group: 'TestRG-VM').get('fogstorageac')
|
136
|
+
storage.destroy
|
137
|
+
|
138
|
+
rg = rs.resource_groups.get('TestRG-VM')
|
139
|
+
rg.destroy
|