Laszlo Hornyak has uploaded a new change for review.

Change subject: proposed cleanup for Amador's patch
......................................................................

proposed cleanup for Amador's patch

This is a cleanup proposal for Amador's patch:
http://gerrit.ovirt.org/#/c/5481/15

The original patch refers to topology element of the <host> node in the
capabilities output, which my be confusing, because there are two of
them:
 - the first is in the <cpu> node, this is the one that is expected
 - the second is right under the <host> node
Therefore the logic builds on their order, but this may be confusing.

Also, added a logging in case the computation fails.

Change-Id: I677f13e9a511bb1652dbbb84fe672714215e5aa8
Signed-off-by: Laszlo Hornyak <[email protected]>
---
M vdsm/caps.py
1 file changed, 7 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/02/8302/1

diff --git a/vdsm/caps.py b/vdsm/caps.py
index c5cb7cb..a26b22e 100644
--- a/vdsm/caps.py
+++ b/vdsm/caps.py
@@ -108,17 +108,18 @@
         try:
             c = libvirtconnection.get()
             caps = minidom.parseString(c.getCapabilities())
-            host = caps.getElementsByTagName('host')
-            host = host[0]
+            host = caps.getElementsByTagName('host')[0]
+            cpu = host.getElementsByTagName('cpu')[0]
             topology = {'numa': int(host.getElementsByTagName('cells')[0].
                                                       getAttribute('num')),
-                        'socket': int(host.getElementsByTagName('topology')[0].
+                        'socket': int(cpu.getElementsByTagName('topology')[0].
                                                       getAttribute('sockets')),
-                        'core': int(host.getElementsByTagName('topology')[0].
+                        'core': int(cpu.getElementsByTagName('topology')[0].
                                                       getAttribute('cores')),
-                        'thread': int(host.getElementsByTagName('topology')[0].
+                        'thread': int(cpu.getElementsByTagName('topology')[0].
                                                       getAttribute('threads'))}
-        except:
+        except BaseException, e:
+            logging.error('error calculating the topology data: %s',e)
             # During tests/make rpm, libvirt may not be available/configured.
             # Hack arround it.
             topology = {'numa': 1,


--
To view, visit http://gerrit.ovirt.org/8302
To unsubscribe, visit http://gerrit.ovirt.org/settings

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

Reply via email to