summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rwxr-xr-xtools/client-query.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/tools/client-query.py b/tools/client-query.py
index e2de0593c..73b9f7ae4 100755
--- a/tools/client-query.py
+++ b/tools/client-query.py
@@ -1,17 +1,22 @@
#!/usr/bin/python
-import lxml.etree, sys
+import lxml.etree, sys, ConfigParser
#this will be replaced by redeadin config file, but I am in a hurry right now
-prefix = "/disks/bcfg2"
+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 <profile name>"
- 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 <profile name>\t shows all the clients of that profile"
- sys.exit(1)
-
+ print "Usage client-query.py -d|u|p <profile name>"
+ 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 <profile name>\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:
@@ -24,7 +29,7 @@ for client in xml.findall('.//Client'):
if client.get("profile") == sys.argv[sys.argv.index('-p') + 1]:
print client.get("name")
elif '-a' in sys.argv:
- print client.get("name")
+ print client.get("name")