lib/fog/azurerm/requests/network/create_virtual_network.rb in fog-azure-rm-0.0.1 vs lib/fog/azurerm/requests/network/create_virtual_network.rb in fog-azure-rm-0.0.2

- old
+ new

@@ -1,16 +1,19 @@ module Fog module Network class AzureRM class Real - def create_virtual_network(name, location, resource_group_name, dns_list, subnet_address_list, network_address_list) + 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 - promise = @network_client.virtual_networks.create_or_update(resource_group_name, name, virtual_network) - promise.value! + promise = @network_client.virtual_networks.create_or_update(resource_group, name, virtual_network) + result = promise.value! + Fog::Logger.debug "Virtual Network #{name} created successfully." + Azure::ARM::Network::Models::VirtualNetwork.serialize_object(result.body) rescue MsRestAzure::AzureOperationError => e - msg = "Exception creating Virtual Network #{name} in Resource Group: #{resource_group_name}. #{e.body['error']['message']}" + msg = "Exception creating Virtual Network #{name} in Resource Group: #{resource_group}. #{e.body['error']['message']}" raise msg end end private @@ -70,10 +73,42 @@ sub_nets end end class Mock - def create_virtual_network(_name, _location, _dns_list, _subnet_address_list, _network_address_list, _resource_group_name) + 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, + 'properties' => + { + 'addressSpace' => + { + 'addressPrefixes' => + [ + network_address_list + ] + }, + 'subnets' => + [ + { + 'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group}providers/Microsoft.Network/virtualNetworks/#{name}/subnets/subnet_0_#{name}", + 'properties' => + { + 'addressPrefix' => subnet_address_list, + 'provisioningState' => 'Succeeded' + }, + 'name' => "subnet_0_#{name}", + 'etag' => "W/\"ffbb0f61-b2bb-404e-9d20-79d854536f62\"" + } + ], + 'resourceGuid' => 'c573f8e2-d916-493f-8b25-a681c31269ef', + 'provisioningState' => 'Succeeded' + }, + 'etag' => "W/\"ffbb0f61-b2bb-404e-9d20-79d854536f62\"" + } end end end end end