fog-azure-rm 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/README.md +2 -1
- data/fog-azure-rm.gemspec +11 -9
- data/lib/fog/azurerm.rb +1 -0
- data/lib/fog/azurerm/compute.rb +3 -3
- data/lib/fog/azurerm/config.rb +33 -0
- data/lib/fog/azurerm/credentials.rb +1 -1
- data/lib/fog/azurerm/dns.rb +2 -2
- data/lib/fog/azurerm/docs/storage.md +120 -66
- data/lib/fog/azurerm/models/application_gateway/gateway.rb +30 -31
- data/lib/fog/azurerm/models/application_gateway/gateways.rb +4 -4
- data/lib/fog/azurerm/models/compute/availability_sets.rb +4 -4
- data/lib/fog/azurerm/models/compute/server.rb +14 -14
- data/lib/fog/azurerm/models/compute/servers.rb +4 -4
- data/lib/fog/azurerm/models/compute/virtual_machine_extension.rb +3 -5
- data/lib/fog/azurerm/models/compute/virtual_machine_extensions.rb +5 -5
- data/lib/fog/azurerm/models/dns/record_sets.rb +4 -4
- data/lib/fog/azurerm/models/dns/zones.rb +4 -4
- data/lib/fog/azurerm/models/network/express_route_circuit.rb +2 -5
- data/lib/fog/azurerm/models/network/express_route_circuit_authorization.rb +1 -1
- data/lib/fog/azurerm/models/network/express_route_circuit_authorizations.rb +4 -4
- data/lib/fog/azurerm/models/network/express_route_circuit_peering.rb +3 -5
- data/lib/fog/azurerm/models/network/express_route_circuit_peerings.rb +4 -4
- data/lib/fog/azurerm/models/network/express_route_circuits.rb +4 -4
- data/lib/fog/azurerm/models/network/express_route_service_providers.rb +2 -2
- data/lib/fog/azurerm/models/network/load_balancers.rb +5 -5
- data/lib/fog/azurerm/models/network/local_network_gateway.rb +1 -1
- data/lib/fog/azurerm/models/network/local_network_gateways.rb +4 -4
- data/lib/fog/azurerm/models/network/network_interfaces.rb +5 -5
- data/lib/fog/azurerm/models/network/network_security_groups.rb +5 -5
- data/lib/fog/azurerm/models/network/network_security_rule.rb +3 -4
- data/lib/fog/azurerm/models/network/network_security_rules.rb +4 -4
- data/lib/fog/azurerm/models/network/public_ips.rb +4 -4
- data/lib/fog/azurerm/models/network/subnets.rb +4 -4
- data/lib/fog/azurerm/models/network/virtual_network_gateway.rb +6 -7
- data/lib/fog/azurerm/models/network/virtual_network_gateway_connection.rb +5 -5
- data/lib/fog/azurerm/models/network/virtual_network_gateway_connections.rb +4 -4
- data/lib/fog/azurerm/models/network/virtual_network_gateways.rb +4 -4
- data/lib/fog/azurerm/models/network/virtual_networks.rb +4 -4
- data/lib/fog/azurerm/models/resources/azure_resources.rb +2 -2
- data/lib/fog/azurerm/models/resources/deployments.rb +4 -4
- data/lib/fog/azurerm/models/resources/resource_groups.rb +4 -4
- data/lib/fog/azurerm/models/sql/firewall_rule.rb +1 -1
- data/lib/fog/azurerm/models/sql/firewall_rules.rb +4 -4
- data/lib/fog/azurerm/models/sql/sql_database.rb +28 -24
- data/lib/fog/azurerm/models/sql/sql_databases.rb +5 -6
- data/lib/fog/azurerm/models/sql/sql_servers.rb +4 -4
- data/lib/fog/azurerm/models/storage/directories.rb +49 -24
- data/lib/fog/azurerm/models/storage/directory.rb +126 -40
- data/lib/fog/azurerm/models/storage/file.rb +226 -114
- data/lib/fog/azurerm/models/storage/files.rb +168 -13
- data/lib/fog/azurerm/models/storage/recovery_vault.rb +1 -1
- data/lib/fog/azurerm/models/storage/recovery_vaults.rb +4 -4
- data/lib/fog/azurerm/models/storage/storage_account.rb +5 -5
- data/lib/fog/azurerm/models/storage/storage_accounts.rb +4 -4
- data/lib/fog/azurerm/models/traffic_manager/traffic_manager_end_point.rb +1 -1
- data/lib/fog/azurerm/models/traffic_manager/traffic_manager_end_points.rb +4 -4
- data/lib/fog/azurerm/models/traffic_manager/traffic_manager_profile.rb +4 -4
- data/lib/fog/azurerm/models/traffic_manager/traffic_manager_profiles.rb +4 -4
- data/lib/fog/azurerm/network.rb +1 -1
- data/lib/fog/azurerm/requests/compute/create_virtual_machine.rb +17 -13
- data/lib/fog/azurerm/requests/network/list_virtual_networks.rb +1 -1
- data/lib/fog/azurerm/requests/resources/create_deployment.rb +1 -1
- data/lib/fog/azurerm/requests/resources/create_resource_group.rb +1 -1
- data/lib/fog/azurerm/requests/resources/delete_deployment.rb +1 -1
- data/lib/fog/azurerm/requests/resources/delete_resource_group.rb +1 -1
- data/lib/fog/azurerm/requests/resources/get_deployment.rb +1 -1
- data/lib/fog/azurerm/requests/resources/get_resource_group.rb +1 -1
- data/lib/fog/azurerm/requests/resources/list_deployments.rb +1 -1
- data/lib/fog/azurerm/requests/resources/list_resource_groups.rb +1 -1
- data/lib/fog/azurerm/requests/resources/list_tagged_resources.rb +1 -1
- data/lib/fog/azurerm/requests/resources/tag_resource.rb +1 -1
- data/lib/fog/azurerm/requests/sql/create_or_update_database.rb +3 -3
- data/lib/fog/azurerm/requests/sql/create_or_update_firewall_rule.rb +3 -3
- data/lib/fog/azurerm/requests/sql/create_or_update_sql_server.rb +3 -3
- data/lib/fog/azurerm/requests/sql/delete_database.rb +2 -2
- data/lib/fog/azurerm/requests/sql/delete_firewall_rule.rb +4 -4
- data/lib/fog/azurerm/requests/sql/delete_sql_server.rb +4 -4
- data/lib/fog/azurerm/requests/sql/get_database.rb +3 -3
- data/lib/fog/azurerm/requests/sql/get_firewall_rule.rb +3 -3
- data/lib/fog/azurerm/requests/sql/get_sql_server.rb +3 -3
- data/lib/fog/azurerm/requests/sql/list_databases.rb +3 -3
- data/lib/fog/azurerm/requests/sql/list_firewall_rules.rb +3 -3
- data/lib/fog/azurerm/requests/sql/list_sql_servers.rb +3 -3
- data/lib/fog/azurerm/requests/storage/acquire_blob_lease.rb +5 -2
- data/lib/fog/azurerm/requests/storage/acquire_container_lease.rb +5 -2
- data/lib/fog/azurerm/requests/storage/commit_blob_blocks.rb +30 -0
- data/lib/fog/azurerm/requests/storage/compare_container_blobs.rb +148 -0
- data/lib/fog/azurerm/requests/storage/copy_blob.rb +8 -8
- data/lib/fog/azurerm/requests/storage/copy_blob_from_uri.rb +8 -8
- data/lib/fog/azurerm/requests/storage/create_block_blob.rb +108 -0
- data/lib/fog/azurerm/requests/storage/create_container.rb +12 -10
- data/lib/fog/azurerm/requests/storage/create_disk.rb +45 -19
- data/lib/fog/azurerm/requests/storage/create_or_update_recovery_vault.rb +2 -2
- data/lib/fog/azurerm/requests/storage/create_page_blob.rb +31 -0
- data/lib/fog/azurerm/requests/storage/create_storage_account.rb +2 -2
- data/lib/fog/azurerm/requests/storage/delete_blob.rb +10 -5
- data/lib/fog/azurerm/requests/storage/delete_container.rb +6 -2
- data/lib/fog/azurerm/requests/storage/delete_disk.rb +19 -16
- data/lib/fog/azurerm/requests/storage/get_all_backup_jobs.rb +2 -2
- data/lib/fog/azurerm/requests/storage/get_backup_container.rb +2 -2
- data/lib/fog/azurerm/requests/storage/get_backup_item.rb +2 -2
- data/lib/fog/azurerm/requests/storage/get_backup_job_for_vm.rb +1 -1
- data/lib/fog/azurerm/requests/storage/get_backup_protection_policy.rb +2 -2
- data/lib/fog/azurerm/requests/storage/get_blob.rb +163 -0
- data/lib/fog/azurerm/requests/storage/get_blob_http_url.rb +39 -0
- data/lib/fog/azurerm/requests/storage/get_blob_https_url.rb +39 -0
- data/lib/fog/azurerm/requests/storage/get_blob_properties.rb +37 -35
- data/lib/fog/azurerm/requests/storage/get_blob_url.rb +28 -0
- data/lib/fog/azurerm/requests/storage/get_container_acl.rb +30 -0
- data/lib/fog/azurerm/requests/storage/get_container_properties.rb +16 -12
- data/lib/fog/azurerm/requests/storage/get_container_url.rb +34 -0
- data/lib/fog/azurerm/requests/storage/get_recovery_vault.rb +2 -2
- data/lib/fog/azurerm/requests/storage/get_storage_access_keys.rb +4 -3
- data/lib/fog/azurerm/requests/storage/get_storage_account.rb +2 -2
- data/lib/fog/azurerm/requests/storage/list_blobs.rb +110 -24
- data/lib/fog/azurerm/requests/storage/list_containers.rb +46 -23
- data/lib/fog/azurerm/requests/storage/list_recovery_vaults.rb +2 -2
- data/lib/fog/azurerm/requests/storage/list_storage_account_for_rg.rb +2 -2
- data/lib/fog/azurerm/requests/storage/list_storage_accounts.rb +2 -2
- data/lib/fog/azurerm/requests/storage/multipart_save_block_blob.rb +110 -0
- data/lib/fog/azurerm/requests/storage/put_blob_block.rb +30 -0
- data/lib/fog/azurerm/requests/storage/{set_blob_metadata.rb → put_blob_metadata.rb} +7 -3
- data/lib/fog/azurerm/requests/storage/put_blob_pages.rb +30 -0
- data/lib/fog/azurerm/requests/storage/put_blob_properties.rb +31 -0
- data/lib/fog/azurerm/requests/storage/put_container_acl.rb +31 -0
- data/lib/fog/azurerm/requests/storage/{set_container_metadata.rb → put_container_metadata.rb} +7 -3
- data/lib/fog/azurerm/requests/storage/release_blob_lease.rb +4 -1
- data/lib/fog/azurerm/requests/storage/release_container_lease.rb +4 -1
- data/lib/fog/azurerm/requests/storage/save_page_blob.rb +111 -0
- data/lib/fog/azurerm/requests/storage/start_backup.rb +1 -1
- data/lib/fog/azurerm/requests/storage/wait_blob_copy_operation_to_finish.rb +56 -0
- data/lib/fog/azurerm/resources.rb +2 -2
- data/lib/fog/azurerm/storage.rb +33 -19
- data/lib/fog/azurerm/traffic_manager.rb +1 -1
- data/lib/fog/azurerm/utilities/general.rb +70 -3
- data/lib/fog/azurerm/version.rb +1 -1
- data/rake-script.sh +5 -2
- data/test/api_stub/models/application_gateway/gateway.rb +1 -1
- data/test/api_stub/models/compute/server.rb +1 -1
- data/test/api_stub/models/dns/record_set.rb +2 -2
- data/test/api_stub/models/dns/zone.rb +1 -1
- data/test/api_stub/models/network/express_route_circuit.rb +1 -1
- data/test/api_stub/models/network/express_route_circuit_authorization.rb +1 -1
- data/test/api_stub/models/network/express_route_circuit_peering.rb +1 -1
- data/test/api_stub/models/network/express_route_service_provider.rb +1 -1
- data/test/api_stub/models/network/load_balancer.rb +1 -1
- data/test/api_stub/models/network/network_interface.rb +1 -1
- data/test/api_stub/models/network/network_security_group.rb +1 -1
- data/test/api_stub/models/network/network_security_rule.rb +1 -1
- data/test/api_stub/models/network/public_ip.rb +1 -1
- data/test/api_stub/models/network/subnet.rb +1 -1
- data/test/api_stub/models/network/virtual_network.rb +1 -1
- data/test/api_stub/models/network/virtual_network_gateway.rb +1 -1
- data/test/api_stub/models/network/virtual_network_gateway_connection.rb +1 -1
- data/test/api_stub/models/resources/resource.rb +2 -2
- data/test/api_stub/models/resources/resource_group.rb +1 -1
- data/test/api_stub/models/storage/directory.rb +148 -62
- data/test/api_stub/models/storage/file.rb +122 -119
- data/test/api_stub/models/traffic_manager/traffic_manager_end_point.rb +1 -1
- data/test/api_stub/models/traffic_manager/traffic_manager_profile.rb +1 -1
- data/test/api_stub/requests/application_gateway/gateway.rb +2 -2
- data/test/api_stub/requests/compute/availability_set.rb +3 -3
- data/test/api_stub/requests/compute/virtual_machine.rb +9 -9
- data/test/api_stub/requests/dns/record_set.rb +3 -3
- data/test/api_stub/requests/dns/zone.rb +18 -18
- data/test/api_stub/requests/network/express_route_circuit.rb +2 -2
- data/test/api_stub/requests/network/express_route_circuit_authorization.rb +1 -1
- data/test/api_stub/requests/network/express_route_circuit_peering.rb +2 -2
- data/test/api_stub/requests/network/express_route_service_provider.rb +1 -1
- data/test/api_stub/requests/network/load_balancer.rb +2 -2
- data/test/api_stub/requests/network/network_interface.rb +4 -4
- data/test/api_stub/requests/network/network_security_group.rb +3 -3
- data/test/api_stub/requests/network/network_security_rule.rb +2 -2
- data/test/api_stub/requests/network/public_ip.rb +2 -2
- data/test/api_stub/requests/network/subnet.rb +2 -2
- data/test/api_stub/requests/network/virtual_network.rb +2 -2
- data/test/api_stub/requests/network/virtual_network_gateway.rb +2 -2
- data/test/api_stub/requests/network/virtual_network_gateway_connection.rb +3 -3
- data/test/api_stub/requests/resources/resource.rb +2 -2
- data/test/api_stub/requests/resources/resource_group.rb +2 -2
- data/test/api_stub/requests/storage/directory.rb +59 -65
- data/test/api_stub/requests/storage/file.rb +183 -113
- data/test/api_stub/requests/storage/storageaccount.rb +1 -1
- data/test/api_stub/requests/traffic_manager/traffic_manager_endpoint.rb +1 -1
- data/test/api_stub/requests/traffic_manager/traffic_manager_profile.rb +2 -2
- data/test/integration/Virtual_network_gateway_connection.rb +189 -182
- data/test/integration/application_gateway.rb +208 -183
- data/test/integration/availability_set.rb +44 -27
- data/test/integration/blob.rb +293 -169
- data/test/integration/container.rb +93 -42
- data/test/integration/data_disk.rb +57 -46
- data/test/integration/deployment.rb +40 -32
- data/test/integration/express_route_circuit.rb +86 -82
- data/test/integration/external_load_balancer.rb +108 -100
- data/test/integration/internal_load_balancer.rb +115 -106
- data/test/integration/local_network_gateway.rb +46 -39
- data/test/integration/network_interface.rb +119 -107
- data/test/integration/network_security_group.rb +86 -74
- data/test/integration/network_security_rule.rb +65 -57
- data/test/integration/public_ip.rb +50 -42
- data/test/integration/record_set.rb +90 -78
- data/test/integration/resource_group.rb +26 -14
- data/test/integration/resource_tag.rb +56 -45
- data/test/integration/server.rb +152 -135
- data/test/integration/server_custom_image.rb +85 -76
- data/test/integration/sql_server.rb +130 -117
- data/test/integration/storage_account.rb +82 -70
- data/test/integration/subnet.rb +87 -74
- data/test/integration/traffic_manager.rb +86 -74
- data/test/integration/virtual_machine_extension.rb +115 -106
- data/test/integration/virtual_network.rb +121 -100
- data/test/integration/virtual_network_gateway.rb +86 -79
- data/test/integration/virtual_network_gateway_connection_to_express_route.rb +94 -87
- data/test/integration/zone.rb +36 -28
- data/test/models/storage/test_directories.rb +26 -71
- data/test/models/storage/test_directory.rb +111 -58
- data/test/models/storage/test_file.rb +179 -143
- data/test/models/storage/test_files.rb +197 -30
- data/test/models/storage/test_storage_account.rb +1 -1
- data/test/requests/compute/test_attach_data_disk_to_vm.rb +15 -17
- data/test/requests/storage/test_acquire_blob_lease.rb +23 -4
- data/test/requests/storage/test_acquire_container_lease.rb +24 -5
- data/test/requests/storage/test_commit_blob_blocks.rb +34 -0
- data/test/requests/storage/test_compare_container_blobs.rb +36 -0
- data/test/requests/storage/test_copy_blob.rb +22 -3
- data/test/requests/storage/test_copy_blob_from_uri.rb +23 -4
- data/test/requests/storage/test_create_block_blob.rb +80 -0
- data/test/requests/storage/test_create_container.rb +18 -13
- data/test/requests/storage/test_create_disk.rb +57 -4
- data/test/requests/storage/test_create_page_blob.rb +34 -0
- data/test/requests/storage/test_delete_blob.rb +25 -5
- data/test/requests/storage/test_delete_container.rb +21 -9
- data/test/requests/storage/test_delete_disk.rb +14 -7
- data/test/requests/storage/test_get_blob.rb +141 -0
- data/test/requests/storage/test_get_blob_http_url.rb +30 -0
- data/test/requests/storage/test_get_blob_https_url.rb +30 -0
- data/test/requests/storage/test_get_blob_properties.rb +29 -7
- data/test/requests/storage/test_get_blob_url.rb +33 -0
- data/test/requests/storage/test_get_container_acl.rb +37 -0
- data/test/requests/storage/test_get_container_properties.rb +25 -11
- data/test/requests/storage/test_get_container_url.rb +33 -0
- data/test/requests/storage/test_list_blobs.rb +77 -0
- data/test/requests/storage/test_list_containers.rb +38 -7
- data/test/requests/storage/test_multipart_save_block_blob.rb +105 -0
- data/test/requests/storage/test_put_blob_block.rb +34 -0
- data/test/requests/storage/test_put_blob_metadata.rb +36 -0
- data/test/requests/storage/test_put_blob_pages.rb +34 -0
- data/test/requests/storage/test_put_blob_properties.rb +39 -0
- data/test/requests/storage/test_put_container_acl.rb +34 -0
- data/test/requests/storage/test_put_container_metadata.rb +36 -0
- data/test/requests/storage/test_release_blob_lease.rb +20 -2
- data/test/requests/storage/test_release_container_lease.rb +21 -3
- data/test/requests/storage/test_save_page_blob.rb +115 -0
- data/test/requests/storage/test_wait_blob_copy_operation_to_finish.rb +148 -0
- data/test/test_helper.rb +34 -21
- metadata +92 -46
- data/lib/fog/azurerm/requests/storage/check_blob_exist.rb +0 -25
- data/lib/fog/azurerm/requests/storage/compare_blob.rb +0 -73
- data/lib/fog/azurerm/requests/storage/download_blob_to_file.rb +0 -56
- data/lib/fog/azurerm/requests/storage/get_blob_metadata.rb +0 -59
- data/lib/fog/azurerm/requests/storage/get_container_access_control_list.rb +0 -30
- data/lib/fog/azurerm/requests/storage/get_container_metadata.rb +0 -32
- data/lib/fog/azurerm/requests/storage/set_blob_properties.rb +0 -26
- data/lib/fog/azurerm/requests/storage/upload_block_blob_from_file.rb +0 -60
- data/test/requests/storage/test_check_blob_exist.rb +0 -17
- data/test/requests/storage/test_compare_blob.rb +0 -17
- data/test/requests/storage/test_download_blob_to_file.rb +0 -25
- data/test/requests/storage/test_get_blob_metadata.rb +0 -18
- data/test/requests/storage/test_get_container_access_control_list.rb +0 -31
- data/test/requests/storage/test_get_container_metadata.rb +0 -18
- data/test/requests/storage/test_list_blobs_in_container.rb +0 -23
- data/test/requests/storage/test_set_blob_metadata.rb +0 -17
- data/test/requests/storage/test_set_blob_properties.rb +0 -16
- data/test/requests/storage/test_set_container_metadata.rb +0 -17
- data/test/requests/storage/test_upload_block_blob_from_file.rb +0 -23
@@ -0,0 +1,108 @@
|
|
1
|
+
module Fog
|
2
|
+
module Storage
|
3
|
+
class AzureRM
|
4
|
+
# This class provides the actual implementation for service calls.
|
5
|
+
class Real
|
6
|
+
def create_block_blob(container_name, blob_name, body, options = {})
|
7
|
+
options[:request_id] = SecureRandom.uuid
|
8
|
+
msg = "create_block_blob #{blob_name} to the container #{container_name}. options: #{options}"
|
9
|
+
Fog::Logger.debug msg
|
10
|
+
|
11
|
+
begin
|
12
|
+
if body.nil?
|
13
|
+
data = nil
|
14
|
+
elsif body.respond_to?(:read)
|
15
|
+
if body.respond_to?(:rewind)
|
16
|
+
begin
|
17
|
+
body.rewind
|
18
|
+
rescue
|
19
|
+
nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
data = body.read
|
23
|
+
else
|
24
|
+
data = Fog::Storage.parse_data(body)
|
25
|
+
options[:content_length] = data[:headers]['Content-Length']
|
26
|
+
options[:content_type] = data[:headers]['Content-Type']
|
27
|
+
data = data[:body]
|
28
|
+
end
|
29
|
+
|
30
|
+
raise ArgumentError.new('The maximum size for a block blob created via create_block_blob is 64 MB.') if !data.nil? && Fog::Storage.get_body_size(data) > 64 * 1024 * 1024
|
31
|
+
blob = @blob_client.create_block_blob(container_name, blob_name, data, options)
|
32
|
+
rescue Azure::Core::Http::HTTPError => ex
|
33
|
+
raise_azure_exception(ex, msg)
|
34
|
+
end
|
35
|
+
|
36
|
+
if data.nil?
|
37
|
+
Fog::Logger.debug "Create a block blob #{blob_name} successfully."
|
38
|
+
else
|
39
|
+
Fog::Logger.debug "Upload a block blob #{blob_name} successfully."
|
40
|
+
end
|
41
|
+
blob
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# This class provides the mock implementation for unit tests.
|
46
|
+
class Mock
|
47
|
+
def create_block_blob(_container_name, _blob_name, body, _options = {})
|
48
|
+
Fog::Logger.debug 'Blob created successfully.'
|
49
|
+
if body.nil?
|
50
|
+
{
|
51
|
+
'name' => 'test_blob',
|
52
|
+
'metadata' => {},
|
53
|
+
'properties' => {
|
54
|
+
'last_modified' => 'Mon, 04 Jul 2016 02:50:20 GMT',
|
55
|
+
'etag' => '0x8D3A3B5F017F52D',
|
56
|
+
'lease_status' => nil,
|
57
|
+
'lease_state' => nil,
|
58
|
+
'content_length' => 0,
|
59
|
+
'content_type' => 'application/octet-stream',
|
60
|
+
'content_encoding' => nil,
|
61
|
+
'content_language' => nil,
|
62
|
+
'content_disposition' => nil,
|
63
|
+
'content_md5' => nil,
|
64
|
+
'cache_control' => nil,
|
65
|
+
'sequence_number' => 0,
|
66
|
+
'blob_type' => 'BlockBlob',
|
67
|
+
'copy_id' => nil,
|
68
|
+
'copy_status' => nil,
|
69
|
+
'copy_source' => nil,
|
70
|
+
'copy_progress' => nil,
|
71
|
+
'copy_completion_time' => nil,
|
72
|
+
'copy_status_description' => nil,
|
73
|
+
'accept_ranges' => 0
|
74
|
+
}
|
75
|
+
}
|
76
|
+
else
|
77
|
+
{
|
78
|
+
'name' => 'test_blob',
|
79
|
+
'metadata' => {},
|
80
|
+
'properties' => {
|
81
|
+
'last_modified' => 'Mon, 04 Jul 2016 02:50:20 GMT',
|
82
|
+
'etag' => '0x8D3A3B5F017F52D',
|
83
|
+
'lease_status' => 'unlocked',
|
84
|
+
'lease_state' => 'available',
|
85
|
+
'content_length' => 4_194_304,
|
86
|
+
'content_type' => 'application/octet-stream',
|
87
|
+
'content_encoding' => nil,
|
88
|
+
'content_language' => nil,
|
89
|
+
'content_disposition' => nil,
|
90
|
+
'content_md5' => 'tXAohIyxuu/t94Lp/ujeRw==',
|
91
|
+
'cache_control' => nil,
|
92
|
+
'sequence_number' => 0,
|
93
|
+
'blob_type' => 'BlockBlob',
|
94
|
+
'copy_id' => '095adc3b-e277-4c3d-97e0-0abca881f60c',
|
95
|
+
'copy_status' => 'success',
|
96
|
+
'copy_source' => 'https://testaccount.blob.core.windows.net/test_container/test_blob?snapshot=2016-02-04T08%3A35%3A50.3256874Z',
|
97
|
+
'copy_progress' => '4194304/4194304',
|
98
|
+
'copy_completion_time' => 'Thu, 04 Feb 2016 08:35:52 GMT',
|
99
|
+
'copy_status_description' => nil,
|
100
|
+
'accept_ranges' => 0
|
101
|
+
}
|
102
|
+
}
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -4,13 +4,16 @@ module Fog
|
|
4
4
|
# This class provides the actual implementation for service calls.
|
5
5
|
class Real
|
6
6
|
def create_container(name, options = {})
|
7
|
-
|
7
|
+
options[:request_id] = SecureRandom.uuid
|
8
|
+
msg = "Creating container: #{name}. options: #{options}"
|
8
9
|
Fog::Logger.debug msg
|
10
|
+
|
9
11
|
begin
|
10
12
|
container = @blob_client.create_container(name, options)
|
11
13
|
rescue Azure::Core::Http::HTTPError => ex
|
12
14
|
raise_azure_exception(ex, msg)
|
13
15
|
end
|
16
|
+
|
14
17
|
Fog::Logger.debug "Container #{name} created successfully."
|
15
18
|
container
|
16
19
|
end
|
@@ -20,16 +23,15 @@ module Fog
|
|
20
23
|
class Mock
|
21
24
|
def create_container(*)
|
22
25
|
{
|
23
|
-
'name' => '
|
24
|
-
'properties' =>
|
25
|
-
{
|
26
|
-
'last_modified' => 'Mon, 04 Jul 2016 02:50:20 GMT',
|
27
|
-
'etag' => '0x8D3A3B5F017F52D',
|
28
|
-
'lease_status' => 'unlocked',
|
29
|
-
'lease_state' => 'available'
|
30
|
-
},
|
26
|
+
'name' => 'test_container',
|
31
27
|
'public_access_level' => nil,
|
32
|
-
'metadata' => {}
|
28
|
+
'metadata' => {},
|
29
|
+
'properties' => {
|
30
|
+
'last_modified' => 'Mon, 04 Jul 2016 02:50:20 GMT',
|
31
|
+
'etag' => '0x8D3A3B5F017F52D',
|
32
|
+
'lease_status' => 'unlocked',
|
33
|
+
'lease_state' => 'available'
|
34
|
+
}
|
33
35
|
}
|
34
36
|
end
|
35
37
|
end
|
@@ -1,34 +1,60 @@
|
|
1
1
|
module Fog
|
2
2
|
module Storage
|
3
3
|
class AzureRM
|
4
|
-
# This class provides the actual
|
4
|
+
# This class provides the actual implementation for service calls.
|
5
5
|
class Real
|
6
|
-
|
7
|
-
|
6
|
+
# Create a disk in Azure storage.
|
7
|
+
#
|
8
|
+
# @param disk_name [String] Name of disk
|
9
|
+
# @param disk_size_in_gb [Integer] Disk size in GiB. Value range: [1, 1023]
|
10
|
+
# @param options [Hash]
|
11
|
+
# @option options [String] container_name Sets name of the container which contains the disk. Default is 'vhds'.
|
12
|
+
#
|
13
|
+
# @return [Boolean]
|
14
|
+
#
|
15
|
+
def create_disk(disk_name, disk_size_in_gb, options = {})
|
16
|
+
msg = "Creating disk(#{disk_name}, #{disk_size_in_gb}). options: #{options}"
|
8
17
|
Fog::Logger.debug msg
|
9
|
-
|
10
|
-
|
18
|
+
|
19
|
+
raise ArgumentError, "disk_size_in_gb #{disk_size_in_gb} must be an integer" unless disk_size_in_gb.is_a?(Integer)
|
20
|
+
raise ArgumentError, "Azure minimum disk size is 1 GiB: #{disk_size_in_gb}" if disk_size_in_gb < 1
|
21
|
+
raise ArgumentError, "Azure maximum disk size is 1023 GiB: #{disk_size_in_gb}" if disk_size_in_gb > 1023
|
22
|
+
|
23
|
+
container_name = options.delete(:container_name)
|
24
|
+
container_name = 'vhds' if container_name.nil?
|
25
|
+
blob_name = "#{disk_name}.vhd"
|
26
|
+
vhd_size = disk_size_in_gb * 1024 * 1024 * 1024
|
27
|
+
blob_size = vhd_size + 512
|
28
|
+
|
29
|
+
opts = {
|
30
|
+
type: :fixed,
|
31
|
+
name: '/tmp/footer.vhd', # Only used to initialize vhd, no local file is generated.
|
32
|
+
size: disk_size_in_gb
|
33
|
+
}
|
34
|
+
vhd_footer = Vhd::Library.new(opts).footer.values.join
|
35
|
+
|
11
36
|
begin
|
12
|
-
|
13
|
-
|
14
|
-
|
37
|
+
create_page_blob(container_name, blob_name, blob_size, options)
|
38
|
+
put_blob_pages(container_name, blob_name, vhd_size, blob_size - 1, vhd_footer, options)
|
39
|
+
rescue
|
40
|
+
begin
|
41
|
+
delete_blob(container_name, blob_name)
|
42
|
+
rescue => ex
|
43
|
+
Fog::Logger.debug "Cannot delete the blob: #{container_name}/#{blob_name} after create_disk failed. #{ex.inspect}"
|
44
|
+
end
|
45
|
+
raise
|
15
46
|
end
|
16
|
-
|
47
|
+
|
48
|
+
Fog::Logger.debug "Created a disk #{disk_name} successfully."
|
49
|
+
true
|
17
50
|
end
|
18
51
|
end
|
52
|
+
|
19
53
|
# This class provides the mock implementation for unit tests.
|
20
54
|
class Mock
|
21
55
|
def create_disk(*)
|
22
|
-
Fog::Logger.debug 'Disk
|
23
|
-
|
24
|
-
'name' => 'test_blob',
|
25
|
-
'properties' =>
|
26
|
-
{
|
27
|
-
'last_modified' => 'Thu, 28 Jul 2016 06:53:05 GMT',
|
28
|
-
'etag' => '0x8D3B6B3D353FFCA',
|
29
|
-
'content_md5' => 'tXAohIyxuu/t94Lp/ujeRw=='
|
30
|
-
}
|
31
|
-
}
|
56
|
+
Fog::Logger.debug 'Disk created successfully.'
|
57
|
+
true
|
32
58
|
end
|
33
59
|
end
|
34
60
|
end
|
@@ -27,7 +27,7 @@ module Fog
|
|
27
27
|
raise_azure_exception(e, msg)
|
28
28
|
end
|
29
29
|
Fog::Logger.debug "Recovery Vault #{name} created/updated successfully"
|
30
|
-
JSON.
|
30
|
+
Fog::JSON.decode(response)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -46,7 +46,7 @@ module Fog
|
|
46
46
|
"name": "standard"
|
47
47
|
}
|
48
48
|
}'
|
49
|
-
JSON.
|
49
|
+
Fog::JSON.decode(recovery_vault)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Fog
|
2
|
+
module Storage
|
3
|
+
class AzureRM
|
4
|
+
# This class provides the actual implementation for service calls.
|
5
|
+
class Real
|
6
|
+
def create_page_blob(container_name, blob_name, blob_size, options = {})
|
7
|
+
options[:request_id] = SecureRandom.uuid
|
8
|
+
msg = "create_page_blob #{blob_name} to the container #{container_name}. blob_size: #{blob_size}, options: #{options}"
|
9
|
+
Fog::Logger.debug msg
|
10
|
+
|
11
|
+
begin
|
12
|
+
@blob_client.create_page_blob(container_name, blob_name, blob_size, options)
|
13
|
+
rescue Azure::Core::Http::HTTPError => ex
|
14
|
+
raise_azure_exception(ex, msg)
|
15
|
+
end
|
16
|
+
|
17
|
+
Fog::Logger.debug "Page blob #{blob_name} created successfully."
|
18
|
+
true
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# This class provides the mock implementation for unit tests.
|
23
|
+
class Mock
|
24
|
+
def create_page_blob(*)
|
25
|
+
Fog::Logger.debug 'Page blob created successfully.'
|
26
|
+
true
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -14,8 +14,8 @@ module Fog
|
|
14
14
|
storage_account = @storage_mgmt_client.storage_accounts.create(storage_account_hash[:resource_group],
|
15
15
|
storage_account_hash[:name],
|
16
16
|
storage_account_params)
|
17
|
-
rescue MsRestAzure::AzureOperationError =>
|
18
|
-
raise_azure_exception(
|
17
|
+
rescue MsRestAzure::AzureOperationError => ex
|
18
|
+
raise_azure_exception(ex, msg)
|
19
19
|
end
|
20
20
|
Fog::Logger.debug 'Storage Account created successfully.'
|
21
21
|
storage_account
|
@@ -1,17 +1,22 @@
|
|
1
1
|
module Fog
|
2
2
|
module Storage
|
3
3
|
class AzureRM
|
4
|
-
# This class provides the actual
|
4
|
+
# This class provides the actual implementation for service calls.
|
5
5
|
class Real
|
6
6
|
def delete_blob(container_name, blob_name, options = {})
|
7
|
-
|
7
|
+
options[:request_id] = SecureRandom.uuid
|
8
|
+
msg = "Deleting blob: #{blob_name} in container #{container_name}. options: #{options}"
|
9
|
+
Fog::Logger.debug msg
|
10
|
+
|
8
11
|
begin
|
9
12
|
@blob_client.delete_blob(container_name, blob_name, options)
|
10
|
-
Fog::Logger.debug "Blob #{blob_name} deleted successfully."
|
11
|
-
true
|
12
13
|
rescue Azure::Core::Http::HTTPError => ex
|
13
|
-
|
14
|
+
return true if ex.message.include?('(404)')
|
15
|
+
raise_azure_exception(ex, msg)
|
14
16
|
end
|
17
|
+
|
18
|
+
Fog::Logger.debug "Blob #{blob_name} deleted successfully."
|
19
|
+
true
|
15
20
|
end
|
16
21
|
end
|
17
22
|
|
@@ -3,14 +3,18 @@ module Fog
|
|
3
3
|
class AzureRM
|
4
4
|
# This class provides the actual implementation for service calls.
|
5
5
|
class Real
|
6
|
-
def delete_container(name
|
7
|
-
|
6
|
+
def delete_container(name)
|
7
|
+
options = { request_id: SecureRandom.uuid }
|
8
|
+
msg = "Deleting container: #{name}. options: #{options}"
|
8
9
|
Fog::Logger.debug msg
|
10
|
+
|
9
11
|
begin
|
10
12
|
@blob_client.delete_container(name, options)
|
11
13
|
rescue Azure::Core::Http::HTTPError => ex
|
14
|
+
return true if ex.message.include?('(404)')
|
12
15
|
raise_azure_exception(ex, msg)
|
13
16
|
end
|
17
|
+
|
14
18
|
Fog::Logger.debug "Container #{name} deleted successfully."
|
15
19
|
true
|
16
20
|
end
|
@@ -3,28 +3,31 @@ module Fog
|
|
3
3
|
class AzureRM
|
4
4
|
# This class provides the actual implementation for service calls.
|
5
5
|
class Real
|
6
|
-
|
7
|
-
|
6
|
+
# Delete a disk in Azure storage.
|
7
|
+
#
|
8
|
+
# @param disk_name [String] Name of disk
|
9
|
+
# @param options [Hash]
|
10
|
+
# @option options [String] container_name Sets name of the container which contains the disk. Default is 'vhds'.
|
11
|
+
#
|
12
|
+
# @return [Boolean]
|
13
|
+
#
|
14
|
+
def delete_disk(disk_name, options = {})
|
15
|
+
msg = "Deleting disk(#{disk_name}). options: #{options}"
|
8
16
|
Fog::Logger.debug msg
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
true
|
17
|
-
else
|
18
|
-
Fog::Logger.debug 'Error deleting Disk.'
|
19
|
-
false
|
20
|
-
end
|
17
|
+
|
18
|
+
container_name = options.delete(:container_name)
|
19
|
+
container_name = 'vhds' if container_name.nil?
|
20
|
+
delete_blob(container_name, "#{disk_name}.vhd")
|
21
|
+
|
22
|
+
Fog::Logger.debug "Successfully deleted Disk: #{disk_name}."
|
23
|
+
true
|
21
24
|
end
|
22
25
|
end
|
26
|
+
|
23
27
|
# This class provides the mock implementation for unit tests.
|
24
28
|
class Mock
|
25
29
|
def delete_disk(*)
|
26
|
-
Fog::Logger.debug '
|
27
|
-
Fog::Logger.debug 'Successfully deleted Disk: test_blob.'
|
30
|
+
Fog::Logger.debug 'Successfully deleted Disk'
|
28
31
|
true
|
29
32
|
end
|
30
33
|
end
|
@@ -20,7 +20,7 @@ module Fog
|
|
20
20
|
raise_azure_exception(e, msg)
|
21
21
|
end
|
22
22
|
Fog::Logger.debug "Successfully retrieved backup jobs for Recovery Vault #{rv_name}"
|
23
|
-
JSON.
|
23
|
+
Fog::JSON.decode(response)['value']
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -48,7 +48,7 @@ module Fog
|
|
48
48
|
}
|
49
49
|
}]
|
50
50
|
}'
|
51
|
-
JSON.
|
51
|
+
Fog::JSON.decode(body)['value']
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
@@ -20,7 +20,7 @@ module Fog
|
|
20
20
|
raise_azure_exception(e, msg)
|
21
21
|
end
|
22
22
|
Fog::Logger.debug "Successfully retrieved backup container from Recovery Vault #{rv_name}"
|
23
|
-
JSON.
|
23
|
+
Fog::JSON.decode(response)['value']
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -45,7 +45,7 @@ module Fog
|
|
45
45
|
}
|
46
46
|
}]
|
47
47
|
}'
|
48
|
-
JSON.
|
48
|
+
Fog::JSON.decode(body)['value']
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -20,7 +20,7 @@ module Fog
|
|
20
20
|
raise_azure_exception(e, msg)
|
21
21
|
end
|
22
22
|
Fog::Logger.debug "Successfully retrieved backup item from Recovery Vault #{rv_name}"
|
23
|
-
JSON.
|
23
|
+
Fog::JSON.decode(response)['value']
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -50,7 +50,7 @@ module Fog
|
|
50
50
|
}
|
51
51
|
}]
|
52
52
|
}'
|
53
|
-
JSON.
|
53
|
+
Fog::JSON.decode(body)['value']
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|