summaryrefslogtreecommitdiff
path: root/examples/scripts
diff options
context:
space:
mode:
authorMichael DeHaan <michael.dehaan@gmail.com>2012-07-12 01:05:49 -0400
committerMichael DeHaan <michael.dehaan@gmail.com>2012-07-12 01:05:49 -0400
commitbcd0001cb1a785039969c4dec0ed4b4f8cf273c7 (patch)
treec25e37e6ab1c24bcf389581563cc2b7b85e3865c /examples/scripts
parent611e5b0c9060089390da5655de58a84ac26d7a30 (diff)
downloadansible-bcd0001cb1a785039969c4dec0ed4b4f8cf273c7.tar.gz
Bring the cobbler external inventory script up to date with current usage (--list, --host hostname)
Diffstat (limited to 'examples/scripts')
-rwxr-xr-xexamples/scripts/cobbler_external_inventory.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/examples/scripts/cobbler_external_inventory.py b/examples/scripts/cobbler_external_inventory.py
index 62d9c99d03..7b6980e6a6 100755
--- a/examples/scripts/cobbler_external_inventory.py
+++ b/examples/scripts/cobbler_external_inventory.py
@@ -69,7 +69,7 @@ conn = xmlrpclib.Server("http://127.0.0.1/cobbler_api", allow_none=True)
# executed with no parameters, return the list of
# all groups and hosts
-if len(sys.argv) == 1:
+if len(sys.argv) == 2 and (sys.argv[1] == '--list'):
systems = conn.get_item_names('system')
groups = { 'ungrouped' : [] }
@@ -103,10 +103,10 @@ if len(sys.argv) == 1:
# executed with a hostname as a parameter, return the
# variables for that host
-if len(sys.argv) == 2:
+elif len(sys.argv) == 3 and (sys.argv[1] == '--host'):
# look up the system record for the given DNS name
- result = conn.find_system_by_dns_name(sys.argv[1])
+ result = conn.find_system_by_dns_name(sys.argv[2])
system = result.get('name', None)
data = {}
if system is None:
@@ -125,3 +125,7 @@ if len(sys.argv) == 2:
print json.dumps(results)
sys.exit(0)
+else:
+
+ print "usage: --list ..OR.. --host <hostname>"
+ sys.exit(1)