lib/fog/azurerm/requests/network/create_virtual_network.rb in fog-azure-rm-0.0.2 vs lib/fog/azurerm/requests/network/create_virtual_network.rb in fog-azure-rm-0.0.3
- old
+ new
@@ -1,8 +1,9 @@
module Fog
module Network
class AzureRM
+ # Real class for Network Request
class Real
def create_virtual_network(resource_group, name, location, dns_list, subnet_address_list, network_address_list)
Fog::Logger.debug "Creating Virtual Network: #{name}..."
virtual_network = define_vnet_object(location, name, network_address_list, dns_list, subnet_address_list)
begin
@@ -24,21 +25,21 @@
virtual_network_properties = Azure::ARM::Network::Models::VirtualNetworkPropertiesFormat.new
if network_address_list.nil?
address_space = Azure::ARM::Network::Models::AddressSpace.new
address_space.address_prefixes = ['10.2.0.0/16']
- virtual_network_properties.address_space = address_space
+
else
network_address_list = network_address_list.split(',')
na_list = []
(0...network_address_list.length).each do |i|
na_list.push(network_address_list[i].strip)
end
address_space = Azure::ARM::Network::Models::AddressSpace.new
address_space.address_prefixes = na_list
- virtual_network_properties.address_space = address_space
end
+ virtual_network_properties.address_space = address_space
unless dns_list.nil?
dns_list = dns_list.split(',')
ns_list = []
(0...dns_list.length).each do |i|
@@ -72,12 +73,13 @@
end
sub_nets
end
end
+ # Mock class for Network Request
class Mock
- def create_virtual_network(resource_group, name, location, dns_list, subnet_address_list, network_address_list)
+ def create_virtual_network(resource_group, name, location, _dns_list, subnet_address_list, network_address_list)
{
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group}/providers/Microsoft.Network/virtualNetworks/#{name}",
'name' => name,
'type' => 'Microsoft.Network/virtualNetworks',
'location' => location,
@@ -85,11 +87,11 @@
{
'addressSpace' =>
{
'addressPrefixes' =>
[
- network_address_list
+ network_address_list
]
},
'subnets' =>
[
{
@@ -97,17 +99,15 @@
'properties' =>
{
'addressPrefix' => subnet_address_list,
'provisioningState' => 'Succeeded'
},
- 'name' => "subnet_0_#{name}",
- 'etag' => "W/\"ffbb0f61-b2bb-404e-9d20-79d854536f62\""
- }
+ 'name' => "subnet_0_#{name}"
+ }
],
'resourceGuid' => 'c573f8e2-d916-493f-8b25-a681c31269ef',
'provisioningState' => 'Succeeded'
- },
- 'etag' => "W/\"ffbb0f61-b2bb-404e-9d20-79d854536f62\""
+ }
}
end
end
end
end