[node-patches] Change in ovirt-node[master]: handle case where there missing are cpu details
mburns at redhat.com
mburns at redhat.com
Tue Dec 18 15:31:51 UTC 2012
Michael Burns has uploaded a new change for review.
Change subject: handle case where there missing are cpu details
......................................................................
handle case where there missing are cpu details
1. Look only at the <cpu> section in the virsh capabilities
otherwise, it could pull info from the wrong section
2. put try/except block around each lookup
vendor, model, topology
3. Print Unknown for each if we can't determine it from xml
4. If we don't know the vendow, don't print anything for
NX or EVP
rhbz#887149
Change-Id: I1811bb17bf48d66cf601f564fd6cb75af681e004
Signed-off-by: Mike Burns <mburns at redhat.com>
---
M scripts/ovirtnode/ovirtfunctions.py
1 file changed, 18 insertions(+), 7 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/04/10204/1
diff --git a/scripts/ovirtnode/ovirtfunctions.py b/scripts/ovirtnode/ovirtfunctions.py
index b5cd75b..4f344a6 100644
--- a/scripts/ovirtnode/ovirtfunctions.py
+++ b/scripts/ovirtnode/ovirtfunctions.py
@@ -1381,12 +1381,23 @@
except:
return "(Failed to Establish Libvirt Connection)"
dom = parseString(libvirt_capabilities)
- vendorTag = dom.getElementsByTagName('vendor')[0].toxml()
- modelTag = dom.getElementsByTagName('model')[0].toxml()
- topologyTag = dom.getElementsByTagName('topology')[0].toxml()
- cpu_model = modelTag.replace('<model>','').replace('</model>','')
- cpu_vendor = vendorTag.replace('<vendor>','').replace('</vendor>','')
- cpu_topology = topologyTag.replace('<topology>','').replace('</topology>','').split()
+ # get cpu section
+ cpu = parseString(dom.getElementsByTagName('cpu'))
+ try:
+ vendorTag = cpu.getElementsByTagName('vendor')[0].toxml()
+ cpu_vendor = vendorTag.replace('<vendor>','').replace('</vendor>','')
+ except:
+ cpu_vendor = "Unknown"
+ try:
+ modelTag = cpu.getElementsByTagName('model')[0].toxml()
+ cpu_model = modelTag.replace('<model>','').replace('</model>','')
+ except:
+ cpu_model = "Unknown"
+ try:
+ topologyTag = cpu.getElementsByTagName('topology')[0].toxml()
+ cpu_topology = topologyTag.replace('<topology>','').replace('</topology>','').split()
+ except:
+ cpu_topology = "Unknown"
status_msg += "CPU Name: %s\n" % cpu_dict["model name"].replace(" "," ")
status_msg += "CPU Type: %s %s\n" % (cpu_vendor, cpu_model)
if kvm_enabled() == 1 and virt_cpu_flags_enabled():
@@ -1399,7 +1410,7 @@
status_msg += "NX Flag: Yes\n"
else:
status_msg += "NX Flag: No\n"
- if cpu_vendor == "AMD":
+ elif cpu_vendor == "AMD":
if "evp" in cpu_dict["flags"]:
status_msg += "EVP Flag: Yes\n"
else:
--
To view, visit http://gerrit.ovirt.org/10204
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1811bb17bf48d66cf601f564fd6cb75af681e004
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Michael Burns <mburns at redhat.com>
More information about the node-patches
mailing list