summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2014-03-17 10:44:40 +0100
committerGuido Günther <agx@sigxcpu.org>2014-03-17 11:18:13 +0100
commit5fb291d42a5a9e268507890a74ca6e6084f7575c (patch)
tree7ca53b823113fa182a3fd819691533edf3e97cf7
parent256dd8261c3a47c808b90fb49026c59f3ee8baf0 (diff)
Allow to blacklist services
This allows to exclude services that we never want restarted like /etc/init.d/kvm which is responsible for loading the kvm module. It also allows us to exclude services on a per package basis. E.g. changes in libvirtd only need libvirt-bin but not libvirt-guests restarted since this just safes and restores all vms.
-rwxr-xr-xwhatmaps26
1 files changed, 24 insertions, 2 deletions
diff --git a/whatmaps b/whatmaps
index 155a56c..74168c3 100755
--- a/whatmaps
+++ b/whatmaps
@@ -1,7 +1,7 @@
#!/usr/bin/python -u
# vim: set fileencoding=utf-8 :
#
-# (C) 2010 Guido Guenther <agx@sigxcpu.org>
+# (C) 2010,2014 Guido Günther <agx@sigxcpu.org>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
@@ -95,6 +95,9 @@ class Distro(object):
@cvar id: distro id as returned by lsb-release
"""
id = None
+ service_blacklist = set()
+ _pkg_services = {}
+ _pkg_blacklist = {}
@classmethod
def pkg(klass, name):
@@ -128,6 +131,17 @@ class Distro(object):
return []
@classmethod
+ def pkg_service_blacklist(klass, pkg):
+ """
+ List of services in pkg that we don't want to be restarted even when
+ a binary from this package maps a shared lib that changed.
+ """
+ try:
+ return klass._pkg_service_blacklist[pkg.name]
+ except KeyError:
+ return []
+
+ @classmethod
def has_apt(klass):
"""Does the distribution use apt"""
return False
@@ -191,6 +205,12 @@ class DebianDistro(Distro):
'exim4-daemon-heavy': [ 'exim4' ],
}
+ # Per package blacklist
+ _pkg_service_blacklist = { 'libvirt-bin': [ 'libvirt-guests' ] }
+
+ # Per distro blacklist
+ service_blacklist = set(['kvm', 'qemu-kvm', 'qemu-system-x86'])
+
@classmethod
def pkg(klass, name):
return DebianPkg(name)
@@ -549,12 +569,14 @@ def main(argv):
all_services = set()
try:
for pkg in pkgs.values():
- services = pkg.services + distro.pkg_services(pkg)
+ services = set(pkg.services + distro.pkg_services(pkg))
+ services -= set(distro.pkg_service_blacklist(pkg))
if not services:
logging.warning("No service script found in '%s' for '%s' "
"- restart manually" % (pkg.name, pkg.procs))
else:
all_services.update(services)
+ all_services -= distro.service_blacklist
except NotImplementedError:
if level > logging.INFO:
logging.error("Getting Service listing not implemented "