summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/Plugins/Cfg
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2013-07-23 14:26:27 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2013-07-23 14:27:37 -0400
commitca9be467a0a4460a2dacadebb2ba9e45433297a4 (patch)
treeec8d3d94f274b6f07d11feb14b5d64455f2e2038 /src/lib/Bcfg2/Server/Plugins/Cfg
parent9084b0e889407956227ae8d65bceff5148f7ee1f (diff)
downloadbcfg2-ca9be467a0a4460a2dacadebb2ba9e45433297a4.tar.gz
bcfg2-ca9be467a0a4460a2dacadebb2ba9e45433297a4.tar.bz2
bcfg2-ca9be467a0a4460a2dacadebb2ba9e45433297a4.zip
Cfg: unknown-cfg-files lint check honors FAM ignore list
Diffstat (limited to 'src/lib/Bcfg2/Server/Plugins/Cfg')
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py b/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py
index 154cd5e63..44455ff13 100644
--- a/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py
+++ b/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py
@@ -10,6 +10,7 @@ import lxml.etree
import Bcfg2.Options
import Bcfg2.Server.Plugin
import Bcfg2.Server.Lint
+from fnmatch import fnmatch
from Bcfg2.Server.Plugin import PluginExecutionError
# pylint: disable=W0622
from Bcfg2.Compat import u_str, unicode, b64encode, walk_packages, \
@@ -940,22 +941,37 @@ class CfgLint(Bcfg2.Server.Lint.ServerPlugin):
"%s has no corresponding pubkey.xml at %s" %
(basename, pubkey))
+ def _list_path_components(self, path):
+ rv = []
+ remaining, component = os.path.split(path)
+ while component != '':
+ rv.append(component)
+ remaining, component = os.path.split(remaining)
+ return rv
+
def check_missing_files(self):
""" check that all files on the filesystem are known to Cfg """
cfg = self.core.plugins['Cfg']
# first, collect ignore patterns from handlers
- ignore = []
+ ignore = set()
for hdlr in handlers():
- ignore.extend(hdlr.__ignore__)
+ ignore.update(hdlr.__ignore__)
# next, get a list of all non-ignored files on the filesystem
all_files = set()
for root, _, files in os.walk(cfg.data):
- all_files.update(os.path.join(root, fname)
- for fname in files
- if not any(fname.endswith("." + i)
- for i in ignore))
+ for fname in files:
+ fpath = os.path.join(root, fname)
+ # check against the handler ignore patterns and the
+ # global FAM ignore list
+ if (not any(fname.endswith("." + i) for i in ignore) and
+ not any(fnmatch(fpath, p)
+ for p in self.config['ignore']) and
+ not any(fnmatch(c, p)
+ for p in self.config['ignore']
+ for c in self._list_path_components(fpath))):
+ all_files.add(fpath)
# next, get a list of all files known to Cfg
cfg_files = set()