aboutsummaryrefslogtreecommitdiff
path: root/libvirt-mem
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2020-03-30 10:08:06 +0200
committerGuido Günther <agx@sigxcpu.org>2020-03-30 10:11:47 +0200
commit1c4a4fb84bf470709541067665dbc232e2c12dd3 (patch)
tree32f9832b73be1f06b48af515d853b259dd28e075 /libvirt-mem
parent35be326f61d8cedbd506ed78463fb182a245bc25 (diff)
flake8 cleanups
Diffstat (limited to 'libvirt-mem')
-rw-r--r--libvirt-mem18
1 files changed, 11 insertions, 7 deletions
diff --git a/libvirt-mem b/libvirt-mem
index 83dea77..a789326 100644
--- a/libvirt-mem
+++ b/libvirt-mem
@@ -18,9 +18,11 @@ import re, sys, os
import libxml2
import libvirt
+
def canon(name):
return re.sub(r"[^a-zA-Z0-9_]", "_", name)
+
def print_config(uri):
"""print the plugin config, determine the domains"""
try:
@@ -116,13 +118,14 @@ total_soft_limit_pc.min 0
return 0
+
def get_memtune(dom):
- memtune = { 'min_guarantee': 0, 'soft_limit': 0, 'hard_limit': 0 }
+ memtune = {'min_guarantee': 0, 'soft_limit': 0, 'hard_limit': 0}
xml = dom.XMLDesc(0)
try:
doc = libxml2.parseDoc(xml)
- except:
+ except Exception:
return []
ctx = doc.xpathNewContext()
@@ -134,12 +137,12 @@ def get_memtune(dom):
memtune[key] = int(child.content)
break
except IndexError:
- # key not found in xml
- pass
+ # key not found in xml
+ pass
finally:
- if ctx != None:
+ if ctx is not None:
ctx.xpathFreeContext()
- if doc != None:
+ if doc is not None:
doc.freeDoc()
return memtune
@@ -197,7 +200,7 @@ def main(sys):
uri = os.getenv("uri", "qemu:///system")
if len(sys) > 1:
- if sys[1] in [ 'autoconf', 'detect' ]:
+ if sys[1] in ['autoconf', 'detect']:
if libvirt.openReadOnly(uri):
print("yes")
return 0
@@ -208,6 +211,7 @@ def main(sys):
return print_config(uri)
return fetch_values(uri)
+
if __name__ == "__main__":
sys.exit(main(sys.argv))