check in latest test scripts
authorScott Baker <bakers@cs.arizona.edu>
Tue, 9 Sep 2008 23:41:25 +0000 (23:41 +0000)
committerScott Baker <bakers@cs.arizona.edu>
Tue, 9 Sep 2008 23:41:25 +0000 (23:41 +0000)
cmdline/genicli.py
cmdline/testComponent.sh [new file with mode: 0644]
cmdline/testCreateAuth.sh [new file with mode: 0644]
cmdline/testSA.sh
cmdline/testUser.sh

index 610f9ab..2c11f5f 100644 (file)
@@ -6,7 +6,7 @@ import os
 from cert import *
 from geniclient import *
 
-long_opts = ["keyfile=", "help", "outfile=", "credfile=", "username=", "email="]
+long_opts = ["keyfile=", "help", "outfile=", "credfile=", "username=", "email=", "ip=", "dns=", "dump_parents", "server="]
 
 # default command line options
 username = "client"
@@ -19,11 +19,15 @@ cred_file = None
 cert_file = None
 out_file = None
 
+ip = None
+dns = None
 email = None
 uuid = None
 gid_pkey_fn = None
 gid_fn = None
 
+dump_parents = False
+
 leaf_name = None
 server_url = "https://localhost:12345/"
 
@@ -38,7 +42,11 @@ def showhelp():
    print "    --outfile        ... save response to a file"
    print "    --credfile       ... credential of user making call (or 'None')"
    print "    --keyfile        ... private key file of user making call"
-   print "    --email          ... email address"
+   print "    --email          ... email address (for registering users)"
+   print "    --ip             ... IP address (for registering nodes)"
+   print "    --dns            ... DNS address (for registering nodes)"
+   print "    --dump_parents   ... dump parents"
+   print "    --server         ... geni server (registry/component) to connect to"
    print "commands:"
    print "    resolve <hrn>"
    print "    dumpCredential"
@@ -48,6 +56,9 @@ def showhelp():
    print "    createGid <hrn> <uuid|None> <pubkey_fn>"
    print "    register <type> <hrn> <gid_filename>"
    print "    remove <type> <hrn>"
+   print "    update <type> <hrn>"
+   print "    startSlice"
+   print "    stopSlice"
 
 def process_options():
    global username
@@ -55,7 +66,9 @@ def process_options():
    global type, hrn
    global cert_file, cred_file
    global key_file, out_file
-   global uuid, pkey_fn, gid_fn, email, gid_pkey_fn
+   global uuid, pkey_fn, gid_fn, email, gid_pkey_fn, ip, dns
+   global dump_parents
+   global server_url
 
    (options, args) = getopt.getopt(sys.argv[1:], '', long_opts)
    for opt in options:
@@ -77,6 +90,14 @@ def process_options():
            key_file = val
        elif name == "--email":
            email = val
+       elif name == "--ip":
+           ip = val
+       elif name == "--dns":
+           dns = val
+       elif name == "--dump_parents":
+           dump_parents = True
+       elif name == "--server":
+           server_url = val
 
    if not args:
        print "no operation specified"
@@ -120,6 +141,12 @@ def process_options():
        type = args[1]
        hrn = args[2]
 
+   elif opname == "update":
+       if len(args) < 3:
+           print "syntax: update <type> <hrn>"
+       type = args[1]
+       hrn = args[2]
+
    leaf_name = get_leaf(username)
 
    if cert_file == None:
@@ -132,6 +159,7 @@ def process_options():
        cred_file = leaf_name + ".cred"
 
 def show_options():
+   print "   server:", server_url
    print " username:", username
    print "cert_file:", cert_file
    print " key_file:", key_file
@@ -227,7 +255,7 @@ def main():
       if result:
           for record in result:
               print "RESULT:"
-              record.dump()
+              record.dump(dump_parents=dump_parents)
       else:
           print "NO RESULT"
 
@@ -235,7 +263,7 @@ def main():
       result = client.get_credential(cred, type, hrn)
       if result:
           print "RESULT:"
-          result.dump()
+          result.dump(dump_parents=dump_parents)
           if out_file:
               file(out_file, "w").write(result.save_to_string(save_parents=True))
       else:
@@ -246,7 +274,7 @@ def main():
       if result:
           for record in result:
               print "RESULT:"
-              record.dump()
+              record.dump(dump_parents=dump_parents)
       else:
           print "NO RESULT"
 
@@ -257,7 +285,7 @@ def main():
        gid = client.create_gid(cred, hrn, uuid, pkey_string)
        if gid:
            print "RESULT:"
-           gid.dump()
+           gid.dump(dump_parents=dump_parents)
            if out_file:
                file(out_file,"w").write(gid.save_to_string(save_parents=True))
        else:
@@ -269,6 +297,15 @@ def main():
            if not email:
                print "ERROR: must specify --email <addr> when registering users"
            geni_info['email'] = email
+
+       if type == "node":
+           if not ip:
+               print "ERROR: must specify --ip <addr> when registering nodes"
+           geni_info['ip'] = ip
+           if not dns:
+               print "ERROR: must specify --dns <addr> when registering nodes"
+           geni_info['dns'] = dns
+
        gid = GID(filename=gid_fn)
        record = GeniRecord(name=hrn, gid=gid, type=type, pointer=-1)
        record.set_geni_info(geni_info)
@@ -291,6 +328,37 @@ def main():
        for record in matching_records:
            client.remove(cred,record)
 
+   elif (opname == "update"):
+       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:
+           geni_info = record.get_geni_info()
+
+           if email:
+               geni_info['email'] = email
+           if ip:
+               geni_info['ip'] = ip
+           if dns:
+               geni_info['dns'] = dns
+
+           client.update(cred, record)
+
+   elif (opname == "stopSlice"):
+       client.stop_slice(cred)
+
+   elif (opname == "startSlice"):
+       client.start_slice(cred)
+
    else:
       print "unknown operation: " + opname
 
diff --git a/cmdline/testComponent.sh b/cmdline/testComponent.sh
new file mode 100644 (file)
index 0000000..7675877
--- /dev/null
@@ -0,0 +1,25 @@
+rm -f test.cred
+rm -f test.cert
+rm -f pltest1.cred
+
+NODE_URL=https://198.0.0.131:12345/
+
+echo XXXXX -------------------------------------------------------------------
+echo XXXXX Getting User Credential
+python ./genicli.py --username test --credfile None --outfile test.cred getCredential user planetlab.us.pl.account_test
+
+echo XXXXX -------------------------------------------------------------------
+echo XXXXX Get Slice Credential
+python ./genicli.py --username test --outfile pltest1.cred getCredential slice planetlab.us.pl.test1
+
+echo XXXXX -------------------------------------------------------------------
+echo XXXXX Stop a Slice
+python ./genicli.py --server $NODE_URL --username test --credfile pltest1.cred --outfile pltest1.cred stopSlice planetlab.us.pl.test1
+
+echo XXXXX -------------------------------------------------------------------
+echo XXXXX Start a Slice
+python ./genicli.py --server $NODE_URL --username test --credfile pltest1.cred --outfile pltest1.cred startSlice planetlab.us.pl.test1
+
+echo XXXXX -------------------------------------------------------------------
+echo XXXXX Reset a Slice
+python ./genicli.py --server $NODE_URL --username test --credfile pltest1.cred --outfile pltest1.cred resetSlice planetlab.us.pl.test1
diff --git a/cmdline/testCreateAuth.sh b/cmdline/testCreateAuth.sh
new file mode 100644 (file)
index 0000000..4adbef8
--- /dev/null
@@ -0,0 +1,41 @@
+rm -f root.cred
+rm -f root.cert
+rm -f rootsa.cred
+rm -f testkey.pkey
+rm -f testkey.gid
+
+echo XXXXX -------------------------------------------------------------------
+echo XXXXX Getting Self Credential
+python ./genicli.py --username root --credfile None --outfile root.cred getCredential user planetlab.us.pl.Administrator_Default
+
+echo XXXXX -------------------------------------------------------------------
+echo XXXXX Getting SA Credential
+python ./genicli.py --username root --outfile rootsa.cred getCredential sa planetlab.us
+
+echo XXXXX -------------------------------------------------------------------
+echo XXXXX Create a private key
+python ./genicli.py --username testkey createKey
+
+echo XXXXX -------------------------------------------------------------------
+echo XXXXX Create a GID for an authority
+python ./genicli.py --username root --credfile rootsa.cred --outfile testauth.gid createGid planetlab.us.testauth None testkey.pkey
+
+echo XXXXX -------------------------------------------------------------------
+echo XXXXX Register a slice authority
+python ./genicli.py --username root --credfile rootsa.cred register sa planetlab.us.testauth testauth.gid
+
+echo XXXXX -------------------------------------------------------------------
+echo XXXXX Register a management authority
+python ./genicli.py --username root --credfile rootsa.cred register ma planetlab.us.testauth testauth.gid
+
+echo XXXXX -------------------------------------------------------------------
+echo XXXXX Resolve the test slice authority
+python ./genicli.py --username root --credfile rootsa.cred resolve planetlab.us.testauth
+
+echo XXXXX -------------------------------------------------------------------
+echo XXXXX Remove a the test management authority
+python ./genicli.py --username root --credfile rootsa.cred remove ma planetlab.us.testauth
+
+echo XXXXX -------------------------------------------------------------------
+echo XXXXX Remove the test slice authority
+python ./genicli.py --username root --credfile rootsa.cred remove sa planetlab.us.testauth
index 1ebd96f..8cdb7cd 100755 (executable)
@@ -24,7 +24,6 @@ echo XXXXX -------------------------------------------------------------------
 echo XXXXX Create a private key
 python ./genicli.py --username testkey createKey
 
-
 echo XXXXX -------------------------------------------------------------------
 echo XXXXX Create a GID for a user
 python ./genicli.py --username root --credfile rootsa.cred --outfile testuser.gid createGid planetlab.us.pl.testuser None testkey.pkey
@@ -33,6 +32,10 @@ echo XXXXX -------------------------------------------------------------------
 echo XXXXX Create a GID for a slice
 python ./genicli.py --username root --credfile rootsa.cred --outfile testslice.gid createGid planetlab.us.pl.testslice1 None testkey.pkey
 
+echo XXXXX -------------------------------------------------------------------
+echo XXXXX Create a GID for a node
+python ./genicli.py --username root --credfile rootsa.cred --outfile testnode.gid createGid planetlab.us.pl.testnode1 None testkey.pkey
+
 echo XXXXX -------------------------------------------------------------------
 echo XXXXX Register a user
 python ./genicli.py --username root --credfile rootsa.cred --email test1234@test.com register user planetlab.us.pl.testuser testuser.gid
@@ -43,9 +46,28 @@ python ./genicli.py --username root --credfile rootsa.cred resolve planetlab.us.
 
 echo XXXXX -------------------------------------------------------------------
 echo XXXXX Register a slice
-python ./genicli.py --username root --credfile rootsa.cred --email test1234@test.com register slice planetlab.us.pl.testslice1 testslice.gid
+python ./genicli.py --username root --credfile rootsa.cred register slice planetlab.us.pl.testslice1 testslice.gid
+
+echo XXXXX -------------------------------------------------------------------
+echo XXXXX Resolve the test node
+python ./genicli.py --username root --credfile rootsa.cred resolve planetlab.us.pl.testslice1
+
+echo XXXXX -------------------------------------------------------------------
+echo XXXXX Register a node
+python ./genicli.py --username root --credfile rootsa.cred --ip 198.0.0.133 --dns testnode1.lan register node planetlab.us.pl.testnode1 testnode.gid
+
+echo XXXXX -------------------------------------------------------------------
+echo XXXXX Resolve the test node
+python ./genicli.py --username root --credfile rootsa.cred resolve planetlab.us.pl.testnode1
+
+echo XXXXX -------------------------------------------------------------------
+echo XXXXX Remove the test node
+python ./genicli.py --username root --credfile rootsa.cred remove node planetlab.us.pl.testnode1
+
+echo XXXXX -------------------------------------------------------------------
+echo XXXXX Remove the test slice
+python ./genicli.py --username root --credfile rootsa.cred remove slice planetlab.us.pl.testslice1
 
 echo XXXXX -------------------------------------------------------------------
 echo XXXXX Remove a user
-python ./genicli.py --username root --credfile rootsa.cred remove user planet\
-lab.us.pl.testuser
+python ./genicli.py --username root --credfile rootsa.cred remove user planetlab.us.pl.testuser
index f709139..b0d797f 100755 (executable)
@@ -10,5 +10,11 @@ echo XXXXX Resolving Self
 python ./genicli.py --username test resolve planetlab.us.pl.account_test
 
 echo XXXXX -------------------------------------------------------------------
-echo XXXXX List records in an authority
-python ./genicli.py --username test list planetlab.us.pl
\ No newline at end of file
+echo XXXXX Update Self
+python ./genicli.py --username test update user planetlab.us.pl.account_test
+
+# XXX - this fails because 'list' is an operation for authorities, and our
+#   credential is a user credential
+#echo XXXXX -------------------------------------------------------------------
+#echo XXXXX List records in an authority
+#python ./genicli.py --username test list