lib/fog/azurerm/requests/network/get_subnet.rb in fog-azure-rm-0.0.4 vs lib/fog/azurerm/requests/network/get_subnet.rb in fog-azure-rm-0.0.5
- old
+ new
@@ -2,34 +2,35 @@
module Network
class AzureRM
# Real class for Network Request
class Real
def get_subnet(resource_group, virtual_network_name, subnet_name)
- Fog::Logger.debug "Getting Subnet: #{subnet_name}."
+ msg = "Getting Subnet: #{subnet_name}."
+ Fog::Logger.debug msg
begin
- promise = @network_client.subnets.get(resource_group, virtual_network_name, subnet_name)
- result = promise.value!
- Fog::Logger.debug "Subnet #{subnet_name} retrieved successfully."
- Azure::ARM::Network::Models::Subnet.serialize_object(result.body)
- rescue MsRestAzure::AzureOperationError => e
- msg = "Exception getting Subnet #{subnet_name} in Resource Group: #{resource_group}. #{e.body['error']['message']}"
- raise msg
+ subnet = @network_client.subnets.get(resource_group, virtual_network_name, subnet_name)
+ rescue MsRestAzure::AzureOperationError => e
+ raise_azure_exception(e, msg)
end
+ Fog::Logger.debug "Subnet #{subnet_name} retrieved successfully."
+ subnet
end
end
# Mock class for Network Request
class Mock
def get_subnet(*)
- {
+ subnet = {
'id' => '/subscriptions/########-####-####-####-############/resourceGroups/fog-rg/providers/Microsoft.Network/virtualNetworks/fog-vnet/subnets/fog-subnet',
'properties' =>
{
'addressPrefix' => '10.1.0.0/24',
'provisioningState' => 'Succeeded'
},
'name' => 'fog-subnet'
}
+ subnet_mapper = Azure::ARM::Network::Models::Subnet.mapper
+ @network_client.deserialize(subnet_mapper, subnet, 'result.body')
end
end
end
end
end