lib/fog/azurerm/requests/network/get_network_interface.rb in fog-azure-rm-0.0.4 vs lib/fog/azurerm/requests/network/get_network_interface.rb in fog-azure-rm-0.0.5
- old
+ new
@@ -2,26 +2,24 @@
module Network
class AzureRM
# Real class for Network Interface Request
class Real
def get_network_interface(resource_group_name, nic_name)
- Fog::Logger.debug "Getting Network Interface#{nic_name} from Resource Group #{resource_group_name}."
+ msg = "Getting Network Interface#{nic_name} from Resource Group #{resource_group_name}"
+ Fog::Logger.debug msg
begin
- promise = @network_client.network_interfaces.get(resource_group_name, nic_name)
- result = promise.value!
- Azure::ARM::Network::Models::NetworkInterface.serialize_object(result.body)
+ @network_client.network_interfaces.get(resource_group_name, nic_name)
rescue MsRestAzure::AzureOperationError => e
- msg = "Exception getting Network Interface #{nic_name} from Resource Group '#{resource_group_name}'. #{e.body['error']['message']}."
- raise msg
+ raise_azure_exception(e, msg)
end
end
end
# Mock class for Network Interface Request
class Mock
def get_network_interface(resource_group_name, nic_name)
- {
+ nic = {
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group_name}/providers/Microsoft.Network/networkInterfaces/#{nic_name}",
'name' => nic_name,
'type' => 'Microsoft.Network/networkInterfaces',
'location' => 'westus',
'properties' =>
@@ -51,9 +49,11 @@
'enableIPForwarding' => false,
'resourceGuid' => '51e01337-fb15-4b04-b9de-e91537c764fd',
'provisioningState' => 'Succeeded'
}
}
+ network_interface_mapper = Azure::ARM::Network::Models::NetworkInterface.mapper
+ @network_client.deserialize(network_interface_mapper, nic, 'result.body')
end
end
end
end
end