Martin Polednik has uploaded a new change for review.

Change subject: caps: remove CPU map parsing
......................................................................

caps: remove CPU map parsing

Because nowadays the cluster is an atomic migration unit and same cpu
vendors across cluster is enforced, it doesn't make sense to limit the
possible baselines processors for the host.

Change-Id: Ic5dc42d8bbf3c5a48b1bc4fb3dade59c94b24e7f
Signed-off-by: Martin Polednik <[email protected]>
---
M vdsm/caps.py
1 file changed, 5 insertions(+), 59 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/57/42757/1

diff --git a/vdsm/caps.py b/vdsm/caps.py
index dc85ea5..413a980 100644
--- a/vdsm/caps.py
+++ b/vdsm/caps.py
@@ -53,7 +53,6 @@
     python_apt = False
 
 PAGE_SIZE_BYTES = os.sysconf('SC_PAGESIZE')
-CPU_MAP_FILE = '/usr/share/libvirt/cpu_map.xml'
 
 try:
     from gluster.api import GLUSTER_RPM_PACKAGES
@@ -402,66 +401,13 @@
     return []
 
 
-def _getAllCpuModels(capfile=CPU_MAP_FILE, arch=None):
-
-    with open(capfile) as xml:
-        cpu_map = ET.fromstring(xml.read())
-
-    if arch is None:
-        arch = platform.machine()
-
-    # In libvirt CPU map XML, both x86_64 and x86 are
-    # the same architecture, so in order to find all
-    # the CPU models for this architecture, 'x86'
-    # must be used
-    if arch == Architecture.X86_64:
-        arch = 'x86'
-
-    # Same goes for ppc64le
-    if arch == Architecture.PPC64LE:
-        arch = 'ppc64'
-
-    architectureElement = None
-
-    architectureElements = cpu_map.findall('arch')
-
-    if architectureElements:
-        for a in architectureElements:
-            if a.get('name') == arch:
-                architectureElement = a
-
-    if architectureElement is None:
-        logging.error('Error while getting all CPU models: the host '
-                      'architecture is not supported', exc_info=True)
-        return {}
-
-    allModels = dict()
-
-    for m in architectureElement.findall('model'):
-        element = m.find('vendor')
-        if element is not None:
-            vendor = element.get('name')
-        else:
-            element = m.find('model')
-            if element is None:
-                vendor = None
-            else:
-                elementName = element.get('name')
-                vendor = allModels.get(elementName, None)
-        allModels[m.get('name')] = vendor
-    return allModels
-
-
 @utils.memoized
 def _getCompatibleCpuModels():
     c = libvirtconnection.get()
-    allModels = _getAllCpuModels()
+    allModels = c.getCPUModelNames(platform.machine())
 
-    def compatible(model, vendor):
-        if not vendor:
-            return False
-        xml = '<cpu match="minimum"><model>%s</model>' \
-              '<vendor>%s</vendor></cpu>' % (model, vendor)
+    def compatible(model):
+        xml = '<cpu match="minimum"><model>%s</model></cpu>' % (model)
         try:
             return c.compareCPU(xml, 0) in (libvirt.VIR_CPU_COMPARE_SUPERSET,
                                             libvirt.VIR_CPU_COMPARE_IDENTICAL)
@@ -471,8 +417,8 @@
                 return False
             raise
 
-    return ['model_' + model for (model, vendor)
-            in allModels.iteritems() if compatible(model, vendor)]
+    return ['model_' + model for model
+            in allModels if compatible(model)]
 
 
 def _parseKeyVal(lines, delim='='):


-- 
To view, visit https://gerrit.ovirt.org/42757
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic5dc42d8bbf3c5a48b1bc4fb3dade59c94b24e7f
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to