summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib/Bcfg2/Server/Admin/Query.py8
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Metadata.py5
2 files changed, 10 insertions, 3 deletions
diff --git a/src/lib/Bcfg2/Server/Admin/Query.py b/src/lib/Bcfg2/Server/Admin/Query.py
index 3dd326645..6c4d3c4b6 100644
--- a/src/lib/Bcfg2/Server/Admin/Query.py
+++ b/src/lib/Bcfg2/Server/Admin/Query.py
@@ -7,8 +7,8 @@ import Bcfg2.Server.Admin
class Query(Bcfg2.Server.Admin.MetadataCore):
__shorthelp__ = "Query clients"
__longhelp__ = (__shorthelp__ + "\n\nbcfg2-admin query [-n] [-c] "
- "[-f filename] g=group p=profile")
- __usage__ = ("bcfg2-admin query [options] <g=group> <p=profile>\n\n"
+ "[-f filename] g=group p=profile b=bundle")
+ __usage__ = ("bcfg2-admin query [options] <g=group> <p=profile> <b=bundle>\n\n"
" %-25s%s\n"
" %-25s%s\n"
" %-25s%s\n" %
@@ -55,8 +55,10 @@ class Query(Bcfg2.Server.Admin.MetadataCore):
for g in glist:
if g in v.split(','):
nc.append(c)
+ elif k == 'b':
+ nc = self.metadata.get_client_names_by_bundles(v.split(','))
else:
- print("One of g= or p= must be specified")
+ print("One of g=, p= or b= must be specified")
raise SystemExit(1)
clients = [c for c in clients if c in nc]
if '-n' in args:
diff --git a/src/lib/Bcfg2/Server/Plugins/Metadata.py b/src/lib/Bcfg2/Server/Plugins/Metadata.py
index acfc0d348..4f6e82128 100644
--- a/src/lib/Bcfg2/Server/Plugins/Metadata.py
+++ b/src/lib/Bcfg2/Server/Plugins/Metadata.py
@@ -682,6 +682,11 @@ class Metadata(Bcfg2.Server.Plugin.Plugin,
for client in list(self.clients.keys())]
return [md.hostname for md in mdata if md.groups.issuperset(groups)]
+ def get_client_names_by_bundles(self, bundles):
+ mdata = [self.core.build_metadata(client)
+ for client in list(self.clients.keys())]
+ return [md.hostname for md in mdata if md.bundles.issuperset(bundles)]
+
def merge_additional_groups(self, imd, groups):
for group in groups:
if (group in self.categories and