Change in vdsm[master]: machinetype: reorganize and rename private functions
mpolednik at redhat.com
mpolednik at redhat.com
Thu Mar 3 13:39:24 UTC 2016
Martin Polednik has uploaded a new change for review.
Change subject: machinetype: reorganize and rename private functions
......................................................................
machinetype: reorganize and rename private functions
This patch renames the private function to better reflect what they
actually do - _get_*_{object} is now called _*_caps_{object}. they are
also moved to the bottom of the module for better comfort of people
reading the module.
Change-Id: Ib0497a62e42926158ed9edd7e2a9782f780cfa45
Signed-off-by: Martin Polednik <mpolednik at redhat.com>
---
M lib/vdsm/machinetype.py
1 file changed, 36 insertions(+), 36 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/00/54300/1
diff --git a/lib/vdsm/machinetype.py b/lib/vdsm/machinetype.py
index 69f8b71..3f9e6ea 100644
--- a/lib/vdsm/machinetype.py
+++ b/lib/vdsm/machinetype.py
@@ -34,40 +34,6 @@
CPU_MAP_FILE = '/usr/share/libvirt/cpu_map.xml'
-def _get_emulated_machines_from_node(node):
- # We have to make sure to inspect 'canonical' attribute where
- # libvirt puts the real machine name. Relevant bug:
- # https://bugzilla.redhat.com/show_bug.cgi?id=1229666
- return list(set((itertools.chain.from_iterable(
- (
- (m.text, m.get('canonical'))
- if m.get('canonical') else
- (m.text,)
- )
- for m in node.iterfind('machine')))))
-
-
-def _get_emulated_machines_from_arch(arch, caps):
- arch_tag = caps.find('.//guest/arch[@name="%s"]' % arch)
- if not arch_tag:
- logging.error('Error while looking for architecture '
- '"%s" in libvirt capabilities', arch)
- return []
-
- return _get_emulated_machines_from_node(arch_tag)
-
-
-def _get_emulated_machines_from_domain(arch, caps):
- domain_tag = caps.find(
- './/guest/arch[@name="%s"]/domain[@type="kvm"]' % arch)
- if not domain_tag:
- logging.error('Error while looking for kvm domain (%s) '
- 'libvirt capabilities', arch)
- return []
-
- return _get_emulated_machines_from_node(domain_tag)
-
-
@utils.memoized
def emulated_machines(arch, capabilities=None):
if capabilities is None:
@@ -77,8 +43,8 @@
# machine list from domain can legally be empty
# (e.g. only qemu-kvm installed)
# in that case it is fine to use machines list from arch
- return (_get_emulated_machines_from_domain(arch, caps) or
- _get_emulated_machines_from_arch(arch, caps))
+ return (_emulated_machines_from_caps_domain(arch, caps) or
+ _emulated_machines_from_caps_arch(arch, caps))
def cpu_models(capfile=CPU_MAP_FILE, arch=None):
@@ -153,6 +119,40 @@
in all_models.iteritems() if compatible(model, vendor)]
+def _emulated_machines_from_caps_node(node):
+ # We have to make sure to inspect 'canonical' attribute where
+ # libvirt puts the real machine name. Relevant bug:
+ # https://bugzilla.redhat.com/show_bug.cgi?id=1229666
+ return list(set((itertools.chain.from_iterable(
+ (
+ (m.text, m.get('canonical'))
+ if m.get('canonical') else
+ (m.text,)
+ )
+ for m in node.iterfind('machine')))))
+
+
+def _emulated_machines_from_caps_arch(arch, caps):
+ arch_tag = caps.find('.//guest/arch[@name="%s"]' % arch)
+ if not arch_tag:
+ logging.error('Error while looking for architecture '
+ '"%s" in libvirt capabilities', arch)
+ return []
+
+ return _emulated_machines_from_caps_node(arch_tag)
+
+
+def _emulated_machines_from_caps_domain(arch, caps):
+ domain_tag = caps.find(
+ './/guest/arch[@name="%s"]/domain[@type="kvm"]' % arch)
+ if not domain_tag:
+ logging.error('Error while looking for kvm domain (%s) '
+ 'libvirt capabilities', arch)
+ return []
+
+ return _emulated_machines_from_caps_node(domain_tag)
+
+
def _get_libvirt_caps():
conn = libvirtconnection.get()
return conn.getCapabilities()
--
To view, visit https://gerrit.ovirt.org/54300
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib0497a62e42926158ed9edd7e2a9782f780cfa45
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <mpolednik at redhat.com>
More information about the vdsm-patches
mailing list