connection: Don't pass redundant 'uri' to callbacks

This commit is contained in:
Cole Robinson 2011-07-22 13:54:40 -04:00
parent 15e6cc18f6
commit 44869d2e6c
7 changed files with 59 additions and 59 deletions

View File

@ -268,13 +268,13 @@ class vmmConnection(vmmGObject):
if name == "vm-added": if name == "vm-added":
for uuid in self.vms.keys(): for uuid in self.vms.keys():
self.emit("vm-added", self.get_uri(), uuid) self.emit("vm-added", uuid)
elif name == "mediadev-added": elif name == "mediadev-added":
for dev in self.mediadevs.values(): for dev in self.mediadevs.values():
self.emit("mediadev-added", dev) self.emit("mediadev-added", dev)
elif name == "nodedev-added": elif name == "nodedev-added":
for key in self.nodedevs.keys(): for key in self.nodedevs.keys():
self.emit("nodedev-added", self.get_uri(), key) self.emit("nodedev-added", key)
return handle_id return handle_id
@ -858,7 +858,7 @@ class vmmConnection(vmmGObject):
self._add_mediadev(key, dev) self._add_mediadev(key, dev)
def _nodedev_mediadev_added(self, ignore1, ignore2, name): def _nodedev_mediadev_added(self, ignore1, name):
if name in self.mediadevs: if name in self.mediadevs:
return return
@ -869,7 +869,7 @@ class vmmConnection(vmmGObject):
self._add_mediadev(name, mediadev) self._add_mediadev(name, mediadev)
def _nodedev_mediadev_removed(self, ignore1, ignore2, name): def _nodedev_mediadev_removed(self, ignore1, name):
if name not in self.mediadevs: if name not in self.mediadevs:
return return
@ -1442,7 +1442,6 @@ class vmmConnection(vmmGObject):
app with long tick operations. app with long tick operations.
""" """
# Connection closed out from under us # Connection closed out from under us
uri = self.get_uri()
if not self.vmm: if not self.vmm:
return return
@ -1455,50 +1454,50 @@ class vmmConnection(vmmGObject):
# Update VM states # Update VM states
for uuid in oldVMs: for uuid in oldVMs:
self.emit("vm-removed", uri, uuid) self.emit("vm-removed", uuid)
oldVMs[uuid].cleanup() oldVMs[uuid].cleanup()
for uuid in newVMs: for uuid in newVMs:
self.emit("vm-added", uri, uuid) self.emit("vm-added", uuid)
# Update virtual network states # Update virtual network states
for uuid in oldNets: for uuid in oldNets:
self.emit("net-removed", uri, uuid) self.emit("net-removed", uuid)
oldNets[uuid].cleanup() oldNets[uuid].cleanup()
for uuid in newNets: for uuid in newNets:
self.emit("net-added", uri, uuid) self.emit("net-added", uuid)
for uuid in startNets: for uuid in startNets:
self.emit("net-started", uri, uuid) self.emit("net-started", uuid)
for uuid in stopNets: for uuid in stopNets:
self.emit("net-stopped", uri, uuid) self.emit("net-stopped", uuid)
# Update storage pool states # Update storage pool states
for uuid in oldPools: for uuid in oldPools:
self.emit("pool-removed", uri, uuid) self.emit("pool-removed", uuid)
oldPools[uuid].cleanup() oldPools[uuid].cleanup()
for uuid in newPools: for uuid in newPools:
self.emit("pool-added", uri, uuid) self.emit("pool-added", uuid)
for uuid in startPools: for uuid in startPools:
self.emit("pool-started", uri, uuid) self.emit("pool-started", uuid)
for uuid in stopPools: for uuid in stopPools:
self.emit("pool-stopped", uri, uuid) self.emit("pool-stopped", uuid)
# Update interface states # Update interface states
for name in oldInterfaces: for name in oldInterfaces:
self.emit("interface-removed", uri, name) self.emit("interface-removed", name)
oldInterfaces[name].cleanup() oldInterfaces[name].cleanup()
for name in newInterfaces: for name in newInterfaces:
self.emit("interface-added", uri, name) self.emit("interface-added", name)
for name in startInterfaces: for name in startInterfaces:
self.emit("interface-started", uri, name) self.emit("interface-started", name)
for name in stopInterfaces: for name in stopInterfaces:
self.emit("interface-stopped", uri, name) self.emit("interface-stopped", name)
# Update nodedev list # Update nodedev list
for name in oldNodedevs: for name in oldNodedevs:
self.emit("nodedev-removed", uri, name) self.emit("nodedev-removed", name)
oldNodedevs[name].cleanup() oldNodedevs[name].cleanup()
for name in newNodedevs: for name in newNodedevs:
self.emit("nodedev-added", uri, name) self.emit("nodedev-added", name)
self.safe_idle_add(tick_send_signals) self.safe_idle_add(tick_send_signals)
@ -1657,26 +1656,26 @@ class vmmConnection(vmmGObject):
self.config.get_iso_paths) self.config.get_iso_paths)
vmmGObject.type_register(vmmConnection) vmmGObject.type_register(vmmConnection)
vmmGObject.signal_new(vmmConnection, "vm-added", [str, str]) vmmGObject.signal_new(vmmConnection, "vm-added", [str])
vmmGObject.signal_new(vmmConnection, "vm-removed", [str, str]) vmmGObject.signal_new(vmmConnection, "vm-removed", [str])
vmmGObject.signal_new(vmmConnection, "net-added", [str, str]) vmmGObject.signal_new(vmmConnection, "net-added", [str])
vmmGObject.signal_new(vmmConnection, "net-removed", [str, str]) vmmGObject.signal_new(vmmConnection, "net-removed", [str])
vmmGObject.signal_new(vmmConnection, "net-started", [str, str]) vmmGObject.signal_new(vmmConnection, "net-started", [str])
vmmGObject.signal_new(vmmConnection, "net-stopped", [str, str]) vmmGObject.signal_new(vmmConnection, "net-stopped", [str])
vmmGObject.signal_new(vmmConnection, "pool-added", [str, str]) vmmGObject.signal_new(vmmConnection, "pool-added", [str])
vmmGObject.signal_new(vmmConnection, "pool-removed", [str, str]) vmmGObject.signal_new(vmmConnection, "pool-removed", [str])
vmmGObject.signal_new(vmmConnection, "pool-started", [str, str]) vmmGObject.signal_new(vmmConnection, "pool-started", [str])
vmmGObject.signal_new(vmmConnection, "pool-stopped", [str, str]) vmmGObject.signal_new(vmmConnection, "pool-stopped", [str])
vmmGObject.signal_new(vmmConnection, "interface-added", [str, str]) vmmGObject.signal_new(vmmConnection, "interface-added", [str])
vmmGObject.signal_new(vmmConnection, "interface-removed", [str, str]) vmmGObject.signal_new(vmmConnection, "interface-removed", [str])
vmmGObject.signal_new(vmmConnection, "interface-started", [str, str]) vmmGObject.signal_new(vmmConnection, "interface-started", [str])
vmmGObject.signal_new(vmmConnection, "interface-stopped", [str, str]) vmmGObject.signal_new(vmmConnection, "interface-stopped", [str])
vmmGObject.signal_new(vmmConnection, "nodedev-added", [str, str]) vmmGObject.signal_new(vmmConnection, "nodedev-added", [str])
vmmGObject.signal_new(vmmConnection, "nodedev-removed", [str, str]) vmmGObject.signal_new(vmmConnection, "nodedev-removed", [str])
vmmGObject.signal_new(vmmConnection, "mediadev-added", [object]) vmmGObject.signal_new(vmmConnection, "mediadev-added", [object])
vmmGObject.signal_new(vmmConnection, "mediadev-removed", [str]) vmmGObject.signal_new(vmmConnection, "mediadev-removed", [str])

View File

@ -373,8 +373,8 @@ class vmmEngine(vmmGObject):
self.exit_app(src) self.exit_app(src)
def _do_vm_removed(self, connection, hvuri, vmuuid): def _do_vm_removed(self, conn, vmuuid):
ignore = connection hvuri = conn.get_uri()
if vmuuid not in self.connections[hvuri]["windowDetails"]: if vmuuid not in self.connections[hvuri]["windowDetails"]:
return return

View File

@ -482,7 +482,7 @@ class vmmHost(vmmGObjectUI):
return self.conn.get_net(curruuid) return self.conn.get_net(curruuid)
return None return None
def refresh_network(self, src_ignore, uri_ignore, uuid): def refresh_network(self, src_ignore, uuid):
uilist = self.widget("net-list") uilist = self.widget("net-list")
sel = uilist.get_selection() sel = uilist.get_selection()
active = sel.get_selected() active = sel.get_selected()
@ -586,7 +586,7 @@ class vmmHost(vmmGObjectUI):
_("Isolated virtual network")) _("Isolated virtual network"))
self.widget("net-apply").set_sensitive(False) self.widget("net-apply").set_sensitive(False)
def repopulate_networks(self, src_ignore, uri_ignore, uuid_ignore): def repopulate_networks(self, src_ignore, uuid_ignore):
self.populate_networks(self.widget("net-list").get_model()) self.populate_networks(self.widget("net-list").get_model())
def populate_networks(self, model): def populate_networks(self, model):
@ -704,7 +704,7 @@ class vmmHost(vmmGObjectUI):
if cp is None: if cp is None:
return return
cp.refresh() cp.refresh()
self.refresh_storage_pool(None, None, cp.get_uuid()) self.refresh_storage_pool(None, cp.get_uuid())
def current_pool(self): def current_pool(self):
sel = self.widget("pool-list").get_selection() sel = self.widget("pool-list").get_selection()
@ -811,7 +811,7 @@ class vmmHost(vmmGObjectUI):
util.tooltip_wrapper(self.widget("vol-add"), util.tooltip_wrapper(self.widget("vol-add"),
str(e)) str(e))
def refresh_storage_pool(self, src_ignore, uri_ignore, uuid): def refresh_storage_pool(self, src_ignore, uuid):
refresh_pool_in_list(self.widget("pool-list"), self.conn, uuid) refresh_pool_in_list(self.widget("pool-list"), self.conn, uuid)
curpool = self.current_pool() curpool = self.current_pool()
if curpool.uuid != uuid: if curpool.uuid != uuid:
@ -867,7 +867,7 @@ class vmmHost(vmmGObjectUI):
clipboard.set_text(target_path) clipboard.set_text(target_path)
def repopulate_storage_pools(self, src_ignore, uri_ignore, uuid_ignore): def repopulate_storage_pools(self, src_ignore, uuid_ignore):
pool_list = self.widget("pool-list") pool_list = self.widget("pool-list")
populate_storage_pools(pool_list, self.conn) populate_storage_pools(pool_list, self.conn)
@ -958,7 +958,7 @@ class vmmHost(vmmGObjectUI):
if cp is None: if cp is None:
return return
self.refresh_interface(None, None, cp.get_name()) self.refresh_interface(None, cp.get_name())
def current_interface(self): def current_interface(self):
sel = self.widget("interface-list").get_selection() sel = self.widget("interface-list").get_selection()
@ -1098,7 +1098,7 @@ class vmmHost(vmmGObjectUI):
self.widget("interface-child-box").set_property("visible", show_child) self.widget("interface-child-box").set_property("visible", show_child)
self.populate_interface_children() self.populate_interface_children()
def refresh_interface(self, src_ignore, uri_ignore, name): def refresh_interface(self, src_ignore, name):
iface_list = self.widget("interface-list") iface_list = self.widget("interface-list")
sel = iface_list.get_selection() sel = iface_list.get_selection()
active = sel.get_selected() active = sel.get_selected()
@ -1121,7 +1121,7 @@ class vmmHost(vmmGObjectUI):
self.widget("interface-start").set_sensitive(False) self.widget("interface-start").set_sensitive(False)
self.widget("interface-apply").set_sensitive(False) self.widget("interface-apply").set_sensitive(False)
def repopulate_interfaces(self, src_ignore, uri_ignore, name_ignore): def repopulate_interfaces(self, src_ignore, name_ignore):
interface_list = self.widget("interface-list") interface_list = self.widget("interface-list")
self.populate_interfaces(interface_list.get_model()) self.populate_interfaces(interface_list.get_model())

View File

@ -47,9 +47,8 @@ class vmmInspection(Thread):
self._q.put(obj) self._q.put(obj)
# Called by the main thread whenever a VM is added to vmlist. # Called by the main thread whenever a VM is added to vmlist.
def vm_added(self, conn, uri, uuid): def vm_added(self, conn, uuid):
ignore = conn ignore = conn
ignore = uri
ignore = uuid ignore = uuid
obj = ("vm_added") obj = ("vm_added")
self._q.put(obj) self._q.put(obj)

View File

@ -676,8 +676,8 @@ class vmmManager(vmmGObjectUI):
def vm_row_key(self, vm): def vm_row_key(self, vm):
return vm.get_uuid() + ":" + vm.get_connection().get_uri() return vm.get_uuid() + ":" + vm.get_connection().get_uri()
def vm_added(self, connection, uri_ignore, vmuuid): def vm_added(self, conn, vmuuid):
vm = connection.get_vm(vmuuid) vm = conn.get_vm(vmuuid)
vm.connect("status-changed", self.vm_status_changed) vm.connect("status-changed", self.vm_status_changed)
vm.connect("resources-sampled", self.vm_resources_sampled) vm.connect("resources-sampled", self.vm_resources_sampled)
vm.connect("config-changed", self.vm_resources_sampled, True) vm.connect("config-changed", self.vm_resources_sampled, True)
@ -686,13 +686,13 @@ class vmmManager(vmmGObjectUI):
vmlist = self.widget("vm-list") vmlist = self.widget("vm-list")
model = vmlist.get_model() model = vmlist.get_model()
self._append_vm(model, vm, connection) self._append_vm(model, vm, conn)
def vm_removed(self, connection, uri_ignore, vmuuid): def vm_removed(self, conn, vmuuid):
vmlist = self.widget("vm-list") vmlist = self.widget("vm-list")
model = vmlist.get_model() model = vmlist.get_model()
parent = self.rows[connection.get_uri()].iter parent = self.rows[conn.get_uri()].iter
for row in range(model.iter_n_children(parent)): for row in range(model.iter_n_children(parent)):
vm = model.get_value(model.iter_nth_child(parent, row), ROW_HANDLE) vm = model.get_value(model.iter_nth_child(parent, row), ROW_HANDLE)
if vm.get_uuid() == vmuuid: if vm.get_uuid() == vmuuid:

View File

@ -231,7 +231,7 @@ class vmmStorageBrowser(vmmGObjectUI):
return return
return pool.get_volume(row[0]) return pool.get_volume(row[0])
def refresh_storage_pool(self, src_ignore, uri_ignore, uuid): def refresh_storage_pool(self, src_ignore, uuid):
pool_list = self.widget("pool-list") pool_list = self.widget("pool-list")
virtManager.host.refresh_pool_in_list(pool_list, self.conn, uuid) virtManager.host.refresh_pool_in_list(pool_list, self.conn, uuid)
curpool = self.current_pool() curpool = self.current_pool()
@ -242,7 +242,7 @@ class vmmStorageBrowser(vmmGObjectUI):
# update vol list # update vol list
self.pool_selected(self.widget("pool-list").get_selection()) self.pool_selected(self.widget("pool-list").get_selection())
def repopulate_storage_pools(self, src_ignore, uri_ignore, uuid_ignore): def repopulate_storage_pools(self, src_ignore, uuid_ignore):
pool_list = self.widget("pool-list") pool_list = self.widget("pool-list")
virtManager.host.populate_storage_pools(pool_list, self.conn) virtManager.host.populate_storage_pools(pool_list, self.conn)
@ -270,7 +270,7 @@ class vmmStorageBrowser(vmmGObjectUI):
if cp is None: if cp is None:
return return
cp.refresh() cp.refresh()
self.refresh_storage_pool(None, None, cp.get_uuid()) self.refresh_storage_pool(None, cp.get_uuid())
def new_volume(self, src_ignore): def new_volume(self, src_ignore):
pool = self.current_pool() pool = self.current_pool()

View File

@ -348,7 +348,8 @@ class vmmSystray(vmmGObject):
vm_item = self.conn_vm_menuitems[uri][uuid] vm_item = self.conn_vm_menuitems[uri][uuid]
vm_submenu.insert(vm_item, i) vm_submenu.insert(vm_item, i)
def vm_added(self, conn, uri, uuid): def vm_added(self, conn, uuid):
uri = conn.get_uri()
vm = conn.get_vm(uuid) vm = conn.get_vm(uuid)
if not vm: if not vm:
return return
@ -372,7 +373,8 @@ class vmmSystray(vmmGObject):
self.vm_state_changed(vm) self.vm_state_changed(vm)
menu_item.show() menu_item.show()
def vm_removed(self, conn_ignore, uri, uuid): def vm_removed(self, conn, uuid):
uri = conn.get_uri()
vm_mappings = self.conn_vm_menuitems[uri] vm_mappings = self.conn_vm_menuitems[uri]
if not vm_mappings: if not vm_mappings:
return return