mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
libvirtobject: Centralize most tick() implementations
Basically all non-domain objects just need to check to see if status changed, which will also refresh the XML if a change occurs. This all works to ensure we are initializing XML at tick time Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
f22e060190
commit
9d34d1da0b
@ -117,11 +117,6 @@ class vmmDomainSnapshot(vmmLibvirtObject):
|
||||
def _get_backend_status(self):
|
||||
return self._STATUS_ACTIVE
|
||||
|
||||
def tick(self, stats_update=True):
|
||||
ignore = stats_update
|
||||
def _init_libvirt_state(self):
|
||||
self.ensure_latest_xml()
|
||||
|
||||
|
||||
###########
|
||||
# Actions #
|
||||
@ -1649,11 +1644,6 @@ class vmmDomainVirtinst(vmmDomain):
|
||||
return False
|
||||
def _get_backend_status(self):
|
||||
return libvirt.VIR_DOMAIN_SHUTOFF
|
||||
def _init_libvirt_state(self):
|
||||
pass
|
||||
|
||||
def tick(self, stats_update=True):
|
||||
ignore = stats_update
|
||||
|
||||
|
||||
################
|
||||
|
@ -27,7 +27,6 @@ class vmmLibvirtObject(vmmGObject):
|
||||
|
||||
self.__initialized = False
|
||||
self.__status = None
|
||||
self._support_isactive = None
|
||||
|
||||
self._xmlobj = None
|
||||
self._xmlobj_to_define = None
|
||||
@ -153,8 +152,6 @@ class vmmLibvirtObject(vmmGObject):
|
||||
return False
|
||||
def _using_events(self):
|
||||
return False
|
||||
def _check_supports_isactive(self):
|
||||
return False
|
||||
def _get_backend_status(self):
|
||||
raise NotImplementedError()
|
||||
|
||||
@ -174,10 +171,11 @@ class vmmLibvirtObject(vmmGObject):
|
||||
return self._backend.name()
|
||||
|
||||
def tick(self, stats_update=True):
|
||||
raise NotImplementedError()
|
||||
ignore = stats_update
|
||||
self._refresh_status()
|
||||
|
||||
def _init_libvirt_state(self):
|
||||
raise NotImplementedError()
|
||||
self.tick()
|
||||
|
||||
def init_libvirt_state(self):
|
||||
"""
|
||||
@ -243,16 +241,6 @@ class vmmLibvirtObject(vmmGObject):
|
||||
self.idle_emit("state-changed")
|
||||
return True
|
||||
|
||||
def _backend_get_active(self):
|
||||
if self._support_isactive is None:
|
||||
self._support_isactive = self._check_supports_isactive()
|
||||
|
||||
if not self._support_isactive:
|
||||
return self._STATUS_ACTIVE
|
||||
return (bool(self._backend.isActive()) and
|
||||
self._STATUS_ACTIVE or
|
||||
self._STATUS_INACTIVE)
|
||||
|
||||
|
||||
##################
|
||||
# Public XML API #
|
||||
|
@ -53,17 +53,10 @@ class vmmNetwork(vmmLibvirtObject):
|
||||
return self.conn.define_network(xml)
|
||||
def _using_events(self):
|
||||
return self.conn.using_network_events
|
||||
def _check_supports_isactive(self):
|
||||
return True
|
||||
def _get_backend_status(self):
|
||||
return self._backend_get_active()
|
||||
|
||||
def tick(self, stats_update=True):
|
||||
ignore = stats_update
|
||||
self._refresh_status()
|
||||
|
||||
def _init_libvirt_state(self):
|
||||
self.tick()
|
||||
return (bool(self._backend.isActive()) and
|
||||
self._STATUS_ACTIVE or
|
||||
self._STATUS_INACTIVE)
|
||||
|
||||
|
||||
###########
|
||||
|
@ -82,16 +82,8 @@ class vmmNodeDevice(vmmLibvirtObject):
|
||||
return self._STATUS_ACTIVE
|
||||
def _backend_get_name(self):
|
||||
return self.get_connkey()
|
||||
def is_active(self):
|
||||
return True
|
||||
def _using_events(self):
|
||||
return self.conn.using_node_device_events
|
||||
|
||||
def tick(self, stats_update=True):
|
||||
# Deliberately empty
|
||||
ignore = stats_update
|
||||
def _init_libvirt_state(self):
|
||||
self.ensure_latest_xml()
|
||||
|
||||
def pretty_name(self):
|
||||
return _pretty_name(self.xmlobj)
|
||||
|
@ -62,12 +62,6 @@ class vmmStorageVolume(vmmLibvirtObject):
|
||||
def _get_backend_status(self):
|
||||
return self._STATUS_ACTIVE
|
||||
|
||||
def tick(self, stats_update=True):
|
||||
# Deliberately empty
|
||||
ignore = stats_update
|
||||
def _init_libvirt_state(self):
|
||||
self.ensure_latest_xml()
|
||||
|
||||
|
||||
###########
|
||||
# Actions #
|
||||
@ -169,17 +163,13 @@ class vmmStoragePool(vmmLibvirtObject):
|
||||
return self.conn.define_pool(xml)
|
||||
def _using_events(self):
|
||||
return self.conn.using_storage_pool_events
|
||||
def _check_supports_isactive(self):
|
||||
return True
|
||||
def _get_backend_status(self):
|
||||
return self._backend_get_active()
|
||||
|
||||
def tick(self, stats_update=True):
|
||||
ignore = stats_update
|
||||
self._refresh_status()
|
||||
return (bool(self._backend.isActive()) and
|
||||
self._STATUS_ACTIVE or
|
||||
self._STATUS_INACTIVE)
|
||||
|
||||
def _init_libvirt_state(self):
|
||||
self.tick()
|
||||
super()._init_libvirt_state()
|
||||
if not self.conn.is_active():
|
||||
# We only want to refresh a pool on initial conn startup,
|
||||
# since the pools may be out of date. But if a storage pool
|
||||
|
Loading…
Reference in New Issue
Block a user