From: Scott Baker Date: Wed, 7 Jan 2009 02:28:16 +0000 (+0000) Subject: add --short option, update arguments for list operation X-Git-Tag: sfa-0.9-0@14641~761 X-Git-Url: http://git.onelab.eu/?p=sfa.git;a=commitdiff_plain;h=de6c5d6233045c4efc86882cb361ceb5f16646d2 add --short option, update arguments for list operation --- diff --git a/cmdline/genicli.py b/cmdline/genicli.py index 4101b5f0..20064606 100644 --- a/cmdline/genicli.py +++ b/cmdline/genicli.py @@ -9,7 +9,7 @@ from geniticket import * long_opts = ["keyfile=", "help", "outfile=", "credfile=", "ticketfile=", "username=", "email=", "ip=", "dns=", "dump_parents", "server=", - "filter="] + "filter=", "short"] # default command line options username = "client" @@ -23,6 +23,7 @@ cert_file = None out_file = None ticket_file = None +short = False ip = None dns = None email = None @@ -54,10 +55,12 @@ def showhelp(): print " --dump_parents ... dump parents" print " --server ... geni server (registry/component) to connect to" print " --filter ... filter the results of a list operation (user | slice | node ...)" + print " --short ... list records in short format (name only)" print "commands:" print " resolve " print " dumpCredential" print " getCredential " + print " list " print " start " print " createKey " print " createGid " @@ -78,6 +81,7 @@ def process_options(): global dump_parents global server_url global filter + global short (options, args) = getopt.getopt(sys.argv[1:], '', long_opts) for opt in options: @@ -111,6 +115,8 @@ def process_options(): server_url = val elif name == "--filter": filter = val + elif name == "--short": + short = True if not args: print "no operation specified" @@ -131,6 +137,13 @@ def process_options(): type = args[1] hrn = args[2] + elif opname == "list": + if len(args) < 2: + print "syntax: list " + sys.exit(-1) + hrn = args[1] + + elif opname == "createGid": if len(args) < 4: print "syntax: createGid " @@ -290,13 +303,16 @@ def main(): print "NO RESULT" elif (opname == "list"): - result = client.list(cred) + result = client.list(cred, hrn) if result: if filter: result = [r for r in result if r.type==filter] + print "RESULT:" for record in result: - print "RESULT:" - record.dump(dump_parents=dump_parents) + if short: + print " ", record.get_name() + else: + record.dump(dump_parents=dump_parents) else: print "NO RESULT" @@ -336,20 +352,6 @@ def main(): elif (opname == "remove"): client.remove(cred, type, hrn) -# record_list = client.resolve(cred, hrn) -# if not record_list: -# print "no records match hrn" -# -# matching_records = [] -# for record in record_list: -# if record.get_type() == type: -# matching_records.append(record) -# -# if not matching_records: -# print "records match hrn, but no records match type" -# -# for record in matching_records: -# client.remove(cred, record) elif (opname == "update"): record_list = client.resolve(cred, hrn)