summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSoren Hansen <soren@linux2go.dk>2011-03-16 12:18:15 +0100
committerSoren Hansen <soren@linux2go.dk>2011-03-16 12:18:15 +0100
commitaf2cae27930a3983c96a0b1705f828d65d4829cd (patch)
tree213c2dc4eeec4c0e531fa523680b0285192e52e6
parentd36b4d5f3797521b1c2d13a0d30fe98a0671768e (diff)
downloadnova-af2cae27930a3983c96a0b1705f828d65d4829cd.tar.gz
nova-af2cae27930a3983c96a0b1705f828d65d4829cd.tar.xz
nova-af2cae27930a3983c96a0b1705f828d65d4829cd.zip
Fix a couple of things that assume that libvirt == kvm/qemu.
-rwxr-xr-xbin/nova-manage4
-rw-r--r--nova/virt/libvirt_conn.py42
2 files changed, 30 insertions, 16 deletions
diff --git a/bin/nova-manage b/bin/nova-manage
index 2b42dfff5..c84891619 100755
--- a/bin/nova-manage
+++ b/bin/nova-manage
@@ -574,7 +574,9 @@ class VmCommands(object):
ctxt = context.get_admin_context()
instance_id = ec2utils.ec2_id_to_id(ec2_id)
- if FLAGS.connection_type != 'libvirt':
+ if (FLAGS.connection_type != 'libvirt' or
+ (FLAGS.connection_type == 'libvirt' and
+ FLAGS.libvirt_type not in ['kvm', 'qemu'])):
msg = _('Only KVM is supported for now. Sorry!')
raise exception.Error(msg)
diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py
index 7994e9547..96463d0f2 100644
--- a/nova/virt/libvirt_conn.py
+++ b/nova/virt/libvirt_conn.py
@@ -991,23 +991,35 @@ class LibvirtConnection(object):
+ xml.serialize())
cpu_info = dict()
- cpu_info['arch'] = xml.xpathEval('//cpu/arch')[0].getContent()
- cpu_info['model'] = xml.xpathEval('//cpu/model')[0].getContent()
- cpu_info['vendor'] = xml.xpathEval('//cpu/vendor')[0].getContent()
- topology_node = xml.xpathEval('//cpu/topology')[0].get_properties()
+ arch_nodes = xml.xpathEval('//cpu/arch')
+ if len(arch_nodes):
+ cpu_info['arch'] = arch_nodes[0].getContent()
+
+ model_nodes = xml.xpathEval('//cpu/model')
+ if len(model_nodes):
+ cpu_info['model'] = model_nodes[0].getContent()
+
+ vendor_nodes = xml.xpathEval('//cpu/vendor')
+ if len(vendor_nodes):
+ cpu_info['vendor'] = vendor_nodes[0].getContent()
+
+ topology_nodes = xml.xpathEval('//cpu/topology')
topology = dict()
- while topology_node != None:
- name = topology_node.get_name()
- topology[name] = topology_node.getContent()
- topology_node = topology_node.get_next()
-
- keys = ['cores', 'sockets', 'threads']
- tkeys = topology.keys()
- if list(set(tkeys)) != list(set(keys)):
- ks = ', '.join(keys)
- raise exception.Invalid(_("Invalid xml: topology(%(topology)s) "
- "must have %(ks)s") % locals())
+ if len(topology_nodes):
+ topology_node = topology_nodes[0].get_properties()
+ while topology_node != None:
+ name = topology_node.get_name()
+ topology[name] = topology_node.getContent()
+ topology_node = topology_node.get_next()
+
+ keys = ['cores', 'sockets', 'threads']
+ tkeys = topology.keys()
+ if list(set(tkeys)) != list(set(keys)):
+ ks = ', '.join(keys)
+ raise exception.Invalid(_("Invalid xml: topology(%(topology)s) "
+ "must have %(ks)s") % locals())
+
feature_nodes = xml.xpathEval('//cpu/feature')
features = list()