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,155 @@
|
|
1
|
+
#Resources
|
2
|
+
|
3
|
+
This document explains how to get started using Azure Resources Service with Fog. With this gem you can create/update/list/delete resource groups.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
First of all, you need to require the Fog library by executing:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
require 'fog/azurerm'
|
11
|
+
```
|
12
|
+
|
13
|
+
## Create Connection
|
14
|
+
|
15
|
+
Next, create a connection to the Resources Service:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
azure_resources_service = Fog::Resources::AzureRM.new(
|
19
|
+
tenant_id: '<Tenantid>', # Tenant id of Azure Active Directory Application
|
20
|
+
client_id: '<Clientid>', # Client id of Azure Active Directory Application
|
21
|
+
client_secret: '<ClientSecret>', # Client Secret of Azure Active Directory Application
|
22
|
+
subscription_id: '<Subscriptionid>' # Subscription id of an Azure Account
|
23
|
+
)
|
24
|
+
```
|
25
|
+
## Create Resource Group
|
26
|
+
|
27
|
+
Create a new resource group
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
azure_resources_service.resource_groups.create(
|
31
|
+
name: '<Resource Group name>',
|
32
|
+
location: 'West US'
|
33
|
+
)
|
34
|
+
```
|
35
|
+
## List Resource Groups
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
azure_resources_service.resource_groups.each do |resource_group|
|
39
|
+
puts "#{resource_group.name}"
|
40
|
+
puts "#{resource_group.location}"
|
41
|
+
end
|
42
|
+
```
|
43
|
+
|
44
|
+
## Retrieve a single Resource Group
|
45
|
+
|
46
|
+
Get a single record of Resource Group
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
resource_group = azure_resources_service
|
50
|
+
.resource_groups
|
51
|
+
.get('<Resource Group name>')
|
52
|
+
puts "#{resource_group.name}"
|
53
|
+
```
|
54
|
+
|
55
|
+
## Destroy a single Resource Group
|
56
|
+
|
57
|
+
Get resource group object from the get method(described above) and then destroy that resource group.
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
resource_group.destroy
|
61
|
+
```
|
62
|
+
## Tagging a Resource
|
63
|
+
|
64
|
+
You can tag a Resource as following:
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
azure_resources_service.tag_resource(
|
68
|
+
'<Resource-ID>',
|
69
|
+
'<Tag-Key>',
|
70
|
+
'<Tag-Value>'
|
71
|
+
)
|
72
|
+
```
|
73
|
+
|
74
|
+
## List Tagged Resources in a Subscription
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
azure_resources_service.resources(tag_name: '<Tag-Key>', tag_value: '<Tag-Value>').each do |resource|
|
78
|
+
puts "#{resource.name}"
|
79
|
+
puts "#{resource.location}"
|
80
|
+
puts "#{resource.type}"
|
81
|
+
end
|
82
|
+
```
|
83
|
+
OR
|
84
|
+
```ruby
|
85
|
+
azure_resources_service.resources(tag_name: '<Tag-Key>').each do |resource|
|
86
|
+
puts "#{resource.name}"
|
87
|
+
puts "#{resource.location}"
|
88
|
+
puts "#{resource.type}"
|
89
|
+
end
|
90
|
+
```
|
91
|
+
## Retrieve a single Resource
|
92
|
+
|
93
|
+
Get a single record of Tagged Resources
|
94
|
+
|
95
|
+
```ruby
|
96
|
+
resource = azure_resources_service
|
97
|
+
.resources(tag_name: '<Tag-Key>')
|
98
|
+
.get('<Resource-ID>')
|
99
|
+
puts "#{resource.name}"
|
100
|
+
```
|
101
|
+
## Remove tag from a Resource
|
102
|
+
|
103
|
+
Remove tag from a resource as following:
|
104
|
+
|
105
|
+
```ruby
|
106
|
+
azure_resources_service.delete_resource_tag(
|
107
|
+
'<Resource-ID>',
|
108
|
+
'<Tag-Key>',
|
109
|
+
'<Tag-Value>'
|
110
|
+
)
|
111
|
+
```
|
112
|
+
|
113
|
+
## Create Deployment
|
114
|
+
|
115
|
+
Create a Deployment
|
116
|
+
|
117
|
+
```ruby
|
118
|
+
azure_resources_service.deployments.create(
|
119
|
+
name: '<Deployment name>',
|
120
|
+
resource_group: '<Resource Group name>',
|
121
|
+
template_link: '<Template Link>',
|
122
|
+
parameters_link: '<Parameters Link>'
|
123
|
+
)
|
124
|
+
```
|
125
|
+
## List Deployments
|
126
|
+
|
127
|
+
List Deployments in a resource group
|
128
|
+
|
129
|
+
```ruby
|
130
|
+
azure_resources_service.deployments(resource_group: '<Resource Group Name>').each do |deployment|
|
131
|
+
puts "#{deployment.name}"
|
132
|
+
end
|
133
|
+
```
|
134
|
+
|
135
|
+
## Retrieve a single Deployment
|
136
|
+
|
137
|
+
Get a single record of Deployment
|
138
|
+
|
139
|
+
```ruby
|
140
|
+
deployment = azure_resources_service
|
141
|
+
.deployments(resource_group: '<Resource Group name>')
|
142
|
+
.get('<Deployment name>')
|
143
|
+
puts "#{deployment.name}"
|
144
|
+
```
|
145
|
+
|
146
|
+
## Destroy a single Deployment
|
147
|
+
|
148
|
+
Get Deployment object from the get method(described above) and then destroy that Deployment.
|
149
|
+
|
150
|
+
```ruby
|
151
|
+
deployment.destroy
|
152
|
+
```
|
153
|
+
|
154
|
+
## Support and Feedback
|
155
|
+
Your feedback is appreciated! If you have specific issues with the fog ARM, you should file an issue via Github.
|
@@ -0,0 +1,222 @@
|
|
1
|
+
#Storage
|
2
|
+
|
3
|
+
This document explains how to get started using Azure Storage Service with Fog. With this gem you can create/update/list/delete storage accounts.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
First of all, you need to require the Fog library by executing:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
require 'fog/azurerm'
|
11
|
+
```
|
12
|
+
|
13
|
+
## Create Connection
|
14
|
+
|
15
|
+
Next, create a connection to the Storage Service:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
azure_storage_service = Fog::Storage.new(
|
19
|
+
:provider => 'AzureRM',
|
20
|
+
:tenant_id => '<Tenantid>', # Tenant id of Azure Active Directory Application
|
21
|
+
:client_id => '<Clientid>', # Client id of Azure Active Directory Application
|
22
|
+
:client_secret => '<ClientSecret>', # Client Secret of Azure Active Directory Application
|
23
|
+
:subscription_id => '<Subscriptionid>' # Subscription id of an Azure Account
|
24
|
+
:azure_storage_account_name => '<StorageAccountName>' # Name of an Azure Storage Account
|
25
|
+
:azure_storage_access_key => '<StorageAccountKey>' # Key of an Azure Storage Account
|
26
|
+
:azure_storage_connection_string => '<StorageConnectionString>' # Connection String of an Azure Storage Account
|
27
|
+
)
|
28
|
+
```
|
29
|
+
|
30
|
+
If you only want to manage the storage accounts, you can create the connection without the storage account information:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
azure_storage_service = Fog::Storage.new(
|
34
|
+
:provider => 'AzureRM',
|
35
|
+
:tenant_id => '<Tenantid>', # Tenant id of Azure Active Directory Application
|
36
|
+
:client_id => '<Clientid>', # Client id of Azure Active Directory Application
|
37
|
+
:client_secret => '<ClientSecret>', # Client Secret of Azure Active Directory Application
|
38
|
+
:subscription_id => '<Subscriptionid>' # Subscription id of an Azure Account
|
39
|
+
)
|
40
|
+
```
|
41
|
+
|
42
|
+
If you only want to manage the storage data, you can create the connection without the Azure subscription information:
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
azure_storage_service = Fog::Storage.new(
|
46
|
+
:provider => 'AzureRM',
|
47
|
+
:azure_storage_account_name => '<StorageAccountName>' # Name of an Azure Storage Account
|
48
|
+
:azure_storage_access_key => '<StorageAccountKey>' # Key of an Azure Storage Account
|
49
|
+
:azure_storage_connection_string => '<StorageConnectionString>' # Connection String of an Azure Storage Account (optional)
|
50
|
+
)
|
51
|
+
```
|
52
|
+
|
53
|
+
## Check Name Availability
|
54
|
+
|
55
|
+
Check Storage Account Name Availability.This operation checks that account name is valid and is not already in use.
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
azure_storage_service.storage_accounts.check_name_availability('<Storage Account name>')
|
59
|
+
```
|
60
|
+
|
61
|
+
## Create Storage Account
|
62
|
+
|
63
|
+
Create a new storage account
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
azure_storage_service.storage_accounts.create(
|
67
|
+
:name => '<Storage Account name>',
|
68
|
+
:location => 'West US',
|
69
|
+
:resource_group => '<Resource Group name>'
|
70
|
+
)
|
71
|
+
```
|
72
|
+
## List storage accounts
|
73
|
+
|
74
|
+
##### List storage accounts in a subscription
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
azure_storage_service.storage_accounts.each do |storage_acc|
|
78
|
+
puts "#{storage_acc.name}"
|
79
|
+
puts "#{storage_acc.location}"
|
80
|
+
end
|
81
|
+
```
|
82
|
+
##### List storage accounts in a resource group
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
storage_accounts = azure_storage_service.storage_accounts(resource_group: '<Resource Group name>')
|
86
|
+
storage_accounts.each do |storage_acc|
|
87
|
+
puts "#{storage_acc.name}"
|
88
|
+
puts "#{storage_acc.location}"
|
89
|
+
end
|
90
|
+
```
|
91
|
+
|
92
|
+
## Retrieve a single Storage Account
|
93
|
+
|
94
|
+
Get a single record of Storage Account
|
95
|
+
|
96
|
+
```ruby
|
97
|
+
storage_acc = azure_storage_service
|
98
|
+
.storage_accounts(resource_group: '<Resource Group name>')
|
99
|
+
.get('<Storage Account name>')
|
100
|
+
puts "#{storage_acc.name}"
|
101
|
+
```
|
102
|
+
|
103
|
+
## Get Access Keys
|
104
|
+
|
105
|
+
Get access keys of a storage account
|
106
|
+
|
107
|
+
```ruby
|
108
|
+
keys_hash = storage_acc.get_access_keys
|
109
|
+
puts "#{keys_hash['key1']} #{keys_hash['key2']}"
|
110
|
+
```
|
111
|
+
|
112
|
+
## Destroy a single Storage Account
|
113
|
+
|
114
|
+
Get storage account object from the get method and then destroy that storage account.
|
115
|
+
|
116
|
+
```ruby
|
117
|
+
storage_acc.destroy
|
118
|
+
```
|
119
|
+
|
120
|
+
## Delete a Disk
|
121
|
+
|
122
|
+
Delete a Disk from a storage account. Disk must be in unlocked state i.e detached from server(virtual machine) to successfully perform this action.
|
123
|
+
|
124
|
+
```ruby
|
125
|
+
azure_storage_service.delete_disk('<Resource Group name>', '<Storage Account name>', '<Data Disk Name>')
|
126
|
+
```
|
127
|
+
|
128
|
+
## Create a storage container
|
129
|
+
|
130
|
+
Create a storage container in the current storage account.
|
131
|
+
|
132
|
+
```ruby
|
133
|
+
container = azure_storage_service.create_container(
|
134
|
+
name: '<container name>'
|
135
|
+
)
|
136
|
+
puts "#{container.name}"
|
137
|
+
```
|
138
|
+
|
139
|
+
## List storage containers
|
140
|
+
|
141
|
+
List all the storage containers in the current storage accounts.
|
142
|
+
|
143
|
+
```ruby
|
144
|
+
azure_storage_service.containers.each do |container|
|
145
|
+
puts "#{container.name}"
|
146
|
+
end
|
147
|
+
```
|
148
|
+
|
149
|
+
## Get storage container properties
|
150
|
+
|
151
|
+
Get the storage container properties. The properties will not fetch the access control list. Call `get_container_access_control_list` to fetch it.
|
152
|
+
|
153
|
+
```ruby
|
154
|
+
container = azure_storage_service.containers.get('<container name>')
|
155
|
+
properties = container.get_properties
|
156
|
+
puts "#{properties.inspect}"
|
157
|
+
```
|
158
|
+
|
159
|
+
## Get the access control list of the storage container
|
160
|
+
|
161
|
+
Get the permissions for the specified container. The permissions indicate whether container data may be accessed publicly.
|
162
|
+
|
163
|
+
```ruby
|
164
|
+
container = azure_storage_service.containers.get('<container name>')
|
165
|
+
access_control_list = container.get_access_control_list('<container name>')
|
166
|
+
puts "#{access_control_list.inspect}"
|
167
|
+
```
|
168
|
+
|
169
|
+
## Delete the storage container
|
170
|
+
|
171
|
+
Mark the specified container for deletion. The container and any blobs contained within it are later deleted during garbage collection.
|
172
|
+
|
173
|
+
```ruby
|
174
|
+
container = azure_storage_service.containers.get('<container name>')
|
175
|
+
result = container.destroy
|
176
|
+
puts "#{result}"
|
177
|
+
```
|
178
|
+
|
179
|
+
### Metadata
|
180
|
+
|
181
|
+
Metadata allows us to provide descriptive information about specific containers or blobs. This is simply providing name/value pairs of data we want to set on the container or blob.
|
182
|
+
|
183
|
+
## Get Blob Metadata
|
184
|
+
|
185
|
+
```ruby
|
186
|
+
azure_storage_service.blobs.get_blob_metadata('<Container name>', '<Blob name>')
|
187
|
+
```
|
188
|
+
|
189
|
+
## Set Blob Metadata
|
190
|
+
|
191
|
+
```ruby
|
192
|
+
metadata = {
|
193
|
+
"Category" => "Images",
|
194
|
+
"Resolution" => "High"
|
195
|
+
}
|
196
|
+
azure_storage_service.blobs.set_blob_metadata('<Container name>', '<Blob name>', metadata)
|
197
|
+
```
|
198
|
+
|
199
|
+
## Get Container Metadata
|
200
|
+
|
201
|
+
```ruby
|
202
|
+
azure_storage_service.containers.get_container_metadata('<Container name>')
|
203
|
+
```
|
204
|
+
|
205
|
+
## Set Container Metadata
|
206
|
+
|
207
|
+
```ruby
|
208
|
+
metadata = {
|
209
|
+
"CreatedBy" => "User",
|
210
|
+
"SourceMachine" => "Mymachine",
|
211
|
+
"category" => "guidance",
|
212
|
+
"docType" => "textDocuments"
|
213
|
+
}
|
214
|
+
azure_storage_service.containers.set_container_metadata('<Container name>', metadata)
|
215
|
+
```
|
216
|
+
|
217
|
+
## Support and Feedback
|
218
|
+
Your feedback is appreciated! If you have specific issues with the fog ARM, you should file an issue via Github.
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# Fog
|
2
|
+
Whether you need compute, dns, storage, or a multitude of other services, fog provides an accessible entry point and facilitates cross service compatibility. Fog delivers the knowledge of cloud experts to you, helping you to bootstrap your cloud usage and guiding you as your own expertise develops.
|
3
|
+
|
4
|
+
By coding with fog from the start you avoid vendor lock-in and give yourself more flexibility to provide value. Whether you are writing a library, designing a software as a service product or just hacking on the weekend this flexibility is a huge boon.
|
5
|
+
|
6
|
+
# Structure
|
7
|
+
fog is the Ruby cloud computing library, top to bottom:
|
8
|
+
|
9
|
+
- Collections provide a simplified interface, making clouds easier to work with and switch between.
|
10
|
+
- Requests allow power users to get the most out of the features of each individual cloud.
|
11
|
+
- Mocks make testing and integrating a breeze.
|
12
|
+
|
13
|
+
#### Collections
|
14
|
+
Some collections are available across multiple providers:
|
15
|
+
- dns providers have `zones` and `records`
|
16
|
+
- compute providers have `images` and `servers`
|
17
|
+
|
18
|
+
Collections share basic CRUD type operations, such as:
|
19
|
+
- **all** - fetch every object of that type from the provider.
|
20
|
+
- **get** - fetch a single object by it’s identity from the provider.
|
21
|
+
|
22
|
+
#### Models
|
23
|
+
Many of the collection methods return individual objects, which also provide common methods:
|
24
|
+
- **destroy** - will destroy the persisted object from the provider.
|
25
|
+
- **save** - persist the object to the provider.
|
26
|
+
|
27
|
+
#### Requests
|
28
|
+
Requests allow you to dive deeper when the models just can’t cut it. You can see a list of available requests by calling `requests` on the connection object.
|
29
|
+
|
30
|
+
#### Mocks
|
31
|
+
As you might imagine, testing code using fog can be slow and expensive, constantly turning on and shutting down instances. Mocking allows skipping this overhead by providing an in-memory representation resources as you make requests.
|
32
|
+
|
33
|
+
# Fog Provider Directory Structure
|
34
|
+
```sh
|
35
|
+
Plugin Root
|
36
|
+
|--- lib
|
37
|
+
|--- fog
|
38
|
+
|--- azurerm.rb #registers provider
|
39
|
+
|--- azurerm
|
40
|
+
|--- compute.rb #registers all models, collections and requests
|
41
|
+
|--- dns.rb #registers all models, collections and requests
|
42
|
+
|--- storage.rb #registers all models, collections and requests
|
43
|
+
|--- models #models and collections
|
44
|
+
|--- compute #models and collections for compute
|
45
|
+
|--- dns
|
46
|
+
|--- storage
|
47
|
+
|--- requests #requests - includes Real and Mock Classes
|
48
|
+
|--- compute #requests for compute
|
49
|
+
|--- dns
|
50
|
+
|--- storage
|
51
|
+
```
|
52
|
+
|
53
|
+
For more information aboute fog struture [Click Here](http://fog.io/about/structure.html)
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'fog/azurerm/models/storage/data_disk'
|
1
2
|
module Fog
|
2
3
|
module Compute
|
3
4
|
class AzureRM
|
@@ -45,8 +46,8 @@ module Fog
|
|
45
46
|
hash['data_disks'] = []
|
46
47
|
|
47
48
|
vm['properties']['storageProfile']['dataDisks'].each do |disk|
|
48
|
-
data_disk = Fog::
|
49
|
-
hash['data_disks'] << data_disk.merge_attributes(Fog::
|
49
|
+
data_disk = Fog::Storage::AzureRM::DataDisk.new
|
50
|
+
hash['data_disks'] << data_disk.merge_attributes(Fog::Storage::AzureRM::DataDisk.parse(disk))
|
50
51
|
end unless vm['properties']['storageProfile']['dataDisks'].nil?
|
51
52
|
|
52
53
|
hash['disable_password_authentication'] =
|
@@ -16,10 +16,14 @@ module Fog
|
|
16
16
|
hash['name'] = frontend_ip_configuration['name']
|
17
17
|
subnet = frontend_ip_configuration['properties']['subnet']
|
18
18
|
hash['subnet_id'] = subnet['id'] unless subnet.nil?
|
19
|
-
private_ip_address = frontend_ip_configuration['properties']['
|
19
|
+
private_ip_address = frontend_ip_configuration['properties']['private_ipaddress']
|
20
20
|
unless private_ip_address.nil?
|
21
21
|
hash['private_ipaddress'] = private_ip_address
|
22
22
|
end
|
23
|
+
private_ipallocation_method = frontend_ip_configuration['properties']['privateIPAllocationMethod']
|
24
|
+
unless private_ipallocation_method.nil?
|
25
|
+
hash['private_ipallocation_method'] = private_ipallocation_method
|
26
|
+
end
|
23
27
|
public_ip_address = frontend_ip_configuration['properties']['publicIPAddress']
|
24
28
|
unless public_ip_address.nil?
|
25
29
|
hash['public_ip_address_id'] = public_ip_address['id']
|