[modules/libvirtvms] Update to latest API
This commit is contained in:
parent
99d88e1e30
commit
d683b02b40
1 changed files with 15 additions and 17 deletions
|
@ -1,30 +1,28 @@
|
||||||
"""Displays count of running libvirt VMs.
|
"""Displays count of running libvirt VMs.
|
||||||
Required the following python packages:
|
Required the following python packages:
|
||||||
* libvirt
|
* libvirt
|
||||||
* sys
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import libvirt
|
import libvirt
|
||||||
import bumblebee.input
|
|
||||||
import bumblebee.output
|
|
||||||
import bumblebee.engine
|
|
||||||
|
|
||||||
|
import core.module
|
||||||
|
import core.widget
|
||||||
|
import core.input
|
||||||
|
import core.decorators
|
||||||
|
|
||||||
class Module(bumblebee.engine.Module):
|
class Module(core.module.Module):
|
||||||
def __init__(self, engine, config):
|
@core.decorators.every(seconds=10)
|
||||||
super(Module, self).__init__(engine, config,
|
def __init__(self, config):
|
||||||
bumblebee.output.Widget(full_text=self.status)
|
super().__init__(config, core.widget.Widget(self.status))
|
||||||
)
|
|
||||||
self._status = self.status
|
|
||||||
engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE,
|
|
||||||
cmd="virt-manager")
|
|
||||||
|
|
||||||
def update(self, widgets):
|
core.input.register(self, button=core.input.LEFT_MOUSE,
|
||||||
self._status = self.status
|
cmd='virt-manager')
|
||||||
|
|
||||||
def status(self, _):
|
def status(self, _):
|
||||||
conn = None
|
|
||||||
conn = libvirt.openReadOnly(None)
|
conn = libvirt.openReadOnly(None)
|
||||||
if conn == None:
|
if conn == None:
|
||||||
print ('Failed to open connection to the hypervisor')
|
return 'Failed to open connection to the hypervisor'
|
||||||
return "VMs %s" % (conn.numOfDomains())
|
return 'VMs %s' % (conn.numOfDomains())
|
||||||
|
|
||||||
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||||
|
|
Loading…
Add table
Reference in a new issue