diff options
author | Tim Laszlo <tim.laszlo@gmail.com> | 2010-10-22 12:11:57 -0500 |
---|---|---|
committer | Tim Laszlo <tim.laszlo@gmail.com> | 2010-10-22 12:11:57 -0500 |
commit | cc1d65d91aa00cdc91637c2e9afa36e11b5cc6a0 (patch) | |
tree | 717e2d87e68436d77e95420e05ac96c34c9e0514 /src/lib/Server/Plugins | |
parent | 7e7529c1f14bf7c421d78a0ad93958504d728f92 (diff) | |
download | bcfg2-cc1d65d91aa00cdc91637c2e9afa36e11b5cc6a0.tar.gz bcfg2-cc1d65d91aa00cdc91637c2e9afa36e11b5cc6a0.tar.bz2 bcfg2-cc1d65d91aa00cdc91637c2e9afa36e11b5cc6a0.zip |
Extend client metadata to include group category information
Diffstat (limited to 'src/lib/Server/Plugins')
-rw-r--r-- | src/lib/Server/Plugins/Metadata.py | 18 |
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] |