diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2007-05-31 15:11:05 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2007-05-31 15:11:05 +0000 |
commit | 920363a9eb77d942eb66775aac8f59cd538871de (patch) | |
tree | af9de2bd781f791e76d4f96ccb5610bf36d9219b /src/sbin | |
parent | 4dcb2a3f626d7439fa9cc3ef2b5571245a5d88a9 (diff) | |
download | bcfg2-920363a9eb77d942eb66775aac8f59cd538871de.tar.gz bcfg2-920363a9eb77d942eb66775aac8f59cd538871de.tar.bz2 bcfg2-920363a9eb77d942eb66775aac8f59cd538871de.zip |
Implement showclient command (Patch from mbrady)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@3209 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/sbin')
-rwxr-xr-x | src/sbin/bcfg2-info | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/src/sbin/bcfg2-info b/src/sbin/bcfg2-info index b8a62cb33..4ad4fa3de 100755 --- a/src/sbin/bcfg2-info +++ b/src/sbin/bcfg2-info @@ -110,6 +110,7 @@ def doHelp(_, dummy): print 'mappings <type*> <name*>- print generator mappings for optional type and name' print 'quit' print 'showentries <hostname> <type> - show abstract configuration entries for a given host' + print 'showclient <client1> <client2> - show metadata for given hosts' print 'update - process pending file events' print 'version - print version of this tool' @@ -137,6 +138,38 @@ def doGroups(_, core): data.append((group, prof, cat, ','.join(gdata))) printTabular(data) +def doShowclient(cmd, core): + ''' print host metadata''' + data = [('Client', 'Profile', "Groups", "Bundles")] + for client in cmd[1:]: + if client not in core.metadata.clients: + print "Client %s not defined" % client + continue + profile = core.metadata.clients[client] + bundles, groups, categories = core.metadata.groups[profile] + groups.remove(profile) + numbundles = len(bundles) + numgroups = len(groups) + num = max((numbundles, numgroups)) + for i in range(0,num): + if i == 0: + c = client + p = profile + else: + c = "" + p = "" + if i < numbundles: + b = bundles[i] + else: + b = "" + if i < numgroups: + g = groups[i] + else: + g = "" + data.append((c, p, g, b)) + if len(data) > 1: + printTabular(data) + def doMappings(cmd, core): '''print out mapping info''' # dump all mappings unless type specified @@ -175,10 +208,13 @@ def doVersion(_, dummy): if __name__ == '__main__': Bcfg2.Logging.setup_logging('bcfg2-info', to_syslog=False) logger = logging.getLogger('bcfg2-info') - dispatch = {'build': doBuild, 'buildall': doBuildAll, 'buildfile': doBuildFile, - 'bundles': doBundles, 'clients': doClients, 'generators': doGenerators, - 'groups': doGroups, 'help': doHelp, 'mappings': doMappings, 'quit': doQuit, - 'showentries': doShowentries, 'update': doUpdate, 'version': doVersion} + dispatch = {'build': doBuild, 'buildall': doBuildAll, + 'buildfile': doBuildFile, 'bundles': doBundles, + 'clients': doClients, 'generators': doGenerators, + 'groups': doGroups, 'help': doHelp, + 'mappings': doMappings, 'quit': doQuit, + 'showentries': doShowentries, 'update': doUpdate, + 'version': doVersion, 'showclient': doShowclient} if '-C' in sys.argv: cfile = sys.argv[-1] else: |