summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Laszlo <tim.laszlo@gmail.com>2010-10-22 12:11:57 -0500
committerTim Laszlo <tim.laszlo@gmail.com>2010-10-27 10:30:05 -0500
commit93f8ad89b0f74322348976efef9f74ffc31ee9d0 (patch)
tree13953d00d0326e9f25b9f1877268f1a374f4e3b1
parent5d2c48f2c4e0245205833b4b70090fa286dceecd (diff)
downloadbcfg2-93f8ad89b0f74322348976efef9f74ffc31ee9d0.tar.gz
bcfg2-93f8ad89b0f74322348976efef9f74ffc31ee9d0.tar.bz2
bcfg2-93f8ad89b0f74322348976efef9f74ffc31ee9d0.zip
Extend client metadata to include group category information
(cherry picked from commit cc1d65d91aa00cdc91637c2e9afa36e11b5cc6a0)
-rw-r--r--src/lib/Server/Plugins/Metadata.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/lib/Server/Plugins/Metadata.py b/src/lib/Server/Plugins/Metadata.py
index 3161a69e3..81fd3e173 100644
--- a/src/lib/Server/Plugins/Metadata.py
+++ b/src/lib/Server/Plugins/Metadata.py
@@ -39,14 +39,21 @@ class ClientMetadata(object):
"""Test to see if client is a member of group."""
return group in self.groups
+ def group_in_category(self, category):
+ for grp in self.query.all_groups_in_category(category):
+ if grp in self.groups:
+ return grp
+ return ''
+
class MetadataQuery(object):
- def __init__(self, by_name, get_clients, by_groups, by_profiles, all_groups):
+ def __init__(self, by_name, get_clients, by_groups, by_profiles, all_groups, all_groups_in_category):
# resolver is set later
self.by_name = by_name
self.names_by_groups = by_groups
self.names_by_profiles = by_profiles
self.all_clients = get_clients
self.all_groups = all_groups
+ self.all_groups_in_category = all_groups_in_category
def by_groups(self, groups):
return [self.by_name(name) for name in self.names_by_groups(groups)]
@@ -105,7 +112,8 @@ class Metadata(Bcfg2.Server.Plugin.Plugin,
lambda:self.clients.keys(),
self.get_client_names_by_groups,
self.get_client_names_by_profiles,
- self.get_all_group_names)
+ self.get_all_group_names,
+ self.get_all_groups_in_category)
@classmethod
def init_repo(cls, repo, groups, os_selection, clients):
@@ -592,6 +600,12 @@ class Metadata(Bcfg2.Server.Plugin.Plugin,
[all_groups.update(g[1]) for g in self.groups.values()]
return all_groups
+ def get_all_groups_in_category(self, category):
+ all_groups = set()
+ [all_groups.add(g) for g in self.categories \
+ if self.categories[g] == category]
+ return all_groups
+
def get_client_names_by_profiles(self, profiles):
return [client for client, profile in self.clients.iteritems() \
if profile in profiles]