mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-03-10 12:58:27 +03:00
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:
parent
f5ee7c256c
commit
68e78244e8
14
configure.ac
14
configure.ac
@ -64,6 +64,14 @@ AC_ARG_WITH([kvm-packages],
|
||||
[KVM_PACKAGES=$withval],
|
||||
[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
|
||||
AC_ARG_ENABLE([unsupported-rhel-options],
|
||||
AC_HELP_STRING(
|
||||
@ -99,6 +107,7 @@ AC_SUBST([ENABLE_UNSUPPORTED_RHEL_OPTS])
|
||||
AC_SUBST([PREFERRED_DISTROS])
|
||||
AC_SUBST([LIBVIRT_PACKAGES])
|
||||
AC_SUBST([KVM_PACKAGES])
|
||||
AC_SUBST([ASKPASS_PACKAGE])
|
||||
AC_SUBST([DEFAULT_GRAPHICS])
|
||||
AM_CONDITIONAL([INSTALL_TUI], [test "x$with_tui" = "xyes"])
|
||||
|
||||
@ -154,6 +163,11 @@ AC_MSG_NOTICE([KVM packages: none])
|
||||
else
|
||||
AC_MSG_NOTICE([KVM packages: $KVM_PACKAGES])
|
||||
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([])
|
||||
|
@ -66,6 +66,7 @@ endif
|
||||
-e "s,::ENABLE_UNSUPPORTED_RHEL_OPTS::,$(ENABLE_UNSUPPORTED_RHEL_OPTS)," \
|
||||
-e "s|::PREFERRED_DISTROS::|$(PREFERRED_DISTROS)|" \
|
||||
-e "s|::HV_PACKAGES::|$(KVM_PACKAGES)|" \
|
||||
-e "s|::ASKPASS_PACKAGE::|$(ASKPASS_PACKAGE)|" \
|
||||
-e "s|::LIBVIRT_PACKAGES::|$(LIBVIRT_PACKAGES)|" \
|
||||
< $< > $@
|
||||
|
||||
|
@ -54,7 +54,8 @@ default_qemu_user = "::DEFAULT_QEMU_USER::"
|
||||
rhel_enable_unsupported_opts = bool(int("::ENABLE_UNSUPPORTED_RHEL_OPTS::"))
|
||||
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::")
|
||||
|
||||
logging_setup = False
|
||||
@ -325,6 +326,7 @@ def main():
|
||||
|
||||
config.hv_packages = hv_packages
|
||||
config.libvirt_packages = libvirt_packages
|
||||
config.askpass_package = askpass_package
|
||||
|
||||
import virtManager.guidiff
|
||||
virtManager.guidiff.is_gui(True)
|
||||
|
@ -109,6 +109,7 @@ class vmmConfig(object):
|
||||
self.preferred_distros = []
|
||||
self.hv_packages = []
|
||||
self.libvirt_packages = []
|
||||
self.askpass_package = []
|
||||
|
||||
self._objects = []
|
||||
|
||||
|
@ -138,10 +138,6 @@ class vmmEngine(vmmGObject):
|
||||
# Show the manager so that the user can control the application
|
||||
self.show_manager()
|
||||
|
||||
########################
|
||||
# First run PackageKit #
|
||||
########################
|
||||
|
||||
def add_default_conn(self, manager):
|
||||
# Only add default if no connections are currently known
|
||||
if self.config.get_conn_uris():
|
||||
@ -163,16 +159,18 @@ class vmmEngine(vmmGObject):
|
||||
libvirt_packages = self.config.libvirt_packages
|
||||
packages = self.config.hv_packages + libvirt_packages
|
||||
|
||||
ret = packageutils.check_packagekit(self.err, packages,
|
||||
libvirt_packages)
|
||||
ret = packageutils.check_packagekit(self.err, packages, True)
|
||||
except:
|
||||
logging.exception("Error talking to PackageKit")
|
||||
|
||||
if ret:
|
||||
# We found the default packages via packagekit: use default URI
|
||||
ignore, did_install_libvirt = ret
|
||||
tryuri = "qemu:///system"
|
||||
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()
|
||||
|
||||
|
@ -23,7 +23,8 @@ import re
|
||||
|
||||
import gtk
|
||||
|
||||
import virtManager.uihelpers as uihelpers
|
||||
from virtManager import packageutils
|
||||
from virtManager import uihelpers
|
||||
from virtManager.connection import vmmConnection
|
||||
from virtManager.baseclass import vmmGObjectUI
|
||||
from virtManager.delete import vmmDeleteDialog
|
||||
@ -658,9 +659,20 @@ class vmmManager(vmmGObjectUI):
|
||||
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):
|
||||
hint += _("You need to install openssh-askpass or similar\n"
|
||||
"to connect to this host.")
|
||||
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"
|
||||
|
@ -32,7 +32,7 @@ from virtManager.asyncjob import vmmAsyncJob
|
||||
# PackageKit lookup helpers #
|
||||
#############################
|
||||
|
||||
def check_packagekit(errbox, packages, libvirt_packages):
|
||||
def check_packagekit(errbox, packages, ishv):
|
||||
"""
|
||||
Returns None when we determine nothing useful.
|
||||
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")
|
||||
return
|
||||
|
||||
if ishv:
|
||||
msg = _("Searching for available hypervisors...")
|
||||
else:
|
||||
msg = _("Checking for installed package '%s'") % packages[0]
|
||||
|
||||
found = []
|
||||
progWin = vmmAsyncJob(_do_async_search,
|
||||
[session, pk_control, packages],
|
||||
_("Searching for available hypervisors..."),
|
||||
_("Searching for available hypervisors..."),
|
||||
[session, pk_control, packages], msg, msg,
|
||||
None, async=False)
|
||||
error, ignore = progWin.run()
|
||||
if error:
|
||||
@ -73,18 +76,24 @@ def check_packagekit(errbox, packages, libvirt_packages):
|
||||
if not not_found:
|
||||
# Got everything we wanted, try to connect
|
||||
logging.debug("All packages found locally.")
|
||||
return (True, False)
|
||||
return []
|
||||
|
||||
else:
|
||||
logging.debug("No packages are available for install.")
|
||||
return
|
||||
|
||||
msg = (_("The following packages are not installed:\n%s\n\n"
|
||||
"These are required to create KVM guests locally.\n"
|
||||
"Would you like to install them now?") %
|
||||
reduce(lambda x, y: x + "\n" + y, do_install, ""))
|
||||
missing = reduce(lambda x, y: x + "\n" + y, do_install, "")
|
||||
if ishv:
|
||||
msg = (_("The following packages are not installed:\n%s\n\n"
|
||||
"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:
|
||||
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))
|
||||
return
|
||||
|
||||
need_libvirt = False
|
||||
for p in libvirt_packages:
|
||||
if p in do_install:
|
||||
need_libvirt = True
|
||||
break
|
||||
|
||||
return (True, need_libvirt)
|
||||
return do_install
|
||||
|
||||
def _do_async_search(asyncjob, session, pk_control, packages):
|
||||
found = []
|
||||
|
Loading…
x
Reference in New Issue
Block a user