"remove": "name",
"add": "record",
"update": "record",
- "nodes": "[name]",
"slices": "",
- "resources": "name",
+ "resources": "[name]",
"create": "name rspec",
"delete": "name",
"reset": "name",
parser = OptionParser(usage="sfi [sfi_options] %s [options] %s" \
% (command, cmdargs[command]))
- if command in ("nodes", "resources"):
+ if command in ("resources"):
parser.add_option("-f", "--format", dest="format",type="choice",
help="display format (dns|ip|rspec)",default="rspec",
choices=("dns","ip","rspec"))
help="type filter (user|slice|sa|ma|node|aggregate)",
choices=("user","slice","sa","ma","node","aggregate", "all"),
default="all")
- if command in ("show", "list", "nodes", "resources"):
+ if command in ("show", "list", "resources"):
parser.add_option("-o", "--output", dest="file",
help="output XML to file", metavar="FILE", default=None)
return parser
(cmd_opts, cmd_args) = create_cmd_parser(command).parse_args(args[1:])
verbose = options.verbose
if verbose :
- print options.registry, options.sm, options.dir, options.verbose,\
- options.user, options.auth
- print command
- if command in ("nodes", "resources"):
- print cmd_opts.format
+ print "Resgistry %s, sm %s, dir %s, user %s, auth %s" % (options.registry,
+ options.sm,
+ options.dir,
+ options.user,
+ options.auth)
+ print "Command %s" %command
+ if command in ("resources"):
+ print "resources cmd_opts %s" %cmd_opts.format
elif command in ("list","show","remove"):
- print cmd_opts.type
- print cmd_args
+ print "cmd_opts.type %s" %cmd_opts.type
+ print "cmd_args %s" %cmd_args
set_servers(options)
global registry
user_cred = get_user_cred()
list = registry.list(user_cred, args[0])
+ # filter on person, slice, site, node, etc.
+ # THis really should be in the filter_records funct def comment...
list = filter_records(opts.type, list)
display_records(list)
if opts.file:
user_cred = get_user_cred()
rec_file = get_record_file(args[0])
record = load_record_from_file(rec_file)
-
if record.get_type() == "user":
- if record.get_name() == user_cred.get_object_gid().get_hrn():
+ if record.get_name() == user_cred.get_gid_object().get_hrn():
cred = user_cred
else:
create = get_auth_cred()
cred = get_auth_cred()
else:
raise "unknown record type" + record.get_type()
-
return registry.update(cred, record)
#
# Slice-related commands
#
-# list available nodes
-def nodes(opts, args):
- global slicemgr
- user_cred = get_user_cred()
- if not opts.format:
- context = None
- else:
- context = opts.format
- results = slicemgr.list_nodes(user_cred)
- if opts.format in ['rspec']:
- display_rspec(results)
- else:
- display_list(results)
- if (opts.file is not None):
- rspec = slicemgr.list_nodes(user_cred, 'rspec')
- save_rspec_to_file(rspec, opts.file)
- return
+# list available nodes -- now use 'resources' w/ no argument instead
+#def nodes(opts, args):
+# global slicemgr
+# user_cred = get_user_cred()
+# if not opts.format:
+# context = None
+# else:
+# context = opts.format
+# results = slicemgr.list_nodes(user_cred)
+# if opts.format in ['rspec']:
+# display_rspec(results)
+# else:
+# display_list(results)
+# if (opts.file is not None):
+# rspec = slicemgr.list_nodes(user_cred)
+# save_rspec_to_file(rspec, opts.file)
+# return
# list instantiated slices
def slices(opts, args):
# show rspec for named slice
def resources(opts, args):
global slicemgr
- slice_cred = get_slice_cred(args[0])
- result = slicemgr.list_resources(slice_cred, args[0])
+ if args:
+ slice_cred = get_slice_cred(args[0])
+ result = slicemgr.get_resources(slice_cred, args[0])
+ else:
+ user_cred = get_user_cred()
+ result = slicemgr.get_resources(user_cred)
display_rspec(result)
if (opts.file is not None):
save_rspec_to_file(opts.file, result)
return
def display_records(recordList, dump = False):
+ ''' Print all fields in the record'''
for record in recordList:
display_record(record, dump)
def display_record(record, dump = False):
if dump:
- record.dump(False)
+ record.dump()
else:
info = record.getdict()
print "%s (%s)" % (info['hrn'], info['type'])
def save_record_to_file(filename, record):
if not filename.startswith(os.sep):
filename = sfi_dir + filename
- print "saving record", record.name, "to file", filename
str = record.save_to_string()
file(filename, "w").write(str)
return