just some comments. nothing major.
[sfa.git] / cmdline / sfi.py
index f56d37e..c7998bf 100755 (executable)
@@ -227,9 +227,8 @@ def create_cmd_parser(command, additional_cmdargs = None):
               "remove": "name",
               "add": "record",
               "update": "record",
-              "nodes": "[name]",
               "slices": "",
-              "resources": "name",
+              "resources": "[name]",
               "create": "name rspec",
               "delete": "name",
               "reset": "name",
@@ -250,7 +249,7 @@ def create_cmd_parser(command, additional_cmdargs = None):
 
    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"))
@@ -259,7 +258,7 @@ def create_cmd_parser(command, additional_cmdargs = None):
            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
@@ -305,14 +304,17 @@ def main():
    (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)
 
@@ -335,6 +337,8 @@ def list(opts, args):
    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:
@@ -391,7 +395,7 @@ def update(opts, args):
    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()
@@ -413,23 +417,23 @@ def update(opts, args):
 # 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)
-      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):
@@ -516,12 +520,13 @@ def save_rspec_to_file(rspec, filename):
    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'])