fixes to test scripts, added filter option to command line tool
authorScott Baker <bakers@cs.arizona.edu>
Tue, 25 Nov 2008 21:46:52 +0000 (21:46 +0000)
committerScott Baker <bakers@cs.arizona.edu>
Tue, 25 Nov 2008 21:46:52 +0000 (21:46 +0000)
cmdline/genicli.py
cmdline/testSA.sh
cmdline/testUser.sh

index caaf084..b54d4f7 100644 (file)
@@ -7,7 +7,9 @@ from cert import *
 from geniclient import *
 from geniticket import *
 
-long_opts = ["keyfile=", "help", "outfile=", "credfile=", "ticketfile=", "username=", "email=", "ip=", "dns=", "dump_parents", "server="]
+long_opts = ["keyfile=", "help", "outfile=", "credfile=", "ticketfile=",
+             "username=", "email=", "ip=", "dns=", "dump_parents", "server=",
+             "filter="]
 
 # default command line options
 username = "client"
@@ -27,6 +29,7 @@ email = None
 uuid = None
 gid_pkey_fn = None
 gid_fn = None
+filter = None
 
 dump_parents = False
 
@@ -50,6 +53,7 @@ def showhelp():
    print "    --dns            ... DNS address (for registering nodes)"
    print "    --dump_parents   ... dump parents"
    print "    --server         ... geni server (registry/component) to connect to"
+   print "    --filter <type>  ... filter the results of a list operation (user | slice | node ...)"
    print "commands:"
    print "    resolve <hrn>"
    print "    dumpCredential"
@@ -73,6 +77,7 @@ def process_options():
    global uuid, pkey_fn, gid_fn, email, gid_pkey_fn, ip, dns
    global dump_parents
    global server_url
+   global filter
 
    (options, args) = getopt.getopt(sys.argv[1:], '', long_opts)
    for opt in options:
@@ -104,6 +109,8 @@ def process_options():
            dump_parents = True
        elif name == "--server":
            server_url = val
+       elif name == "--filter":
+           filter = val
 
    if not args:
        print "no operation specified"
@@ -285,6 +292,8 @@ def main():
    elif (opname == "list"):
       result = client.list(cred)
       if result:
+          if filter:
+              result = [r for r in result if r.type==filter]
           for record in result:
               print "RESULT:"
               record.dump(dump_parents=dump_parents)
index fc9bba4..5074d03 100755 (executable)
@@ -1,15 +1,15 @@
 # The following lines use the root account of the MyPLC. This assumes that the
 # Administrator_Default has a private key that is located in the file
 # root.pkey in the current directory.
-USERNAME=root
-PARENT_HRN=planetlab.us.pl
-USER_HRN=$PARENT_HRN.Administrator_Default
+#USERNAME=root
+#PARENT_HRN=planetlab.us.pl
+#USER_HRN=$PARENT_HRN.Administrator_Default
 
 # The following lines use Tony Mack's planetlab account on a live PLC
 # database (tony: copy your private key to tmack.pkey in the current directory)
-#USERNAME=tmack
-#PARENT_HRN=planetlab.us.princeton
-#USER_HRN=$PARENT_HRN.Mack_Tony
+USERNAME=tmack
+PARENT_HRN=planetlab.us.princeton
+USER_HRN=$PARENT_HRN.Mack_Tony
 
 TEST_USER_HRN=$PARENT_HRN.testuser
 TEST_SLICE_HRN=$PARENT_HRN.testslice1
@@ -17,15 +17,19 @@ TEST_NODE_HRN=$PARENT_HRN.testnode1
 
 TEST_NODE_IP=198.0.0.133
 
-rm -f root.cred
-rm -f root.cert
-rm -f rootsa.cred
+CRED_FN=$USERNAME.cred
+CERT_FN=$USERNAME.cert
+SA_CRED_FN=$USERNAME_ma.cred
+
+rm -f $CRED_FN
+rm -f $CERT_FN
+rm -f $SA_CRED_FN
 rm -f testkey.pkey
 rm -f testkey.gid
 
 echo XXXXX -------------------------------------------------------------------
 echo XXXXX Getting Self Credential
-python ./genicli.py --username $USERNAME --credfile None --outfile root.cred getCredential user $USER_HRN
+python ./genicli.py --username $USERNAME --credfile None --outfile $CRED_FN getCredential user $USER_HRN
 
 echo XXXXX -------------------------------------------------------------------
 echo XXXXX Resolving Self
@@ -33,11 +37,11 @@ python ./genicli.py --username $USERNAME resolve $USER_HRN
 
 echo XXXXX -------------------------------------------------------------------
 echo XXXXX Getting SA Credential
-python ./genicli.py --username $USERNAME --outfile rootsa.cred getCredential sa $PARENT_HRN
+python ./genicli.py --username $USERNAME --outfile $SA_CRED_FN getCredential sa $PARENT_HRN
 
 echo XXXXX -------------------------------------------------------------------
 echo XXXXX List records in an authority
-python ./genicli.py --username $USERNAME --credfile rootsa.cred list
+python ./genicli.py --username $USERNAME --credfile $SA_CRED_FN list
 
 echo XXXXX -------------------------------------------------------------------
 echo XXXXX Create a private key
@@ -45,48 +49,48 @@ python ./genicli.py --username testkey createKey
 
 echo XXXXX -------------------------------------------------------------------
 echo XXXXX Create a GID for a user
-python ./genicli.py --username $USERNAME --credfile rootsa.cred --outfile testuser.gid createGid $TEST_USER_HRN None testkey.pkey
+python ./genicli.py --username $USERNAME --credfile $SA_CRED_FN --outfile testuser.gid createGid $TEST_USER_HRN None testkey.pkey
 
 echo XXXXX -------------------------------------------------------------------
 echo XXXXX Create a GID for a slice
-python ./genicli.py --username $USERNAME --credfile rootsa.cred --outfile testslice.gid createGid $TEST_SLICE_HRN None testkey.pkey
+python ./genicli.py --username $USERNAME --credfile $SA_CRED_FN --outfile testslice.gid createGid $TEST_SLICE_HRN None testkey.pkey
 
 echo XXXXX -------------------------------------------------------------------
 echo XXXXX Create a GID for a node
-python ./genicli.py --username $USERNAME --credfile rootsa.cred --outfile testnode.gid createGid $TEST_NODE_HRN None testkey.pkey
+python ./genicli.py --username $USERNAME --credfile $SA_CRED_FN --outfile testnode.gid createGid $TEST_NODE_HRN None testkey.pkey
 
 echo XXXXX -------------------------------------------------------------------
 echo XXXXX Register a user
-python ./genicli.py --username $USERNAME --credfile rootsa.cred --email test1234@test.com register user $TEST_USER_HRN testuser.gid
+python ./genicli.py --username $USERNAME --credfile $SA_CRED_FN --email test1234@test.com register user $TEST_USER_HRN testuser.gid
 
 echo XXXXX -------------------------------------------------------------------
 echo XXXXX Resolve the test user
-python ./genicli.py --username $USERNAME --credfile rootsa.cred resolve $TEST_USER_HRN
+python ./genicli.py --username $USERNAME --credfile $SA_CRED_FN resolve $TEST_USER_HRN
 
 echo XXXXX -------------------------------------------------------------------
 echo XXXXX Register a slice
-python ./genicli.py --username $USERNAME --credfile rootsa.cred register slice $TEST_SLICE_HRN testslice.gid
+python ./genicli.py --username $USERNAME --credfile $SA_CRED_FN register slice $TEST_SLICE_HRN testslice.gid
 
 echo XXXXX -------------------------------------------------------------------
 echo XXXXX Resolve the test slice
-python ./genicli.py --username $USERNAME --credfile rootsa.cred resolve $TEST_SLICE_HRN
+python ./genicli.py --username $USERNAME --credfile $SA_CRED_FN resolve $TEST_SLICE_HRN
 
 echo XXXXX -------------------------------------------------------------------
 echo XXXXX Register a node
-python ./genicli.py --username $USERNAME --credfile rootsa.cred --ip $TEST_NODE_IP --dns testnode1.lan register node $TEST_NODE_HRN testnode.gid
+python ./genicli.py --username $USERNAME --credfile $SA_CRED_FN --ip $TEST_NODE_IP --dns testnode1.lan register node $TEST_NODE_HRN testnode.gid
 
 echo XXXXX -------------------------------------------------------------------
 echo XXXXX Resolve the test node
-python ./genicli.py --username $USERNAME --credfile rootsa.cred resolve $TEST_NODE_HRN
+python ./genicli.py --username $USERNAME --credfile $SA_CRED_FN resolve $TEST_NODE_HRN
 
 echo XXXXX -------------------------------------------------------------------
 echo XXXXX Remove the test node
-python ./genicli.py --username $USERNAME --credfile rootsa.cred remove node $TEST_NODE_HRN
+python ./genicli.py --username $USERNAME --credfile $SA_CRED_FN remove node $TEST_NODE_HRN
 
 echo XXXXX -------------------------------------------------------------------
 echo XXXXX Remove the test slice
-python ./genicli.py --username $USERNAME --credfile rootsa.cred remove slice $TEST_SLICE_HRN
+python ./genicli.py --username $USERNAME --credfile $SA_CRED_FN remove slice $TEST_SLICE_HRN
 
 echo XXXXX -------------------------------------------------------------------
 echo XXXXX Remove a user
-python ./genicli.py --username $USERNAME --credfile rootsa.cred remove user $TEST_USER_HRN
+python ./genicli.py --username $USERNAME --credfile $SA_CRED_FN remove user $TEST_USER_HRN
index 05f89de..12b9f5d 100755 (executable)
@@ -18,13 +18,13 @@ USER_HRN=$PARENT_HRN.account_test
 
 # The following lines use Tony Mack's planetlab account on a live PLC
 # database (tony: copy your private key to tmack.pkey in the current directory)
-USERNAME=tmack
-PARENT_HRN=planetlab.us.princeton
-USER_HRN=$PARENT_HRN.Mack_Tony
+USERNAME=tmack
+PARENT_HRN=planetlab.us.princeton
+USER_HRN=$PARENT_HRN.Mack_Tony
 
 PRIVKEY_FN=$USERNAME.pkey
 CRED_FN=$USERNAME.cred
-CERTN_FN=$USERNAME.cert
+CERT_FN=$USERNAME.cert
 
 rm -f $CRED_FN
 rm -f $CERT_FN