fog-azure-rm 0.0.6 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/lib/fog/azurerm/compute.rb +6 -0
- data/lib/fog/azurerm/docs/compute.md +67 -11
- data/lib/fog/azurerm/docs/network.md +59 -0
- data/lib/fog/azurerm/docs/storage.md +107 -35
- data/lib/fog/azurerm/models/compute/server.rb +15 -9
- data/lib/fog/azurerm/models/compute/virtual_machine_extension.rb +78 -0
- data/lib/fog/azurerm/models/compute/virtual_machine_extensions.rb +30 -0
- data/lib/fog/azurerm/models/network/express_route_circuit.rb +21 -21
- data/lib/fog/azurerm/models/network/express_route_circuit_peering.rb +21 -21
- data/lib/fog/azurerm/models/network/express_route_service_provider.rb +8 -8
- data/lib/fog/azurerm/models/network/network_security_rule.rb +27 -0
- data/lib/fog/azurerm/models/network/network_security_rules.rb +31 -0
- data/lib/fog/azurerm/models/network/subnet.rb +16 -12
- data/lib/fog/azurerm/models/network/virtual_network_gateway.rb +6 -6
- data/lib/fog/azurerm/models/storage/{containers.rb → directories.rb} +10 -10
- data/lib/fog/azurerm/models/storage/{container.rb → directory.rb} +13 -13
- data/lib/fog/azurerm/models/storage/file.rb +151 -0
- data/lib/fog/azurerm/models/storage/files.rb +31 -0
- data/lib/fog/azurerm/network.rb +6 -0
- data/lib/fog/azurerm/requests/compute/create_or_update_vm_extension.rb +63 -0
- data/lib/fog/azurerm/requests/compute/create_virtual_machine.rb +45 -8
- data/lib/fog/azurerm/requests/compute/delete_vm_extension.rb +28 -0
- data/lib/fog/azurerm/requests/compute/get_vm_extension.rb +46 -0
- data/lib/fog/azurerm/requests/network/create_or_update_express_route_circuit.rb +44 -31
- data/lib/fog/azurerm/requests/network/create_or_update_express_route_circuit_peering.rb +23 -13
- data/lib/fog/azurerm/requests/network/create_or_update_network_security_rule.rb +59 -0
- data/lib/fog/azurerm/requests/network/create_or_update_virtual_network_gateway.rb +23 -15
- data/lib/fog/azurerm/requests/network/delete_network_security_rule.rb +30 -0
- data/lib/fog/azurerm/requests/network/get_available_ipaddresses_count.rb +23 -0
- data/lib/fog/azurerm/requests/network/get_network_security_rule.rb +47 -0
- data/lib/fog/azurerm/requests/network/list_network_security_groups.rb +1 -1
- data/lib/fog/azurerm/requests/network/list_network_security_rules.rb +51 -0
- data/lib/fog/azurerm/requests/storage/acquire_blob_lease.rb +29 -0
- data/lib/fog/azurerm/requests/storage/acquire_container_lease.rb +29 -0
- data/lib/fog/azurerm/requests/storage/check_blob_exist.rb +25 -0
- data/lib/fog/azurerm/requests/storage/compare_blob.rb +73 -0
- data/lib/fog/azurerm/requests/storage/copy_blob.rb +30 -0
- data/lib/fog/azurerm/requests/storage/copy_blob_from_uri.rb +30 -0
- data/lib/fog/azurerm/requests/storage/delete_blob.rb +27 -0
- data/lib/fog/azurerm/requests/storage/download_blob_to_file.rb +56 -0
- data/lib/fog/azurerm/requests/storage/get_blob_metadata.rb +37 -9
- data/lib/fog/azurerm/requests/storage/get_blob_properties.rb +53 -0
- data/lib/fog/azurerm/requests/storage/get_container_metadata.rb +2 -2
- data/lib/fog/azurerm/requests/storage/list_blobs.rb +82 -0
- data/lib/fog/azurerm/requests/storage/list_containers.rb +1 -1
- data/lib/fog/azurerm/requests/storage/release_blob_lease.rb +27 -0
- data/lib/fog/azurerm/requests/storage/release_container_lease.rb +27 -0
- data/lib/fog/azurerm/requests/storage/set_blob_metadata.rb +4 -4
- data/lib/fog/azurerm/requests/storage/set_blob_properties.rb +26 -0
- data/lib/fog/azurerm/requests/storage/set_container_metadata.rb +3 -3
- data/lib/fog/azurerm/requests/storage/upload_block_blob_from_file.rb +60 -0
- data/lib/fog/azurerm/storage.rb +26 -8
- data/lib/fog/azurerm/utilities/general.rb +14 -1
- data/lib/fog/azurerm/version.rb +1 -1
- data/test/api_stub.rb +8 -4
- data/test/api_stub/models/compute/virtual_machine_extension.rb +31 -0
- data/test/api_stub/models/network/network_security_rule.rb +30 -0
- data/test/api_stub/models/storage/{container.rb → directory.rb} +1 -1
- data/test/api_stub/models/storage/file.rb +178 -0
- data/test/api_stub/requests/compute/virtual_machine.rb +119 -0
- data/test/api_stub/requests/compute/virtual_machine_extension.rb +46 -0
- data/test/api_stub/requests/network/network_security_rule.rb +72 -0
- data/test/api_stub/requests/storage/{container.rb → directory.rb} +2 -2
- data/test/api_stub/requests/storage/file.rb +164 -0
- data/test/integration/availability_set.rb +6 -0
- data/test/integration/blob.rb +205 -0
- data/test/integration/credentials/azure.yml +4 -4
- data/test/integration/deployment.rb +9 -0
- data/test/integration/external_load_balancer.rb +9 -0
- data/test/integration/internal_load_balancer.rb +8 -0
- data/test/integration/network_security_group.rb +9 -0
- data/test/integration/network_security_rule.rb +86 -0
- data/test/integration/server.rb +62 -9
- data/test/integration/server_custom_image.rb +118 -0
- data/test/integration/subnet.rb +12 -1
- data/test/integration/virtual_machine_extension.rb +148 -0
- data/test/integration/virtual_network.rb +9 -1
- data/test/integration/virtual_network_gateway.rb +7 -29
- data/test/integration/virtual_network_gateway_connection_to_express_route.rb +116 -0
- data/test/models/compute/test_virtual_machine_extension.rb +61 -0
- data/test/models/compute/test_virtual_machine_extensions.rb +36 -0
- data/test/models/network/test_express_route_circuit.rb +4 -10
- data/test/models/network/test_express_route_circuit_peering.rb +4 -10
- data/test/models/network/test_network_interface.rb +4 -8
- data/test/models/network/test_network_security_rule.rb +14 -0
- data/test/models/network/test_network_security_rules.rb +42 -0
- data/test/models/network/test_subnet.rb +5 -0
- data/test/models/storage/test_directories.rb +106 -0
- data/test/models/storage/test_directory.rb +125 -0
- data/test/models/storage/test_file.rb +258 -0
- data/test/models/storage/test_files.rb +67 -0
- data/test/models/storage/test_storage_account.rb +2 -4
- data/test/requests/compute/test_create_virtual_machine.rb +19 -5
- data/test/requests/compute/test_create_vm_extension.rb +35 -0
- data/test/requests/compute/test_get_vm_extension.rb +26 -0
- data/test/requests/compute/test_update_vm_extension.rb +35 -0
- data/test/requests/network/test_create_or_update_network_security_rule.rb +28 -0
- data/test/requests/network/test_delete_network_security_rule.rb +25 -0
- data/test/requests/network/test_get_available_ipaddresses_count.rb +18 -0
- data/test/requests/network/test_get_network_security_rule.rb +26 -0
- data/test/requests/network/test_list_network_security_groups.rb +2 -2
- data/test/requests/network/test_list_network_security_rules.rb +26 -0
- data/test/requests/storage/test_acquire_blob_lease.rb +17 -0
- data/test/requests/storage/test_acquire_container_lease.rb +17 -0
- data/test/requests/storage/test_check_blob_exist.rb +17 -0
- data/test/requests/storage/test_compare_blob.rb +17 -0
- data/test/requests/storage/test_copy_blob.rb +17 -0
- data/test/requests/storage/test_copy_blob_from_uri.rb +17 -0
- data/test/requests/storage/test_create_container.rb +2 -2
- data/test/requests/storage/test_delete_blob.rb +22 -0
- data/test/requests/storage/test_delete_container.rb +1 -1
- data/test/requests/storage/test_download_blob_to_file.rb +25 -0
- data/test/requests/storage/test_get_blob_metadata.rb +2 -2
- data/test/requests/storage/test_get_blob_properties.rb +23 -0
- data/test/requests/storage/test_get_container_access_control_list.rb +2 -2
- data/test/requests/storage/test_get_container_metadata.rb +2 -2
- data/test/requests/storage/test_get_container_properties.rb +2 -2
- data/test/requests/storage/test_list_blobs_in_container.rb +23 -0
- data/test/requests/storage/test_list_containers.rb +2 -2
- data/test/requests/storage/test_release_blob_lease.rb +16 -0
- data/test/requests/storage/test_release_container_lease.rb +16 -0
- data/test/requests/storage/test_set_blob_metadata.rb +1 -1
- data/test/requests/storage/test_set_blob_properties.rb +16 -0
- data/test/requests/storage/test_set_container_metadata.rb +1 -1
- data/test/requests/storage/test_upload_block_blob_from_file.rb +23 -0
- data/test/test_helper.rb +116 -3
- metadata +73 -15
- data/.DS_Store +0 -0
- data/lib/fog/azurerm/fog_azure_rm_exception.rb +0 -13
- data/lib/fog/azurerm/models/storage/blob.rb +0 -13
- data/lib/fog/azurerm/models/storage/blobs.rb +0 -22
- data/test/api_stub/models/storage/blob.rb +0 -17
- data/test/api_stub/requests/storage/blob.rb +0 -24
- data/test/models/storage/test_blobs.rb +0 -32
- data/test/models/storage/test_container.rb +0 -67
- data/test/models/storage/test_containers.rb +0 -56
@@ -19,25 +19,35 @@ module Fog
|
|
19
19
|
private
|
20
20
|
|
21
21
|
def get_circuit_peering_object(circuit_peering_params)
|
22
|
-
circuit_peering =
|
23
|
-
circuit_peering.name = circuit_peering_params[:peering_name]
|
24
|
-
circuit_peering.peering_type = circuit_peering_params[:peering_type]
|
25
|
-
circuit_peering.peer_asn = circuit_peering_params[:peer_asn]
|
26
|
-
circuit_peering.primary_peer_address_prefix = circuit_peering_params[:primary_peer_address_prefix]
|
27
|
-
circuit_peering.secondary_peer_address_prefix = circuit_peering_params[:secondary_peer_address_prefix]
|
28
|
-
circuit_peering.vlan_id = circuit_peering_params[:vlan_id]
|
22
|
+
circuit_peering = create_express_route_circuit_peering(circuit_peering_params[:peering_type], circuit_peering_params[:peer_asn], circuit_peering_params[:primary_peer_address_prefix], circuit_peering_params[:secondary_peer_address_prefix], circuit_peering_params[:vlan_id], circuit_peering_params[:name])
|
29
23
|
|
30
|
-
if circuit_peering_params[:peering_type].casecmp(MICROSOFT_PEERING)
|
31
|
-
peering_config =
|
32
|
-
peering_config.advertised_public_prefixes = circuit_peering_params[:advertised_public_prefixes]
|
33
|
-
peering_config.advertised_public_prefixes_state = circuit_peering_params[:advertised_public_prefix_state]
|
34
|
-
peering_config.customer_asn = circuit_peering_params[:customer_asn]
|
35
|
-
peering_config.routing_registry_name = circuit_peering_params[:routing_registry_name]
|
24
|
+
if circuit_peering_params[:peering_type].casecmp(MICROSOFT_PEERING).zero?
|
25
|
+
peering_config = create_express_route_circuit_peering_config(circuit_peering_params[:advertised_public_prefixes], circuit_peering_params[:advertised_public_prefix_state], circuit_peering_params[:customer_asn], circuit_peering_params[:routing_registry_name])
|
36
26
|
circuit_peering.microsoft_peering_config = peering_config
|
37
27
|
end
|
38
28
|
|
39
29
|
circuit_peering
|
40
30
|
end
|
31
|
+
|
32
|
+
def create_express_route_circuit_peering(peering_type, peer_asn, primary_peer_address_prefix, secondary_peer_address_prefix, vlan_id, name)
|
33
|
+
circuit_peering = Azure::ARM::Network::Models::ExpressRouteCircuitPeering.new
|
34
|
+
circuit_peering.peering_type = peering_type
|
35
|
+
circuit_peering.peer_asn = peer_asn
|
36
|
+
circuit_peering.primary_peer_address_prefix = primary_peer_address_prefix
|
37
|
+
circuit_peering.secondary_peer_address_prefix = secondary_peer_address_prefix
|
38
|
+
circuit_peering.vlan_id = vlan_id
|
39
|
+
circuit_peering.name = name
|
40
|
+
circuit_peering
|
41
|
+
end
|
42
|
+
|
43
|
+
def create_express_route_circuit_peering_config(advertised_public_prefixes, advertised_public_prefix_state, customer_asn, routing_registry_name)
|
44
|
+
peering_config = Azure::ARM::Network::Models::ExpressRouteCircuitPeeringConfig.new
|
45
|
+
peering_config.advertised_public_prefixes = advertised_public_prefixes
|
46
|
+
peering_config.advertised_public_prefixes_state = advertised_public_prefix_state
|
47
|
+
peering_config.customer_asn = customer_asn
|
48
|
+
peering_config.routing_registry_name = routing_registry_name
|
49
|
+
peering_config
|
50
|
+
end
|
41
51
|
end
|
42
52
|
|
43
53
|
# Mock class for Network Request
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Fog
|
2
|
+
module Network
|
3
|
+
class AzureRM
|
4
|
+
# Real class for Network Request
|
5
|
+
class Real
|
6
|
+
def create_or_update_network_security_rule(security_rule)
|
7
|
+
msg = "Creating/Updating Network Security Rule #{security_rule[:name]} in Resource Group #{security_rule[:resource_group]}."
|
8
|
+
Fog::Logger.debug msg
|
9
|
+
security_rule_params = get_security_rule_params(security_rule)
|
10
|
+
begin
|
11
|
+
security_rule_obj = @network_client.security_rules.create_or_update(security_rule[:resource_group], security_rule[:network_security_group_name], security_rule[:name], security_rule_params)
|
12
|
+
rescue MsRestAzure::AzureOperationError => e
|
13
|
+
raise_azure_exception(e, msg)
|
14
|
+
end
|
15
|
+
Fog::Logger.debug "Network Security Rule #{security_rule[:name]} Created/Updated Successfully!"
|
16
|
+
security_rule_obj
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_security_rule_params(security_rule_hash)
|
20
|
+
security_rule = Azure::ARM::Network::Models::SecurityRule.new
|
21
|
+
security_rule.protocol = security_rule_hash[:protocol]
|
22
|
+
security_rule.source_port_range = security_rule_hash[:source_port_range]
|
23
|
+
security_rule.destination_port_range = security_rule_hash[:destination_port_range]
|
24
|
+
security_rule.source_address_prefix = security_rule_hash[:source_address_prefix]
|
25
|
+
security_rule.destination_address_prefix = security_rule_hash[:destination_address_prefix]
|
26
|
+
security_rule.access = security_rule_hash[:access]
|
27
|
+
security_rule.priority = security_rule_hash[:priority]
|
28
|
+
security_rule.direction = security_rule_hash[:direction]
|
29
|
+
security_rule
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# Mock class for Network Security Rule Request
|
34
|
+
class Mock
|
35
|
+
def create_or_update_network_security_rule(*)
|
36
|
+
network_security_rule = '{
|
37
|
+
"name":"myNsRule",
|
38
|
+
"id":"/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/myNsg/securityRules/myNsRule",
|
39
|
+
"etag":"W/\"00000000-0000-0000-0000-000000000000\"",
|
40
|
+
"properties":{
|
41
|
+
"provisioningState":"Succeeded",
|
42
|
+
"description":"description-of-this-rule",
|
43
|
+
"protocol": "*",
|
44
|
+
"sourcePortRange":"source-port-range",
|
45
|
+
"destinationPortRange":"destination-port-range",
|
46
|
+
"sourceAddressPrefix":"*",
|
47
|
+
"destinationAddressPrefix":"*",
|
48
|
+
"access":"Allow",
|
49
|
+
"priority":6500,
|
50
|
+
"direction":"Inbound"
|
51
|
+
}
|
52
|
+
}'
|
53
|
+
network_security_rule_mapper = Azure::ARM::Network::Models::SecurityRule.mapper
|
54
|
+
@network_client.deserialize(network_security_rule_mapper, JSON.load(network_security_rule), 'result.body')
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -22,31 +22,23 @@ module Fog
|
|
22
22
|
def get_network_gateway_object(virtual_network_params)
|
23
23
|
network_gateway = Azure::ARM::Network::Models::VirtualNetworkGateway.new
|
24
24
|
|
25
|
-
default_site = MsRestAzure::SubResource.new
|
26
|
-
default_site.id = virtual_network_params[:gateway_default_site]
|
27
|
-
|
28
|
-
sku = Azure::ARM::Network::Models::VirtualNetworkGatewaySku.new
|
29
|
-
sku.name = virtual_network_params[:sku_name]
|
30
|
-
sku.capacity = virtual_network_params[:sku_capacity]
|
31
|
-
sku.tier = virtual_network_params[:sku_tier]
|
32
|
-
|
33
25
|
network_gateway.enable_bgp = virtual_network_params[:enable_bgp]
|
34
26
|
network_gateway.gateway_type = virtual_network_params[:gateway_type]
|
35
27
|
network_gateway.provisioning_state = virtual_network_params[:provisioning_state]
|
36
28
|
network_gateway.vpn_type = virtual_network_params[:vpn_type]
|
37
|
-
network_gateway.sku =
|
38
|
-
|
29
|
+
network_gateway.sku = get_virtual_network_gateway_sku(virtual_network_params)
|
30
|
+
if virtual_network_params[:gateway_default_site]
|
31
|
+
default_site = MsRestAzure::SubResource.new
|
32
|
+
default_site.id = virtual_network_params[:gateway_default_site]
|
33
|
+
network_gateway.gateway_default_site = default_site
|
34
|
+
end
|
39
35
|
if virtual_network_params[:ip_configurations]
|
40
36
|
ip_configurations = get_ip_configurations(virtual_network_params[:ip_configurations])
|
41
37
|
network_gateway.ip_configurations = ip_configurations
|
42
38
|
end
|
43
39
|
|
44
40
|
if virtual_network_params[:enable_bgp]
|
45
|
-
bgp_settings =
|
46
|
-
bgp_settings.asn = virtual_network_params[:asn]
|
47
|
-
bgp_settings.bgp_peering_address = virtual_network_params[:bgp_peering_address]
|
48
|
-
bgp_settings.peer_weight = virtual_network_params[:peer_weight]
|
49
|
-
network_gateway.bgp_settings = bgp_settings
|
41
|
+
network_gateway.bgp_settings = get_bgp_settings(virtual_network_params)
|
50
42
|
end
|
51
43
|
|
52
44
|
if virtual_network_params[:vpn_client_configuration]
|
@@ -61,6 +53,22 @@ module Fog
|
|
61
53
|
network_gateway
|
62
54
|
end
|
63
55
|
|
56
|
+
def get_bgp_settings(virtual_network_params)
|
57
|
+
bgp_settings = Azure::ARM::Network::Models::BgpSettings.new
|
58
|
+
bgp_settings.asn = virtual_network_params[:asn]
|
59
|
+
bgp_settings.bgp_peering_address = virtual_network_params[:bgp_peering_address]
|
60
|
+
bgp_settings.peer_weight = virtual_network_params[:peer_weight]
|
61
|
+
bgp_settings
|
62
|
+
end
|
63
|
+
|
64
|
+
def get_virtual_network_gateway_sku(virtual_network_params)
|
65
|
+
sku = Azure::ARM::Network::Models::VirtualNetworkGatewaySku.new
|
66
|
+
sku.name = virtual_network_params[:sku_name]
|
67
|
+
sku.capacity = virtual_network_params[:sku_capacity]
|
68
|
+
sku.tier = virtual_network_params[:sku_tier]
|
69
|
+
sku
|
70
|
+
end
|
71
|
+
|
64
72
|
def get_vpn_client_config(vpn_client_config)
|
65
73
|
client_config = Azure::ARM::Network::Models::VpnClientConfiguration.new
|
66
74
|
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Fog
|
2
|
+
module Network
|
3
|
+
class AzureRM
|
4
|
+
# Real class for Network Request
|
5
|
+
class Real
|
6
|
+
def delete_network_security_rule(resource_group, network_security_group_name, security_rule_name)
|
7
|
+
msg = "Deleting Network Security Rule #{security_rule_name} in Security Group #{network_security_group_name}"
|
8
|
+
Fog::Logger.debug msg
|
9
|
+
|
10
|
+
begin
|
11
|
+
@network_client.security_rules.delete(resource_group, network_security_group_name, security_rule_name)
|
12
|
+
rescue MsRestAzure::AzureOperationError => e
|
13
|
+
raise_azure_exception(e, msg)
|
14
|
+
end
|
15
|
+
|
16
|
+
Fog::Logger.debug "Network Security Rule #{security_rule_name} deleted successfully."
|
17
|
+
true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Mock class for Network Request
|
22
|
+
class Mock
|
23
|
+
def delete_network_security_rule(*)
|
24
|
+
Fog::Logger.debug 'Network Security Rule test-security-rule from Resource group test-rg deleted successfully.'
|
25
|
+
true
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Fog
|
2
|
+
module Network
|
3
|
+
class AzureRM
|
4
|
+
# Real class for Network Request
|
5
|
+
class Real
|
6
|
+
def get_available_ipaddresses_count(subnet_name, address_prefix, ip_configurations_ids, express_route_enabled)
|
7
|
+
Fog::Logger.debug "Getting free IP Address count of Subnet #{subnet_name}"
|
8
|
+
total_ipaddresses = (2**(32 - address_prefix.split('/').last.to_i)) - 2
|
9
|
+
total_ipaddresses -= 3 if express_route_enabled
|
10
|
+
used_ip_address = ip_configurations_ids.nil? ? 0 : ip_configurations_ids.count
|
11
|
+
total_ipaddresses - used_ip_address
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# Mock class for Network Request
|
16
|
+
class Mock
|
17
|
+
def get_available_ipaddress_count(*)
|
18
|
+
65_531
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Fog
|
2
|
+
module Network
|
3
|
+
class AzureRM
|
4
|
+
# Real class for Network Security rule Request
|
5
|
+
class Real
|
6
|
+
def get_network_security_rule(resource_group_name, network_security_group_name, security_rule_name)
|
7
|
+
msg = "Getting Network Security Rule #{security_rule_name} from Resource Group #{resource_group_name}."
|
8
|
+
Fog::Logger.debug msg
|
9
|
+
|
10
|
+
begin
|
11
|
+
security_rule = @network_client.security_rules.get(resource_group_name, network_security_group_name, security_rule_name)
|
12
|
+
rescue MsRestAzure::AzureOperationError => e
|
13
|
+
raise_azure_exception(e, msg)
|
14
|
+
end
|
15
|
+
|
16
|
+
Fog::Logger.debug "Network Security Rule #{security_rule_name} retrieved successfully."
|
17
|
+
security_rule
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Mock class for Network Security Rule Request
|
22
|
+
class Mock
|
23
|
+
def get_network_security_rule(*)
|
24
|
+
nsr = '{
|
25
|
+
"name":"myNsRule",
|
26
|
+
"id":"/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/myNsg/securityRules/myNsRule",
|
27
|
+
"etag":"W/\"00000000-0000-0000-0000-000000000000\"",
|
28
|
+
"properties":{
|
29
|
+
"provisioningState":"Succeeded",
|
30
|
+
"description":"description-of-this-rule",
|
31
|
+
"protocol": "*",
|
32
|
+
"sourcePortRange":"source-port-range",
|
33
|
+
"destinationPortRange":"destination-port-range",
|
34
|
+
"sourceAddressPrefix":"*",
|
35
|
+
"destinationAddressPrefix":"*",
|
36
|
+
"access":"Allow",
|
37
|
+
"priority":6500,
|
38
|
+
"direction":"Inbound"
|
39
|
+
}
|
40
|
+
}'
|
41
|
+
nsr_mapper = Azure::ARM::Network::Models::SecurityRule.mapper
|
42
|
+
@network_client.deserialize(nsr_mapper, JSON.load(nsr), 'result.body')
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -8,7 +8,7 @@ module Fog
|
|
8
8
|
Fog::Logger.debug msg
|
9
9
|
|
10
10
|
begin
|
11
|
-
nsg_list_result = @network_client.network_security_groups.
|
11
|
+
nsg_list_result = @network_client.network_security_groups.list_as_lazy(resource_group)
|
12
12
|
rescue MsRestAzure::AzureOperationError => e
|
13
13
|
raise_azure_exception(e, msg)
|
14
14
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Fog
|
2
|
+
module Network
|
3
|
+
class AzureRM
|
4
|
+
# Real class for Network Request
|
5
|
+
class Real
|
6
|
+
def list_network_security_rules(resource_group, network_security_group_name)
|
7
|
+
msg = "Getting list of Network Security Rule in Security Group #{network_security_group_name} from Resource Group #{resource_group}."
|
8
|
+
Fog::Logger.debug msg
|
9
|
+
|
10
|
+
begin
|
11
|
+
nsr_list_result = @network_client.security_rules.list_as_lazy(resource_group, network_security_group_name)
|
12
|
+
rescue MsRestAzure::AzureOperationError => e
|
13
|
+
raise_azure_exception(e, msg)
|
14
|
+
end
|
15
|
+
|
16
|
+
Fog::Logger.debug "Network Security Rules list retrieved successfully from Resource Group #{resource_group}."
|
17
|
+
nsr_list_result.value
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Mock class for Network Security Rule Request
|
22
|
+
class Mock
|
23
|
+
def list_network_security_rules(*)
|
24
|
+
nsr_list = '{
|
25
|
+
"value":[
|
26
|
+
{
|
27
|
+
"name":"myNsRule",
|
28
|
+
"id":"/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/myNsg/securityRules/myNsRule",
|
29
|
+
"etag":"W/\"00000000-0000-0000-0000-000000000000\"",
|
30
|
+
"properties":{
|
31
|
+
"provisioningState":"Succeeded",
|
32
|
+
"description":"description-of-this-rule",
|
33
|
+
"protocol": "*",
|
34
|
+
"sourcePortRange":"source-port-range",
|
35
|
+
"destinationPortRange":"destination-port-range",
|
36
|
+
"sourceAddressPrefix":"*",
|
37
|
+
"destinationAddressPrefix":"*",
|
38
|
+
"access":"Allow",
|
39
|
+
"priority":100,
|
40
|
+
"direction":"Inbound"
|
41
|
+
}
|
42
|
+
}
|
43
|
+
]
|
44
|
+
}'
|
45
|
+
nsr_mapper = Azure::ARM::Network::Models::SecurityRuleListResult.mapper
|
46
|
+
@network_client.deserialize(nsr_mapper, JSON.load(nsr_list), 'result.body')
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Fog
|
2
|
+
module Storage
|
3
|
+
class AzureRM
|
4
|
+
# This class provides the actual implementation for service calls.
|
5
|
+
class Real
|
6
|
+
def acquire_blob_lease(container_name, name, options={})
|
7
|
+
msg = "Leasing blob: #{name} of container #{container_name}"
|
8
|
+
Fog::Logger.debug msg
|
9
|
+
begin
|
10
|
+
lease_id = @blob_client.acquire_blob_lease(container_name, name, options)
|
11
|
+
rescue Azure::Core::Http::HTTPError => ex
|
12
|
+
raise_azure_exception(ex, msg)
|
13
|
+
end
|
14
|
+
Fog::Logger.debug "Blob #{name} leased successfully."
|
15
|
+
lease_id
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# This class provides the mock implementation for unit tests.
|
20
|
+
class Mock
|
21
|
+
def acquire_blob_lease(*)
|
22
|
+
{
|
23
|
+
'leaseId' => 'abc123'
|
24
|
+
}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Fog
|
2
|
+
module Storage
|
3
|
+
class AzureRM
|
4
|
+
# This class provides the actual implementation for service calls.
|
5
|
+
class Real
|
6
|
+
def acquire_container_lease(name, options={})
|
7
|
+
msg = "Leasing container: #{name}"
|
8
|
+
Fog::Logger.debug msg
|
9
|
+
begin
|
10
|
+
lease_id = @blob_client.acquire_container_lease(name, options)
|
11
|
+
rescue Azure::Core::Http::HTTPError => ex
|
12
|
+
raise_azure_exception(ex, msg)
|
13
|
+
end
|
14
|
+
Fog::Logger.debug "Container #{name} leased successfully."
|
15
|
+
lease_id
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# This class provides the mock implementation for unit tests.
|
20
|
+
class Mock
|
21
|
+
def acquire_container_lease(*)
|
22
|
+
{
|
23
|
+
'leaseId' => 'abc123'
|
24
|
+
}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Fog
|
2
|
+
module Storage
|
3
|
+
class AzureRM
|
4
|
+
# This class provides the actual implemention for service calls.
|
5
|
+
class Real
|
6
|
+
def check_blob_exist(container_name, name, options = {})
|
7
|
+
Fog::Logger.debug "Check Blob #{name} exist in container #{container_name}."
|
8
|
+
begin
|
9
|
+
@blob_client.get_blob_properties(container_name, name, options)
|
10
|
+
rescue Azure::Core::Http::HTTPError
|
11
|
+
return false
|
12
|
+
end
|
13
|
+
Fog::Logger.debug "Blob #{name} Exists."
|
14
|
+
true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
# This class provides the mock implementation for unit tests.
|
18
|
+
class Mock
|
19
|
+
def check_blob_exist(*)
|
20
|
+
true
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module Fog
|
2
|
+
module Storage
|
3
|
+
class AzureRM
|
4
|
+
# This class provides the actual implementation for service calls.
|
5
|
+
class Real
|
6
|
+
def compare_blob(container1, container2)
|
7
|
+
msg = "Comparing blobs from container #{container1} to container #{container2}"
|
8
|
+
Fog::Logger.debug msg
|
9
|
+
begin
|
10
|
+
identical_blobs = get_identical_blobs_from_containers(container1, container2)
|
11
|
+
rescue Azure::Core::Http::HTTPError => ex
|
12
|
+
raise_azure_exception(ex, msg)
|
13
|
+
end
|
14
|
+
identical_blobs
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def get_identical_blobs_from_containers(container1, container2)
|
20
|
+
container1_blobs = list_blobs(container1)
|
21
|
+
container2_blobs = list_blobs(container2)
|
22
|
+
|
23
|
+
identical_blobs = []
|
24
|
+
container1_blobs.each do |container1_blob|
|
25
|
+
container2_blobs.each do |container2_blob|
|
26
|
+
container1_prop = get_blob_properties(container1, container1_blob.name)
|
27
|
+
container2_prop = get_blob_properties(container2, container2_blob.name)
|
28
|
+
if container1_blob.name == container2_blob.name && container1_prop.properties[:content_md5] == container2_prop.properties[:content_md5]
|
29
|
+
identical_blobs.push(container1_blob)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
identical_blobs
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# This class provides the mock implementation for unit tests.
|
38
|
+
class Mock
|
39
|
+
def compare_blob(*)
|
40
|
+
[
|
41
|
+
{
|
42
|
+
'name' => 'blob_name',
|
43
|
+
'metadata' => {},
|
44
|
+
'properties' =>
|
45
|
+
{
|
46
|
+
'last_modified' => 'Thu, 28 Jul 2016 06:53:05 GMT',
|
47
|
+
'etag' => '0x8D3B6B3D353FFCA',
|
48
|
+
'lease_status' => 'unlocked',
|
49
|
+
'lease_state' => 'available',
|
50
|
+
'lease_duration' => nil,
|
51
|
+
'content_length' => 4_194_304,
|
52
|
+
'content_type' => 'application/atom+xml; charset=utf-8',
|
53
|
+
'content_encoding' => 'ASCII-8BIT',
|
54
|
+
'content_language' => nil,
|
55
|
+
'content_disposition' => nil,
|
56
|
+
'content_md5' => 'tXAohIyxuu/t94Lp/ujeRw==',
|
57
|
+
'cache_control' => nil,
|
58
|
+
'blob_type' => 'BlockBlob',
|
59
|
+
'copy_id' => nil,
|
60
|
+
'copy_status' => nil,
|
61
|
+
'copy_source' => nil,
|
62
|
+
'copy_progress' => nil,
|
63
|
+
'copy_completion_time' => nil,
|
64
|
+
'copy_status_description' => nil,
|
65
|
+
'accept_ranges' => 0
|
66
|
+
}
|
67
|
+
}
|
68
|
+
]
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|