Changeset 2ee4226


Ignore:
Timestamp:
Apr 26, 2010 6:10:57 AM (14 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
Children:
05fceef
Parents:
d8442da
Message:

More attempts to make the SSL more reliable on users. Not completely
successful.

Location:
fedd/federation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • fedd/federation/emulab_access.py

    rd8442da r2ee4226  
    172172
    173173        self.call_SetValue = service_caller('SetValue')
    174         self.call_GetValue = service_caller('GetValue')
     174        self.call_GetValue = service_caller('GetValue', log=self.log)
    175175
    176176        if not config.has_option("allocate", "uri"):
     
    13071307        """
    13081308
    1309         call_SetValue = service_caller('SetValue', log=self.log)
    13101309        for c in connInfo:
    13111310            for p in [ p for p in c.get('parameter', []) \
     
    13211320                        self.log.debug("Setting %s to %s on %s" % \
    13221321                                (k, value, surl))
    1323                         call_SetValue(surl, req, cf)
     1322                        self.call_SetValue(surl, req, cf)
    13241323                    else:
    13251324                        self.log.error("Bad export request: %s" % p)
     
    13311330                        self.log.debug("Setting %s to %s on %s" % \
    13321331                                (k, self.ssh_port, surl))
    1333                         call_SetValue(surl, req, cf)
     1332                        self.call_SetValue(surl, req, cf)
    13341333                    else:
    13351334                        self.log.error("Bad export request: %s" % p)
     
    13561355                    self.log.debug("Waiting for %s (%s) from %s" % \
    13571356                            (name, key, store))
    1358                     call_GetValue = service_caller('GetValue')
    1359                     r = call_GetValue(store, req, cf)
     1357                    r = self.call_GetValue(store, req, cf)
    13601358                    r = r.get('GetValueResponseBody', None)
    13611359                    if r :
  • fedd/federation/remote_service.py

    rd8442da r2ee4226  
    345345        # basic string if it isn't one already.
    346346        r = self.strip_unicode(copy.deepcopy(req))
    347         url = str(url)
    348        
    349         transport = SSL_Transport(ctx)
    350         port = ServerProxy(url, transport=transport)
    351         # Make the call, and convert faults back to service_errors
    352347        if self.request_body_name:
    353348            r  = self.apply_to_tags(\
     
    356351            r = self.apply_to_tags(r, self.encap_fedids)
    357352
     353        url = str(url)
    358354        ok = False
    359355        retries = 0
     
    361357        while not ok and retries < self.max_retries:
    362358            try:
     359                transport = SSL_Transport(ctx)
     360                port = ServerProxy(url, transport=transport)
    363361                remote_method = getattr(port, self.service_name, None)
    364362                resp = remote_method(r)
     
    405403                    "Call to soap service without a configured request body");
    406404
    407         # If a context is given, use it.  Otherwise construct one from
    408         # components.  The construction shouldn't call out for passwords.
    409         if context:
    410             ctx = context
    411         else:
    412             try:
    413                 ctx = fedd_ssl_context(cert_file, trusted_certs,
    414                         password=cert_pwd)
    415             except SSL.SSLError:
    416                 raise service_error(service_error.server_config,
    417                         "Certificates misconfigured")
    418         loc = self.locator()
    419         get_port = getattr(loc, self.port_name, None)
    420         if not get_port:
    421             raise service_error(service_error.internal,
    422                     "Cannot get port %s from locator" % self.port_name)
    423         port = get_port(url,
    424                 transport=M2Crypto.httpslib.HTTPSConnection,
    425                 transdict={ 'ssl_context' : ctx },
    426                 tracefile=tf)
    427         remote_method = getattr(port, self.service_name, None)
    428         if not remote_method:
    429             raise service_error(service_error.internal,
    430                     "Cannot get service from SOAP port")
    431 
    432         # Reconstruct the full request message
    433         msg = self.request_message()
    434         set_element = getattr(msg, "set_element_%s" % self.request_body_name,
    435                 None)
    436         if not set_element:
    437             raise service_error(service_error.internal,
    438                     "Cannot get element setting method for %s" % \
    439                             self.request_body_name)
    440         set_element(self.pack_soap(msg, self.request_body_name, req))
    441405        ok = False
    442406        retries = 0
    443407        while not ok and retries < self.max_retries:
    444408            try:
     409                # Reconstruct the full request message
     410                msg = self.request_message()
     411                set_element = getattr(msg, "set_element_%s" % \
     412                        self.request_body_name,
     413                        None)
     414                if not set_element:
     415                    raise service_error(service_error.internal,
     416                            "Cannot get element setting method for %s" % \
     417                                    self.request_body_name)
     418                set_element(self.pack_soap(msg, self.request_body_name, req))
     419                # If a context is given, use it.  Otherwise construct one from
     420                # components.  The construction shouldn't call out for
     421                # passwords.
     422                if context:
     423                    if self.log:
     424                        self.log.debug("Context passed in to call_soap")
     425                    ctx = context
     426                else:
     427                    if self.log:
     428                        self.log.debug(
     429                                "Constructing context in call_soap: %s" % \
     430                                        cert_file)
     431                    try:
     432                        ctx = fedd_ssl_context(cert_file, trusted_certs,
     433                                password=cert_pwd)
     434                    except SSL.SSLError, e:
     435                        if self.log:
     436                            self.log.debug("Certificate error: %s" % e)
     437                        raise service_error(service_error.server_config,
     438                                "Certificates misconfigured")
     439                loc = self.locator()
     440                get_port = getattr(loc, self.port_name, None)
     441                if not get_port:
     442                    raise service_error(service_error.internal,
     443                            "Cannot get port %s from locator" % self.port_name)
     444                port = get_port(url,
     445                        transport=M2Crypto.httpslib.HTTPSConnection,
     446                        transdict={ 'ssl_context' : ctx },
     447                        tracefile=tf)
     448                remote_method = getattr(port, self.service_name, None)
     449                if not remote_method:
     450                    raise service_error(service_error.internal,
     451                            "Cannot get service from SOAP port")
     452
    445453                fail_exc = None
     454                if self.log:
     455                    self.log.debug("Calling %s (retry %d)" % \
     456                            (self.service_name, retries))
    446457                resp = remote_method(msg)
    447458                ok = True
Note: See TracChangeset for help on using the changeset viewer.