From 6c87661d4dc0f9cbaa09a16d713d1690e23d62c9 Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Tue, 9 May 2006 21:38:28 +0000 Subject: Implement the showentries command (from Cory) git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@1861 ce84e21b-d406-0410-9b95-82705330c041 --- src/sbin/bcfg2-info | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/sbin/bcfg2-info b/src/sbin/bcfg2-info index 9ad7972e2..a7ff04a92 100755 --- a/src/sbin/bcfg2-info +++ b/src/sbin/bcfg2-info @@ -20,6 +20,28 @@ def getInput(): return raw_input('> ').split(" ") except KeyboardInterrupt: return [''] +def doShowentries(cmd, core): + '''show abstract configuration entries for a given host''' + if len(cmd) not in [2, 3]: + print "Usage: showentries " + return + try: + meta = core.metadata.get_metadata(cmd[1]) + except: + print "Unable to find metadata for host %s" % cmd[1] + return + structures = core.GetStructures(meta) + output = [('entrytype', 'name')] + if len(cmd) == 2: + for item in structures: + for child in item.getchildren(): + output.append((child.tag, child.get('name'))) + if len(cmd) == 3: + for item in structures: + for child in item.getchildren(): + if child.tag == cmd[2]: + output.append((child.tag, child.get('name'))) + printTabular(output) def doBuild(cmd, core): '''build client configuration''' @@ -71,6 +93,7 @@ def doHelp(_, dummy): print 'help - print this text' print 'mappings - print generator mappings for optional type and name' print 'quit' + print 'showentries - show abstract configuration entries for a given host' print 'update - process pending file events' print 'version - print version of this tool' @@ -139,7 +162,7 @@ if __name__ == '__main__': dispatch = {'build': doBuild, 'buildfile': doBuildFile, 'bundles': doBundles, 'clients': doClients, 'generators': doGenerators, 'groups': doGroups, 'help': doHelp, 'mappings': doMappings, 'quit': doQuit, - 'update': doUpdate, 'version': doVersion} + 'showentries': doShowentries, 'update': doUpdate, 'version': doVersion} if '-c' in sys.argv: cfile = sys.argv[-1] else: -- cgit v1.2.3-1-g7c22