diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2009-09-18 03:01:17 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2009-09-18 03:01:17 +0000 |
commit | 5e17fd65e4f8ed1ec888ab2771aae9026b93c7ee (patch) | |
tree | 8954ca48f02dc38069cbbf982d2fabdd3e7f24e6 | |
parent | ef919aad378b25684fde42f1ecec29e228c3a68e (diff) | |
download | bcfg2-5e17fd65e4f8ed1ec888ab2771aae9026b93c7ee.tar.gz bcfg2-5e17fd65e4f8ed1ec888ab2771aae9026b93c7ee.tar.bz2 bcfg2-5e17fd65e4f8ed1ec888ab2771aae9026b93c7ee.zip |
Packages: implement config file reloads
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5444 ce84e21b-d406-0410-9b95-82705330c041
-rw-r--r-- | src/lib/Server/Plugins/Packages.py | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/src/lib/Server/Plugins/Packages.py b/src/lib/Server/Plugins/Packages.py index 789133177..6b581dd0d 100644 --- a/src/lib/Server/Plugins/Packages.py +++ b/src/lib/Server/Plugins/Packages.py @@ -422,28 +422,29 @@ class Packages(Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.Generator): name = 'Packages' experimental = True - __rmi__ = ['update_cache'] + __rmi__ = ['Refresh'] def __init__(self, core, datastore): Bcfg2.Server.Plugin.Plugin.__init__(self, core, datastore) Bcfg2.Server.Plugin.StructureValidator.__init__(self) Bcfg2.Server.Plugin.Generator.__init__(self) - cachepath = self.data + '/cache' - self.sentinels = set() - if not os.path.exists(cachepath): + self.cachepath = self.data + '/cache' + + if not os.path.exists(self.cachepath): # create cache directory if needed - os.makedirs(cachepath) + os.makedirs(self.cachepath) try: xdata = lxml.etree.parse(self.data + '/config.xml').getroot() except IOError, e: self.logger.error("Failed to read Packages configuration. Have" " you created your config.xml file?") raise Bcfg2.Server.Plugin.PluginInitError + self.sentinels = set() self.sources = [] for s in xdata.findall('APTSource'): - self.sources.append(APTSource(cachepath, **source_from_xml(s))) + self.sources.append(APTSource(self.cachepath, **source_from_xml(s))) for s in xdata.findall('YUMSource'): - self.sources.append(YUMSource(cachepath, **source_from_xml(s))) + self.sources.append(YUMSource(self.cachepath, **source_from_xml(s))) for source in self.sources: source.setup_data() self.sentinels.update(source.basegroups) @@ -522,13 +523,31 @@ class Packages(Bcfg2.Server.Plugin.Plugin, redundant.add(rpkg) return pkgnames.difference(redundant), redundant - def update_cache(self): + def Refresh(self): + '''Packages.Refresh() => True|False\nReload configuration specification and sources\n''' + try: + xdata = lxml.etree.parse(self.data + '/config.xml').getroot() + except IOError, e: + self.logger.error("Failed to read Packages configuration. Have" + " you created your config.xml file?") + raise Bcfg2.Server.Plugin.PluginInitError + self.sentinels = set() + self.sources = [] + for s in xdata.findall('APTSource'): + self.sources.append(APTSource(self.cachepath, **source_from_xml(s))) + for s in xdata.findall('YUMSource'): + self.sources.append(YUMSource(self.cachepath, **source_from_xml(s))) + for source in self.sources: + source.setup_data() + self.sentinels.update(source.basegroups) for source in self.sources: try: source.update() except: self.logger.error("Failed to update source", exc_info=1) + continue source.read_files() + return True if __name__ == '__main__': Bcfg2.Logger.setup_logging('Packages', to_console=True) |