r1.3 move bonfire.py code to sfa/bonfire repository
[sfa.git] / sfa / client / sfi.py
index 213f755..8aec7c1 100644 (file)
@@ -14,6 +14,7 @@ import codecs
 import pickle
 import json
 import shutil
+
 from lxml import etree
 from StringIO import StringIO
 from optparse import OptionParser
@@ -1493,8 +1494,9 @@ $ sfi myslice
 $ sfi -v myslice  -- or sfi -vv myslice
   same but with more and more verbosity
 
-$ sfi m
+$ sfi m -b http://mymanifold.foo.com:7080/
   is synonym to sfi myslice as no other command starts with an 'm'
+  and uses a custom backend for this one call
 """
 ) # register_command
     def myslice (self, options, args):
@@ -1513,15 +1515,18 @@ $ sfi m
         # enable info by default
         self.logger.setLevelFromOptVerbose(self.options.verbose+1)
         ### the rough sketch goes like this
+        # (0) produce a p12 file
+        self.client_bootstrap.my_pkcs12()
+
         # (a) rain check for sufficient config in sfi_config
         myslice_dict={}
-        myslice_keys=['backend', 'delegate', 'platform', 'username']
+        myslice_keys=[ 'backend', 'delegate', 'platform', 'username']
         for key in myslice_keys:
             value=None
             # oct 2013 - I'm finding myself juggling with config files
             # so a couple of command-line options can now override config
-            if hasattr(args,key):
-                value=getattr(args,key)
+            if hasattr(options,key) and getattr(options,key) is not None:
+                value=getattr(options,key)
             else:
                 full_key="MYSLICE_" + key.upper()
                 value=getattr(self.config_instance,full_key,None)
@@ -1582,6 +1587,7 @@ $ sfi m
         # (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'],
@@ -1597,8 +1603,8 @@ $ sfi m
             if uploader.upload(delegated_credential,message=message):
                 count_success+=1
             count_all+=1
-
         self.logger.info("Successfully uploaded %d/%d credentials"%(count_success,count_all))
+
         # at first I thought we would want to save these,
         # like 'sfi delegate does' but on second thought
         # it is probably not helpful as people would not