diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2006-09-15 16:15:17 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2006-09-15 16:15:17 +0000 |
commit | 32b52fc0ff2918b62d427ac7d88a3ea441311bee (patch) | |
tree | 974e5ffd7a1d9780269086f6f4918debbd1de2e7 /src/sbin | |
parent | 9daa6e3cbbded222b232554b2ac6a3b0ed628426 (diff) | |
download | bcfg2-32b52fc0ff2918b62d427ac7d88a3ea441311bee.tar.gz bcfg2-32b52fc0ff2918b62d427ac7d88a3ea441311bee.tar.bz2 bcfg2-32b52fc0ff2918b62d427ac7d88a3ea441311bee.zip |
Switch bcfg2-query over to using XPATH
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@2269 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/sbin')
-rwxr-xr-x | src/sbin/bcfg2-query | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/sbin/bcfg2-query b/src/sbin/bcfg2-query index c250773da..a446ab60c 100755 --- a/src/sbin/bcfg2-query +++ b/src/sbin/bcfg2-query @@ -17,15 +17,15 @@ if len(sys.argv) < 2: 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") +if '-p' in sys.argv: + profile = sys.argv[sys.argv.index('-p') + 1] + clients = xml.xpath(".//Client[@profile='%s']" % (profile)) +elif '-d' in sys.argv: + clients = xml.xpath(".//Client[@pingable='N']") +elif '-u' in sys.argv: + clients = xml.xpath(".//Client[@pingable='Y']") +elif '-a' in sys.argv: + clients = xml.xpath(".//Client") + +for client in clients: + print client.get('name') |