fix for sfi version and sfi trusted, that were broken because of the -R option
[sfa.git] / sfa / client / sfi.py
index 8793da3..6e60f63 100644 (file)
@@ -138,7 +138,7 @@ def save_rspec_to_file(rspec, filename):
     if not filename.endswith(".rspec"):
         filename = filename + ".rspec"
     f = open(filename, 'w')
-    f.write(rspec)
+    f.write("%s"%rspec)
     f.close()
     return
 
@@ -387,13 +387,15 @@ class Sfi:
                               help='how myslice config variables as well')
 
         if command in ("version"):
-            parser.add_option("-R","--registry-version",
-                              action="store_true", dest="version_registry", default=False,
-                              help="probe registry version instead of sliceapi")
             parser.add_option("-l","--local",
                               action="store_true", dest="version_local", default=False,
                               help="display version of the local client")
 
+        if command in ("version", "trusted"):
+            parser.add_option("-R","--registry_interface",
+                              action="store_true", dest="registry_interface", default=False,
+                              help="target the registry interface instead of slice interface")
+
         if command in ("add", "update"):
             parser.add_option('-x', '--xrn', dest='xrn', metavar='<xrn>', help='object hrn/urn (mandatory)')
             parser.add_option('-t', '--type', dest='type', metavar='<type>', help='object type', default=None)
@@ -434,7 +436,7 @@ class Sfi:
                               help="specify specific keys to be displayed from record")
         if command in ("resources", "describe"):
             # rspec version
-            parser.add_option("-r", "--rspec-version", dest="rspec_version", default="SFA 1",
+            parser.add_option("-r", "--rspec-version", dest="rspec_version", default="GENI 3",
                               help="schema type and version of resulting RSpec")
             # disable/enable cached rspecs
             parser.add_option("-c", "--current", dest="current", default=False,
@@ -878,7 +880,7 @@ use this if you mean an authority instead""")
         if options.version_local:
             version=version_core()
         else:
-            if options.version_registry:
+            if options.registry_interface:
                 server=self.registry()
             else:
                 server = self.sliceapi()
@@ -1136,7 +1138,7 @@ use this if you mean an authority instead""")
         if self.options.raw:
             save_raw_to_file(result, self.options.raw, self.options.rawformat, self.options.rawbanner)
         if options.file is not None:
-            save_rspec_to_file(value, options.file)
+            save_rspec_to_file(value['geni_rspec'], options.file)
         if (self.options.raw is None) and (options.file is None):
             display_rspec(value, options.format)
 
@@ -1221,7 +1223,7 @@ use this if you mean an authority instead""")
         if self.options.raw:
             save_raw_to_file(result, self.options.raw, self.options.rawformat, self.options.rawbanner)
         if options.file is not None:
-            save_rspec_to_file (value, options.file)
+            save_rspec_to_file (value['geni_rspec'], options.file)
         if (self.options.raw is None) and (options.file is None):
             print value
         return value
@@ -1281,7 +1283,7 @@ use this if you mean an authority instead""")
         if self.options.raw:
             save_raw_to_file(result, self.options.raw, self.options.rawformat, self.options.rawbanner)
         if options.file is not None:
-            save_rspec_to_file (value, options.file)
+            save_rspec_to_file (value['geni_rspec'], options.file)
         if (self.options.raw is None) and (options.file is None):
             print value
         return value     
@@ -1586,6 +1588,7 @@ $ sfi m -b http://mymanifold.foo.com:7080/
         # (f) and finally upload them to manifold server
         # xxx todo add an option so the password can be set on the command line
         # (but *NOT* in the config file) so other apps can leverage this
+        self.logger.info("Uploading on backend at %s"%myslice_dict['backend'])
         uploader = ManifoldUploader (logger=self.logger,
                                      url=myslice_dict['backend'],
                                      platform=myslice_dict['platform'],
@@ -1615,7 +1618,15 @@ $ sfi m -b http://mymanifold.foo.com:7080/
         """
         return the trusted certs at this interface (get_trusted_certs)
         """ 
-        trusted_certs = self.registry().get_trusted_certs()
+        if options.registry_interface:
+            server=self.registry()
+        else:
+            server = self.sliceapi()
+        cred = self.my_authority_credential_string()
+        trusted_certs = server.get_trusted_certs(cred)
+        if not options.registry_interface:
+            trusted_certs = ReturnValue.get_value(trusted_certs)
+
         for trusted_cert in trusted_certs:
             print "\n===========================================================\n"
             gid = GID(string=trusted_cert)