connection: Log when objects are added/removed

This commit is contained in:
Cole Robinson 2014-05-28 08:26:31 -04:00
parent 3654d56aa6
commit 519e3b5768
4 changed files with 20 additions and 7 deletions

View File

@ -941,6 +941,7 @@ class vmmConnection(vmmGObject):
return
self.mediadevs[name] = mediadev
logging.debug("mediadev=%s added", name)
self.emit("mediadev-added", mediadev)
def _nodedev_mediadev_removed(self, ignore1, name):
@ -949,6 +950,7 @@ class vmmConnection(vmmGObject):
self.mediadevs[name].cleanup()
del(self.mediadevs[name])
logging.debug("mediadev=%s removed", name)
self.emit("mediadev-removed", name)
@ -1270,17 +1272,21 @@ class vmmConnection(vmmGObject):
# Update VM states
for uuid, obj in goneVMs.items():
logging.debug("domain=%s removed", obj.get_name())
self.emit("vm-removed", uuid)
obj.cleanup()
for uuid, obj in newVMs.items():
ignore = obj
logging.debug("domain=%s status=%s added",
obj.get_name(), obj.run_status())
self.emit("vm-added", uuid)
# Update virtual network states
for uuid, obj in goneNets.items():
logging.debug("network=%s removed", obj.get_name())
self.emit("net-removed", uuid)
obj.cleanup()
for uuid, obj in newNets.items():
logging.debug("network=%s added", obj.get_name())
obj.connect("started", self._obj_signal_proxy,
"net-started", uuid)
obj.connect("stopped", self._obj_signal_proxy,
@ -1289,9 +1295,11 @@ class vmmConnection(vmmGObject):
# Update storage pool states
for uuid, obj in gonePools.items():
logging.debug("pool=%s removed", obj.get_name())
self.emit("pool-removed", uuid)
obj.cleanup()
for uuid, obj in newPools.items():
logging.debug("pool=%s added", obj.get_name())
obj.connect("started", self._obj_signal_proxy,
"pool-started", uuid)
obj.connect("stopped", self._obj_signal_proxy,
@ -1300,9 +1308,11 @@ class vmmConnection(vmmGObject):
# Update interface states
for name, obj in goneInterfaces.items():
logging.debug("interface=%s removed", obj.get_name())
self.emit("interface-removed", name)
obj.cleanup()
for name, obj in newInterfaces.items():
logging.debug("interface=%s added", obj.get_name())
obj.connect("started", self._obj_signal_proxy,
"interface-started", name)
obj.connect("stopped", self._obj_signal_proxy,

View File

@ -359,7 +359,7 @@ class vmmDomain(vmmLibvirtObject):
self.toggle_sample_mem_stats()
self.toggle_sample_cpu_stats()
self.force_update_status(from_event=True)
self.force_update_status(from_event=True, log=False)
# Hook up listeners that need to be cleaned up
self.add_gconf_handle(
@ -1673,7 +1673,7 @@ class vmmDomain(vmmLibvirtObject):
status = libvirt.VIR_DOMAIN_NOSTATE
return vm_status_icons[status]
def force_update_status(self, from_event=False):
def force_update_status(self, from_event=False, log=True):
"""
Fetch current domain state and clear status cache
"""
@ -1682,8 +1682,9 @@ class vmmDomain(vmmLibvirtObject):
try:
info = self._backend.info()
logging.debug("domain=%s status changed to %d=%s",
self.get_name(), info[0], self.pretty_run_status(info[0]))
if log:
logging.debug("domain=%s status changed to %d=%s",
self.get_name(), info[0], self.pretty_run_status(info[0]))
self._update_status(info[0])
except libvirt.libvirtError, e:

View File

@ -121,8 +121,9 @@ class vmmLibvirtObject(vmmGObject):
def delete(self, force=True):
ignore = force
def force_update_status(self, from_event=False):
def force_update_status(self, from_event=False, log=True):
ignore = from_event
ignore = log
##################

View File

@ -83,7 +83,8 @@ class vmmNetwork(vmmLibvirtObject):
self.idle_emit(state and "started" or "stopped")
self._active = state
def force_update_status(self, from_event=False):
def force_update_status(self, from_event=False, log=True):
ignore = log
if self._using_events() and not from_event:
return