[PATCH libvirt-python v2 13/22] event-test.py: Convert AGENT events

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



to use new Description class

Signed-off-by: Philipp Hahn <hahn@xxxxxxxxxxxxx>
---
 examples/event-test.py | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/examples/event-test.py b/examples/event-test.py
index 4a801b7..b559ede 100755
--- a/examples/event-test.py
+++ b/examples/event-test.py
@@ -496,14 +496,8 @@ BLOCK_JOB_TYPES = Description("unknown", "Pull", "Copy", "Commit", "ActiveCommit
 BLOCK_JOB_STATUS = Description("Completed", "Failed", "Canceled", "Ready")
 WATCHDOG_ACTIONS = Description("none", "Pause", "Reset", "Poweroff", "Shutdown", "Debug", "Inject NMI")
 ERROR_EVENTS = Description("None", "Pause", "Report")
-
-def agentLifecycleStateToString(state):
-    agentStates = ( "unknown", "connected", "disconnected", )
-    return agentStates[state]
-
-def agentLifecycleReasonToString(reason):
-    agentReasons = ( "unknown", "domain started", "channel event", )
-    return agentReasons[reason]
+AGENT_STATES = Description("unknown", "connected", "disconnected")
+AGENT_REASONS = Description("unknown", "domain started", "channel event")
 
 
 def myDomainEventCallback(conn, dom, event, detail, opaque):
@@ -572,8 +566,13 @@ def myDomainEventBlockJob2Callback(conn, dom, disk, type, status, opaque):
 
 def myDomainEventTunableCallback(conn, dom, params, opaque):
     print("myDomainEventTunableCallback: Domain %s(%s) %s" % (dom.name(), dom.ID(), params))
+
+
 def myDomainEventAgentLifecycleCallback(conn, dom, state, reason, opaque):
-    print("myDomainEventAgentLifecycleCallback: Domain %s(%s) %s %s" % (dom.name(), dom.ID(), agentLifecycleStateToString(state), agentLifecycleReasonToString(reason)))
+    print("myDomainEventAgentLifecycleCallback: Domain %s(%s) %s %s" % (
+        dom.name(), dom.ID(), AGENT_STATES[state], AGENT_REASONS[reason]))
+
+
 def myDomainEventDeviceAddedCallback(conn, dom, dev, opaque):
     print("myDomainEventDeviceAddedCallback: Domain %s(%s) device added: %s" % (
             dom.name(), dom.ID(), dev))
-- 
2.11.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux