From nobody Wed Nov 27 19:32:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 153742385793298.35443015077578; Wed, 19 Sep 2018 23:10:57 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5F37F3002C66; Thu, 20 Sep 2018 06:10:56 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AD100C17A8; Thu, 20 Sep 2018 06:10:55 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 67500181A139; Thu, 20 Sep 2018 06:10:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8K6ArI9012188 for ; Thu, 20 Sep 2018 02:10:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8B671D6359; Thu, 20 Sep 2018 06:10:53 +0000 (UTC) Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8347BD58FD for ; Thu, 20 Sep 2018 06:10:50 +0000 (UTC) Received: from mail.univention.de (mail.univention.de [82.198.197.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A64B2CD4DE for ; Thu, 20 Sep 2018 06:10:49 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by solig.knut.univention.de (Postfix) with ESMTP id DBE98326275E for ; Thu, 20 Sep 2018 08:10:47 +0200 (CEST) Received: from mail.univention.de ([127.0.0.1]) by localhost (solig.knut.univention.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DSMCGM0txWv6; Thu, 20 Sep 2018 08:10:46 +0200 (CEST) Received: from fixa.knut.univention.de (mail.univention.de [82.198.197.8]) by solig.knut.univention.de (Postfix) with ESMTPSA id D649D326272C; Thu, 20 Sep 2018 08:10:45 +0200 (CEST) Received: by fixa.knut.univention.de (Postfix, from userid 2260) id D7A61165C1D; Thu, 20 Sep 2018 08:10:44 +0200 (CEST) X-Virus-Scanned: by amavisd-new-2.10.1 (20141025) (Debian) at knut.univention.de X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" From: Philipp Hahn To: libvir-list@redhat.com Date: Thu, 20 Sep 2018 08:10:43 +0200 Message-Id: <2bf7f9fff1dc52d890184ff4ee9f3a7c2d849e54.1537423774.git.hahn@univention.de> In-Reply-To: References: In-Reply-To: References: X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 214 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 20 Sep 2018 06:10:49 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 20 Sep 2018 06:10:49 +0000 (UTC) for IP:'82.198.197.8' DOMAIN:'mail.univention.de' HELO:'mail.univention.de' FROM:'hahn@univention.de' RCPT:'' X-RedHat-Spam-Score: -0.011 (RCVD_IN_DNSWL_NONE, SPF_PASS) 82.198.197.8 mail.univention.de 82.198.197.8 mail.univention.de X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH libvirt-python 1/2] event-test.py: Sync list of domain lifecycle events X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 20 Sep 2018 06:10:56 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add new events to prevent crash: > raceback (most recent call last): > File "/usr/lib/python2.7/dist-packages/libvirt.py", line 4601, in _disp= atchDomainEventCallbacks > cb(self, virDomain(self, _obj=3Ddom), event, detail, opaque) > File "libvirt-python/examples/event-test.py", line 505, in myDomainEven= tCallback1 > domDetailToString(event, detail))) > File "libvirt-python/examples/event-test.py", line 484, in domDetailToS= tring > return domEventStrings[event][detail] > IndexError: tuple index out of range Signed-off-by: Philipp Hahn --- examples/event-test.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/event-test.py b/examples/event-test.py index 281e661..04310e1 100755 --- a/examples/event-test.py +++ b/examples/event-test.py @@ -471,11 +471,11 @@ def domEventToString(event): =20 def domDetailToString(event, detail): domEventStrings =3D ( - ( "Added", "Updated" ), - ( "Removed", ), + ( "Added", "Updated", "Renamed", "Snapshot" ), + ( "Removed", "Renamed", ), ( "Booted", "Migrated", "Restored", "Snapshot", "Wakeup" ), - ( "Paused", "Migrated", "IOError", "Watchdog", "Restored", "Snapsh= ot", "API error" ), - ( "Unpaused", "Migrated", "Snapshot" ), + ( "Paused", "Migrated", "IOError", "Watchdog", "Restored", "Snapsh= ot", "API error", "Postcopy", "Postcopy failed" ), + ( "Unpaused", "Migrated", "Snapshot", "Postcopy" ), ( "Shutdown", "Destroyed", "Crashed", "Migrated", "Saved", "Failed= ", "Snapshot"), ( "Finished", "On guest request", "On host request"), ( "Memory", "Disk" ), --=20 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed Nov 27 19:32:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1537423858926371.77730269830784; Wed, 19 Sep 2018 23:10:58 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BBA2A308421D; Thu, 20 Sep 2018 06:10:56 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8A943308BDAF; Thu, 20 Sep 2018 06:10:56 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 41239181A13C; Thu, 20 Sep 2018 06:10:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8K6AsB3012195 for ; Thu, 20 Sep 2018 02:10:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 97B307A001; Thu, 20 Sep 2018 06:10:54 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8CD3A183C1 for ; Thu, 20 Sep 2018 06:10:50 +0000 (UTC) Received: from mail.univention.de (mail.univention.de [82.198.197.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 95D4883F4C for ; Thu, 20 Sep 2018 06:10:48 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by solig.knut.univention.de (Postfix) with ESMTP id E6C20326274A for ; Thu, 20 Sep 2018 08:10:46 +0200 (CEST) Received: from mail.univention.de ([127.0.0.1]) by localhost (solig.knut.univention.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VIlyCAWqQNwE; Thu, 20 Sep 2018 08:10:45 +0200 (CEST) Received: from fixa.knut.univention.de (mail.univention.de [82.198.197.8]) by solig.knut.univention.de (Postfix) with ESMTPSA id CEA983262728; Thu, 20 Sep 2018 08:10:45 +0200 (CEST) Received: by fixa.knut.univention.de (Postfix, from userid 2260) id D6A8516381E; Thu, 20 Sep 2018 08:10:44 +0200 (CEST) X-Virus-Scanned: by amavisd-new-2.10.1 (20141025) (Debian) at knut.univention.de X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" From: Philipp Hahn To: libvir-list@redhat.com Date: Thu, 20 Sep 2018 08:10:44 +0200 Message-Id: <586006fd5854f63a6d90540fe43f8bd5ad74d277.1537423774.git.hahn@univention.de> In-Reply-To: References: In-Reply-To: References: X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 214 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 20 Sep 2018 06:10:49 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 20 Sep 2018 06:10:49 +0000 (UTC) for IP:'82.198.197.8' DOMAIN:'mail.univention.de' HELO:'mail.univention.de' FROM:'hahn@univention.de' RCPT:'' X-RedHat-Spam-Score: -0.011 (RCVD_IN_DNSWL_NONE, SPF_PASS) 82.198.197.8 mail.univention.de 82.198.197.8 mail.univention.de X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH libvirt-python 2/2] event-test.py: Future proof lifecycle event handling X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Thu, 20 Sep 2018 06:10:57 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Catch exception if the event or details is outside the known type to prevent a traceback like the following: > raceback (most recent call last): > File "/usr/lib/python2.7/dist-packages/libvirt.py", line 4601, in _disp= atchDomainEventCallbacks > cb(self, virDomain(self, _obj=3Ddom), event, detail, opaque) > File "libvirt-python/examples/event-test.py", line 505, in myDomainEven= tCallback1 > domDetailToString(event, detail))) > File "libvirt-python/examples/event-test.py", line 484, in domDetailToS= tring > return domEventStrings[event][detail] > IndexError: tuple index out of range Signed-off-by: Philipp Hahn --- examples/event-test.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/event-test.py b/examples/event-test.py index 04310e1..4632110 100755 --- a/examples/event-test.py +++ b/examples/event-test.py @@ -467,7 +467,10 @@ def domEventToString(event): "PMSuspended", "Crashed", ) - return domEventStrings[event] + try: + return domEventStrings[event] + except IndexError: + return 'Unknown domain event %d' % (event,) =20 def domDetailToString(event, detail): domEventStrings =3D ( @@ -481,7 +484,10 @@ def domDetailToString(event, detail): ( "Memory", "Disk" ), ( "Panicked", ), ) - return domEventStrings[event][detail] + try: + return domEventStrings[event][detail] + except IndexError: + return 'Unknown domain event %d detail %d' % (event, detail) =20 def blockJobTypeToString(type): blockJobTypes =3D ( "unknown", "Pull", "Copy", "Commit", "ActiveCommit= ", ) --=20 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list