From e3759d2a2e5fdb0e0a7f7dfa4f8244fdbb3ffe92 Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Wed, 25 Jan 2006 16:48:06 +0000 Subject: Introduce the new logging infrastructure and convert the server (and bcfg2-info) over to using it git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@1717 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Server/Plugins/Hostbase.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/lib/Server/Plugins/Hostbase.py') diff --git a/src/lib/Server/Plugins/Hostbase.py b/src/lib/Server/Plugins/Hostbase.py index e729030fb..96f215451 100644 --- a/src/lib/Server/Plugins/Hostbase.py +++ b/src/lib/Server/Plugins/Hostbase.py @@ -1,7 +1,6 @@ '''This file provides the Hostbase plugin. It manages dns/dhcp/nis host information''' __revision__ = '$Revision$' -from syslog import syslog, LOG_INFO from lxml.etree import XML, SubElement from Cheetah.Template import Template from Bcfg2.Server.Plugin import Plugin, PluginExecutionError, PluginInitError, DirectoryBacked @@ -9,6 +8,10 @@ from time import strftime from sets import Set import re +import logging + +logger = logging.getLogger('Bcfg2.Plugins.Hostbase') + class DataNexus(DirectoryBacked): '''DataNexus is an object that watches multiple files and handles changes in an intelligent fashion.''' @@ -23,7 +26,7 @@ class DataNexus(DirectoryBacked): action = event.code2str() if action in ['exists', 'created']: if (event.filename != self.name) and (event.filename not in self.files): - syslog(LOG_INFO, "%s:Got event for unexpected file %s" % (self.__name__, event.filename)) + logger.info("%s:Got event for unexpected file %s" % (self.__name__, event.filename)) return DirectoryBacked.HandleEvent(self, event) if action != 'endExist' and event.filename != self.name: @@ -48,7 +51,7 @@ class Hostbase(Plugin, DataNexus): DataNexus.__init__(self, datastore + '/Hostbase/data', files, self.core.fam) except: - self.LogError("Failed to load data directory") + logger.error("Failed to load data directory") raise PluginInitError self.xdata = {} self.filedata = {} @@ -96,12 +99,12 @@ class Hostbase(Plugin, DataNexus): todaydate = (strftime('%Y%m%d')) try: if todaydate == zone.get('serial')[:8]: - serial = atoi(zone.get('serial')) + 1 + serial = int(zone.get('serial')) + 1 else: - serial = atoi(todaydate) * 100 + serial = int(todaydate) * 100 return str(serial) except (KeyError): - serial = atoi(todaydate) * 100 + serial = int(todaydate) * 100 return str(serial) if self.entries.has_key(event.filename) and not self.xdata.has_key(event.filename): -- cgit v1.2.3-1-g7c22