From: Frank Brehm Date: Tue, 14 Dec 2010 21:53:58 +0000 (+0000) Subject: Bugfixing, mit apply_tmplates() angefangen X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=def1f404feceec8073ec95daf52587994d32f114;p=my-stuff%2Fnagios.git Bugfixing, mit apply_tmplates() angefangen git-svn-id: http://svn.brehm-online.com/svn/my-stuff/nagios/trunk@156 ec8d2aa5-1599-4edb-8739-2b3a1bc399aa --- diff --git a/bin/nagios/cfg/struct.py b/bin/nagios/cfg/struct.py index 2053a20..686b6c4 100755 --- a/bin/nagios/cfg/struct.py +++ b/bin/nagios/cfg/struct.py @@ -461,7 +461,7 @@ returns None on failure""" re_timerange = re_time + r'\s*-\s*' + re_time re_timeranges = r'(' + re_timerange + r')(?:,(' + re_timerange + r'))*' re_weekdays = r'(monday|tuesday|wednesday|thursday|friday|saturday|sunday)' - re_isodate = r'(\d\d\d\d)-(0[1-9]|1[0-2])-([0-2][1-9]|3[01])' + re_isodate = r'(\d\d\d\d)-(0[1-9]|1[0-2])-([0-2][0-9]|3[01])' re_monthname = r'(january|february|march|april|may|june|july|august|september|october|november|december)' re_monthname_wd = r'(day|january|february|march|april|may|june|july|august|september|october|november|december)' diff --git a/bin/nagios/config.py b/bin/nagios/config.py index 79abfb7..1fc6eaf 100644 --- a/bin/nagios/config.py +++ b/bin/nagios/config.py @@ -315,16 +315,30 @@ class NagiosConfig(LoggingObject): for file_name in files: self.read_objectfile(file_name) + self.register_templates() + self.apply_tmplates() + pp = pprint.PrettyPrinter( indent = 4, depth = 6, width = 120 ) if self.verbose >= 3: self.logger.debug( "Read objects:\n{0}".format( pp.pformat( self.objects_read ) ) ) del self.struct_verifier - self.register_templates() - return + #------------------------------------------------------ + def apply_tmplates( self ): + '''Apply definitions from templates (from 'use' declarations) into the object definitions in self.objects_read. + @return: None + @rtype: None + ''' + + pp = pprint.PrettyPrinter( indent = 4, depth = 6, width = 120 ) + for object_type in self.objects_read: + for object in self.objects_read[object_type]: + object['templates'] = {} + object['templates_applied'] = set([]) + #------------------------------------------------------ def register_templates( self ): '''Searches the self.objects_read structure, searches for templates and registers them in self.templates