fog-azure-rm 0.3.3 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.arclint +8 -0
- data/CHANGELOG.md +10 -0
- data/CONTRIBUTORS.md +4 -0
- data/lib/fog/azurerm/compute.rb +1 -0
- data/lib/fog/azurerm/docs/application_gateway.md +6 -7
- data/lib/fog/azurerm/docs/compute.md +45 -11
- data/lib/fog/azurerm/docs/dns.md +4 -1
- data/lib/fog/azurerm/docs/key_vault.md +3 -0
- data/lib/fog/azurerm/docs/network.md +18 -13
- data/lib/fog/azurerm/docs/resources.md +11 -8
- data/lib/fog/azurerm/docs/sql.md +18 -16
- data/lib/fog/azurerm/docs/storage.md +13 -78
- data/lib/fog/azurerm/docs/traffic_manager.md +7 -6
- data/lib/fog/azurerm/models/application_gateway/gateway.rb +5 -1
- data/lib/fog/azurerm/models/compute/availability_set.rb +4 -1
- data/lib/fog/azurerm/models/compute/creation_data.rb +4 -2
- data/lib/fog/azurerm/models/compute/data_disk.rb +26 -0
- data/lib/fog/azurerm/models/compute/managed_disk.rb +4 -4
- data/lib/fog/azurerm/models/compute/server.rb +31 -5
- data/lib/fog/azurerm/models/key_vault/vault.rb +3 -1
- data/lib/fog/azurerm/models/network/load_balancer.rb +3 -1
- data/lib/fog/azurerm/models/network/local_network_gateway.rb +3 -1
- data/lib/fog/azurerm/models/network/network_interface.rb +3 -1
- data/lib/fog/azurerm/models/network/network_security_group.rb +4 -2
- data/lib/fog/azurerm/models/network/public_ip.rb +4 -2
- data/lib/fog/azurerm/models/network/virtual_network.rb +4 -2
- data/lib/fog/azurerm/models/resources/resource_group.rb +3 -1
- data/lib/fog/azurerm/models/sql/sql_database.rb +3 -3
- data/lib/fog/azurerm/models/sql/sql_server.rb +3 -2
- data/lib/fog/azurerm/models/storage/storage_account.rb +4 -1
- data/lib/fog/azurerm/models/traffic_manager/traffic_manager_profile.rb +3 -1
- data/lib/fog/azurerm/requests/application_gateway/create_or_update_application_gateway.rb +1 -0
- data/lib/fog/azurerm/requests/compute/attach_data_disk_to_vm.rb +49 -13
- data/lib/fog/azurerm/requests/compute/create_availability_set.rb +4 -2
- data/lib/fog/azurerm/requests/compute/create_virtual_machine.rb +38 -36
- data/lib/fog/azurerm/requests/compute/detach_data_disk_from_vm.rb +1 -2
- data/lib/fog/azurerm/requests/dns/create_or_update_zone.rb +1 -2
- data/lib/fog/azurerm/requests/key_vault/create_or_update_vault.rb +1 -0
- data/lib/fog/azurerm/requests/network/check_express_route_cir_auth_exists.rb +1 -1
- data/lib/fog/azurerm/requests/network/create_load_balancer.rb +4 -4
- data/lib/fog/azurerm/requests/network/create_or_update_express_route_circuit.rb +1 -1
- data/lib/fog/azurerm/requests/network/create_or_update_local_network_gateway.rb +1 -2
- data/lib/fog/azurerm/requests/network/create_or_update_network_interface.rb +4 -3
- data/lib/fog/azurerm/requests/network/create_or_update_network_security_group.rb +4 -3
- data/lib/fog/azurerm/requests/network/create_or_update_public_ip.rb +5 -3
- data/lib/fog/azurerm/requests/network/create_or_update_virtual_network.rb +4 -3
- data/lib/fog/azurerm/requests/network/create_or_update_virtual_network_gateway_connection.rb +1 -1
- data/lib/fog/azurerm/requests/resources/check_azure_resource_exists.rb +1 -1
- data/lib/fog/azurerm/requests/resources/create_resource_group.rb +2 -1
- data/lib/fog/azurerm/requests/resources/delete_resource_tag.rb +4 -4
- data/lib/fog/azurerm/requests/resources/tag_resource.rb +4 -4
- data/lib/fog/azurerm/requests/sql/create_or_update_database.rb +13 -10
- data/lib/fog/azurerm/requests/sql/create_or_update_sql_server.rb +8 -5
- data/lib/fog/azurerm/requests/storage/create_storage_account.rb +4 -2
- data/lib/fog/azurerm/requests/traffic_manager/create_or_update_traffic_manager_profile.rb +13 -3
- data/lib/fog/azurerm/storage.rb +0 -19
- data/lib/fog/azurerm/version.rb +1 -1
- data/test/api_stub.rb +0 -2
- data/test/api_stub/models/compute/server.rb +62 -0
- data/test/api_stub/requests/compute/virtual_machine.rb +75 -0
- data/test/api_stub/requests/resources/resource_group.rb +1 -1
- data/test/integration/application_gateway.rb +8 -1
- data/test/integration/availability_set.rb +9 -2
- data/test/integration/external_load_balancer.rb +2 -1
- data/test/integration/internal_load_balancer.rb +2 -1
- data/test/integration/key_vault.rb +2 -1
- data/test/integration/managed_disk.rb +10 -5
- data/test/integration/network_interface.rb +2 -1
- data/test/integration/network_security_group.rb +2 -1
- data/test/integration/public_ip.rb +2 -1
- data/test/integration/resource_group.rb +5 -2
- data/test/integration/resource_tag.rb +4 -2
- data/test/integration/server.rb +81 -3
- data/test/integration/sql_server.rb +10 -2
- data/test/integration/storage_account.rb +32 -20
- data/test/integration/traffic_manager.rb +6 -1
- data/test/integration/virtual_network.rb +2 -1
- data/test/integration/virtual_network_gateway_connection.rb +3 -3
- data/test/models/application_gateway/test_gateway.rb +2 -1
- data/test/models/compute/test_availability_set.rb +2 -1
- data/test/models/{storage → compute}/test_data_disk.rb +2 -2
- data/test/models/compute/test_managed_disk.rb +2 -1
- data/test/models/compute/test_server.rb +31 -2
- data/test/models/dns/test_zone.rb +2 -1
- data/test/models/key_vault/test_vault.rb +2 -1
- data/test/models/network/test_load_balancer.rb +2 -1
- data/test/models/network/test_network_interface.rb +2 -1
- data/test/models/network/test_network_security_group.rb +2 -1
- data/test/models/network/test_public_ip.rb +2 -1
- data/test/models/network/test_virtual_network.rb +2 -1
- data/test/models/resources/test_resource_group.rb +2 -1
- data/test/models/sql/test_database.rb +2 -1
- data/test/models/sql/test_sql_server.rb +2 -1
- data/test/models/storage/test_storage_account.rb +2 -1
- data/test/models/traffic_manager/test_traffic_manager_profile.rb +2 -1
- data/test/requests/compute/test_attach_data_disk_to_vm.rb +21 -6
- data/test/requests/network/test_check_express_route_cir_auth_exists.rb +1 -1
- data/test/requests/network/test_create_load_balancer.rb +3 -2
- data/test/requests/network/test_create_network_interface.rb +4 -3
- data/test/requests/network/test_create_or_update_network_security_group.rb +3 -2
- data/test/requests/network/test_create_or_update_virtual_network.rb +5 -3
- data/test/requests/network/test_create_public_ip.rb +3 -2
- data/test/requests/network/test_update_public_ip.rb +3 -2
- data/test/requests/resources/test_create_resource_group.rb +3 -2
- data/test/requests/resources/test_delete_resource_tag.rb +3 -3
- data/test/requests/resources/test_tag_resource.rb +3 -3
- data/test/test_helper.rb +0 -14
- metadata +5 -36
- data/lib/fog/azurerm/models/storage/data_disk.rb +0 -27
- data/lib/fog/azurerm/models/storage/recovery_vault.rb +0 -50
- data/lib/fog/azurerm/models/storage/recovery_vaults.rb +0 -27
- data/lib/fog/azurerm/requests/storage/create_or_update_recovery_vault.rb +0 -54
- data/lib/fog/azurerm/requests/storage/delete_recovery_vault.rb +0 -35
- data/lib/fog/azurerm/requests/storage/disable_backup_protection.rb +0 -60
- data/lib/fog/azurerm/requests/storage/enable_backup_protection.rb +0 -61
- data/lib/fog/azurerm/requests/storage/get_all_backup_jobs.rb +0 -56
- data/lib/fog/azurerm/requests/storage/get_backup_container.rb +0 -53
- data/lib/fog/azurerm/requests/storage/get_backup_item.rb +0 -58
- data/lib/fog/azurerm/requests/storage/get_backup_job_for_vm.rb +0 -53
- data/lib/fog/azurerm/requests/storage/get_backup_protection_policy.rb +0 -64
- data/lib/fog/azurerm/requests/storage/get_recovery_vault.rb +0 -49
- data/lib/fog/azurerm/requests/storage/list_recovery_vaults.rb +0 -48
- data/lib/fog/azurerm/requests/storage/set_recovery_vault_context.rb +0 -36
- data/lib/fog/azurerm/requests/storage/start_backup.rb +0 -54
- data/test/api_stub/models/storage/recovery_vault.rb +0 -23
- data/test/api_stub/requests/storage/recovery_vault.rb +0 -189
- data/test/models/storage/test_recovery_vault.rb +0 -61
- data/test/models/storage/test_recovery_vaults.rb +0 -47
- data/test/requests/storage/test_create_recovery_vault.rb +0 -35
- data/test/requests/storage/test_delete_recovery_vault.rb +0 -34
- data/test/requests/storage/test_disable_backup_protection.rb +0 -52
- data/test/requests/storage/test_enable_backup_protection.rb +0 -66
- data/test/requests/storage/test_get_all_backup_jobs.rb +0 -35
- data/test/requests/storage/test_get_backup_container.rb +0 -35
- data/test/requests/storage/test_get_backup_item.rb +0 -35
- data/test/requests/storage/test_get_backup_job_for_vm.rb +0 -26
- data/test/requests/storage/test_get_backup_protection_policy.rb +0 -35
- data/test/requests/storage/test_get_recovery_vault.rb +0 -35
- data/test/requests/storage/test_list_recovery_vault.rb +0 -35
- data/test/requests/storage/test_set_recovery_vault_context.rb +0 -34
- data/test/requests/storage/test_start_backup.rb +0 -55
|
@@ -4,10 +4,10 @@ module Fog
|
|
|
4
4
|
class AzureRM
|
|
5
5
|
# Real class for Network Request
|
|
6
6
|
class Real
|
|
7
|
-
def create_or_update_network_interface(resource_group_name, name, location, subnet_id, public_ip_address_id, network_security_group_id, ip_config_name, private_ip_allocation_method, private_ip_address, load_balancer_backend_address_pools_ids, load_balancer_inbound_nat_rules_ids)
|
|
7
|
+
def create_or_update_network_interface(resource_group_name, name, location, subnet_id, public_ip_address_id, network_security_group_id, ip_config_name, private_ip_allocation_method, private_ip_address, load_balancer_backend_address_pools_ids, load_balancer_inbound_nat_rules_ids, tags)
|
|
8
8
|
msg = "Creating/Updating Network Interface Card: #{name}"
|
|
9
9
|
Fog::Logger.debug msg
|
|
10
|
-
network_interface = get_network_interface_object(name, location, subnet_id, public_ip_address_id, network_security_group_id, ip_config_name, private_ip_allocation_method, private_ip_address, load_balancer_backend_address_pools_ids, load_balancer_inbound_nat_rules_ids)
|
|
10
|
+
network_interface = get_network_interface_object(name, location, subnet_id, public_ip_address_id, network_security_group_id, ip_config_name, private_ip_allocation_method, private_ip_address, load_balancer_backend_address_pools_ids, load_balancer_inbound_nat_rules_ids, tags)
|
|
11
11
|
begin
|
|
12
12
|
network_interface_obj = @network_client.network_interfaces.create_or_update(resource_group_name, name, network_interface)
|
|
13
13
|
rescue MsRestAzure::AzureOperationError => e
|
|
@@ -19,7 +19,7 @@ module Fog
|
|
|
19
19
|
|
|
20
20
|
private
|
|
21
21
|
|
|
22
|
-
def get_network_interface_object(name, location, subnet_id, public_ip_address_id, network_security_group_id, ip_config_name, private_ip_allocation_method, private_ip_address, load_balancer_backend_address_pools_ids, load_balancer_inbound_nat_rules_ids)
|
|
22
|
+
def get_network_interface_object(name, location, subnet_id, public_ip_address_id, network_security_group_id, ip_config_name, private_ip_allocation_method, private_ip_address, load_balancer_backend_address_pools_ids, load_balancer_inbound_nat_rules_ids, tags)
|
|
23
23
|
if public_ip_address_id
|
|
24
24
|
public_ipaddress = Azure::ARM::Network::Models::PublicIPAddress.new
|
|
25
25
|
public_ipaddress.id = public_ip_address_id
|
|
@@ -59,6 +59,7 @@ module Fog
|
|
|
59
59
|
network_interface.name = name
|
|
60
60
|
network_interface.location = location
|
|
61
61
|
network_interface.ip_configurations = [ip_configs]
|
|
62
|
+
network_interface.tags = tags
|
|
62
63
|
|
|
63
64
|
if network_security_group_id
|
|
64
65
|
network_security_group = Azure::ARM::Network::Models::NetworkSecurityGroup.new
|
|
@@ -3,11 +3,11 @@ module Fog
|
|
|
3
3
|
class AzureRM
|
|
4
4
|
# Real class for Network Request
|
|
5
5
|
class Real
|
|
6
|
-
def create_or_update_network_security_group(resource_group_name, security_group_name, location, security_rules)
|
|
6
|
+
def create_or_update_network_security_group(resource_group_name, security_group_name, location, security_rules, tags)
|
|
7
7
|
msg = "Creating/Updating Network Security Group #{security_group_name} in Resource Group #{resource_group_name}."
|
|
8
8
|
Fog::Logger.debug msg
|
|
9
9
|
|
|
10
|
-
security_group = get_security_group_object(security_rules, location)
|
|
10
|
+
security_group = get_security_group_object(security_rules, location, tags)
|
|
11
11
|
|
|
12
12
|
begin
|
|
13
13
|
security_group = @network_client.network_security_groups.begin_create_or_update(resource_group_name, security_group_name, security_group)
|
|
@@ -21,10 +21,11 @@ module Fog
|
|
|
21
21
|
|
|
22
22
|
private
|
|
23
23
|
|
|
24
|
-
def get_security_group_object(security_rules, location)
|
|
24
|
+
def get_security_group_object(security_rules, location, tags)
|
|
25
25
|
security_group = Azure::ARM::Network::Models::NetworkSecurityGroup.new
|
|
26
26
|
security_group.security_rules = get_security_rule_objects(security_rules)
|
|
27
27
|
security_group.location = location
|
|
28
|
+
security_group.tags = tags
|
|
28
29
|
security_group
|
|
29
30
|
end
|
|
30
31
|
|
|
@@ -3,10 +3,10 @@ module Fog
|
|
|
3
3
|
class AzureRM
|
|
4
4
|
# Real class for Network Request
|
|
5
5
|
class Real
|
|
6
|
-
def create_or_update_public_ip(resource_group, name, location, public_ip_allocation_method, idle_timeout_in_minutes, domain_name_label)
|
|
6
|
+
def create_or_update_public_ip(resource_group, name, location, public_ip_allocation_method, idle_timeout_in_minutes, domain_name_label, tags)
|
|
7
7
|
msg = "Creating/Updating PublicIP #{name} in Resource Group #{resource_group}."
|
|
8
8
|
Fog::Logger.debug msg
|
|
9
|
-
public_ip = get_public_ip_object(name, location, public_ip_allocation_method, idle_timeout_in_minutes, domain_name_label)
|
|
9
|
+
public_ip = get_public_ip_object(name, location, public_ip_allocation_method, idle_timeout_in_minutes, domain_name_label, tags)
|
|
10
10
|
begin
|
|
11
11
|
public_ip_obj = @network_client.public_ipaddresses.create_or_update(resource_group, name, public_ip)
|
|
12
12
|
rescue MsRestAzure::AzureOperationError => e
|
|
@@ -18,12 +18,14 @@ module Fog
|
|
|
18
18
|
|
|
19
19
|
private
|
|
20
20
|
|
|
21
|
-
def get_public_ip_object(name, location, public_ip_allocation_method, idle_timeout_in_minutes, domain_name_label)
|
|
21
|
+
def get_public_ip_object(name, location, public_ip_allocation_method, idle_timeout_in_minutes, domain_name_label, tags)
|
|
22
22
|
public_ip = Azure::ARM::Network::Models::PublicIPAddress.new
|
|
23
23
|
public_ip.name = name
|
|
24
24
|
public_ip.location = location
|
|
25
25
|
public_ip.public_ipallocation_method = public_ip_allocation_method unless public_ip_allocation_method.nil?
|
|
26
26
|
public_ip.idle_timeout_in_minutes = idle_timeout_in_minutes unless idle_timeout_in_minutes.nil?
|
|
27
|
+
public_ip.tags = tags
|
|
28
|
+
|
|
27
29
|
unless domain_name_label.nil?
|
|
28
30
|
public_ip.dns_settings = Azure::ARM::Network::Models::PublicIPAddressDnsSettings.new
|
|
29
31
|
public_ip.dns_settings.domain_name_label = domain_name_label
|
|
@@ -3,8 +3,8 @@ module Fog
|
|
|
3
3
|
class AzureRM
|
|
4
4
|
# Real class for Network Request
|
|
5
5
|
class Real
|
|
6
|
-
def create_or_update_virtual_network(resource_group_name, virtual_network_name, location, dns_servers, subnets, address_prefixes)
|
|
7
|
-
virtual_network = define_vnet_object(location, address_prefixes, dns_servers, subnets)
|
|
6
|
+
def create_or_update_virtual_network(resource_group_name, virtual_network_name, location, dns_servers, subnets, address_prefixes, tags)
|
|
7
|
+
virtual_network = define_vnet_object(location, address_prefixes, dns_servers, subnets, tags)
|
|
8
8
|
create_or_update_vnet(resource_group_name, virtual_network_name, virtual_network)
|
|
9
9
|
end
|
|
10
10
|
|
|
@@ -22,9 +22,10 @@ module Fog
|
|
|
22
22
|
virtual_network
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
def define_vnet_object(location, address_prefixes, dns_servers, subnets)
|
|
25
|
+
def define_vnet_object(location, address_prefixes, dns_servers, subnets, tags)
|
|
26
26
|
virtual_network = Azure::ARM::Network::Models::VirtualNetwork.new
|
|
27
27
|
virtual_network.location = location
|
|
28
|
+
virtual_network.tags = tags
|
|
28
29
|
|
|
29
30
|
if address_prefixes.nil? || !address_prefixes.any?
|
|
30
31
|
address_space = Azure::ARM::Network::Models::AddressSpace.new
|
data/lib/fog/azurerm/requests/network/create_or_update_virtual_network_gateway_connection.rb
CHANGED
|
@@ -26,7 +26,7 @@ module Fog
|
|
|
26
26
|
|
|
27
27
|
gateway_connection.name = gateway_connection_params[:name]
|
|
28
28
|
gateway_connection.location = gateway_connection_params[:location]
|
|
29
|
-
gateway_connection.tags = gateway_connection_params[:tags]
|
|
29
|
+
gateway_connection.tags = gateway_connection_params[:tags]
|
|
30
30
|
|
|
31
31
|
if gateway_connection_params[:virtual_network_gateway1]
|
|
32
32
|
gateway_connection.virtual_network_gateway1 = get_virtual_network_gateway(gateway_connection_params[:virtual_network_gateway1][:resource_group], gateway_connection_params[:virtual_network_gateway1][:name])
|
|
@@ -3,7 +3,7 @@ module Fog
|
|
|
3
3
|
class AzureRM
|
|
4
4
|
# This class provides the actual implementation for service calls.
|
|
5
5
|
class Real
|
|
6
|
-
def check_azure_resource_exists(resource_id, api_version)
|
|
6
|
+
def check_azure_resource_exists(resource_id, api_version = API_VERSION)
|
|
7
7
|
split_resource = resource_id.split('/') unless resource_id.nil?
|
|
8
8
|
raise 'Invalid Resource Id' if split_resource.count != 9
|
|
9
9
|
|
|
@@ -3,11 +3,12 @@ module Fog
|
|
|
3
3
|
class AzureRM
|
|
4
4
|
# This class provides the actual implementation for service calls.
|
|
5
5
|
class Real
|
|
6
|
-
def create_resource_group(name, location)
|
|
6
|
+
def create_resource_group(name, location, tags)
|
|
7
7
|
msg = "Creating Resource Group: #{name}."
|
|
8
8
|
Fog::Logger.debug msg
|
|
9
9
|
resource_group = Azure::ARM::Resources::Models::ResourceGroup.new
|
|
10
10
|
resource_group.location = location
|
|
11
|
+
resource_group.tags = tags
|
|
11
12
|
begin
|
|
12
13
|
resource_group = @rmc.resource_groups.create_or_update(name, resource_group)
|
|
13
14
|
rescue MsRestAzure::AzureOperationError => e
|
|
@@ -3,7 +3,7 @@ module Fog
|
|
|
3
3
|
class AzureRM
|
|
4
4
|
# This class provides the actual implementation for service calls.
|
|
5
5
|
class Real
|
|
6
|
-
def delete_resource_tag(resource_id, tag_name, tag_value)
|
|
6
|
+
def delete_resource_tag(resource_id, tag_name, tag_value, api_version = API_VERSION)
|
|
7
7
|
split_resource = resource_id.split('/') unless resource_id.nil?
|
|
8
8
|
if split_resource.count != 9
|
|
9
9
|
raise 'Invalid Resource Id'
|
|
@@ -18,12 +18,12 @@ module Fog
|
|
|
18
18
|
Fog::Logger.debug msg
|
|
19
19
|
|
|
20
20
|
begin
|
|
21
|
-
resource = @rmc.resources.get(resource_group_name, resource_provider_namespace, '', resource_type, resource_name,
|
|
21
|
+
resource = @rmc.resources.get(resource_group_name, resource_provider_namespace, '', resource_type, resource_name, api_version)
|
|
22
22
|
|
|
23
23
|
if resource.tags.key?(tag_name)
|
|
24
24
|
resource.tags.delete_if { |key, value| key == tag_name && value == tag_value }
|
|
25
25
|
end
|
|
26
|
-
@rmc.resources.create_or_update(resource_group_name, resource_provider_namespace, '', resource_type, resource_name,
|
|
26
|
+
@rmc.resources.create_or_update(resource_group_name, resource_provider_namespace, '', resource_type, resource_name, api_version, resource)
|
|
27
27
|
rescue MsRestAzure::AzureOperationError => e
|
|
28
28
|
raise_azure_exception(e, msg)
|
|
29
29
|
end
|
|
@@ -34,7 +34,7 @@ module Fog
|
|
|
34
34
|
|
|
35
35
|
# This class provides the mock implementation for unit tests.
|
|
36
36
|
class Mock
|
|
37
|
-
def delete_resource_tag(_resource_id, tag_name, _tag_value)
|
|
37
|
+
def delete_resource_tag(_resource_id, tag_name, _tag_value, _api_version)
|
|
38
38
|
Fog::Logger.debug "Tag #{tag_name} deleted successfully from Resource your-resource-name"
|
|
39
39
|
true
|
|
40
40
|
end
|
|
@@ -3,7 +3,7 @@ module Fog
|
|
|
3
3
|
class AzureRM
|
|
4
4
|
# This class provides the actual implementation for service calls.
|
|
5
5
|
class Real
|
|
6
|
-
def tag_resource(resource_id, tag_name, tag_value)
|
|
6
|
+
def tag_resource(resource_id, tag_name, tag_value, api_version = API_VERSION)
|
|
7
7
|
split_resource = resource_id.split('/') unless resource_id.nil?
|
|
8
8
|
if split_resource.count != 9
|
|
9
9
|
raise 'Invalid Resource Id'
|
|
@@ -19,10 +19,10 @@ module Fog
|
|
|
19
19
|
Fog::Logger.debug msg
|
|
20
20
|
|
|
21
21
|
begin
|
|
22
|
-
resource = @rmc.resources.get(resource_group_name, resource_provider_namespace, parent_resource_id, resource_type, resource_name,
|
|
22
|
+
resource = @rmc.resources.get(resource_group_name, resource_provider_namespace, parent_resource_id, resource_type, resource_name, api_version)
|
|
23
23
|
resource.tags = {} if resource.tags.nil?
|
|
24
24
|
resource.tags[tag_name] = tag_value
|
|
25
|
-
@rmc.resources.create_or_update(resource_group_name, resource_provider_namespace, parent_resource_id, resource_type, resource_name,
|
|
25
|
+
@rmc.resources.create_or_update(resource_group_name, resource_provider_namespace, parent_resource_id, resource_type, resource_name, api_version, resource)
|
|
26
26
|
rescue MsRestAzure::AzureOperationError => e
|
|
27
27
|
raise_azure_exception(e, msg)
|
|
28
28
|
end
|
|
@@ -33,7 +33,7 @@ module Fog
|
|
|
33
33
|
|
|
34
34
|
# This class provides the mock implementation for unit tests.
|
|
35
35
|
class Mock
|
|
36
|
-
def tag_resource(_resource_id, tag_name, _tag_value)
|
|
36
|
+
def tag_resource(_resource_id, tag_name, _tag_value, _api_version)
|
|
37
37
|
Fog::Logger.debug "Tag #{tag_name} created successfully for Resource 'resource_name'"
|
|
38
38
|
true
|
|
39
39
|
end
|
|
@@ -6,19 +6,21 @@ module Fog
|
|
|
6
6
|
def create_or_update_database(database_hash)
|
|
7
7
|
msg = "Creating SQL Database: #{database_hash[:name]}."
|
|
8
8
|
Fog::Logger.debug msg
|
|
9
|
+
formatted_database_params = format_database_parameters(database_hash[:location],
|
|
10
|
+
database_hash[:create_mode],
|
|
11
|
+
database_hash[:edition],
|
|
12
|
+
database_hash[:source_database_id],
|
|
13
|
+
database_hash[:collation],
|
|
14
|
+
database_hash[:max_size_bytes],
|
|
15
|
+
database_hash[:requested_service_objective_name],
|
|
16
|
+
database_hash[:elastic_pool_name],
|
|
17
|
+
database_hash[:requested_service_objective_id],
|
|
18
|
+
database_hash[:tags])
|
|
9
19
|
begin
|
|
10
20
|
sql_database = @sql_mgmt_client.databases.create_or_update(database_hash[:resource_group],
|
|
11
21
|
database_hash[:server_name],
|
|
12
22
|
database_hash[:name],
|
|
13
|
-
|
|
14
|
-
database_hash[:create_mode],
|
|
15
|
-
database_hash[:edition],
|
|
16
|
-
database_hash[:source_database_id],
|
|
17
|
-
database_hash[:collation],
|
|
18
|
-
database_hash[:max_size_bytes],
|
|
19
|
-
database_hash[:requested_service_objective_name],
|
|
20
|
-
database_hash[:elastic_pool_name],
|
|
21
|
-
database_hash[:requested_service_objective_id]))
|
|
23
|
+
formatted_database_params)
|
|
22
24
|
rescue MsRestAzure::AzureOperationError => e
|
|
23
25
|
raise_azure_exception(e, msg)
|
|
24
26
|
end
|
|
@@ -28,7 +30,7 @@ module Fog
|
|
|
28
30
|
|
|
29
31
|
private
|
|
30
32
|
|
|
31
|
-
def format_database_parameters(location, create_mode, edition, source_database_id, collation, max_size_bytes, requested_service_objective_name, elastic_pool_name, requested_service_objective_id)
|
|
33
|
+
def format_database_parameters(location, create_mode, edition, source_database_id, collation, max_size_bytes, requested_service_objective_name, elastic_pool_name, requested_service_objective_id, tags)
|
|
32
34
|
database = Azure::ARM::SQL::Models::Database.new
|
|
33
35
|
database.location = location
|
|
34
36
|
database.edition = edition unless edition.nil?
|
|
@@ -39,6 +41,7 @@ module Fog
|
|
|
39
41
|
database.source_database_id = source_database_id unless source_database_id.nil?
|
|
40
42
|
database.requested_service_objective_id = requested_service_objective_id unless requested_service_objective_id.nil?
|
|
41
43
|
database.requested_service_objective_name = requested_service_objective_name unless requested_service_objective_name.nil?
|
|
44
|
+
database.tags = tags
|
|
42
45
|
database
|
|
43
46
|
end
|
|
44
47
|
end
|
|
@@ -6,13 +6,15 @@ module Fog
|
|
|
6
6
|
def create_or_update_sql_server(server_hash)
|
|
7
7
|
msg = "Creating SQL Server: #{server_hash[:name]}."
|
|
8
8
|
Fog::Logger.debug msg
|
|
9
|
+
formatted_server_params = format_server_parameters(server_hash[:location],
|
|
10
|
+
server_hash[:version],
|
|
11
|
+
server_hash[:administrator_login],
|
|
12
|
+
server_hash[:administrator_login_password],
|
|
13
|
+
server_hash[:tags])
|
|
9
14
|
begin
|
|
10
15
|
sql_server = @sql_mgmt_client.servers.create_or_update(server_hash[:resource_group],
|
|
11
16
|
server_hash[:name],
|
|
12
|
-
|
|
13
|
-
server_hash[:version],
|
|
14
|
-
server_hash[:administrator_login],
|
|
15
|
-
server_hash[:administrator_login_password]))
|
|
17
|
+
formatted_server_params)
|
|
16
18
|
rescue MsRestAzure::AzureOperationError => e
|
|
17
19
|
raise_azure_exception(e, msg)
|
|
18
20
|
end
|
|
@@ -22,12 +24,13 @@ module Fog
|
|
|
22
24
|
|
|
23
25
|
private
|
|
24
26
|
|
|
25
|
-
def format_server_parameters(location, version, admin_login, admin_password)
|
|
27
|
+
def format_server_parameters(location, version, admin_login, admin_password, tags)
|
|
26
28
|
server = Azure::ARM::SQL::Models::Server.new
|
|
27
29
|
server.version = version
|
|
28
30
|
server.location = location
|
|
29
31
|
server.administrator_login = admin_login
|
|
30
32
|
server.administrator_login_password = admin_password
|
|
33
|
+
server.tags = tags
|
|
31
34
|
server
|
|
32
35
|
end
|
|
33
36
|
end
|
|
@@ -9,7 +9,8 @@ module Fog
|
|
|
9
9
|
storage_account_params = get_storage_account_params(storage_account_hash[:sku_name],
|
|
10
10
|
storage_account_hash[:location],
|
|
11
11
|
storage_account_hash[:replication],
|
|
12
|
-
storage_account_hash[:encryption]
|
|
12
|
+
storage_account_hash[:encryption],
|
|
13
|
+
storage_account_hash[:tags])
|
|
13
14
|
begin
|
|
14
15
|
storage_account = @storage_mgmt_client.storage_accounts.create(storage_account_hash[:resource_group],
|
|
15
16
|
storage_account_hash[:name],
|
|
@@ -23,7 +24,7 @@ module Fog
|
|
|
23
24
|
|
|
24
25
|
private
|
|
25
26
|
|
|
26
|
-
def get_storage_account_params(sku_name, location, replication, encryption_enabled)
|
|
27
|
+
def get_storage_account_params(sku_name, location, replication, encryption_enabled, tags)
|
|
27
28
|
params = Azure::ARM::Storage::Models::StorageAccountCreateParameters.new
|
|
28
29
|
sku = Azure::ARM::Storage::Models::Sku.new
|
|
29
30
|
sku.name = "#{sku_name}_#{replication}"
|
|
@@ -40,6 +41,7 @@ module Fog
|
|
|
40
41
|
encryption.services = encryption_services
|
|
41
42
|
params.encryption = encryption
|
|
42
43
|
end
|
|
44
|
+
params.tags = tags
|
|
43
45
|
params
|
|
44
46
|
end
|
|
45
47
|
end
|
|
@@ -6,9 +6,18 @@ module Fog
|
|
|
6
6
|
def create_or_update_traffic_manager_profile(profile_hash)
|
|
7
7
|
msg = "Creating Traffic Manager Profile: #{profile_hash[:name]}."
|
|
8
8
|
Fog::Logger.debug msg
|
|
9
|
-
profile_parameters = get_profile_object(profile_hash[:traffic_routing_method],
|
|
9
|
+
profile_parameters = get_profile_object(profile_hash[:traffic_routing_method],
|
|
10
|
+
profile_hash[:relative_name],
|
|
11
|
+
profile_hash[:ttl],
|
|
12
|
+
profile_hash[:protocol],
|
|
13
|
+
profile_hash[:port],
|
|
14
|
+
profile_hash[:path],
|
|
15
|
+
profile_hash[:endpoints],
|
|
16
|
+
profile_hash[:tags])
|
|
10
17
|
begin
|
|
11
|
-
traffic_manager_profile = @traffic_mgmt_client.profiles.create_or_update(profile_hash[:resource_group],
|
|
18
|
+
traffic_manager_profile = @traffic_mgmt_client.profiles.create_or_update(profile_hash[:resource_group],
|
|
19
|
+
profile_hash[:name],
|
|
20
|
+
profile_parameters)
|
|
12
21
|
rescue MsRestAzure::AzureOperationError => e
|
|
13
22
|
raise_azure_exception(e, msg)
|
|
14
23
|
end
|
|
@@ -18,7 +27,7 @@ module Fog
|
|
|
18
27
|
|
|
19
28
|
private
|
|
20
29
|
|
|
21
|
-
def get_profile_object(traffic_routing_method, relative_name, ttl, protocol, port, path, endpoints)
|
|
30
|
+
def get_profile_object(traffic_routing_method, relative_name, ttl, protocol, port, path, endpoints, tags)
|
|
22
31
|
traffic_manager_profile = Azure::ARM::TrafficManager::Models::Profile.new
|
|
23
32
|
traffic_manager_profile.traffic_routing_method = traffic_routing_method
|
|
24
33
|
traffic_manager_profile.location = GLOBAL
|
|
@@ -26,6 +35,7 @@ module Fog
|
|
|
26
35
|
traffic_manager_profile.dns_config = get_traffic_manager_dns_config(relative_name, ttl)
|
|
27
36
|
traffic_manager_profile.monitor_config = get_traffic_manager_monitor_config(protocol, port, path)
|
|
28
37
|
traffic_manager_profile.endpoints = get_endpoints(endpoints) unless endpoints.nil?
|
|
38
|
+
traffic_manager_profile.tags = tags
|
|
29
39
|
traffic_manager_profile
|
|
30
40
|
end
|
|
31
41
|
|
data/lib/fog/azurerm/storage.rb
CHANGED
|
@@ -64,32 +64,13 @@ module Fog
|
|
|
64
64
|
request :save_page_blob
|
|
65
65
|
request :multipart_save_block_blob
|
|
66
66
|
|
|
67
|
-
# Azure Recovery Vault requests
|
|
68
|
-
request :create_or_update_recovery_vault
|
|
69
|
-
request :get_recovery_vault
|
|
70
|
-
request :list_recovery_vaults
|
|
71
|
-
request :delete_recovery_vault
|
|
72
|
-
request :enable_backup_protection
|
|
73
|
-
request :set_recovery_vault_context
|
|
74
|
-
request :get_backup_protection_policy
|
|
75
|
-
request :start_backup
|
|
76
|
-
request :get_backup_item
|
|
77
|
-
request :get_backup_container
|
|
78
|
-
request :disable_backup_protection
|
|
79
|
-
request :get_all_backup_jobs
|
|
80
|
-
request :get_all_backup_jobs
|
|
81
|
-
request :get_backup_job_for_vm
|
|
82
|
-
|
|
83
67
|
model_path 'fog/azurerm/models/storage'
|
|
84
68
|
model :storage_account
|
|
85
69
|
collection :storage_accounts
|
|
86
|
-
model :data_disk
|
|
87
70
|
model :directory
|
|
88
71
|
collection :directories
|
|
89
72
|
model :file
|
|
90
73
|
collection :files
|
|
91
|
-
model :recovery_vault
|
|
92
|
-
collection :recovery_vaults
|
|
93
74
|
|
|
94
75
|
# This class provides the mock implementation for unit tests.
|
|
95
76
|
class Mock
|
data/lib/fog/azurerm/version.rb
CHANGED
data/test/api_stub.rb
CHANGED
|
@@ -18,7 +18,6 @@ module ApiStub
|
|
|
18
18
|
autoload :StorageAccount, File.expand_path('api_stub/models/storage/storageaccount', __dir__)
|
|
19
19
|
autoload :File, ::File.expand_path('api_stub/models/storage/file', __dir__)
|
|
20
20
|
autoload :Directory, ::File.expand_path('api_stub/models/storage/directory', __dir__)
|
|
21
|
-
autoload :RecoveryVault, ::File.expand_path('api_stub/models/storage/recovery_vault', __dir__)
|
|
22
21
|
end
|
|
23
22
|
|
|
24
23
|
module Network
|
|
@@ -81,7 +80,6 @@ module ApiStub
|
|
|
81
80
|
autoload :StorageAccount, File.expand_path('api_stub/requests/storage/storageaccount', __dir__)
|
|
82
81
|
autoload :File, ::File.expand_path('api_stub/requests/storage/file', __dir__)
|
|
83
82
|
autoload :Directory, ::File.expand_path('api_stub/requests/storage/directory', __dir__)
|
|
84
|
-
autoload :RecoveryVault, ::File.expand_path('api_stub/requests/storage/recovery_vault', __dir__)
|
|
85
83
|
end
|
|
86
84
|
|
|
87
85
|
module Network
|
|
@@ -124,6 +124,68 @@ module ApiStub
|
|
|
124
124
|
compute_client.deserialize(vm_mapper, Fog::JSON.decode(body), 'result.body').value
|
|
125
125
|
end
|
|
126
126
|
|
|
127
|
+
def self.attach_managed_disk_response(compute_client)
|
|
128
|
+
body = {
|
|
129
|
+
'id' => '/subscriptions/########-####-####-####-############/resourceGroups/fog-test-rg/providers/Microsoft.Compute/virtualMachines/fog-test-server',
|
|
130
|
+
'name' => 'fog-test-server',
|
|
131
|
+
'location' => 'West US',
|
|
132
|
+
'properties' => {
|
|
133
|
+
'hardwareProfile' => {
|
|
134
|
+
'vmSize' => 'Basic_A0'
|
|
135
|
+
},
|
|
136
|
+
'storageProfile' => {
|
|
137
|
+
'imageReference' => {
|
|
138
|
+
'publisher' => 'Canonical',
|
|
139
|
+
'offer' => 'UbuntuServer',
|
|
140
|
+
'sku' => '14.04.2-LTS',
|
|
141
|
+
'version' => 'latest'
|
|
142
|
+
},
|
|
143
|
+
'osDisk' => {
|
|
144
|
+
'name' => 'fog-test-server_os_disk',
|
|
145
|
+
'vhd' => {
|
|
146
|
+
'uri' => 'http://storageAccount.blob.core.windows.net/vhds/fog-test-server_os_disk.vhd'
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
'dataDisks' => [
|
|
150
|
+
{
|
|
151
|
+
'name' => 'disk1',
|
|
152
|
+
'diskSizeGB' => '10',
|
|
153
|
+
'lun' => 0,
|
|
154
|
+
'vhd' => {
|
|
155
|
+
'uri' => 'http://mystorage1.blob.core.windows.net/vhds/disk1.vhd'
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
'lun' => 1, # add new managed datadisk
|
|
160
|
+
'name' => 'datadisk2',
|
|
161
|
+
'managedDisk' => {
|
|
162
|
+
'id' => '/subscriptions/{subscription-id}/resourceGroups/myresourcegroup1/providers/Microsoft.Compute/disks/myDisk2',
|
|
163
|
+
'storageAccountType' => 'Standard_LRS'
|
|
164
|
+
},
|
|
165
|
+
'createOption' => 'attach'
|
|
166
|
+
}
|
|
167
|
+
]
|
|
168
|
+
},
|
|
169
|
+
'osProfile' => {
|
|
170
|
+
'computerName' => 'fog-test-server',
|
|
171
|
+
'adminUsername' => 'shaffan',
|
|
172
|
+
'linuxConfiguration' => {
|
|
173
|
+
'disablePasswordAuthentication' => false
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
'networkProfile' => {
|
|
177
|
+
'networkInterfaces' => [
|
|
178
|
+
{
|
|
179
|
+
'id' => '/subscriptions/########-####-####-####-############/resourceGroups/fog-test-rg/providers/Microsoft.Network/networkInterfaces/fogtestnetworkinterface'
|
|
180
|
+
}
|
|
181
|
+
]
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
vm_mapper = Azure::ARM::Compute::Models::VirtualMachine.mapper
|
|
186
|
+
compute_client.deserialize(vm_mapper, body, 'result.body')
|
|
187
|
+
end
|
|
188
|
+
|
|
127
189
|
def self.attach_data_disk_response(compute_client)
|
|
128
190
|
body = {
|
|
129
191
|
'id' => '/subscriptions/########-####-####-####-############/resourceGroups/fog-test-rg/providers/Microsoft.Compute/virtualMachines/fog-test-server',
|