connectauth: Drop systemd libvirtd service startup
Latest libvirt uses socket activation, so libvirtd.service in offline state does not indicate a problem necessarily. Also on Fedora nowadays we have a weak RPM dependency on libvirt-daemon which we didn't in the past. Both things combine to make this code less useful and less accurate, so let's remove most of it. Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
54ae6f2723
commit
83fcab0177
|
@ -159,7 +159,7 @@ class VMMDogtailApp(object):
|
||||||
window_name=None, xmleditor_enabled=False, keyfile=None,
|
window_name=None, xmleditor_enabled=False, keyfile=None,
|
||||||
break_setfacl=False, first_run=True, no_fork=True,
|
break_setfacl=False, first_run=True, no_fork=True,
|
||||||
will_fail=False, enable_libguestfs=False,
|
will_fail=False, enable_libguestfs=False,
|
||||||
firstrun_uri=None, fake_systemd_success=True):
|
firstrun_uri=None):
|
||||||
extra_opts = extra_opts or []
|
extra_opts = extra_opts or []
|
||||||
|
|
||||||
if tests.utils.TESTCONFIG.debug and no_fork:
|
if tests.utils.TESTCONFIG.debug and no_fork:
|
||||||
|
@ -191,8 +191,6 @@ class VMMDogtailApp(object):
|
||||||
cmd.append("--test-options=enable-libguestfs")
|
cmd.append("--test-options=enable-libguestfs")
|
||||||
if enable_libguestfs is False:
|
if enable_libguestfs is False:
|
||||||
cmd.append("--test-options=disable-libguestfs")
|
cmd.append("--test-options=disable-libguestfs")
|
||||||
if fake_systemd_success:
|
|
||||||
cmd.append("--test-options=fake-systemd-success")
|
|
||||||
if keyfile:
|
if keyfile:
|
||||||
import atexit
|
import atexit
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
|
@ -123,11 +123,23 @@ class VMMCLI(lib.testcase.UITestCase):
|
||||||
self.app.root.find("test default", "table cell")
|
self.app.root.find("test default", "table cell")
|
||||||
|
|
||||||
def testCLIFirstRunURIBad(self):
|
def testCLIFirstRunURIBad(self):
|
||||||
# Emulate first run with a URI that will succeed
|
# Emulate first run with a URI that will not succeed
|
||||||
self.app.open(use_uri=False, firstrun_uri="bad:///uri")
|
self.app.open(use_uri=False, firstrun_uri="bad:///uri")
|
||||||
self.app.topwin.find("bad uri", "table cell")
|
self.app.topwin.find("bad uri", "table cell")
|
||||||
self.app.click_alert_button("bad:///uri", "Close")
|
self.app.click_alert_button("bad:///uri", "Close")
|
||||||
|
|
||||||
|
def testCLIFirstRunNoLibvirtd(self):
|
||||||
|
# Emulate first run with no libvirtd detected
|
||||||
|
self.app.open(use_uri=False, firstrun_uri="bad:///uri",
|
||||||
|
extra_opts=["--test-options=fake-no-libvirtd"])
|
||||||
|
errlabel = self.app.topwin.find("error-label")
|
||||||
|
lib.utils.check(
|
||||||
|
lambda: "Checking for virtualization" in errlabel.text)
|
||||||
|
lib.utils.check(
|
||||||
|
lambda: "libvirtd service does not appear" in errlabel.text)
|
||||||
|
lib.utils.check(
|
||||||
|
lambda: "detect a default hypervisor" in errlabel.text)
|
||||||
|
|
||||||
def testCLITraceLibvirt(self):
|
def testCLITraceLibvirt(self):
|
||||||
# Just test this for code coverage
|
# Just test this for code coverage
|
||||||
self.app.open(keyfile="allstats.ini",
|
self.app.open(keyfile="allstats.ini",
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
import collections
|
import collections
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import shutil
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from gi.repository import GLib
|
from gi.repository import GLib
|
||||||
|
@ -202,65 +203,12 @@ def connect_error(conn, errmsg, tb, warnconsole):
|
||||||
# App first run connection setup #
|
# App first run connection setup #
|
||||||
##################################
|
##################################
|
||||||
|
|
||||||
def _start_libvirtd(config):
|
|
||||||
log.debug("Trying to start libvirtd through systemd")
|
|
||||||
|
|
||||||
unitname = "libvirtd.service"
|
|
||||||
libvirtd_installed = False
|
|
||||||
libvirtd_active = False
|
|
||||||
unitpath = None
|
|
||||||
|
|
||||||
# Fetch all units from systemd
|
|
||||||
try:
|
|
||||||
bus = Gio.bus_get_sync(Gio.BusType.SYSTEM, None)
|
|
||||||
systemd = Gio.DBusProxy.new_sync(bus, 0, None,
|
|
||||||
"org.freedesktop.systemd1",
|
|
||||||
"/org/freedesktop/systemd1",
|
|
||||||
"org.freedesktop.systemd1.Manager", None)
|
|
||||||
units = systemd.ListUnits()
|
|
||||||
log.debug("Successfully listed units via systemd")
|
|
||||||
except Exception: # pragma: no cover
|
|
||||||
units = []
|
|
||||||
log.exception("Couldn't connect to systemd")
|
|
||||||
libvirtd_installed = os.path.exists("/var/run/libvirt")
|
|
||||||
libvirtd_active = os.path.exists("/var/run/libvirt/libvirt-sock")
|
|
||||||
|
|
||||||
# Check if libvirtd is installed and running
|
|
||||||
for unitinfo in units:
|
|
||||||
if unitinfo[0] != unitname:
|
|
||||||
continue
|
|
||||||
libvirtd_installed = True
|
|
||||||
libvirtd_active = unitinfo[3] == "active"
|
|
||||||
unitpath = unitinfo[6]
|
|
||||||
break
|
|
||||||
|
|
||||||
log.debug("libvirtd_installed=%s libvirtd_active=%s unitpath=%s",
|
|
||||||
libvirtd_installed, libvirtd_active, unitpath)
|
|
||||||
|
|
||||||
# If it's not running, try to start it
|
|
||||||
try:
|
|
||||||
if unitpath and libvirtd_installed and not libvirtd_active: # pragma: no cover
|
|
||||||
unit = Gio.DBusProxy.new_sync(
|
|
||||||
bus, 0, None,
|
|
||||||
"org.freedesktop.systemd1", unitpath,
|
|
||||||
"org.freedesktop.systemd1.Unit", None)
|
|
||||||
if config.CLITestOptions.fake_systemd_success:
|
|
||||||
unit.Start("(s)", "fail")
|
|
||||||
time.sleep(2)
|
|
||||||
libvirtd_active = True
|
|
||||||
except Exception: # pragma: no cover
|
|
||||||
log.exception("Error starting libvirtd")
|
|
||||||
|
|
||||||
return libvirtd_installed, libvirtd_active
|
|
||||||
|
|
||||||
|
|
||||||
def setup_first_uri(config, tryuri):
|
def setup_first_uri(config, tryuri):
|
||||||
libvirtd_installed, libvirtd_active = _start_libvirtd(config)
|
libvirtd_installed = bool(shutil.which("libvirtd"))
|
||||||
if config.CLITestOptions.fake_systemd_success:
|
if config.CLITestOptions.fake_no_libvirtd:
|
||||||
libvirtd_installed = True
|
libvirtd_installed = False
|
||||||
libvirtd_active = True
|
|
||||||
|
|
||||||
if tryuri and libvirtd_installed and libvirtd_active:
|
if tryuri and libvirtd_installed:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Manager fail message
|
# Manager fail message
|
||||||
|
@ -269,9 +217,6 @@ def setup_first_uri(config, tryuri):
|
||||||
msg += _("The libvirtd service does not appear to be installed. "
|
msg += _("The libvirtd service does not appear to be installed. "
|
||||||
"Install and run the libvirtd service to manage "
|
"Install and run the libvirtd service to manage "
|
||||||
"virtualization on this host.")
|
"virtualization on this host.")
|
||||||
elif not libvirtd_active: # pragma: no cover
|
|
||||||
msg += _("libvirtd is installed but not running. Start the "
|
|
||||||
"libvirtd service to manage virtualization on this host.")
|
|
||||||
|
|
||||||
if not tryuri or "qemu" not in tryuri:
|
if not tryuri or "qemu" not in tryuri:
|
||||||
if msg:
|
if msg:
|
||||||
|
@ -286,7 +231,4 @@ def setup_first_uri(config, tryuri):
|
||||||
msg += _("A virtualization connection can be manually "
|
msg += _("A virtualization connection can be manually "
|
||||||
"added via File->Add Connection")
|
"added via File->Add Connection")
|
||||||
|
|
||||||
if (tryuri is None or
|
return msg or None
|
||||||
not libvirtd_installed or
|
|
||||||
not libvirtd_active):
|
|
||||||
return msg
|
|
||||||
|
|
|
@ -150,8 +150,8 @@ class CLITestOptionsClass:
|
||||||
|
|
||||||
* firstrun-uri: If set, use this as the initial connection URI
|
* firstrun-uri: If set, use this as the initial connection URI
|
||||||
if we are doing firstrun testing
|
if we are doing firstrun testing
|
||||||
* fake-systemd-success: If doing firstrun testing, fake that
|
* fake-no-libvirtd: If doing firstrun testing, fake that
|
||||||
systemd checks for libvirtd succeeded
|
libvirtd is not installed
|
||||||
* fake-vnc-username: Fake VNC username auth request
|
* fake-vnc-username: Fake VNC username auth request
|
||||||
* fake-console-resolution: Fake viewer console resolution response.
|
* fake-console-resolution: Fake viewer console resolution response.
|
||||||
Spice doesn't return values here when we are just testing
|
Spice doesn't return values here when we are just testing
|
||||||
|
@ -201,7 +201,7 @@ class CLITestOptionsClass:
|
||||||
self.test_vm_run_fail = _get("test-vm-run-fail")
|
self.test_vm_run_fail = _get("test-vm-run-fail")
|
||||||
self.spice_agent = _get("spice-agent")
|
self.spice_agent = _get("spice-agent")
|
||||||
self.firstrun_uri = _get_value("firstrun-uri")
|
self.firstrun_uri = _get_value("firstrun-uri")
|
||||||
self.fake_systemd_success = _get("fake-systemd-success")
|
self.fake_no_libvirtd = _get("fake-no-libvirtd")
|
||||||
self.fake_vnc_username = _get("fake-vnc-username")
|
self.fake_vnc_username = _get("fake-vnc-username")
|
||||||
self.fake_console_resolution = _get("fake-console-resolution")
|
self.fake_console_resolution = _get("fake-console-resolution")
|
||||||
self.fake_systray = _get("fake-systray")
|
self.fake_systray = _get("fake-systray")
|
||||||
|
|
Loading…
Reference in New Issue