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"
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/"
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"
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
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:
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"
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:
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
if result:
for record in result:
print "RESULT:"
- record.dump()
+ record.dump(dump_parents=dump_parents)
else:
print "NO RESULT"
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:
if result:
for record in result:
print "RESULT:"
- record.dump()
+ record.dump(dump_parents=dump_parents)
else:
print "NO RESULT"
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:
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)
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
--- /dev/null
+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
--- /dev/null
+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
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
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
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
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