diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2007-01-24 16:16:27 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2007-01-24 16:16:27 +0000 |
commit | 0b85306d1a3c645503e6fe349ae6111d9ae21348 (patch) | |
tree | 42964f6c15ee378fc8bfc5653d903085e985bef7 /src/lib | |
parent | b89ad4480d6d94d0d881279d0819c481603c1456 (diff) | |
download | bcfg2-0b85306d1a3c645503e6fe349ae6111d9ae21348.tar.gz bcfg2-0b85306d1a3c645503e6fe349ae6111d9ae21348.tar.bz2 bcfg2-0b85306d1a3c645503e6fe349ae6111d9ae21348.zip |
Implement dynamic groups
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@2715 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/Server/Plugins/Metadata.py | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/lib/Server/Plugins/Metadata.py b/src/lib/Server/Plugins/Metadata.py index f28db386b..a4ee1640c 100644 --- a/src/lib/Server/Plugins/Metadata.py +++ b/src/lib/Server/Plugins/Metadata.py @@ -42,6 +42,7 @@ class Metadata(Bcfg2.Server.Plugin.Plugin): self.clients = {} self.aliases = {} self.groups = {} + self.cgroups = {} self.public = [] self.profiles = [] self.toolsets = {} @@ -223,7 +224,19 @@ class Metadata(Bcfg2.Server.Plugin.Plugin): raise MetadataConsistencyError toolset = toolinfo[0] probed = self.probedata.get(client, {}) - return ClientMetadata(client, groups, bundles, toolset, categories, probed) + newgroups = groups[:] + newbundles = bundles[:] + newcategories = {} + newcategories.update(categories) + for group in self.cgroups.get(client, []): + if self.groups.has_key(group): + nbundles, ngroups, ncategories = self.groups[group] + else: + nbundles, ngroups, ncategories = ([], [group], {}) + [newbundles.append(b) for b in nbundles if b not in newbundles] + [newgroups.append(g) for g in ngroups if g not in newgroups] + newcategories.update(ncategories) + return ClientMetadata(client, newgroups, newbundles, toolset, newcategories, probed) def GetProbes(self, _): '''Return a set of probes for execution on client''' @@ -246,7 +259,16 @@ class Metadata(Bcfg2.Server.Plugin.Plugin): def ReceiveData(self, client, data): '''Receive probe results pertaining to client''' + if not self.cgroups.has_key(client.hostname): + self.cgroups[client.hostname] = [] + dlines = data.text.split('\n') + for line in dlines[:]: + if line.split(':')[0] == 'group': + if line.split(':')[1] not in self.cgroups[client.hostname]: + self.cgroups[client.hostname].append(line.split(':')[1]) + dlines.remove(line) + dtext = "\n".join(dlines) try: - self.probedata[client.hostname].update({ data.get('name'):data.text }) + self.probedata[client.hostname].update({ data.get('name'):dtext }) except KeyError: - self.probedata[client.hostname] = { data.get('name'):data.text } + self.probedata[client.hostname] = { data.get('name'):dtext } |