Ignore:
Timestamp:
Sep 10, 2008 1:17:43 PM (16 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master, version-1.30, version-2.00, version-3.01, version-3.02
Children:
89d9502
Parents:
03e0290
Message:

more data on a create request, including user requested local name

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/fedd_client.py

    r03e0290 re40c7ee  
    9999        fedd_client_opts.__init__(self)
    100100        self.add_option("-e", "--experiment_cert", dest="out_certfile",
     101                type="string", help="output certificate file")
     102        self.add_option("-E", "--experiment_name", dest="exp_name",
    101103                type="string", help="output certificate file")
    102104        self.add_option("-F","--useFedid", action="store_true",
     
    141143                help="Testbed identifier (URI) to contact (required)")
    142144
    143 def exit_with_fault(dict, out=sys.stderr):
    144     """ Print an error message and exit.
    145 
    146     The dictionary contains the FeddFaultBody elements."""
    147     codestr = ""
    148 
    149     if dict.has_key('errstr'):
    150         codestr = "Error: %s" % dict['errstr']
    151 
    152     if dict.has_key('code'):
    153         if len(codestr) > 0 :
    154             codestr += " (%d)" % dict['code']
    155         else:
    156             codestr = "Error Code: %d" % dict['code']
    157 
    158     print>>out, codestr
    159     print>>out, "Description: %s" % dict['desc']
    160     sys.exit(dict.get('code', 20))
    161 
    162145class fedd_exp_data_opts(fedd_client_opts):
    163146    def __init__(self):
     
    165148        self.add_option("-e", "--experiment_cert", dest="exp_certfile",
    166149                type="string", help="output certificate file")
    167 
     150        self.add_option("-E", "--experiment_name", dest="exp_name",
     151                type="string", help="output certificate file")
     152
     153def exit_with_fault(dict, out=sys.stderr):
     154    """ Print an error message and exit.
     155
     156    The dictionary contains the FeddFaultBody elements."""
     157    codestr = ""
     158
     159    if dict.has_key('errstr'):
     160        codestr = "Error: %s" % dict['errstr']
     161
     162    if dict.has_key('code'):
     163        if len(codestr) > 0 :
     164            codestr += " (%d)" % dict['code']
     165        else:
     166            codestr = "Error Code: %d" % dict['code']
     167
     168    print>>out, codestr
     169    print>>out, "Description: %s" % dict['desc']
     170    sys.exit(dict.get('code', 20))
    168171# Base class that will do a the SOAP/XMLRPC exchange for a request.
    169172class fedd_rpc:
     
    171174        def __init__(self, fb):
    172175            self.desc = fb.get('desc', None)
    173             self.code = fb.get('code', None)
     176            self.code = fb.get('code', -1)
    174177            self.errstr = fb.get('errstr', None)
    175178
     
    310313                method_call = getattr(port, self.method, None)
    311314                resp = method_call(
    312                         encapsulate_binaries({ self.RequestBody: msg},\
     315                        encapsulate_binaries({ self.RequestBody: req_dict},\
    313316                            ('fedid',)))
    314317            except Error, e:
     
    317320            if resp:
    318321                if resp.has_key(self.ResponseBody):
    319                     return resp[self.ResponseBody]
     322                    return decapsulate_binaries(resp[self.ResponseBody],
     323                            ('fedid',))
    320324                elif resp.has_key('FeddFaultBody'):
    321325                    raise self.RPCException(resp['FeddFaultBody'])
     
    387391            sys.exit("Cannot read certificate (%s)" % cert)
    388392
     393        if opts.exp_name and opts.exp_certfile:
     394            sys.exit("Only one of --experiment_cert and " +\
     395                    "--experiment_name permitted");
     396
    389397        if opts.exp_certfile:
    390             exp_fedid = fedid(file=opts.exp_certfile)
    391         else:
    392             sys.exit("Experiment certfile required")
     398            exp_id = { 'fedid': fedid(file=opts.exp_certfile) }
     399
     400        if opts.exp_name:
     401            exp_id = { 'localname' : opts.exp_name }
     402
     403        req = { 'experiment': exp_id }
    393404
    394405        try:
    395             resp_dict = self.do_rpc({ 'experiment': { 'fedid': exp_fedid } },
     406            resp_dict = self.do_rpc(req,
    396407                    opts.url, opts.transport, cert, opts.trusted,
    397408                    serialize_only=opts.serialize_only,
     
    401412                    {'desc': e.desc, 'errstr': e.errstr, 'code': e.code})
    402413        except RuntimeError, e:
    403             sys.exit("Error processing RPC: %s" % e.message)
     414            print e
     415            sys.exit("Error processing RPC: %s" % e)
    404416
    405417        try:
     
    469481                        } ]
    470482                }
     483
     484        if opts.exp_name:
     485            msg['experimentID'] = { 'localname': opts.exp_name }
    471486
    472487        if opts.debug > 1: print >>sys.stderr, msg
     
    493508            except IOError:
    494509                sys.exit('Could not write to %s' %  out_certfile)
     510        eid = resp_dict.get('experimentID', None)
     511        if eid:
     512            for id in eid:
     513                for k in id.keys():
     514                    if k == 'fedid': print "%s: %s" % (k,fedid(bits=id[k]))
     515                    else: print "%s: %s" % (k, id[k])
    495516
    496517class access(fedd_rpc):
Note: See TracChangeset for help on using the changeset viewer.