From ed6952fbf7270ef48b645964c03ff00ab34b2eee Mon Sep 17 00:00:00 2001 From: Ohad Levy Date: Mon, 9 Apr 2012 16:41:23 +0300 Subject: [PATCH] [libvirt] makes libvirt code more debian friendly debian based libvirt does not know interfaces and some node information --- lib/fog/libvirt/requests/compute/get_node_info.rb | 4 ++-- lib/fog/libvirt/requests/compute/list_interfaces.rb | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/fog/libvirt/requests/compute/get_node_info.rb b/lib/fog/libvirt/requests/compute/get_node_info.rb index 6cff387f1..1d1d037da 100644 --- a/lib/fog/libvirt/requests/compute/get_node_info.rb +++ b/lib/fog/libvirt/requests/compute/get_node_info.rb @@ -12,10 +12,10 @@ module Fog node_hash[param] = client.send(param) rescue nil end node_hash[:uri] = client.uri - xml = client.sys_info + xml = client.sys_info rescue nil [:uuid, :manufacturer, :product, :serial].each do |attr| node_hash[attr] = node_attr(attr, xml) - end + end if xml node_hash[:hostname] = client.hostname [node_hash] diff --git a/lib/fog/libvirt/requests/compute/list_interfaces.rb b/lib/fog/libvirt/requests/compute/list_interfaces.rb index 2b1d1b21a..2af2ff6b4 100644 --- a/lib/fog/libvirt/requests/compute/list_interfaces.rb +++ b/lib/fog/libvirt/requests/compute/list_interfaces.rb @@ -5,7 +5,9 @@ module Fog def list_interfaces(filter = { }) data=[] if filter.keys.empty? - (client.list_interfaces + client.list_defined_interfaces).each do |ifname| + active_networks = client.list_interfaces rescue [] + defined_networks = client.list_defined_interfaces rescue [] + (active_networks + defined_networks).each do |ifname| data << interface_to_attributes(client.lookup_interface_by_name(ifname)) end else