From 099753d1463bfdcb5b72a4d96c78f7a8f19997b5 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Fri, 22 Jul 2011 16:43:26 -0400 Subject: [PATCH] s/connection/conn/g in all internal APIs For consistency and line reduction --- src/virt-manager.py.in | 4 +- src/virtManager/addhardware.py | 2 +- src/virtManager/choosecd.py | 2 +- src/virtManager/clone.py | 6 +- src/virtManager/config.py | 20 ++-- src/virtManager/connect.py | 8 +- src/virtManager/create.py | 10 +- src/virtManager/delete.py | 2 +- src/virtManager/details.py | 50 ++++----- src/virtManager/domain.py | 48 ++++----- src/virtManager/engine.py | 170 +++++++++++++++---------------- src/virtManager/interface.py | 8 +- src/virtManager/libvirtobject.py | 9 +- src/virtManager/manager.py | 80 +++++++-------- src/virtManager/mediadev.py | 2 +- src/virtManager/migrate.py | 16 +-- src/virtManager/network.py | 6 +- src/virtManager/nodedev.py | 4 +- src/virtManager/serialcon.py | 4 +- src/virtManager/storagepool.py | 8 +- src/virtManager/storagevol.py | 6 +- src/virtManager/systray.py | 6 +- src/virtManager/uihelpers.py | 2 +- 23 files changed, 237 insertions(+), 236 deletions(-) diff --git a/src/virt-manager.py.in b/src/virt-manager.py.in index e8934bc11..88fe09ea6 100755 --- a/src/virt-manager.py.in +++ b/src/virt-manager.py.in @@ -180,7 +180,7 @@ def show_engine(engine, show, uri, uuid, no_conn_auto): engine.show_manager() if uri: - conn = engine.add_connection(uri) + conn = engine.add_conn(uri) if conn and show: conn.connect_opt_out("state-changed", @@ -190,7 +190,7 @@ def show_engine(engine, show, uri, uuid, no_conn_auto): engine.connect_to_uri(uri) if not no_conn_auto: - engine.autostart_connections() + engine.autostart_conns() # maps --show-* to remote manager (ie dbus call) methods def show_remote(managerObj, show, uri, uuid): diff --git a/src/virtManager/addhardware.py b/src/virtManager/addhardware.py index d5c286c84..e2b23f909 100644 --- a/src/virtManager/addhardware.py +++ b/src/virtManager/addhardware.py @@ -65,7 +65,7 @@ class vmmAddHardware(vmmGObjectUI): "vmm-add-hardware.glade", "vmm-add-hardware") self.vm = vm - self.conn = vm.get_connection() + self.conn = vm.conn self.storage_browser = None diff --git a/src/virtManager/choosecd.py b/src/virtManager/choosecd.py index 9b7cea862..9f3065dea 100644 --- a/src/virtManager/choosecd.py +++ b/src/virtManager/choosecd.py @@ -31,7 +31,7 @@ class vmmChooseCD(vmmGObjectUI): vmmGObjectUI.__init__(self, "vmm-choose-cd.glade", "vmm-choose-cd") self.vm = vm - self.conn = self.vm.get_connection() + self.conn = self.vm.conn self.disk = disk self.storage_browser = None self.media_type = disk.device diff --git a/src/virtManager/clone.py b/src/virtManager/clone.py index 1c112b81f..5357517ad 100644 --- a/src/virtManager/clone.py +++ b/src/virtManager/clone.py @@ -124,7 +124,7 @@ class vmmCloneVM(vmmGObjectUI): vmmGObjectUI.__init__(self, "vmm-clone.glade", "vmm-clone") self.orig_vm = orig_vm - self.conn = self.orig_vm.connection + self.conn = self.orig_vm.conn self.clone_design = None self.storage_list = {} @@ -316,7 +316,7 @@ class vmmCloneVM(vmmGObjectUI): label = _("Usermode") elif net_type == VirtualNetworkInterface.TYPE_VIRTUAL: - net = self.orig_vm.get_connection().get_net_by_name(net_dev) + net = self.orig_vm.conn.get_net_by_name(net_dev) if net: label = "" @@ -672,7 +672,7 @@ class vmmCloneVM(vmmGObjectUI): def set_orig_vm(self, new_orig): self.orig_vm = new_orig - self.conn = self.orig_vm.connection + self.conn = self.orig_vm.conn def change_mac_finish(self, ignore): orig = self.change_mac_window.get_widget("change-mac-orig").get_text() diff --git a/src/virtManager/config.py b/src/virtManager/config.py index a3473e1a0..4aa7c10d0 100644 --- a/src/virtManager/config.py +++ b/src/virtManager/config.py @@ -592,7 +592,7 @@ class vmmConfig(object): # Manager view connection list - def add_connection(self, uri): + def add_conn(self, uri): uris = self.conf.get_list(self.conf_dir + "/connections/uris", gconf.VALUE_STRING) if uris == None: @@ -602,7 +602,7 @@ class vmmConfig(object): uris.insert(len(uris) - 1, uri) self.conf.set_list(self.conf_dir + "/connections/uris", gconf.VALUE_STRING, uris) - def remove_connection(self, uri): + def remove_conn(self, uri): uris = self.conf.get_list(self.conf_dir + "/connections/uris", gconf.VALUE_STRING) if uris == None: @@ -621,7 +621,7 @@ class vmmConfig(object): self.conf.set_list(self.conf_dir + "/connections/autoconnect", gconf.VALUE_STRING, uris) - def get_connections(self): + def get_conn_uris(self): return self.conf.get_list(self.conf_dir + "/connections/uris", gconf.VALUE_STRING) @@ -686,11 +686,11 @@ class vmmConfig(object): self.conf.set_string(self.conf_dir + "/paths/default-%s-path" % _type, folder) - def get_default_image_dir(self, connection): - if connection.is_xen(): + def get_default_image_dir(self, conn): + if conn.is_xen(): return self.DEFAULT_XEN_IMAGE_DIR - if (connection.is_qemu_session() or + if (conn.is_qemu_session() or not os.access(self.DEFAULT_VIRT_IMAGE_DIR, os.W_OK)): return os.getcwd() @@ -698,8 +698,8 @@ class vmmConfig(object): # is a managed pool and the user will be able to install to it. return self.DEFAULT_VIRT_IMAGE_DIR - def get_default_save_dir(self, connection): - if connection.is_xen(): + def get_default_save_dir(self, conn): + if conn.is_xen(): return self.DEFAULT_XEN_SAVE_DIR elif os.access(self.DEFAULT_VIRT_SAVE_DIR, os.W_OK): return self.DEFAULT_VIRT_SAVE_DIR @@ -742,7 +742,7 @@ class vmmConfig(object): if secret != None and secret.get_name() == self.get_secret_name(vm): if not(secret.has_attribute("hvuri")): return ("", "") - if secret.get_attribute("hvuri") != vm.get_connection().get_uri(): + if secret.get_attribute("hvuri") != vm.conn.get_uri(): return ("", "") if not(secret.has_attribute("uuid")): return ("", "") @@ -763,7 +763,7 @@ class vmmConfig(object): secret = vmmSecret(self.get_secret_name(vm), password, {"uuid" : vm.get_uuid(), - "hvuri": vm.get_connection().get_uri()}) + "hvuri": vm.conn.get_uri()}) _id = self.keyring.add_secret(secret) if _id != None: self.conf.set_int(self.conf_dir + "/console/passwords/" + vm.get_uuid(), _id) diff --git a/src/virtManager/connect.py b/src/virtManager/connect.py index 8aec0b00f..238cf126e 100644 --- a/src/virtManager/connect.py +++ b/src/virtManager/connect.py @@ -56,13 +56,13 @@ class vmmConnect(vmmGObjectUI): self.window.signal_autoconnect({ "on_hypervisor_changed": self.hypervisor_changed, - "on_connection_changed": self.connection_changed, + "on_connection_changed": self.conn_changed, "on_hostname_combo_changed": self.hostname_combo_changed, "on_connect_remote_toggled": self.connect_remote_toggled, "on_username_entry_changed": self.username_changed, "on_cancel_clicked": self.cancel, - "on_connect_clicked": self.open_connection, + "on_connect_clicked": self.open_conn, "on_vmm_open_connection_delete_event": self.cancel, }) @@ -268,7 +268,7 @@ class vmmConnect(vmmGObjectUI): self.populate_default_user() self.populate_uri() - def connection_changed(self, src_ignore): + def conn_changed(self, src_ignore): self.populate_default_user() self.populate_uri() @@ -329,7 +329,7 @@ class vmmConnect(vmmGObjectUI): return True - def open_connection(self, ignore): + def open_conn(self, ignore): if not self.validate(): return diff --git a/src/virtManager/create.py b/src/virtManager/create.py index 06f511987..71034ca13 100644 --- a/src/virtManager/create.py +++ b/src/virtManager/create.py @@ -681,8 +681,8 @@ class vmmCreate(vmmGObjectUI): model.clear() default = -1 - for c in self.engine.connections.values(): - connobj = c["connection"] + for c in self.engine.conns.values(): + connobj = c["conn"] if not connobj.is_active(): continue @@ -705,7 +705,7 @@ class vmmCreate(vmmGObjectUI): if not no_conns: conn_list.set_active(default) activeuri, activedesc = model[default] - activeconn = self.engine.connections[activeuri]["connection"] + activeconn = self.engine.conns[activeuri]["conn"] self.widget("create-conn-label").set_text(activedesc) if len(model) <= 1: @@ -981,7 +981,7 @@ class vmmCreate(vmmGObjectUI): conn = None else: uri = model[idx][0] - conn = self.engine.connections[uri]["connection"] + conn = self.engine.conns[uri]["conn"] # If we aren't visible, let reset_state handle this for us, which # has a better chance of reporting error @@ -1365,7 +1365,7 @@ class vmmCreate(vmmGObjectUI): name = self.get_config_name() try: - g = virtinst.Guest(connection=self.conn.vmm) + g = virtinst.Guest(conn=self.conn.vmm) g.name = name except Exception, e: return self.verr(_("Invalid System Name"), str(e)) diff --git a/src/virtManager/delete.py b/src/virtManager/delete.py index 4ae5ddb43..16b13c16d 100644 --- a/src/virtManager/delete.py +++ b/src/virtManager/delete.py @@ -69,7 +69,7 @@ class vmmDeleteDialog(vmmGObjectUI): def show(self, vm, parent): self.vm = vm - self.conn = vm.get_connection() + self.conn = vm.conn self.reset_state() self.topwin.set_transient_for(parent) diff --git a/src/virtManager/details.py b/src/virtManager/details.py index e1033856a..7dd1ff4e7 100644 --- a/src/virtManager/details.py +++ b/src/virtManager/details.py @@ -272,7 +272,7 @@ class vmmDetails(vmmGObjectUI): def __init__(self, vm, parent=None): vmmGObjectUI.__init__(self, "vmm-details.glade", "vmm-details") self.vm = vm - self.conn = self.vm.get_connection() + self.conn = self.vm.conn self.is_customize_dialog = False if parent: @@ -781,7 +781,7 @@ class vmmDetails(vmmGObjectUI): no_default = not self.is_customize_dialog # CPU features - caps = self.vm.get_connection().get_capabilities() + caps = self.vm.conn.get_capabilities() cpu_values = None cpu_names = [] all_features = [] @@ -1419,41 +1419,41 @@ class vmmDetails(vmmGObjectUI): if not self.vm.is_paused(): self.emit("action-suspend-domain", - self.vm.get_connection().get_uri(), + self.vm.conn.get_uri(), self.vm.get_uuid()) else: self.emit("action-resume-domain", - self.vm.get_connection().get_uri(), + self.vm.conn.get_uri(), self.vm.get_uuid()) def control_vm_run(self, src_ignore): self.emit("action-run-domain", - self.vm.get_connection().get_uri(), self.vm.get_uuid()) + self.vm.conn.get_uri(), self.vm.get_uuid()) def control_vm_shutdown(self, src_ignore): self.emit("action-shutdown-domain", - self.vm.get_connection().get_uri(), self.vm.get_uuid()) + self.vm.conn.get_uri(), self.vm.get_uuid()) def control_vm_reboot(self, src_ignore): self.emit("action-reboot-domain", - self.vm.get_connection().get_uri(), self.vm.get_uuid()) + self.vm.conn.get_uri(), self.vm.get_uuid()) def control_vm_save(self, src_ignore): self.emit("action-save-domain", - self.vm.get_connection().get_uri(), self.vm.get_uuid()) + self.vm.conn.get_uri(), self.vm.get_uuid()) def control_vm_destroy(self, src_ignore): self.emit("action-destroy-domain", - self.vm.get_connection().get_uri(), self.vm.get_uuid()) + self.vm.conn.get_uri(), self.vm.get_uuid()) def control_vm_clone(self, src_ignore): self.emit("action-clone-domain", - self.vm.get_connection().get_uri(), self.vm.get_uuid()) + self.vm.conn.get_uri(), self.vm.get_uuid()) def control_vm_migrate(self, src_ignore): self.emit("action-migrate-domain", - self.vm.get_connection().get_uri(), self.vm.get_uuid()) + self.vm.conn.get_uri(), self.vm.get_uuid()) def control_vm_screenshot(self, src_ignore): image = self.console.viewer.get_pixbuf() @@ -1463,7 +1463,7 @@ class vmmDetails(vmmGObjectUI): path = util.browse_local( self.topwin, _("Save Virtual Machine Screenshot"), - self.vm.get_connection(), + self.vm.conn, _type=("png", "PNG files"), dialog_type=gtk.FILE_CHOOSER_ACTION_SAVE, browse_reason=self.config.CONFIG_DIR_SCREENSHOT) @@ -1476,7 +1476,7 @@ class vmmDetails(vmmGObjectUI): # Save along with a little metadata about us & the domain image.save(filename, 'png', - {'tEXt::Hypervisor URI': self.vm.get_connection().get_uri(), + {'tEXt::Hypervisor URI': self.vm.conn.get_uri(), 'tEXt::Domain Name': self.vm.get_name(), 'tEXt::Domain UUID': self.vm.get_uuid(), 'tEXt::Generator App': self.config.get_appname(), @@ -1672,7 +1672,7 @@ class vmmDetails(vmmGObjectUI): def config_vcpus_changed(self, ignore): self.enable_apply(EDIT_VCPUS) - conn = self.vm.get_connection() + conn = self.vm.conn host_active_count = conn.host_active_processor_count() cur = self.config_get_vcpus() @@ -1692,7 +1692,7 @@ class vmmDetails(vmmGObjectUI): def config_cpu_copy_host(self, src_ignore): # Update UI with output copied from host try: - CPU = virtinst.CPU(self.vm.get_connection().vmm) + CPU = virtinst.CPU(self.vm.conn.vmm) CPU.copy_host_cpu() self._refresh_cpu_config(CPU) @@ -1953,7 +1953,7 @@ class vmmDetails(vmmGObjectUI): vcpu_list = self.widget("config-vcpu-list") vcpu_model = vcpu_list.get_model() row = vcpu_model[path] - conn = self.vm.get_connection() + conn = self.vm.conn try: new_text = new_text.strip() @@ -1972,7 +1972,7 @@ class vmmDetails(vmmGObjectUI): self._refresh_runtime_pinning() def config_vcpu_pin_cpuset(self, cpuset): - conn = self.vm.get_connection() + conn = self.vm.conn vcpu_list = self.widget("config-vcpu-list") vcpu_model = vcpu_list.get_model() @@ -2448,7 +2448,7 @@ class vmmDetails(vmmGObjectUI): # Security details semodel, ignore, vmlabel = self.vm.get_seclabel() - caps = self.vm.get_connection().get_capabilities() + caps = self.vm.conn.get_capabilities() if caps.host.secmodel and caps.host.secmodel.model: semodel = caps.host.secmodel.model @@ -2486,7 +2486,7 @@ class vmmDetails(vmmGObjectUI): cpu_txt = "%d %%" % self.vm.host_cpu_time_percentage() vm_memory = self.vm.stats_memory() - host_memory = self.vm.get_connection().host_memory_size() + host_memory = self.vm.conn.host_memory_size() mem_txt = "%d MB of %d MB" % (int(round(vm_memory / 1024.0)), int(round(host_memory / 1024.0))) @@ -2513,7 +2513,7 @@ class vmmDetails(vmmGObjectUI): self.vm.network_traffic_vector()) def _refresh_cpu_count(self): - conn = self.vm.get_connection() + conn = self.vm.conn host_active_count = conn.host_active_processor_count() maxvcpus = self.vm.vcpu_max_count() curvcpus = self.vm.vcpu_count() @@ -2534,7 +2534,7 @@ class vmmDetails(vmmGObjectUI): self.widget("config-vcpupin").set_text(vcpupin) def _refresh_runtime_pinning(self): - conn = self.vm.get_connection() + conn = self.vm.conn host_active_count = conn.host_active_processor_count() vcpu_list = self.widget("config-vcpu-list") @@ -2577,7 +2577,7 @@ class vmmDetails(vmmGObjectUI): def _refresh_cpu_config(self, cpu): feature_ui = self.widget("cpu-features") model = cpu.model or "" - caps = self.vm.get_connection().get_capabilities() + caps = self.vm.conn.get_capabilities() capscpu = None try: @@ -2625,7 +2625,7 @@ class vmmDetails(vmmGObjectUI): def refresh_config_memory(self): host_mem_widget = self.widget("state-host-memory") - host_mem = self.vm.get_connection().host_memory_size() / 1024 + host_mem = self.vm.conn.host_memory_size() / 1024 vm_cur_mem = self.vm.get_memory() / 1024.0 vm_max_mem = self.vm.maximum_memory() / 1024.0 @@ -2961,7 +2961,7 @@ class vmmDetails(vmmGObjectUI): devtype = hostdev.type pretty_name = None - nodedev = lookup_nodedev(self.vm.get_connection(), hostdev) + nodedev = lookup_nodedev(self.vm.conn, hostdev) if nodedev: pretty_name = nodedev.pretty_name() @@ -3087,7 +3087,7 @@ class vmmDetails(vmmGObjectUI): buses.append(["usb", "USB"]) if self.vm.get_hv_type() == "kvm": buses.append(["virtio", "Virtio"]) - if self.vm.get_connection().is_xen(): + if self.vm.conn.is_xen(): buses.append(["xen", "Xen"]) for row in buses: diff --git a/src/virtManager/domain.py b/src/virtManager/domain.py index 6eeb08de6..969314226 100644 --- a/src/virtManager/domain.py +++ b/src/virtManager/domain.py @@ -124,8 +124,8 @@ class vmmDomain(vmmLibvirtObject): Class wrapping virDomain libvirt objects. Is also extended to be backed by a virtinst.Guest object for new VM 'customize before install' """ - def __init__(self, connection, backend, uuid): - vmmLibvirtObject.__init__(self, connection) + def __init__(self, conn, backend, uuid): + vmmLibvirtObject.__init__(self, conn) self._backend = backend self.uuid = uuid @@ -181,7 +181,7 @@ class vmmDomain(vmmLibvirtObject): """ self._reparse_xml() - self.managedsave_supported = self.connection.get_dom_managedsave_supported(self._backend) + self.managedsave_supported = self.conn.get_dom_managedsave_supported(self._backend) self.getjobinfo_supported = support.check_domain_support(self._backend, support.SUPPORT_DOMAIN_JOB_INFO) @@ -192,7 +192,7 @@ class vmmDomain(vmmLibvirtObject): # Determine available XML flags (older libvirt versions will error # out if passed SECURE_XML, INACTIVE_XML, etc) (self._inactive_xml_flags, - self._active_xml_flags) = self.connection.get_dom_flags(self._backend) + self._active_xml_flags) = self.conn.get_dom_flags(self._backend) self.toggle_sample_network_traffic() self.toggle_sample_disk_io() @@ -245,10 +245,10 @@ class vmmDomain(vmmLibvirtObject): return bool(self._install_abort) def rhel6_defaults(self): - return self.connection.rhel6_defaults(self.get_emulator()) + return self.conn.rhel6_defaults(self.get_emulator()) def is_read_only(self): - if self.connection.is_read_only(): + if self.conn.is_read_only(): return True if self.is_management_domain(): return True @@ -332,9 +332,9 @@ class vmmDomain(vmmLibvirtObject): return self._guest def _build_guest(self, xml): - return virtinst.Guest(connection=self.connection.vmm, + return virtinst.Guest(conn=self.conn.vmm, parsexml=xml, - caps=self.connection.get_capabilities()) + caps=self.conn.get_capabilities()) def _reparse_xml(self, ignore=None): self._guest = self._build_guest(self._get_domain_xml()) @@ -363,7 +363,7 @@ class vmmDomain(vmmLibvirtObject): newxml = guest.get_xml_config() try: - self.get_connection().rename_vm(self, origxml, newxml) + self.conn.rename_vm(self, origxml, newxml) finally: self._invalidate_xml() @@ -739,7 +739,7 @@ class vmmDomain(vmmLibvirtObject): ######################## def _define(self, newxml): - self.get_connection().define_domain(newxml) + self.conn.define_domain(newxml) def _XMLDesc(self, flags): return self._backend.XMLDesc(flags) @@ -865,8 +865,8 @@ class vmmDomain(vmmLibvirtObject): def get_graphics_console(self): gdevs = self.get_graphics_devices() - connhost = self.connection.get_uri_hostname() - transport, connuser = self.connection.get_transport() + connhost = self.conn.get_uri_hostname() + transport, connuser = self.conn.get_transport() gdev = gdevs and gdevs[0] or None gtype = None @@ -1122,7 +1122,7 @@ class vmmDomain(vmmLibvirtObject): if not self.is_active(): curmem = 0 - pcentCurrMem = curmem * 100.0 / self.connection.host_memory_size() + pcentCurrMem = curmem * 100.0 / self.conn.host_memory_size() pcentCurrMem = max(0.0, min(pcentCurrMem, 100.0)) return pcentCurrMem, curmem @@ -1143,7 +1143,7 @@ class vmmDomain(vmmLibvirtObject): libvirt.VIR_DOMAIN_CRASHED]): cpuTime = info[4] - prevCpuTime cpuTimeAbs = info[4] - hostcpus = self.connection.host_active_processor_count() + hostcpus = self.conn.host_active_processor_count() guestcpus = self.vcpu_count() pcentbase = (((cpuTime) * 100.0) / @@ -1400,21 +1400,21 @@ class vmmDomain(vmmLibvirtObject): ################# def set_console_scaling(self, value): - self.config.set_pervm(self.connection.get_uri(), self.uuid, + self.config.set_pervm(self.conn.get_uri(), self.uuid, self.config.set_console_scaling, value) def get_console_scaling(self): - return self.config.get_pervm(self.connection.get_uri(), self.uuid, + return self.config.get_pervm(self.conn.get_uri(), self.uuid, self.config.get_console_scaling) def on_console_scaling_changed(self, cb): - return self.config.listen_pervm(self.connection.get_uri(), self.uuid, + return self.config.listen_pervm(self.conn.get_uri(), self.uuid, self.config.on_console_scaling_changed, cb) def set_details_window_size(self, w, h): - self.config.set_pervm(self.connection.get_uri(), self.uuid, + self.config.set_pervm(self.conn.get_uri(), self.uuid, self.config.set_details_window_size, (w, h)) def get_details_window_size(self): - return self.config.get_pervm(self.connection.get_uri(), self.uuid, + return self.config.get_pervm(self.conn.get_uri(), self.uuid, self.config.get_details_window_size) def inspection_data_updated(self): @@ -1494,7 +1494,7 @@ class vmmDomain(vmmLibvirtObject): return rd, wr def tick(self, now): - if self.connection.get_state() != self.connection.STATE_ACTIVE: + if self.conn.get_state() != self.conn.STATE_ACTIVE: return # Invalidate cached values @@ -1510,9 +1510,9 @@ class vmmDomain(vmmLibvirtObject): # (ie MAX_LONG) so lets clamp it to the actual # physical RAM in machine which is the effective # real world limit - if (self.get_connection().is_xen() and + if (self.conn.is_xen() and self.is_management_domain()): - info[1] = self.connection.host_memory_size() + info[1] = self.conn.host_memory_size() (cpuTime, cpuTimeAbs, pcentHostCpu, pcentGuestCpu) = self._sample_cpu_stats(info, now) @@ -1553,8 +1553,8 @@ class vmmDomainVirtinst(vmmDomain): Used for launching a details window for customizing a VM before install. """ - def __init__(self, connection, backend, uuid): - vmmDomain.__init__(self, connection, backend, uuid) + def __init__(self, conn, backend, uuid): + vmmDomain.__init__(self, conn, backend, uuid) self._orig_xml = None diff --git a/src/virtManager/engine.py b/src/virtManager/engine.py index 58a99cf9e..283402119 100644 --- a/src/virtManager/engine.py +++ b/src/virtManager/engine.py @@ -223,7 +223,7 @@ class vmmEngine(vmmGObject): self.windowManager = None self.windowMigrate = None - self.connections = {} + self.conns = {} self.err = vmmErrorDialog() self.timer = None @@ -281,9 +281,9 @@ class vmmEngine(vmmGObject): # First run PackageKit # ######################## - def add_default_connection(self, manager): + def add_default_conn(self, manager): # Only add default if no connections are currently known - if self.config.get_connections(): + if self.config.get_conn_uris(): return # Manager fail message @@ -335,24 +335,24 @@ class vmmEngine(vmmGObject): def load_stored_uris(self): - uris = self.config.get_connections() + uris = self.config.get_conn_uris() if uris != None: logging.debug("About to connect to uris %s" % uris) for uri in uris: - self.add_connection(uri) + self.add_conn(uri) - def autostart_connections(self): - for uri in self.connections: - conn = self.connections[uri]["connection"] + def autostart_conns(self): + for uri in self.conns: + conn = self.conns[uri]["conn"] if conn.get_autoconnect(): self.connect_to_uri(uri) def connect_to_uri(self, uri, autoconnect=None, do_start=True): try: - conn = self._check_connection(uri) + conn = self._check_conn(uri) if not conn: # Unknown connection, add it - conn = self.add_connection(uri) + conn = self.add_conn(uri) if autoconnect is not None: conn.set_autoconnect(bool(autoconnect)) @@ -369,28 +369,28 @@ class vmmEngine(vmmGObject): return self.connect_to_uri(uri) def _connect_cancelled(self, src): - if len(self.connections.keys()) == 0: + if len(self.conns.keys()) == 0: self.exit_app(src) def _do_vm_removed(self, conn, vmuuid): hvuri = conn.get_uri() - if vmuuid not in self.connections[hvuri]["windowDetails"]: + if vmuuid not in self.conns[hvuri]["windowDetails"]: return - self.connections[hvuri]["windowDetails"][vmuuid].cleanup() - del(self.connections[hvuri]["windowDetails"][vmuuid]) + self.conns[hvuri]["windowDetails"][vmuuid].cleanup() + del(self.conns[hvuri]["windowDetails"][vmuuid]) - def _do_connection_changed(self, connection): - if (connection.get_state() == connection.STATE_ACTIVE or - connection.get_state() == connection.STATE_CONNECTING): + def _do_conn_changed(self, conn): + if (conn.get_state() == conn.STATE_ACTIVE or + conn.get_state() == conn.STATE_CONNECTING): return - hvuri = connection.get_uri() + hvuri = conn.get_uri() - for vmuuid in self.connections[hvuri]["windowDetails"].keys(): - self.connections[hvuri]["windowDetails"][vmuuid].cleanup() - del(self.connections[hvuri]["windowDetails"][vmuuid]) + for vmuuid in self.conns[hvuri]["windowDetails"].keys(): + self.conns[hvuri]["windowDetails"][vmuuid].cleanup() + del(self.conns[hvuri]["windowDetails"][vmuuid]) if (self.windowCreate and self.windowCreate.conn and @@ -428,8 +428,8 @@ class vmmEngine(vmmGObject): return 1 def _tick(self): - for uri in self.connections.keys(): - conn = self.connections[uri]["connection"] + for uri in self.conns.keys(): + conn = self.conns[uri]["conn"] try: conn.tick() except KeyboardInterrupt: @@ -508,9 +508,9 @@ class vmmEngine(vmmGObject): # Do this last, so any manually 'disconnected' signals # take precedence over cleanup signal removal - for uri in self.connections: - self.cleanup_connection(uri) - self.connections = {} + for uri in self.conns: + self.cleanup_conn(uri) + self.conns = {} except: logging.exception("Error cleaning up engine") @@ -546,73 +546,73 @@ class vmmEngine(vmmGObject): from virtManager.inspection import vmmInspection self.inspection = vmmInspection() self.inspection.start() - self.connect("connection-added", self.inspection.conn_added) - self.connect("connection-removed", self.inspection.conn_removed) + self.connect("conn-added", self.inspection.conn_added) + self.connect("conn-removed", self.inspection.conn_removed) return - def add_connection(self, uri): - conn = self._check_connection(uri) + def add_conn(self, uri): + conn = self._check_conn(uri) if conn: return conn conn = vmmConnection(uri) - self.connections[uri] = { - "connection": conn, + self.conns[uri] = { + "conn": conn, "windowHost": None, "windowDetails": {}, "windowClone": None, } conn.connect("vm-removed", self._do_vm_removed) - conn.connect("state-changed", self._do_connection_changed) + conn.connect("state-changed", self._do_conn_changed) conn.tick() - self.emit("connection-added", conn) - self.config.add_connection(conn.get_uri()) + self.emit("conn-added", conn) + self.config.add_conn(conn.get_uri()) return conn - def cleanup_connection(self, uri): + def cleanup_conn(self, uri): try: - if self.connections[uri]["windowHost"]: - self.connections[uri]["windowHost"].cleanup() - if self.connections[uri]["windowClone"]: - self.connections[uri]["windowClone"].cleanup() + if self.conns[uri]["windowHost"]: + self.conns[uri]["windowHost"].cleanup() + if self.conns[uri]["windowClone"]: + self.conns[uri]["windowClone"].cleanup() - details = self.connections[uri]["windowDetails"] + details = self.conns[uri]["windowDetails"] for win in details.values(): win.cleanup() - self.connections[uri]["connection"].cleanup() + self.conns[uri]["conn"].cleanup() except: logging.exception("Error cleaning up conn in engine") - def remove_connection(self, src, uri): + def remove_conn(self, src, uri): ignore = src - self.cleanup_connection(uri) - del(self.connections[uri]) + self.cleanup_conn(uri) + del(self.conns[uri]) - self.emit("connection-removed", uri) - self.config.remove_connection(uri) + self.emit("conn-removed", uri) + self.config.remove_conn(uri) def connect(self, name, callback, *args): handle_id = vmmGObject.connect(self, name, callback, *args) - if name == "connection-added": - for uri in self.connections.keys(): - self.emit("connection-added", - self.connections[uri]["connection"]) + if name == "conn-added": + for uri in self.conns.keys(): + self.emit("conn-added", + self.conns[uri]["conn"]) return handle_id - def _check_connection(self, uri): - conn = self.connections.get(uri) + def _check_conn(self, uri): + conn = self.conns.get(uri) if conn: - return conn["connection"] + return conn["conn"] return None - def _lookup_connection(self, uri): - conn = self._check_connection(uri) + def _lookup_conn(self, uri): + conn = self._check_conn(uri) if not conn: raise RuntimeError(_("Unknown connection URI %s") % uri) return conn @@ -656,10 +656,10 @@ class vmmEngine(vmmGObject): src.err.show_err(_("Error launching preferences: %s") % str(e)) def _get_host_dialog(self, uri): - if self.connections[uri]["windowHost"]: - return self.connections[uri]["windowHost"] + if self.conns[uri]["windowHost"]: + return self.conns[uri]["windowHost"] - con = self._lookup_connection(uri) + con = self._lookup_conn(uri) obj = vmmHost(con) obj.connect("action-show-help", self._do_show_help) @@ -669,8 +669,8 @@ class vmmEngine(vmmGObject): obj.connect("host-opened", self.increment_window_counter) obj.connect("host-closed", self.decrement_window_counter) - self.connections[uri]["windowHost"] = obj - return self.connections[uri]["windowHost"] + self.conns[uri]["windowHost"] = obj + return self.conns[uri]["windowHost"] def _do_show_host(self, src, uri): try: @@ -699,10 +699,10 @@ class vmmEngine(vmmGObject): src.err.show_err(_("Error launching connect dialog: %s") % str(e)) def _get_details_dialog(self, uri, uuid): - if uuid in self.connections[uri]["windowDetails"]: - return self.connections[uri]["windowDetails"][uuid] + if uuid in self.conns[uri]["windowDetails"]: + return self.conns[uri]["windowDetails"][uuid] - con = self._lookup_connection(uri) + con = self._lookup_conn(uri) obj = vmmDetails(con.get_vm(uuid)) obj.connect("action-save-domain", self._do_save_domain) @@ -720,8 +720,8 @@ class vmmEngine(vmmGObject): obj.connect("details-opened", self.increment_window_counter) obj.connect("details-closed", self.decrement_window_counter) - self.connections[uri]["windowDetails"][uuid] = obj - return self.connections[uri]["windowDetails"][uuid] + self.conns[uri]["windowDetails"][uuid] = obj + return self.conns[uri]["windowDetails"][uuid] def _show_vm_helper(self, src, uri, uuid, page=None, forcepage=False): try: @@ -770,11 +770,11 @@ class vmmEngine(vmmGObject): obj.connect("action-exit-app", self.exit_app) obj.connect("manager-opened", self.increment_window_counter) obj.connect("manager-closed", self.decrement_window_counter) - obj.connect("remove-connection", self.remove_connection) - obj.connect("add-default-connection", self.add_default_connection) + obj.connect("remove-conn", self.remove_conn) + obj.connect("add-default-conn", self.add_default_conn) - self.connect("connection-added", obj.add_connection) - self.connect("connection-removed", obj.remove_connection) + self.connect("conn-added", obj.add_conn) + self.connect("conn-removed", obj.remove_conn) self.windowManager = obj return self.windowManager @@ -813,7 +813,7 @@ class vmmEngine(vmmGObject): def _do_show_migrate(self, src, uri, uuid): try: - conn = self._lookup_connection(uri) + conn = self._lookup_conn(uri) vm = conn.get_vm(uuid) if not self.windowMigrate: @@ -825,15 +825,15 @@ class vmmEngine(vmmGObject): src.err.show_err(_("Error launching migrate dialog: %s") % str(e)) def _do_show_clone(self, src, uri, uuid): - con = self._lookup_connection(uri) + con = self._lookup_conn(uri) orig_vm = con.get_vm(uuid) - clone_window = self.connections[uri]["windowClone"] + clone_window = self.conns[uri]["windowClone"] try: if clone_window == None: clone_window = vmmCloneVM(orig_vm) clone_window.connect("action-show-help", self._do_show_help) - self.connections[uri]["windowClone"] = clone_window + self.conns[uri]["windowClone"] = clone_window else: clone_window.set_orig_vm(orig_vm) @@ -874,7 +874,7 @@ class vmmEngine(vmmGObject): ####################################### def _do_save_domain(self, src, uri, uuid): - conn = self._lookup_connection(uri) + conn = self._lookup_conn(uri) vm = conn.get_vm(uuid) managed = bool(vm.managedsave_supported) @@ -935,14 +935,14 @@ class vmmEngine(vmmGObject): return def _save_callback(self, asyncjob, vm, file_to_save): - conn = util.dup_conn(vm.connection) + conn = util.dup_conn(vm.conn) newvm = conn.get_vm(vm.get_uuid()) meter = vmmCreateMeter(asyncjob) newvm.save(file_to_save, meter=meter) def _do_restore_domain(self, src, uri): - conn = self._lookup_connection(uri) + conn = self._lookup_conn(uri) if conn.is_remote(): src.err.val_err(_("Restoring virtual machines over remote " "connections is not yet supported")) @@ -964,7 +964,7 @@ class vmmEngine(vmmGObject): _("Error restoring domain")) def _do_destroy_domain(self, src, uri, uuid): - conn = self._lookup_connection(uri) + conn = self._lookup_conn(uri) vm = conn.get_vm(uuid) if not util.chkbox_helper(src, self.config.get_confirm_forcepoweroff, @@ -980,7 +980,7 @@ class vmmEngine(vmmGObject): _("Error shutting down domain")) def _do_suspend_domain(self, src, uri, uuid): - conn = self._lookup_connection(uri) + conn = self._lookup_conn(uri) vm = conn.get_vm(uuid) if not util.chkbox_helper(src, self.config.get_confirm_pause, @@ -994,7 +994,7 @@ class vmmEngine(vmmGObject): _("Error pausing domain")) def _do_resume_domain(self, src, uri, uuid): - conn = self._lookup_connection(uri) + conn = self._lookup_conn(uri) vm = conn.get_vm(uuid) logging.debug("Unpausing vm '%s'." % vm.get_name()) @@ -1002,7 +1002,7 @@ class vmmEngine(vmmGObject): _("Error unpausing domain")) def _do_run_domain(self, src, uri, uuid): - conn = self._lookup_connection(uri) + conn = self._lookup_conn(uri) vm = conn.get_vm(uuid) logging.debug("Starting vm '%s'." % vm.get_name()) @@ -1023,7 +1023,7 @@ class vmmEngine(vmmGObject): vmmAsyncJob.simple_async_noshow(vm.startup, [], src, errorintro) def _do_shutdown_domain(self, src, uri, uuid): - conn = self._lookup_connection(uri) + conn = self._lookup_conn(uri) vm = conn.get_vm(uuid) if not util.chkbox_helper(src, self.config.get_confirm_poweroff, @@ -1037,7 +1037,7 @@ class vmmEngine(vmmGObject): _("Error shutting down domain")) def _do_reboot_domain(self, src, uri, uuid): - conn = self._lookup_connection(uri) + conn = self._lookup_conn(uri) vm = conn.get_vm(uuid) if not util.chkbox_helper(src, self.config.get_confirm_poweroff, @@ -1076,5 +1076,5 @@ class vmmEngine(vmmGObject): vmmAsyncJob.simple_async_noshow(reboot_cb, [], src, "") vmmGObject.type_register(vmmEngine) -vmmEngine.signal_new(vmmEngine, "connection-added", [object]) -vmmEngine.signal_new(vmmEngine, "connection-removed", [str]) +vmmEngine.signal_new(vmmEngine, "conn-added", [object]) +vmmEngine.signal_new(vmmEngine, "conn-removed", [str]) diff --git a/src/virtManager/interface.py b/src/virtManager/interface.py index bd74c35da..01bf05514 100644 --- a/src/virtManager/interface.py +++ b/src/virtManager/interface.py @@ -24,8 +24,8 @@ from virtManager import util from virtManager.libvirtobject import vmmLibvirtObject class vmmInterface(vmmLibvirtObject): - def __init__(self, connection, interface, name, active): - vmmLibvirtObject.__init__(self, connection) + def __init__(self, conn, interface, name, active): + vmmLibvirtObject.__init__(self, conn) self.interface = interface # Libvirt virInterface object self.name = name # String name @@ -35,7 +35,7 @@ class vmmInterface(vmmLibvirtObject): self._xml_flags = None (self._inactive_xml_flags, - self._active_xml_flags) = self.connection.get_interface_flags( + self._active_xml_flags) = self.conn.get_interface_flags( self.interface) self.refresh_xml() @@ -45,7 +45,7 @@ class vmmInterface(vmmLibvirtObject): return self.interface.XMLDesc(flags) def _define(self, xml): - return self.get_connection().define_interface(xml) + return self.conn.define_interface(xml) def xpath(self, *args, **kwargs): # Must use this function for ALL XML parsing diff --git a/src/virtManager/libvirtobject.py b/src/virtManager/libvirtobject.py index 27190ffb2..8afcb4ed2 100644 --- a/src/virtManager/libvirtobject.py +++ b/src/virtManager/libvirtobject.py @@ -35,9 +35,9 @@ def _sanitize_xml(xml): return xml class vmmLibvirtObject(vmmGObject): - def __init__(self, connection): + def __init__(self, conn): vmmGObject.__init__(self) - self.connection = connection + self._conn = conn self._xml = None self._is_xml_valid = False @@ -46,8 +46,9 @@ class vmmLibvirtObject(vmmGObject): self._inactive_xml_flags = 0 self._active_xml_flags = 0 - def get_connection(self): - return self.connection + def _get_conn(self): + return self._conn + conn = property(_get_conn) ############################################################# # Functions that should probably be overridden in sub class # diff --git a/src/virtManager/manager.py b/src/virtManager/manager.py index 0f4534ec9..d69833fcc 100644 --- a/src/virtManager/manager.py +++ b/src/virtManager/manager.py @@ -109,7 +109,7 @@ class vmmManager(vmmGObjectUI): "on_vm_manager_delete_event": self.close, "on_vmm_manager_configure_event": self.window_resized, - "on_menu_file_add_connection_activate": self.new_connection, + "on_menu_file_add_connection_activate": self.new_conn, "on_menu_file_quit_activate": self.exit_app, "on_menu_file_close_activate": self.close, "on_vmm_close_clicked": self.close, @@ -157,7 +157,7 @@ class vmmManager(vmmGObjectUI): vmlist.get_model().get_iter_first()) # Queue up the default connection detector - self.idle_emit("add-default-connection") + self.idle_emit("add-default-conn") ################## # Common methods # @@ -343,9 +343,9 @@ class vmmManager(vmmGObjectUI): # Build connection context menu add_conn_menu("create", gtk.STOCK_NEW, None, self.new_vm) - add_conn_menu("connect", gtk.STOCK_CONNECT, None, self.open_connection) + add_conn_menu("connect", gtk.STOCK_CONNECT, None, self.open_conn) add_conn_menu("disconnect", gtk.STOCK_DISCONNECT, None, - self.close_connection) + self.close_conn) add_sep(self.connmenu, self.connmenu_items, "hsep1") add_conn_menu("delete", gtk.STOCK_DELETE, None, self.do_delete) add_sep(self.connmenu, self.connmenu_items, "hsep2") @@ -457,7 +457,7 @@ class vmmManager(vmmGObjectUI): return row[ROW_HANDLE] - def current_connection(self): + def current_conn(self): row = self.current_row() if not row: return None @@ -466,7 +466,7 @@ class vmmManager(vmmGObjectUI): if row[ROW_IS_CONN]: return handle else: - return handle.get_connection() + return handle.conn def current_vmuuid(self): vm = self.current_vm() @@ -474,11 +474,11 @@ class vmmManager(vmmGObjectUI): return None return vm.get_uuid() - def current_connection_uri(self, default_selection=False): + def current_conn_uri(self, default_selection=False): vmlist = self.widget("vm-list") model = vmlist.get_model() - conn = self.current_connection() + conn = self.current_conn() if conn is None and default_selection: # Nothing selected, use first connection row for row in model: @@ -504,11 +504,11 @@ class vmmManager(vmmGObjectUI): def exit_app(self, src_ignore=None, src2_ignore=None): self.emit("action-exit-app") - def new_connection(self, src_ignore=None): + def new_conn(self, src_ignore=None): self.emit("action-show-connect") def new_vm(self, src_ignore=None): - self.emit("action-show-create", self.current_connection_uri()) + self.emit("action-show-create", self.current_conn_uri()) def show_about(self, src_ignore): self.emit("action-show-about") @@ -520,11 +520,11 @@ class vmmManager(vmmGObjectUI): self.emit("action-show-preferences") def show_host(self, src_ignore): - uri = self.current_connection_uri(default_selection=True) + uri = self.current_conn_uri(default_selection=True) self.emit("action-show-host", uri) def show_vm(self, ignore, ignore2=None, ignore3=None): - conn = self.current_connection() + conn = self.current_conn() vm = self.current_vm() if conn is None: return @@ -532,23 +532,23 @@ class vmmManager(vmmGObjectUI): if vm: self.emit("action-show-vm", conn.get_uri(), vm.get_uuid()) else: - if not self.open_connection(): + if not self.open_conn(): self.emit("action-show-host", conn.get_uri()) def open_clone_window(self, ignore1=None, ignore2=None, ignore3=None): if self.current_vmuuid(): - self.emit("action-clone-domain", self.current_connection_uri(), + self.emit("action-clone-domain", self.current_conn_uri(), self.current_vmuuid()) def do_delete(self, ignore=None): - conn = self.current_connection() + conn = self.current_conn() vm = self.current_vm() if vm is None: - self._do_delete_connection(conn) + self._do_delete_conn(conn) else: self._do_delete_vm(vm) - def _do_delete_connection(self, conn): + def _do_delete_conn(self, conn): if conn is None: return @@ -557,7 +557,7 @@ class vmmManager(vmmGObjectUI): if not result: return - self.emit("remove-connection", conn.get_uri()) + self.emit("remove-conn", conn.get_uri()) def _do_delete_vm(self, vm): if vm.is_active(): @@ -594,57 +594,57 @@ class vmmManager(vmmGObjectUI): vm = self.current_vm() if vm is not None: self.emit("action-run-domain", - vm.get_connection().get_uri(), vm.get_uuid()) + vm.conn.get_uri(), vm.get_uuid()) def reboot_vm(self, ignore): vm = self.current_vm() if vm is not None: self.emit("action-reboot-domain", - vm.get_connection().get_uri(), vm.get_uuid()) + vm.conn.get_uri(), vm.get_uuid()) def poweroff_vm(self, ignore): vm = self.current_vm() if vm is not None: self.emit("action-shutdown-domain", - vm.get_connection().get_uri(), vm.get_uuid()) + vm.conn.get_uri(), vm.get_uuid()) def destroy_vm(self, ignore): vm = self.current_vm() if vm is not None: self.emit("action-destroy-domain", - vm.get_connection().get_uri(), vm.get_uuid()) + vm.conn.get_uri(), vm.get_uuid()) def save_vm(self, ignore): vm = self.current_vm() if vm is not None: self.emit("action-save-domain", - vm.get_connection().get_uri(), vm.get_uuid()) + vm.conn.get_uri(), vm.get_uuid()) def pause_vm(self, ignore): vm = self.current_vm() if vm is not None: self.emit("action-suspend-domain", - vm.get_connection().get_uri(), vm.get_uuid()) + vm.conn.get_uri(), vm.get_uuid()) def resume_vm(self, ignore): vm = self.current_vm() if vm is not None: self.emit("action-resume-domain", - vm.get_connection().get_uri(), vm.get_uuid()) + vm.conn.get_uri(), vm.get_uuid()) def migrate_vm(self, ignore): vm = self.current_vm() if vm is not None: self.emit("action-migrate-domain", - vm.get_connection().get_uri(), vm.get_uuid()) + vm.conn.get_uri(), vm.get_uuid()) - def close_connection(self, ignore): - conn = self.current_connection() + def close_conn(self, ignore): + conn = self.current_conn() if conn.get_state() != vmmConnection.STATE_DISCONNECTED: conn.close() - def open_connection(self, ignore=None): - conn = self.current_connection() + def open_conn(self, ignore=None): + conn = self.current_conn() if conn.get_state() == vmmConnection.STATE_DISCONNECTED: conn.open() return True @@ -674,7 +674,7 @@ class vmmManager(vmmGObjectUI): #################################### def vm_row_key(self, vm): - return vm.get_uuid() + ":" + vm.get_connection().get_uri() + return vm.get_uuid() + ":" + vm.conn.get_uri() def vm_added(self, conn, vmuuid): vm = conn.get_vm(vmuuid) @@ -766,7 +766,7 @@ class vmmManager(vmmGObjectUI): # Expand a connection when adding a vm to it self.widget("vm-list").expand_row(model.get_path(parent), False) - def _append_connection(self, model, conn): + def _append_conn(self, model, conn): row = [] row.insert(ROW_HANDLE, conn) row.insert(ROW_NAME, conn.get_pretty_desc_inactive(False)) @@ -789,7 +789,7 @@ class vmmManager(vmmGObjectUI): self.rows[conn.get_uri()] = model[path] return _iter - def add_connection(self, engine_ignore, conn): + def add_conn(self, engine_ignore, conn): # Make sure error page isn't showing self.widget("vm-notebook").set_current_page(0) @@ -804,7 +804,7 @@ class vmmManager(vmmGObjectUI): # add the connection to the treeModel vmlist = self.widget("vm-list") - row = self._append_connection(vmlist.get_model(), conn) + row = self._append_conn(vmlist.get_model(), conn) vmlist.get_selection().select_iter(row) # Try to make sure that 2 row descriptions don't collide @@ -825,7 +825,7 @@ class vmmManager(vmmGObjectUI): newname = conn.get_pretty_desc_inactive(False, True) self.conn_refresh_resources(conn, newname) - def remove_connection(self, engine_ignore, uri): + def remove_conn(self, engine_ignore, uri): model = self.widget("vm-list").get_model() parent = self.rows[uri].iter @@ -849,7 +849,7 @@ class vmmManager(vmmGObjectUI): def vm_status_changed(self, vm, oldstatus, newstatus): ignore = newstatus ignore = oldstatus - parent = self.rows[vm.get_connection().get_uri()].iter + parent = self.rows[vm.conn.get_uri()].iter vmlist = self.widget("vm-list") model = vmlist.get_model() @@ -861,7 +861,7 @@ class vmmManager(vmmGObjectUI): break if missing: - self._append_vm(model, vm, vm.get_connection()) + self._append_vm(model, vm, vm.conn) # Update run/shutdown/pause button states self.vm_selected() @@ -953,7 +953,7 @@ class vmmManager(vmmGObjectUI): self.widget("vm-run").set_label(strip_text) def vm_selected(self, ignore=None): - conn = self.current_connection() + conn = self.current_conn() vm = self.current_vm() show_open = bool(vm) @@ -1193,5 +1193,5 @@ vmmManager.signal_new(vmmManager, "action-clone-domain", [str, str]) vmmManager.signal_new(vmmManager, "action-exit-app", []) vmmManager.signal_new(vmmManager, "manager-closed", []) vmmManager.signal_new(vmmManager, "manager-opened", []) -vmmManager.signal_new(vmmManager, "remove-connection", [str]) -vmmManager.signal_new(vmmManager, "add-default-connection", []) +vmmManager.signal_new(vmmManager, "remove-conn", [str]) +vmmManager.signal_new(vmmManager, "add-default-conn", []) diff --git a/src/virtManager/mediadev.py b/src/virtManager/mediadev.py index 57e418361..e7be21253 100644 --- a/src/virtManager/mediadev.py +++ b/src/virtManager/mediadev.py @@ -146,7 +146,7 @@ class vmmMediaDevice(vmmGObject): if not self.nodedev_obj: return False - if not self.nodedev_obj.get_connection().is_active(): + if not self.nodedev_obj.conn.is_active(): return False try: diff --git a/src/virtManager/migrate.py b/src/virtManager/migrate.py index 4c31b268b..c0dffed2e 100644 --- a/src/virtManager/migrate.py +++ b/src/virtManager/migrate.py @@ -50,7 +50,7 @@ class vmmMigrateDialog(vmmGObjectUI): def __init__(self, vm, engine): vmmGObjectUI.__init__(self, "vmm-migrate.glade", "vmm-migrate") self.vm = vm - self.conn = vm.connection + self.conn = vm.conn self.engine = engine self.destconn_rows = [] @@ -118,8 +118,8 @@ class vmmMigrateDialog(vmmGObjectUI): # XXX no way to set tooltips here, kind of annoying # Hook up signals to get connection listing - self.engine.connect("connection-added", self.dest_add_connection) - self.engine.connect("connection-removed", self.dest_remove_connection) + self.engine.connect("conn-added", self.dest_add_conn) + self.engine.connect("conn-removed", self.dest_remove_conn) self.destconn_changed(dest_combo) def reset_state(self): @@ -178,7 +178,7 @@ class vmmMigrateDialog(vmmGObjectUI): def set_state(self, vm): self.vm = vm - self.conn = vm.connection + self.conn = vm.conn self.reset_state() def destconn_changed(self, src): @@ -371,7 +371,7 @@ class vmmMigrateDialog(vmmGObjectUI): combo.set_active(idx) - def dest_add_connection(self, engine_ignore, conn): + def dest_add_conn(self, engine_ignore, conn): combo = self.widget("migrate-dest") model = combo.get_model() @@ -386,7 +386,7 @@ class vmmMigrateDialog(vmmGObjectUI): self.destconn_rows.append(newrow) self.populate_dest_combo() - def dest_remove_connection(self, engine_ignore, uri): + def dest_remove_conn(self, engine_ignore, uri): # Make sure connection isn't already present for row in self.destconn_rows: if row[1] and row[1].get_uri() == uri: @@ -452,7 +452,7 @@ class vmmMigrateDialog(vmmGObjectUI): return destconn = self.get_config_destconn() - srchost = self.vm.get_connection().get_hostname() + srchost = self.vm.conn.get_hostname() dsthost = destconn.get_qualified_hostname() max_downtime = self.get_config_max_downtime() live = not self.get_config_offline() @@ -537,7 +537,7 @@ class vmmMigrateDialog(vmmGObjectUI): secure, max_downtime): meter = vmmCreateMeter(asyncjob) - srcconn = util.dup_conn(origvm.get_connection()) + srcconn = util.dup_conn(origvm.conn) dstconn = util.dup_conn(origdconn) vminst = srcconn.vmm.lookupByName(origvm.get_name()) diff --git a/src/virtManager/network.py b/src/virtManager/network.py index 27ebcd756..aa918b8a5 100644 --- a/src/virtManager/network.py +++ b/src/virtManager/network.py @@ -46,8 +46,8 @@ class vmmNetwork(vmmLibvirtObject): return desc - def __init__(self, connection, net, uuid, active): - vmmLibvirtObject.__init__(self, connection) + def __init__(self, conn, net, uuid, active): + vmmLibvirtObject.__init__(self, conn) self.net = net self.uuid = uuid self.active = active @@ -58,7 +58,7 @@ class vmmNetwork(vmmLibvirtObject): def _XMLDesc(self, flags): return self.net.XMLDesc(flags) def _define(self, xml): - return self.get_connection().vmm.networkDefineXML(xml) + return self.conn.vmm.networkDefineXML(xml) def set_active(self, state): self.active = state diff --git a/src/virtManager/nodedev.py b/src/virtManager/nodedev.py index eb57b200b..cc102f82c 100644 --- a/src/virtManager/nodedev.py +++ b/src/virtManager/nodedev.py @@ -23,8 +23,8 @@ import virtinst from virtManager.libvirtobject import vmmLibvirtObject class vmmNodeDevice(vmmLibvirtObject): - def __init__(self, connection, backend, name): - vmmLibvirtObject.__init__(self, connection) + def __init__(self, conn, backend, name): + vmmLibvirtObject.__init__(self, conn) self.name = name self._backend = backend diff --git a/src/virtManager/serialcon.py b/src/virtManager/serialcon.py index 996c2dd4c..2b33f6cdf 100644 --- a/src/virtManager/serialcon.py +++ b/src/virtManager/serialcon.py @@ -39,7 +39,7 @@ class ConsoleConnection(vmmGObject): vmmGObject.__init__(self) self.vm = vm - self.conn = vm.get_connection() + self.conn = vm.conn def cleanup(self): vmmGObject.cleanup(self) @@ -257,7 +257,7 @@ class vmmSerialConsole(vmmGObject): ctype = dev.char_type path = dev.source_path - is_remote = vm.get_connection().is_remote() + is_remote = vm.conn.is_remote() support_tunnel = vmmSerialConsole.support_remote_console(vm) err = "" diff --git a/src/virtManager/storagepool.py b/src/virtManager/storagepool.py index 685581667..659c702f4 100644 --- a/src/virtManager/storagepool.py +++ b/src/virtManager/storagepool.py @@ -25,8 +25,8 @@ from virtManager.libvirtobject import vmmLibvirtObject from virtManager.storagevol import vmmStorageVolume class vmmStoragePool(vmmLibvirtObject): - def __init__(self, connection, pool, uuid, active): - vmmLibvirtObject.__init__(self, connection) + def __init__(self, conn, pool, uuid, active): + vmmLibvirtObject.__init__(self, conn) self.pool = pool # Libvirt pool object self.uuid = uuid # String UUID @@ -43,7 +43,7 @@ class vmmStoragePool(vmmLibvirtObject): def _XMLDesc(self, flags): return self.pool.XMLDesc(flags) def _define(self, xml): - return self.get_connection().vmm.storagePoolDefineXML(xml, 0) + return self.conn.vmm.storagePoolDefineXML(xml, 0) def set_active(self, state): @@ -129,7 +129,7 @@ class vmmStoragePool(vmmLibvirtObject): if volname in self._volumes: new_vol_list[volname] = self._volumes[volname] else: - new_vol_list[volname] = vmmStorageVolume(self.connection, + new_vol_list[volname] = vmmStorageVolume(self.conn, self.pool.storageVolLookupByName(volname), volname) self._volumes = new_vol_list diff --git a/src/virtManager/storagevol.py b/src/virtManager/storagevol.py index f183444db..d6e7be731 100644 --- a/src/virtManager/storagevol.py +++ b/src/virtManager/storagevol.py @@ -22,8 +22,8 @@ from virtManager import util from virtManager.libvirtobject import vmmLibvirtObject class vmmStorageVolume(vmmLibvirtObject): - def __init__(self, connection, vol, name): - vmmLibvirtObject.__init__(self, connection) + def __init__(self, conn, vol, name): + vmmLibvirtObject.__init__(self, conn) self.vol = vol # Libvirt storage volume object self.name = name @@ -39,7 +39,7 @@ class vmmStorageVolume(vmmLibvirtObject): def get_pool(self): pobj = self.vol.storagePoolLookupByVolume() - return self.connection.get_pool_by_name(pobj.name()) + return self.conn.get_pool_by_name(pobj.name()) def delete(self): self.vol.delete(0) diff --git a/src/virtManager/systray.py b/src/virtManager/systray.py index 6eb2a7841..b8b2407fd 100644 --- a/src/virtManager/systray.py +++ b/src/virtManager/systray.py @@ -55,8 +55,8 @@ class vmmSystray(vmmGObject): self.systray_icon = None self.systray_indicator = False - engine.connect("connection-added", self.conn_added) - engine.connect("connection-removed", self.conn_removed) + engine.connect("conn-added", self.conn_added) + engine.connect("conn-removed", self.conn_removed) # Are we using Application Indicators? if appindicator is not None: @@ -237,7 +237,7 @@ class vmmSystray(vmmGObject): # Helper functions def _get_vm_menu_item(self, vm): uuid = vm.get_uuid() - uri = vm.get_connection().get_uri() + uri = vm.conn.get_uri() if uri in self.conn_vm_menuitems: if uuid in self.conn_vm_menuitems[uri]: diff --git a/src/virtManager/uihelpers.py b/src/virtManager/uihelpers.py index 7f9cbce3d..de18ad820 100644 --- a/src/virtManager/uihelpers.py +++ b/src/virtManager/uihelpers.py @@ -150,7 +150,7 @@ def populate_video_combo(vm, video_dev, no_default=None): vm.get_video_devices())) video_dev_model.clear() - tmpdev = virtinst.VirtualVideoDevice(vm.get_connection().vmm) + tmpdev = virtinst.VirtualVideoDevice(vm.conn.vmm) for m in tmpdev.model_types: if not vm.rhel6_defaults(): if m == "qxl" and not has_spice and not has_qxl: