introduced locking on actions)
Message-ID: <5a1fc8b0.kwYHA2rIdPrpL0XQ%lm(a)mathias-kettner.de>
User-Agent: Heirloom mailx 12.5 6/20/10
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Module: check_mk
Branch: master
Commit: 764f5999b9168933028a5f0715ee47a57fadaf4d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=764f5999b91689…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Nov 30 09:11:40 2017 +0100
Custom attributes: Use store methods for loading the config (introduced locking on
actions)
Change-Id: Ib6f1802d5e176771f2489c9903b535fa336b771c
---
web/htdocs/wato.py | 30 +++++++++---------------------
1 file changed, 9 insertions(+), 21 deletions(-)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 1d15c23..e5af8de 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -15259,29 +15259,17 @@ class CustomAttrMode(WatoMode):
self._attrs = self._all_attrs.get(self._what, {})
- # TODO: Use lock!
def _load(self, lock):
- try:
- filename = multisite_dir + "custom_attrs.mk"
- if not os.path.exists(filename):
- return {}
-
- vars = {
- 'wato_user_attrs': [],
- 'wato_host_attrs': [],
- }
- execfile(filename, vars, vars)
-
- attrs = {}
- for self._what in [ "user", "host" ]:
- attrs[self._what] = vars.get("wato_%s_attrs" % self._what, [])
- return attrs
+ filename = os.path.join(multisite_dir, "custom_attrs.mk")
+ vars = store.load_mk_file(filename, {
+ 'wato_user_attrs': [],
+ 'wato_host_attrs': [],
+ }, lock=lock)
- except Exception, e:
- if config.debug:
- raise
- raise MKGeneralException(_("Cannot read configuration file %s: %s")
%
- (filename, e))
+ attrs = {}
+ for self._what in [ "user", "host" ]:
+ attrs[self._what] = vars.get("wato_%s_attrs" % self._what, [])
+ return attrs
def _save_attributes(self):