def _connect_error(self, conn, errmsg, tb, warnconsole):
        errmsg = errmsg.strip(" \n")
        tb = tb.strip(" \n")
        hint = ""
        show_errmsg = True

        if conn.is_remote():
            logging.debug(conn.get_transport())
            if re.search(r"nc: .* -- 'U'", tb):
                hint += _("The remote host requires a version of netcat/nc\n"
                          "which supports the -U option.")
                show_errmsg = False
            elif (conn.get_transport()[0] == "ssh" and
                  re.search(r"ssh-askpass", tb)):

                if self.config.askpass_package:
                    ret = packageutils.check_packagekit(
                                            self.err,
                                            self.config.askpass_package,
                                            False)
                    if ret:
                        conn.open()
                        return

                hint += _("You need to install openssh-askpass or "
                          "similar\nto connect to this host.")
                show_errmsg = False
            else:
                hint += _("Verify that the 'libvirtd' daemon is running\n"
                          "on the remote host.")

        elif conn.is_xen():
            hint += _("Verify that:\n"
                      " - A Xen host kernel was booted\n"
                      " - The Xen service has been started")

        else:
            if warnconsole:
                hint += _("Could not detect a local session: if you are \n"
                          "running virt-manager over ssh -X or VNC, you \n"
                          "may not be able to connect to libvirt as a \n"
                          "regular user. Try running as root.")
                show_errmsg = False
            elif re.search(r"libvirt-sock", tb):
                hint += _("Verify that the 'libvirtd' daemon is running.")
                show_errmsg = False

        msg = _("Unable to connect to libvirt.")
        if show_errmsg:
            msg += "\n\n%s" % errmsg
        if hint:
            msg += "\n\n%s" % hint

        msg = msg.strip("\n")
        details = msg
        details += "\n\n"
        details += "Libvirt URI is: %s\n\n" % conn.get_uri()
        details += tb

        self.err.show_err(msg, details, title=_("Virtual Machine Manager Connection Failure"))
    def add_default_conn(self, manager):
        # Only add default if no connections are currently known
        if self.config.get_conn_uris():
            return

        # Manager fail message
        msg = _(
            "Could not detect a default hypervisor. Make\n"
            "sure the appropriate virtualization packages\n"
            "are installed (kvm, qemu, libvirt, etc.), and\n"
            "that libvirtd is running.\n\n"
            "A hypervisor connection can be manually\n"
            "added via File->Add Connection"
        )

        logging.debug("Determining default libvirt URI")

        ret = None
        did_install_libvirt = False
        try:
            libvirt_packages = self.config.libvirt_packages
            packages = self.config.hv_packages + libvirt_packages

            ret = packageutils.check_packagekit(self.err, packages, True)
        except:
            logging.exception("Error talking to PackageKit")

        if ret is not None:
            did_install_libvirt = False
            for p in libvirt_packages:
                if p in ret:
                    did_install_libvirt = True
                    break

            tryuri = "qemu:///system"
        else:
            tryuri = default_uri()

        if tryuri is None:
            manager.set_startup_error(msg)
            return

        if did_install_libvirt:
            didstart = packageutils.start_libvirtd()
            warnmsg = _(
                "Libvirt was just installed, so the 'libvirtd' service will\n"
                "will need to be started.\n"
                "virt-manager will connect to libvirt on the next application\n"
                "start up."
            )

            if not didstart:
                self.err.ok(_("Libvirt service must be started"), warnmsg)

        self.connect_to_uri(tryuri, autoconnect=True, do_start=not did_install_libvirt)
Exemplo n.º 3
0
    def add_default_conn(self, manager):
        # Only add default if no connections are currently known
        if self.config.get_conn_uris():
            return

        # Manager fail message
        msg = _("Could not detect a default hypervisor. Make\n"
                "sure the appropriate virtualization packages\n"
                "are installed (kvm, qemu, libvirt, etc.), and\n"
                "that libvirtd is running.\n\n"
                "A hypervisor connection can be manually\n"
                "added via File->Add Connection")

        logging.debug("Determining default libvirt URI")

        ret = None
        did_install_libvirt = False
        try:
            libvirt_packages = self.config.libvirt_packages
            packages = self.config.hv_packages + libvirt_packages

            ret = packageutils.check_packagekit(self.err, packages, True)
        except:
            logging.exception("Error talking to PackageKit")

        if ret is not None:
            did_install_libvirt = False
            for p in libvirt_packages:
                if p in ret:
                    did_install_libvirt = True
                    break

            tryuri = "qemu:///system"
        else:
            tryuri = default_uri()

        if tryuri is None:
            manager.set_startup_error(msg)
            return

        if did_install_libvirt:
            didstart = packageutils.start_libvirtd()
            warnmsg = _(
                "Libvirt was just installed, so the 'libvirtd' service will\n"
                "will need to be started.\n"
                "virt-manager will connect to libvirt on the next application\n"
                "start up.")

            if not didstart:
                self.err.ok(_("Libvirt service must be started"), warnmsg)

        self.connect_to_uri(tryuri,
                            autoconnect=True,
                            do_start=not did_install_libvirt)
Exemplo n.º 4
0
    def add_default_conn(self, manager):
        # Only add default if no connections are currently known
        if self.config.get_conn_uris():
            return

        # Manager fail message
        msg = _("Could not detect a default hypervisor. Make\n"
                "sure the appropriate virtualization packages\n"
                "are installed (kvm, qemu, libvirt, etc.), and\n"
                "that libvirtd is running.\n\n"
                "A hypervisor connection can be manually\n"
                "added via File->Add Connection")

        logging.debug("Determining default libvirt URI")

        ret = None
        try:
            libvirt_packages = self.config.libvirt_packages
            packages = self.config.hv_packages + libvirt_packages

            ret = packageutils.check_packagekit(manager.err, packages, True)
        except:
            logging.exception("Error talking to PackageKit")

        if ret is not None:
            tryuri = "qemu:///system"
        else:
            tryuri = default_uri()

        if tryuri is None:
            manager.set_startup_error(msg)
            return

        warnmsg = _("virt-manager will connect to libvirt on the next\n"
            "application start up.")
        if any(["libvirt" in p for p in ret or []]):
            warnmsg = _(
              "Libvirt was just installed, so the 'libvirtd' service will\n"
              "will need to be started.") + "\n\n" + warnmsg

        # Do the initial connection in an idle callback, so the
        # packagekit async dialog has a chance to go away
        def idle_connect():
            do_start = packageutils.start_libvirtd()
            if not do_start:
                manager.err.ok(_("Libvirt service must be started"), warnmsg)

            self.connect_to_uri(tryuri, autoconnect=True, do_start=do_start)
        self.idle_add(idle_connect)
Exemplo n.º 5
0
    def add_default_conn(self, manager):
        # Only add default if no connections are currently known
        if self.config.get_conn_uris():
            return

        # Manager fail message
        msg = _("Could not detect a default hypervisor. Make\n"
                "sure the appropriate virtualization packages\n"
                "are installed (kvm, qemu, libvirt, etc.), and\n"
                "that libvirtd is running.\n\n"
                "A hypervisor connection can be manually\n"
                "added via File->Add Connection")

        logging.debug("Determining default libvirt URI")

        ret = None
        try:
            libvirt_packages = self.config.libvirt_packages
            packages = self.config.hv_packages + libvirt_packages

            ret = packageutils.check_packagekit(manager.err, packages, True)
        except:
            logging.exception("Error talking to PackageKit")

        if ret is not None:
            tryuri = "qemu:///system"
        else:
            tryuri = default_uri()

        if tryuri is None:
            manager.set_startup_error(msg)
            return

        warnmsg = _("virt-manager will connect to libvirt on the next\n"
            "application start up.")
        if any(["libvirt" in p for p in ret or []]):
            warnmsg = _(
              "Libvirt was just installed, so the 'libvirtd' service will\n"
              "will need to be started.") + "\n\n" + warnmsg

        # Do the initial connection in an idle callback, so the
        # packagekit async dialog has a chance to go away
        def idle_connect():
            do_start = packageutils.start_libvirtd()
            if not do_start:
                manager.err.ok(_("Libvirt service must be started"), warnmsg)

            self.connect_to_uri(tryuri, autoconnect=True, do_start=do_start)
        self.idle_add(idle_connect)
Exemplo n.º 6
0
    def _add_default_conn(self, manager):
        # Manager fail message
        msg = _("Could not detect a default hypervisor. Make\n"
                "sure the appropriate virtualization packages\n"
                "are installed (kvm, qemu, libvirt, etc.), and\n"
                "that libvirtd is running.\n\n"
                "A hypervisor connection can be manually\n"
                "added via File->Add Connection")

        logging.debug("Determining default libvirt URI")

        ret = None
        try:
            libvirt_packages = self.config.libvirt_packages
            packages = self.config.hv_packages + libvirt_packages

            ret = packageutils.check_packagekit(manager, manager.err, packages)
        except:
            logging.exception("Error talking to PackageKit")

        if ret:
            tryuri = "qemu:///system"
        else:
            tryuri = vmmConnect.default_uri(always_system=True)

        if tryuri is None:
            manager.set_startup_error(msg)
            return

        warnmsg = _("The 'libvirtd' service will need to be started.\n\n"
                    "After that, virt-manager will connect to libvirt on\n"
                    "the next application start up.")

        # Do the initial connection in an idle callback, so the
        # packagekit async dialog has a chance to go away
        def idle_connect():
            do_start = packageutils.start_libvirtd()
            connected = self.connect_to_uri(tryuri,
                autoconnect=True, do_start=do_start)
            if not connected and do_start:
                manager.err.ok(_("Libvirt service must be started"), warnmsg)

        self.idle_add(idle_connect)
Exemplo n.º 7
0
    def _connect_error(self, conn, errmsg, tb, warnconsole):
        errmsg = errmsg.strip(" \n")
        tb = tb.strip(" \n")
        hint = ""
        show_errmsg = True

        if conn.is_remote():
            logging.debug(conn.get_transport())
            if re.search(r"nc: .* -- 'U'", tb):
                hint += _("The remote host requires a version of netcat/nc\n"
                          "which supports the -U option.")
                show_errmsg = False
            elif (conn.get_transport()[0] == "ssh" and
                  re.search(r"ssh-askpass", tb)):

                if self.config.askpass_package:
                    ret = packageutils.check_packagekit(
                                            None,
                                            self.err,
                                            self.config.askpass_package)
                    if ret:
                        conn.open()
                        return

                hint += _("You need to install openssh-askpass or "
                          "similar\nto connect to this host.")
                show_errmsg = False
            else:
                hint += _("Verify that the 'libvirtd' daemon is running\n"
                          "on the remote host.")

        elif conn.is_xen():
            hint += _("Verify that:\n"
                      " - A Xen host kernel was booted\n"
                      " - The Xen service has been started")

        else:
            if warnconsole:
                hint += _("Could not detect a local session: if you are \n"
                          "running virt-manager over ssh -X or VNC, you \n"
                          "may not be able to connect to libvirt as a \n"
                          "regular user. Try running as root.")
                show_errmsg = False
            elif re.search(r"libvirt-sock", tb):
                hint += _("Verify that the 'libvirtd' daemon is running.")
                show_errmsg = False

        probe_connection = self.conns[conn.get_uri()]["probeConnection"]
        msg = _("Unable to connect to libvirt.")
        if show_errmsg:
            msg += "\n\n%s" % errmsg
        if hint:
            msg += "\n\n%s" % hint

        msg = msg.strip("\n")
        details = msg
        details += "\n\n"
        details += "Libvirt URI is: %s\n\n" % conn.get_uri()
        details += tb

        if probe_connection:
            msg += "\n\n%s" % _("Would you still like to remember this connection?")

        title = _("Virtual Machine Manager Connection Failure")
        if probe_connection:
            remember_connection = self.err.show_err(msg, details, title,
                    buttons=Gtk.ButtonsType.YES_NO,
                    dialog_type=Gtk.MessageType.QUESTION, modal=True)
            if remember_connection:
                self.conns[conn.get_uri()]["probeConnection"] = False
            else:
                self.idle_add(self._do_edit_connect, self.windowManager, conn)
        else:
            if self._can_exit():
                self.err.show_err(msg, details, title, modal=True)
                self.idle_add(self.exit_app, conn)
            else:
                self.err.show_err(msg, details, title)
Exemplo n.º 8
0
    def _connect_error(self, conn, errmsg, tb, warnconsole):
        errmsg = errmsg.strip(" \n")
        tb = tb.strip(" \n")
        hint = ""
        show_errmsg = True

        if conn.is_remote():
            logging.debug(conn.get_transport())
            if re.search(r"nc: .* -- 'U'", tb):
                hint += _("The remote host requires a version of netcat/nc\n"
                          "which supports the -U option.")
                show_errmsg = False
            elif (conn.get_transport()[0] == "ssh"
                  and re.search(r"ssh-askpass", tb)):

                if self.config.askpass_package:
                    ret = packageutils.check_packagekit(
                        self.err, self.config.askpass_package, False)
                    if ret:
                        conn.open()
                        return

                hint += _("You need to install openssh-askpass or "
                          "similar\nto connect to this host.")
                show_errmsg = False
            else:
                hint += _("Verify that the 'libvirtd' daemon is running\n"
                          "on the remote host.")

        elif conn.is_xen():
            hint += _("Verify that:\n"
                      " - A Xen host kernel was booted\n"
                      " - The Xen service has been started")

        else:
            if warnconsole:
                hint += _("Could not detect a local session: if you are \n"
                          "running virt-manager over ssh -X or VNC, you \n"
                          "may not be able to connect to libvirt as a \n"
                          "regular user. Try running as root.")
                show_errmsg = False
            elif re.search(r"libvirt-sock", tb):
                hint += _("Verify that the 'libvirtd' daemon is running.")
                show_errmsg = False

        msg = _("Unable to connect to libvirt.")
        if show_errmsg:
            msg += "\n\n%s" % errmsg
        if hint:
            msg += "\n\n%s" % hint

        msg = msg.strip("\n")
        details = msg
        details += "\n\n"
        details += "Libvirt URI is: %s\n\n" % conn.get_uri()
        details += tb

        self.err.show_err(
            msg,
            details,
            title=_("Virtual Machine Manager Connection Failure"))