From 5fb291d42a5a9e268507890a74ca6e6084f7575c Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Mon, 17 Mar 2014 10:44:40 +0100 Subject: 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. --- whatmaps | 26 ++++++++++++++++++++++++-- 1 file 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 +# (C) 2010,2014 Guido Günther # 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): @@ -127,6 +130,17 @@ class Distro(object): except (KeyError, AttributeError): 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""" @@ -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 " -- cgit v1.2.3