summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2009-02-02 16:38:01 +0000
committerNarayan Desai <desai@mcs.anl.gov>2009-02-02 16:38:01 +0000
commit67ea84767b1c06c9efd0449f435cae103cb03fb0 (patch)
treeb08b4ed7cb02086993034879122f978780fcb71d /src
parent527fa203685fc8c93f6094f8cfe61ff4a39f1e2e (diff)
downloadbcfg2-67ea84767b1c06c9efd0449f435cae103cb03fb0.tar.gz
bcfg2-67ea84767b1c06c9efd0449f435cae103cb03fb0.tar.bz2
bcfg2-67ea84767b1c06c9efd0449f435cae103cb03fb0.zip
Split out connector interface to allow for additional data generation based on complete group list
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5055 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src')
-rw-r--r--src/lib/Server/Core.py8
-rw-r--r--src/lib/Server/Plugin.py12
-rw-r--r--src/lib/Server/Plugins/Metadata.py6
-rw-r--r--src/lib/Server/Plugins/Probes.py8
-rw-r--r--src/lib/Server/Plugins/Properties.py5
5 files changed, 24 insertions, 15 deletions
diff --git a/src/lib/Server/Core.py b/src/lib/Server/Core.py
index 120835a65..c57e983f8 100644
--- a/src/lib/Server/Core.py
+++ b/src/lib/Server/Core.py
@@ -232,10 +232,12 @@ class Core(object):
def build_metadata(self, client_name):
imd = self.metadata.get_initial_metadata(client_name)
for conn in self.connectors:
- grps, data = conn.get_additional_metadata(imd)
- self.metadata.merge_additional_metadata(imd, conn.name, grps, data)
+ grps = conn.get_additional_groups(imd)
+ self.metadata.merge_additional_groups(imd, grps)
+ for conn in self.connectors:
+ data = conn.get_additional_data(imd)
+ self.metadata.merge_additional_data(imd, conn.name, data)
return imd
-
def process_statistics(self, client_name, statistics):
meta = self.build_metadata(client_name)
diff --git a/src/lib/Server/Plugin.py b/src/lib/Server/Plugin.py
index 21699657f..a1d82200a 100644
--- a/src/lib/Server/Plugin.py
+++ b/src/lib/Server/Plugin.py
@@ -83,10 +83,14 @@ class Metadata(object):
raise PluginExecutionError
class Connector(object):
- '''MetadataConnectorPlugins augment client metadata instances'''
- def get_additional_metadata(self, metadata):
- '''determine additional ([groups], {k:v}) for metadata'''
- return (list(), dict())
+ '''Connector Plugins augment client metadata instances'''
+ def get_additional_groups(self, metadata):
+ '''determine additional groups for metadata'''
+ return list()
+
+ def get_additional_data(self, metadata):
+ '''determine additional data for metadata inst'''
+ return dict()
class Probing(object):
'''Signal probe capability for this plugin'''
diff --git a/src/lib/Server/Plugins/Metadata.py b/src/lib/Server/Plugins/Metadata.py
index df7e3ddf2..f63e2d558 100644
--- a/src/lib/Server/Plugins/Metadata.py
+++ b/src/lib/Server/Plugins/Metadata.py
@@ -395,7 +395,7 @@ class Metadata(Bcfg2.Server.Plugin.Plugin,
newcategories, uuid, password,
(groupscopy, clientscopy))
- def merge_additional_metadata(self, imd, source, groups, data):
+ def merge_additional_groups(self, imd, groups):
for group in groups:
if group in self.categories and \
self.categories[group] in imd.categories:
@@ -410,9 +410,11 @@ class Metadata(Bcfg2.Server.Plugin.Plugin,
self.categories[g] in imd.categories:
continue
imd.groups.append(g)
+
+ def merge_additional_data(self, imd, source, data):
if not hasattr(imd, source):
setattr(imd, source, data)
- imd.connectors.append(source)
+ imd.connectors.append(source)
def AuthenticateConnection(self, user, password, address):
'''This function checks user and password'''
diff --git a/src/lib/Server/Plugins/Probes.py b/src/lib/Server/Plugins/Probes.py
index 10b729fde..f2973169b 100644
--- a/src/lib/Server/Plugins/Probes.py
+++ b/src/lib/Server/Plugins/Probes.py
@@ -139,6 +139,8 @@ class Probes(Bcfg2.Server.Plugin.Plugin,
except KeyError:
self.probedata[client.hostname] = { data.get('name'):dtext }
- def get_additional_metadata(self, meta):
- return (self.cgroups.get(meta.hostname, list()),
- self.probedata.get(meta.hostname, dict()))
+ def get_additional_groups(self, meta):
+ return self.cgroups.get(meta.hostname, list())
+
+ def get_additional_data(self, meta):
+ return self.probedata.get(meta.hostname, dict())
diff --git a/src/lib/Server/Plugins/Properties.py b/src/lib/Server/Plugins/Properties.py
index 2692c742e..87fcc16d3 100644
--- a/src/lib/Server/Plugins/Properties.py
+++ b/src/lib/Server/Plugins/Properties.py
@@ -20,11 +20,10 @@ class Properties(Bcfg2.Server.Plugin.Plugin,
version = '$Revision: $'
experimental = True
-
def __init__(self, core, datastore):
Bcfg2.Server.Plugin.Plugin.__init__(self, core, datastore)
Bcfg2.Server.Plugin.Connector.__init__(self)
self.store = PropDirectoryBacked(self.data, core.fam)
- def get_additional_metadata(self, _):
- return ((), copy.deepcopy(self.store.entries))
+ def get_additional_data(self, _):
+ return copy.deepcopy(self.store.entries)