Offer to install openssh-askpass if user needs it

The distro's package name can be passed in with --with-askpass-package
This commit is contained in:
Cole Robinson 2012-07-08 15:38:52 -04:00
parent f5ee7c256c
commit 68e78244e8
7 changed files with 63 additions and 32 deletions

View File

@ -64,6 +64,14 @@ AC_ARG_WITH([kvm-packages],
[KVM_PACKAGES=$withval], [KVM_PACKAGES=$withval],
[KVM_PACKAGES=""]) [KVM_PACKAGES=""])
dnl askpass package name
AC_ARG_WITH([askpass-package],
AC_HELP_STRING(
[--with-askpass-package],
[name of your distros openssh askpass package@<:@default=none@:>@]),
[ASKPASS_PACKAGE=$withval],
[ASKPASS_PACKAGE=""])
dnl Don't list options that rhel doesn't support dnl Don't list options that rhel doesn't support
AC_ARG_ENABLE([unsupported-rhel-options], AC_ARG_ENABLE([unsupported-rhel-options],
AC_HELP_STRING( AC_HELP_STRING(
@ -99,6 +107,7 @@ AC_SUBST([ENABLE_UNSUPPORTED_RHEL_OPTS])
AC_SUBST([PREFERRED_DISTROS]) AC_SUBST([PREFERRED_DISTROS])
AC_SUBST([LIBVIRT_PACKAGES]) AC_SUBST([LIBVIRT_PACKAGES])
AC_SUBST([KVM_PACKAGES]) AC_SUBST([KVM_PACKAGES])
AC_SUBST([ASKPASS_PACKAGE])
AC_SUBST([DEFAULT_GRAPHICS]) AC_SUBST([DEFAULT_GRAPHICS])
AM_CONDITIONAL([INSTALL_TUI], [test "x$with_tui" = "xyes"]) AM_CONDITIONAL([INSTALL_TUI], [test "x$with_tui" = "xyes"])
@ -154,6 +163,11 @@ AC_MSG_NOTICE([KVM packages: none])
else else
AC_MSG_NOTICE([KVM packages: $KVM_PACKAGES]) AC_MSG_NOTICE([KVM packages: $KVM_PACKAGES])
fi fi
if test "x$ASKPASS_PACKAGE" = "x" ; then
AC_MSG_NOTICE([askpass package: none])
else
AC_MSG_NOTICE([askpass package: $ASKPASS_PACKAGE])
fi
AC_MSG_NOTICE([Default graphics: $DEFAULT_GRAPHICS]) AC_MSG_NOTICE([Default graphics: $DEFAULT_GRAPHICS])
AC_MSG_NOTICE([]) AC_MSG_NOTICE([])

View File

@ -66,6 +66,7 @@ endif
-e "s,::ENABLE_UNSUPPORTED_RHEL_OPTS::,$(ENABLE_UNSUPPORTED_RHEL_OPTS)," \ -e "s,::ENABLE_UNSUPPORTED_RHEL_OPTS::,$(ENABLE_UNSUPPORTED_RHEL_OPTS)," \
-e "s|::PREFERRED_DISTROS::|$(PREFERRED_DISTROS)|" \ -e "s|::PREFERRED_DISTROS::|$(PREFERRED_DISTROS)|" \
-e "s|::HV_PACKAGES::|$(KVM_PACKAGES)|" \ -e "s|::HV_PACKAGES::|$(KVM_PACKAGES)|" \
-e "s|::ASKPASS_PACKAGE::|$(ASKPASS_PACKAGE)|" \
-e "s|::LIBVIRT_PACKAGES::|$(LIBVIRT_PACKAGES)|" \ -e "s|::LIBVIRT_PACKAGES::|$(LIBVIRT_PACKAGES)|" \
< $< > $@ < $< > $@

View File

@ -54,7 +54,8 @@ default_qemu_user = "::DEFAULT_QEMU_USER::"
rhel_enable_unsupported_opts = bool(int("::ENABLE_UNSUPPORTED_RHEL_OPTS::")) rhel_enable_unsupported_opts = bool(int("::ENABLE_UNSUPPORTED_RHEL_OPTS::"))
preferred_distros = split_list("::PREFERRED_DISTROS::") preferred_distros = split_list("::PREFERRED_DISTROS::")
hv_packages = split_list("::HV_PACKAGES::") hv_packages = split_list("::KVM_PACKAGES::")
askpass_package = split_list("::ASKPASS_PACKAGE::")
libvirt_packages = split_list("::LIBVIRT_PACKAGES::") libvirt_packages = split_list("::LIBVIRT_PACKAGES::")
logging_setup = False logging_setup = False
@ -325,6 +326,7 @@ def main():
config.hv_packages = hv_packages config.hv_packages = hv_packages
config.libvirt_packages = libvirt_packages config.libvirt_packages = libvirt_packages
config.askpass_package = askpass_package
import virtManager.guidiff import virtManager.guidiff
virtManager.guidiff.is_gui(True) virtManager.guidiff.is_gui(True)

View File

@ -109,6 +109,7 @@ class vmmConfig(object):
self.preferred_distros = [] self.preferred_distros = []
self.hv_packages = [] self.hv_packages = []
self.libvirt_packages = [] self.libvirt_packages = []
self.askpass_package = []
self._objects = [] self._objects = []

View File

@ -138,10 +138,6 @@ class vmmEngine(vmmGObject):
# Show the manager so that the user can control the application # Show the manager so that the user can control the application
self.show_manager() self.show_manager()
########################
# First run PackageKit #
########################
def add_default_conn(self, manager): def add_default_conn(self, manager):
# Only add default if no connections are currently known # Only add default if no connections are currently known
if self.config.get_conn_uris(): if self.config.get_conn_uris():
@ -163,16 +159,18 @@ class vmmEngine(vmmGObject):
libvirt_packages = self.config.libvirt_packages libvirt_packages = self.config.libvirt_packages
packages = self.config.hv_packages + libvirt_packages packages = self.config.hv_packages + libvirt_packages
ret = packageutils.check_packagekit(self.err, packages, ret = packageutils.check_packagekit(self.err, packages, True)
libvirt_packages)
except: except:
logging.exception("Error talking to PackageKit") logging.exception("Error talking to PackageKit")
if ret: if ret is not None:
# We found the default packages via packagekit: use default URI did_install_libvirt = False
ignore, did_install_libvirt = ret for p in libvirt_packages:
tryuri = "qemu:///system" if p in ret:
did_install_libvirt = True
break
tryuri = "qemu:///system"
else: else:
tryuri = default_uri() tryuri = default_uri()

View File

@ -23,7 +23,8 @@ import re
import gtk import gtk
import virtManager.uihelpers as uihelpers from virtManager import packageutils
from virtManager import uihelpers
from virtManager.connection import vmmConnection from virtManager.connection import vmmConnection
from virtManager.baseclass import vmmGObjectUI from virtManager.baseclass import vmmGObjectUI
from virtManager.delete import vmmDeleteDialog from virtManager.delete import vmmDeleteDialog
@ -658,9 +659,20 @@ class vmmManager(vmmGObjectUI):
hint += _("The remote host requires a version of netcat/nc\n" hint += _("The remote host requires a version of netcat/nc\n"
"which supports the -U option.") "which supports the -U option.")
show_errmsg = False show_errmsg = False
elif conn.get_transport()[0] == "ssh" and re.search(r"ssh-askpass", tb): elif (conn.get_transport()[0] == "ssh" and
hint += _("You need to install openssh-askpass or similar\n" re.search(r"ssh-askpass", tb)):
"to connect to this host.")
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 show_errmsg = False
else: else:
hint += _("Verify that the 'libvirtd' daemon is running\n" hint += _("Verify that the 'libvirtd' daemon is running\n"

View File

@ -32,7 +32,7 @@ from virtManager.asyncjob import vmmAsyncJob
# PackageKit lookup helpers # # PackageKit lookup helpers #
############################# #############################
def check_packagekit(errbox, packages, libvirt_packages): def check_packagekit(errbox, packages, ishv):
""" """
Returns None when we determine nothing useful. Returns None when we determine nothing useful.
Returns (success, did we just install libvirt) otherwise. Returns (success, did we just install libvirt) otherwise.
@ -53,11 +53,14 @@ def check_packagekit(errbox, packages, libvirt_packages):
logging.exception("Couldn't connect to packagekit") logging.exception("Couldn't connect to packagekit")
return return
if ishv:
msg = _("Searching for available hypervisors...")
else:
msg = _("Checking for installed package '%s'") % packages[0]
found = [] found = []
progWin = vmmAsyncJob(_do_async_search, progWin = vmmAsyncJob(_do_async_search,
[session, pk_control, packages], [session, pk_control, packages], msg, msg,
_("Searching for available hypervisors..."),
_("Searching for available hypervisors..."),
None, async=False) None, async=False)
error, ignore = progWin.run() error, ignore = progWin.run()
if error: if error:
@ -73,18 +76,24 @@ def check_packagekit(errbox, packages, libvirt_packages):
if not not_found: if not not_found:
# Got everything we wanted, try to connect # Got everything we wanted, try to connect
logging.debug("All packages found locally.") logging.debug("All packages found locally.")
return (True, False) return []
else: else:
logging.debug("No packages are available for install.") logging.debug("No packages are available for install.")
return return
msg = (_("The following packages are not installed:\n%s\n\n" missing = reduce(lambda x, y: x + "\n" + y, do_install, "")
"These are required to create KVM guests locally.\n" if ishv:
"Would you like to install them now?") % msg = (_("The following packages are not installed:\n%s\n\n"
reduce(lambda x, y: x + "\n" + y, do_install, "")) "These are required to create KVM guests locally.\n"
"Would you like to install them now?") % missing)
title = _("Packages required for KVM usage")
else:
msg = _("The following packages are not installed:\n%s\n\n"
"Would you like to install them now?" % missing)
title = _("Recommended package installs")
ret = errbox.yes_no(_("Packages required for KVM usage"), msg) ret = errbox.yes_no(title, msg)
if not ret: if not ret:
logging.debug("Package install declined.") logging.debug("Package install declined.")
@ -96,13 +105,7 @@ def check_packagekit(errbox, packages, libvirt_packages):
errbox.show_err(_("Error talking to PackageKit: %s") % str(e)) errbox.show_err(_("Error talking to PackageKit: %s") % str(e))
return return
need_libvirt = False return do_install
for p in libvirt_packages:
if p in do_install:
need_libvirt = True
break
return (True, need_libvirt)
def _do_async_search(asyncjob, session, pk_control, packages): def _do_async_search(asyncjob, session, pk_control, packages):
found = [] found = []