From 78dfedb4b450005246508cea08874637fcc86885 Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Tue, 30 Oct 2012 09:24:10 -0400 Subject: removed deprecated FAM filemonitor --- src/lib/Bcfg2/Server/FileMonitor/__init__.py | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src/lib/Bcfg2/Server/FileMonitor/__init__.py') diff --git a/src/lib/Bcfg2/Server/FileMonitor/__init__.py b/src/lib/Bcfg2/Server/FileMonitor/__init__.py index 42ad4c041..a1ff655d0 100644 --- a/src/lib/Bcfg2/Server/FileMonitor/__init__.py +++ b/src/lib/Bcfg2/Server/FileMonitor/__init__.py @@ -322,12 +322,6 @@ available = dict() # pylint: disable=C0103 from Bcfg2.Server.FileMonitor.Pseudo import Pseudo available['pseudo'] = Pseudo -try: - from Bcfg2.Server.FileMonitor.Fam import Fam - available['fam'] = Fam -except ImportError: - pass - try: from Bcfg2.Server.FileMonitor.Gamin import Gamin available['gamin'] = Gamin -- cgit v1.2.3-1-g7c22 From 45c7bbf24ae3c6530f33ebb33c062818ad44816d Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Tue, 30 Oct 2012 11:35:46 -0400 Subject: added a module-level FAM object to avoid passing it as an argument a billion times --- src/lib/Bcfg2/Server/FileMonitor/__init__.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/lib/Bcfg2/Server/FileMonitor/__init__.py') diff --git a/src/lib/Bcfg2/Server/FileMonitor/__init__.py b/src/lib/Bcfg2/Server/FileMonitor/__init__.py index a1ff655d0..37a2a8763 100644 --- a/src/lib/Bcfg2/Server/FileMonitor/__init__.py +++ b/src/lib/Bcfg2/Server/FileMonitor/__init__.py @@ -311,6 +311,31 @@ class FileMonitor(Debuggable): raise NotImplementedError +#: A module-level FAM object that all plugins, etc., can use. This +#: should not be used directly, but retrieved via :func:`get_fam`. +_FAM = None + +def get_fam(filemonitor='default', ignore=None, debug=False): + """ Get a filemonitor object. If :attr:`_FAM` already exists, + that will be used; if not, a new filemonitor object will be + created. + + :param filemonitor: Which filemonitor backend to use + :type filemonitor: string + :param ignore: A list of filenames to ignore + :type ignore: list of strings (filename globs) + :param debug: Produce debugging information + :type debug: bool + :returns: :class:`Bcfg2.Server.FileMonitor.FileMonitor` + """ + global _FAM # pylint: disable=W0603 + if _FAM is None: + if ignore is None: + ignore = [] + _FAM = available[filemonitor](ignore=ignore, debug=debug) + return _FAM + + #: A dict of all available FAM backends. Keys are the human-readable #: names of the backends, which are used in bcfg2.conf to select a #: backend; values are the backend classes. In addition, the -- cgit v1.2.3-1-g7c22 From 1a6ad2805f5b12ed111f7a3a6adb127f2cbcef8e Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Thu, 17 Jan 2013 11:01:41 -0500 Subject: FAM: split loading a new FileMonitor from fetching an existing one --- src/lib/Bcfg2/Server/FileMonitor/__init__.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src/lib/Bcfg2/Server/FileMonitor/__init__.py') diff --git a/src/lib/Bcfg2/Server/FileMonitor/__init__.py b/src/lib/Bcfg2/Server/FileMonitor/__init__.py index 37a2a8763..d77f21b93 100644 --- a/src/lib/Bcfg2/Server/FileMonitor/__init__.py +++ b/src/lib/Bcfg2/Server/FileMonitor/__init__.py @@ -315,10 +315,11 @@ class FileMonitor(Debuggable): #: should not be used directly, but retrieved via :func:`get_fam`. _FAM = None -def get_fam(filemonitor='default', ignore=None, debug=False): - """ Get a filemonitor object. If :attr:`_FAM` already exists, - that will be used; if not, a new filemonitor object will be - created. + +def load_fam(filemonitor='default', ignore=None, debug=False): + """ Load a new :class:`Bcfg2.Server.FileMonitor.FileMonitor` + object, caching it in :attr:`_FAM` for later retrieval via + :func:`get_fam`. :param filemonitor: Which filemonitor backend to use :type filemonitor: string @@ -336,6 +337,19 @@ def get_fam(filemonitor='default', ignore=None, debug=False): return _FAM +def get_fam(): + """ Get an already-created + :class:`Bcfg2.Server.FileMonitor.FileMonitor` object. If + :attr:`_FAM` has not been populated, then a new default + FileMonitor will be created. + + :returns: :class:`Bcfg2.Server.FileMonitor.FileMonitor` + """ + if _FAM is None: + return load_fam('default') + return _FAM + + #: A dict of all available FAM backends. Keys are the human-readable #: names of the backends, which are used in bcfg2.conf to select a #: backend; values are the backend classes. In addition, the -- cgit v1.2.3-1-g7c22