Dan Kenigsberg has uploaded a new change for review. Change subject: pep8: fix libvirtconnection.py ......................................................................
pep8: fix libvirtconnection.py Change-Id: Ie6fef13e80b2330dbc65c3440ceb994c5c6903b5 Signed-off-by: Dan Kenigsberg <[email protected]> --- M Makefile.am M vdsm/libvirtconnection.py 2 files changed, 13 insertions(+), 6 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/37/9437/1 diff --git a/Makefile.am b/Makefile.am index 26ce402..a234428 100644 --- a/Makefile.am +++ b/Makefile.am @@ -67,6 +67,7 @@ vdsm/hooks.py \ vdsm/kaxmlrpclib.py \ vdsm/ksm.py \ + vdsm/libvirtconnection.py \ vdsm/libvirtev.py \ vdsm/libvirtvm.py \ vdsm/lsblk.py \ diff --git a/vdsm/libvirtconnection.py b/vdsm/libvirtconnection.py index 41ba933..faf0cd0 100644 --- a/vdsm/libvirtconnection.py +++ b/vdsm/libvirtconnection.py @@ -30,6 +30,7 @@ # TODO: make this internal to libvirtev, and make the thread stoppable libvirtev.virEventLoopPureStart() + def __eventCallback(conn, dom, *args): try: cif, eventid = args[-1] @@ -38,7 +39,7 @@ if not v: cif.log.debug('unknown vm %s eventid %s args %s', vmid, eventid, - args) + args) return if eventid == libvirt.VIR_DOMAIN_EVENT_ID_LIFECYCLE: @@ -74,6 +75,8 @@ __connections = {} __connectionLock = threading.Lock() + + def get(cif=None): """Return current connection to libvirt or open a new one. @@ -91,8 +94,9 @@ setattr(ret, name, wrapMethod(method)) return ret except libvirt.libvirtError, e: - if (e.get_error_domain() in (libvirt.VIR_FROM_REMOTE, libvirt.VIR_FROM_RPC) - and e.get_error_code() == libvirt.VIR_ERR_SYSTEM_ERROR): + if (e.get_error_domain() in (libvirt.VIR_FROM_REMOTE, + libvirt.VIR_FROM_RPC) and + e.get_error_code() == libvirt.VIR_ERR_SYSTEM_ERROR): cif.log.error('connection to libvirt broken. ' 'taking vdsm down.') cif.prepareForShutdown() @@ -102,14 +106,16 @@ return wrapper def req(credentials, user_data): + passwd = file(constants.P_VDSM_LIBVIRT_PASSWD).readline().rstrip("\n") for cred in credentials: if cred[0] == libvirt.VIR_CRED_AUTHNAME: cred[4] = constants.SASL_USERNAME elif cred[0] == libvirt.VIR_CRED_PASSPHRASE: - cred[4] = file(constants.P_VDSM_LIBVIRT_PASSWD).readline().rstrip("\n") + cred[4] = passwd return 0 - auth = [[libvirt.VIR_CRED_AUTHNAME, libvirt.VIR_CRED_PASSPHRASE], req, None] + auth = [[libvirt.VIR_CRED_AUTHNAME, libvirt.VIR_CRED_PASSPHRASE], + req, None] with __connectionLock: conn = __connections.get(id(cif)) @@ -118,7 +124,7 @@ 'qemu:///system', auth, 0) conn = utils.retry(libvirtOpenAuth, timeout=10, sleep=0.2) __connections[id(cif)] = conn - if cif != None: + if cif is not None: for ev in (libvirt.VIR_DOMAIN_EVENT_ID_LIFECYCLE, libvirt.VIR_DOMAIN_EVENT_ID_REBOOT, libvirt.VIR_DOMAIN_EVENT_ID_RTC_CHANGE, -- To view, visit http://gerrit.ovirt.org/9437 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie6fef13e80b2330dbc65c3440ceb994c5c6903b5 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Dan Kenigsberg <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
