diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2008-05-01 17:44:20 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2008-05-01 17:44:20 +0000 |
commit | 0b1e814f89afb560c5d1b3af7ddb2cd2f5f2ab88 (patch) | |
tree | 52be3167255e588068d345d0bd4fda8cdeb6e9df /src/lib/Server | |
parent | 220dea241c2ceac979ad7e668e20bf8fb4e2d22a (diff) | |
download | bcfg2-0b1e814f89afb560c5d1b3af7ddb2cd2f5f2ab88.tar.gz bcfg2-0b1e814f89afb560c5d1b3af7ddb2cd2f5f2ab88.tar.bz2 bcfg2-0b1e814f89afb560c5d1b3af7ddb2cd2f5f2ab88.zip |
Replace bcfg2-query with bcfg2-admin query
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@4582 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Server')
-rw-r--r-- | src/lib/Server/Admin/Query.py | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/lib/Server/Admin/Query.py b/src/lib/Server/Admin/Query.py index 6d37f6371..0c0659213 100644 --- a/src/lib/Server/Admin/Query.py +++ b/src/lib/Server/Admin/Query.py @@ -1,8 +1,8 @@ import Bcfg2.Server.Admin, Bcfg2.Logging, logging class Query(Bcfg2.Server.Admin.Mode): - __shorthelp__ = 'bcfg2-admin query <pattern>' - __longhelp__ = __shorthelp__ + '\n\tCreate or delete client entries' + __shorthelp__ = 'bcfg2-admin query [-n] [-c] g=group p=profile' + __longhelp__ = __shorthelp__ + '\n\tQuery clients' def __init__(self, cfile): logging.root.setLevel(100) Bcfg2.Logging.setup_logging(100, to_console=False, to_syslog=False) @@ -21,18 +21,25 @@ class Query(Bcfg2.Server.Admin.Mode): def __call__(self, args): Bcfg2.Server.Admin.Mode.__call__(self, args) - clients = None + clients = self.meta.clients.keys() for arg in args: - k, v = arg.split('=') + if arg in ['-n', '-c']: + continue + try: + k, v = arg.split('=') + except: + print "Unknown argument %s" % arg + continue if k == 'p': nc = [c for c, p in self.meta.clients.iteritems() if p == v] elif k == 'g': nc = [c for c in self.meta.clients if v in self.meta.groups[self.meta.clients[c]][1] or v in self.meta.cgroups.get(c, [])] - if clients == None: - clients = nc - else: - clients = [c for c in clients if c in nc] - - print ','.join(clients) + clients = [c for c in clients if c in nc] + + if '-n' in args: + for client in clients: + print client + else: + print ','.join(clients) |