From f7146b07e3dda92ef7dd80dba2f1a7252d86375f Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Fri, 15 Sep 2006 16:01:53 +0000 Subject: Move bcfg2-query into the install area git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@2266 ce84e21b-d406-0410-9b95-82705330c041 --- src/sbin/bcfg2-query | 31 +++++++++++++++++++++++++++++++ tools/client-query.py | 38 -------------------------------------- 2 files changed, 31 insertions(+), 38 deletions(-) create mode 100755 src/sbin/bcfg2-query delete mode 100755 tools/client-query.py diff --git a/src/sbin/bcfg2-query b/src/sbin/bcfg2-query new file mode 100755 index 000000000..c250773da --- /dev/null +++ b/src/sbin/bcfg2-query @@ -0,0 +1,31 @@ +#!/usr/bin/python + +import lxml.etree, sys, ConfigParser + +CP = ConfigParser.ConfigParser() +CP.read(['/etc/bcfg2.conf']) +try: + prefix = CP.get('server', 'repository') +except: + prefix = "/var/lib/bcfg2" + +if len(sys.argv) < 2: + print "Usage bcfg2-query -d|u|p " + print "\t -d\t\t shows the clients that are currently down" + print "\t -u\t\t shows the clients that are currently up" + print "\t -p \t shows all the clients of that profile" + sys.exit(1) + +xml = lxml.etree.parse('%s/Metadata/clients.xml'%prefix) +for client in xml.findall('.//Client'): + if '-u' in sys.argv: + if client.get("pingable") == "Y": + print client.get("name") + elif '-d' in sys.argv: + if client.get("pingable") == "N": + print client.get("name") + elif '-p' in sys.argv and sys.argv[sys.argv.index('-p') + 1] != '': + if client.get("profile") == sys.argv[sys.argv.index('-p') + 1]: + print client.get("name") + elif '-a' in sys.argv: + print client.get("name") diff --git a/tools/client-query.py b/tools/client-query.py deleted file mode 100755 index 73b9f7ae4..000000000 --- a/tools/client-query.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/python - -import lxml.etree, sys, ConfigParser - -#this will be replaced by redeadin config file, but I am in a hurry right now -CP = ConfigParser.ConfigParser() -CP.read(['/etc/bcfg2.conf']) -try: - prefix = CP.get('server', 'repository') -except: - prefix = "/disks/bcfg2" - -if len(sys.argv) < 2: - print "Usage client-query.py -d|u|p " - print "\t -d\t\t shows the clients that are currently down" - print "\t -u\t\t shows the clients that are currently up" - print "\t -p \t shows all the clients of that profile" - sys.exit(1) - -xml = lxml.etree.parse('%s/Metadata/clients.xml'%prefix) -for client in xml.findall('.//Client'): - if '-u' in sys.argv: - if client.get("pingable") == "Y": - print client.get("name") - elif '-d' in sys.argv: - if client.get("pingable") == "N": - print client.get("name") - elif '-p' in sys.argv and sys.argv[sys.argv.index('-p') + 1] != '': - if client.get("profile") == sys.argv[sys.argv.index('-p') + 1]: - print client.get("name") - elif '-a' in sys.argv: - print client.get("name") - - - - - - -- cgit v1.2.3-1-g7c22