Changeset f069052


Ignore:
Timestamp:
Nov 30, 2008 5:38:16 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:
05191a6
Parents:
edbc841
Message:

Two changes. Get allow_any_CA checking to work (i.e., self signed certs or
certs signed by an unknown entity) and put more of the ZSI-dependent stuff into
the hidden parts or remote_services. Now those routines will find all the
relevant classes and part names from the naming conventions.

Location:
fedd
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • fedd/fedd/access.py

    redbc841 rf069052  
    1010from threading import *
    1111
    12 from fedd_services import *
    1312from util import *
    1413from allocate_project import allocate_project_local, allocate_project_remote
     
    4544    id_list_attrs = ("restricted",)
    4645
    47     proxy_RequestAccess= \
    48             service_caller('RequestAccess', 'getfeddPortType',
    49                     feddServiceLocator, RequestAccessRequestMessage,
    50                     'RequestAccessRequestBody')
    51 
    52     proxy_ReleaseAccess= \
    53             service_caller('ReleaseAccess', 'getfeddPortType',
    54                     feddServiceLocator, ReleaseAccessRequestMessage,
    55                     'ReleaseAccessRequestBody')
     46    proxy_RequestAccess= service_caller('RequestAccess')
     47    proxy_ReleaseAccess= service_caller('ReleaseAccess')
    5648
    5749    def __init__(self, config=None, auth=None):
     
    154146
    155147        self.soap_services = {\
    156             'RequestAccess': soap_handler(\
    157                 RequestAccessRequestMessage.typecode,\
    158                 self.RequestAccess, RequestAccessResponseMessage,\
    159                 "RequestAccessResponseBody"), \
    160             'ReleaseAccess': soap_handler(\
    161                 ReleaseAccessRequestMessage.typecode,\
    162                 self.ReleaseAccess, ReleaseAccessResponseMessage,\
    163                 "ReleaseAccessResponseBody")\
     148            'RequestAccess': soap_handler("RequestAccess", self.RequestAccess),
     149            'ReleaseAccess': soap_handler("ReleaseAccess", self.ReleaseAccess),
    164150            }
    165151        self.xmlrpc_services =  {\
    166             'RequestAccess': xmlrpc_handler(\
    167                 self.RequestAccess, "RequestAccessResponseBody"),\
    168             'ReleaseAccess': xmlrpc_handler(\
    169                 self.ReleaseAccess, "ReleaseAccessResponseBody")\
     152            'RequestAccess': xmlrpc_handler('RequestAccess',
     153                self.RequestAccess),
     154            'ReleaseAccess': xmlrpc_handler('ReleaseAccess',
     155                self.ReleaseAccess),
    170156            }
    171157
     
    518504
    519505        Build the dictionary description of the response and use
    520         fedd_utils.pack_soap to create the soap message.  NB that alloc_id is
    521         a fedd_services_types.IDType_Holder pulled from the incoming message.
    522         ap is the allocate project message returned from a remote project
    523         allocation (even if that allocation was done locally).
     506        fedd_utils.pack_soap to create the soap message.  ap is the allocate
     507        project message returned from a remote project allocation (even if that
     508        allocation was done locally).
    524509        """
    525510        # Because alloc_id is already a fedd_services_types.IDType_Holder,
  • fedd/fedd/allocate_project.py

    redbc841 rf069052  
    88import tempfile
    99
    10 from fedd_services import *
    11 from fedd_internal_services import *
    1210from util import *
    1311from fedid import fedid
     
    9290        # Internal services are SOAP only
    9391        self.soap_services = {\
    94                 "AllocateProject": soap_handler(\
    95                 AllocateProjectRequestMessage.typecode,\
    96                 self.dynamic_project, AllocateProjectResponseMessage,\
    97                 "AllocateProjectResponseBody"),
    98                 "StaticProject": soap_handler(\
    99                 StaticProjectRequestMessage.typecode,\
    100                 self.static_project, StaticProjectResponseMessage,\
    101                 "StaticProjectResponseBody"),\
    102                 "ReleaseProject": soap_handler(\
    103                 ReleaseProjectRequestMessage.typecode,\
    104                 self.release_project, ReleaseProjectResponseMessage,\
    105                 "ReleaseProjectResponseBody")\
     92                "AllocateProject": soap_handler("AllocateProject",
     93                    self.dynamic_project),
     94                "StaticProject": soap_handler("StaticProject",
     95                    self.static_project),
     96                "ReleaseProject": soap_handler("ReleaseProject",
     97                    self.release_project),
    10698                }
    10799        self.xmlrpc_services = { }
     
    388380        """
    389381
    390         def __init__(self, url, cert_file, cert_pwd, trusted_certs,
    391                 method, req_name, req_alloc, resp_name):
    392             service_caller.__init__(self, method, 'getfeddInternalPortType',
    393                     feddInternalServiceLocator, req_alloc, req_name)
     382        def __init__(self, url, cert_file, cert_pwd, trusted_certs, method):
     383            service_caller.__init__(self, method)
    394384            self.url = url
    395385            self.cert_file = cert_file
     
    471461        # The specializations of the proxy functions
    472462        self.dynamic_project = self.proxy(self.url, self.cert_file,
    473                 self.cert_pwd, self.trusted_certs, "AllocateProject",
    474                 "AllocateProjectRequestBody", AllocateProjectRequestMessage,
    475                 "AllocateProjectResponseBody")
     463                self.cert_pwd, self.trusted_certs, "AllocateProject")
    476464        self.static_project = self.proxy(self.url, self.cert_file,
    477                 self.cert_pwd, self.trusted_certs, "StaticProject",
    478                 "StaticProjectRequestBody", StaticProjectRequestMessage,
    479                 "StaticProjectResponseBody")
     465                self.cert_pwd, self.trusted_certs, "StaticProject")
    480466        self.release_project = self.proxy(self.url, self.cert_file,
    481                 self.cert_pwd, self.trusted_certs, "ReleaseProject",
    482                 "ReleaseProjectRequestBody", ReleaseProjectRequestMessage,
    483                 "ReleaseProjectResponseBody")
    484 
     467                self.cert_pwd, self.trusted_certs, "ReleaseProject")
     468
  • fedd/fedd/experiment_control.py

    redbc841 rf069052  
    1919from subprocess import *
    2020
    21 from fedd_services import *
    22 from fedd_internal_services import *
    2321from util import *
    2422from fedid import fedid, generate_fedid
     
    140138                self.pdata.terminate()
    141139
    142     call_RequestAccess = service_caller('RequestAccess',
    143             'getfeddPortType', feddServiceLocator,
    144             RequestAccessRequestMessage, 'RequestAccessRequestBody')
    145 
    146     call_ReleaseAccess = service_caller('ReleaseAccess',
    147             'getfeddPortType', feddServiceLocator,
    148             ReleaseAccessRequestMessage, 'ReleaseAccessRequestBody')
    149 
    150     call_Ns2Split = service_caller('Ns2Split',
    151             'getfeddInternalPortType', feddInternalServiceLocator,
    152             Ns2SplitRequestMessage, 'Ns2SplitRequestBody')
     140    call_RequestAccess = service_caller('RequestAccess')
     141    call_ReleaseAccess = service_caller('ReleaseAccess')
     142    call_Ns2Split = service_caller('Ns2Split')
    153143
    154144    def __init__(self, config=None, auth=None):
     
    275265        # Dispatch tables
    276266        self.soap_services = {\
    277                 'Create': soap_handler(\
    278                         CreateRequestMessage.typecode,
    279                         getattr(self, "create_experiment"),
    280                         CreateResponseMessage,
    281                         "CreateResponseBody"),
    282                 'Vtopo': soap_handler(\
    283                         VtopoRequestMessage.typecode,
    284                         getattr(self, "get_vtopo"),
    285                         VtopoResponseMessage,
    286                         "VtopoResponseBody"),
    287                 'Vis': soap_handler(\
    288                         VisRequestMessage.typecode,
    289                         getattr(self, "get_vis"),
    290                         VisResponseMessage,
    291                         "VisResponseBody"),
    292                 'Info': soap_handler(\
    293                         InfoRequestMessage.typecode,
    294                         getattr(self, "get_info"),
    295                         InfoResponseMessage,
    296                         "InfoResponseBody"),
    297                 'Terminate': soap_handler(\
    298                         TerminateRequestMessage.typecode,
    299                         getattr(self, "terminate_experiment"),
    300                         TerminateResponseMessage,
    301                         "TerminateResponseBody"),
     267                'Create': soap_handler('Create', self.create_experiment),
     268                'Vtopo': soap_handler('Vtopo', self.get_vtopo),
     269                'Vis': soap_handler('Vis', self.get_vis),
     270                'Info': soap_handler('Info', self.get_info),
     271                'Terminate': soap_handler('Terminate',
     272                    self.terminate_experiment),
    302273        }
    303274
    304275        self.xmlrpc_services = {\
    305                 'Create': xmlrpc_handler(\
    306                         getattr(self, "create_experiment"),
    307                         "CreateResponseBody"),
    308                 'Vtopo': xmlrpc_handler(\
    309                         getattr(self, "get_vtopo"),
    310                         "VtopoResponseBody"),
    311                 'Vis': xmlrpc_handler(\
    312                         getattr(self, "get_vis"),
    313                         "VisResponseBody"),
    314                 'Info': xmlrpc_handler(\
    315                         getattr(self, "get_info"),
    316                         "InfoResponseBody"),
    317                 'Terminate': xmlrpc_handler(\
    318                         getattr(self, "terminate_experiment"),
    319                         "TerminateResponseBody"),
     276                'Create': xmlrpc_handler('Create', self.create_experiment),
     277                'Vtopo': xmlrpc_handler('Vtopo', self.get_vtopo),
     278                'Vis': xmlrpc_handler('Vis', self.get_vis),
     279                'Info': xmlrpc_handler('Info', self.get_info),
     280                'Terminate': xmlrpc_handler('Terminate',
     281                    self.terminate_experiment),
    320282        }
    321283
  • fedd/fedd/remote_service.py

    redbc841 rf069052  
    1111from ZSI import ParseException, FaultException, SoapWriter
    1212
    13 from service_error import *
     13from service_error import service_error
    1414from xmlrpclib import ServerProxy, dumps, loads, Fault, Error, Binary
    1515
     16import fedd_services
     17import fedd_internal_services
    1618from util import fedd_ssl_context
    1719from fedid import fedid
     
    181183    created constructors will result in None being returned.
    182184    """
    183     def __init__(self, typecode, method, constructor, body_name):
    184         self.typecode = typecode
     185    def __init__(self, service_name, method, typecode=None,
     186            constructor=None, body_name=None):
    185187        self.method = method
    186         self.constructor = constructor
    187         self.body_name = body_name
     188
     189        response_class_name = "%sResponseMessage" % service_name
     190        request_class_name = "%sRequestMessage" % service_name
     191
     192        if body_name: self.body_name = body_name
     193        else: self.body_name = "%sResponseBody" % service_name
     194
     195        if constructor: self.constructor = constructor
     196        else:
     197            self.constructor = self.get_class(response_class_name)
     198            if not self.constructor:
     199                raise service_error(service_error.internal,
     200                        "Cannot find class for %s" % response_class_name)
     201
     202        if typecode: self.typecode = typecode
     203        else:
     204            req = self.get_class(request_class_name)
     205            if req:
     206                self.typecode = req.typecode
     207            else:
     208                raise service_error(service_error.internal,
     209                        "Cannot find class for %s" % request_class_name)
     210
     211            if not self.typecode:
     212                raise service_error(service_error.internal,
     213                        "Cannot get typecode for %s" % class_name)
     214
     215    def get_class(self, class_name):
     216        return getattr(fedd_services, class_name, None) or \
     217                getattr(fedd_internal_services, class_name, None)
    188218
    189219    def __call__(self, ps, fid):
     
    197227        resp = self.constructor()
    198228        set_element = getattr(resp, "set_element_%s" % self.body_name, None)
     229        print "set_element_%s" % self.body_name
    199230        if set_element and callable(set_element):
    200231            try:
     
    220251    to fedid objects on input and encapsulated as Binaries on output.
    221252    """
    222     def __init__(self, method, body_name):
     253    def __init__(self, service_name, method):
    223254        self.method = method
    224         self.body_name = body_name
     255        self.body_name = "%sResponseBody" % service_name
    225256
    226257    def __call__(self, params, fid):
     
    239270
    240271class service_caller(remote_service_base):
    241     def __init__(self, service_name, port_name, locator, request_message,
    242             request_body_name, tracefile=None):
     272    def __init__(self, service_name, request_message=None,
     273            request_body_name=None, tracefile=None):
    243274        self.service_name = service_name
    244         self.port_name = port_name
    245         self.locator = locator
    246         self.request_message = request_message
    247         self.request_body_name = request_body_name
     275
     276        if getattr(fedd_services.feddBindingSOAP, service_name, None):
     277            self.locator = fedd_services.feddServiceLocator
     278            self.port_name = 'getfeddPortType'
     279        elif getattr(fedd_internal_services.feddInternalBindingSOAP,
     280                service_name, None):
     281            self.locator = fedd_internal_services.feddInternalServiceLocator
     282            self.port_name = 'getfeddInternalPortType'
     283
     284        if request_message: self.request_message = request_message
     285        else:
     286            request_message_name = "%sRequestMessage" % service_name
     287            self.request_message = \
     288                    getattr(fedd_services, request_message_name, None) or \
     289                    getattr(fedd_internal_services, request_message_name, None)
     290            if not self.request_message:
     291                raise service_error(service_error.internal,
     292                        "Cannot find class for %s" % request_message_name)
     293
     294        if request_body_name: self.request_body_name = request_body_name
     295        else: self.request_body_name = "%sRequestBody" % service_name
     296
    248297        self.tracefile = tracefile
    249298        self.__call__ = self.call_service
  • fedd/fedd/split.py

    redbc841 rf069052  
    66import logging
    77
    8 from fedd_services import *
    9 from fedd_internal_services import *
    108from util import *
    119from fedid import fedid
     
    4543        # Dispatch tables
    4644        self.soap_services = {\
    47                 'Ns2Split': soap_handler(\
    48                         Ns2SplitRequestMessage.typecode,
    49                         getattr(self, "run_splitter"),
    50                         Ns2SplitResponseMessage,
    51                         "Ns2SplitResponseBody"),
     45                'Ns2Split': soap_handler("Ns2Split", self.run_splitter),
    5246        }
    5347
    5448        self.xmlrpc_services = {\
    55                 'Ns2Split': xmlrpc_handler(\
    56                         getattr(self, "run_splitter"),
    57                         "Ns2SplitResponseBody"),
     49                'Ns2Split': xmlrpc_handler('Ns2Split', self.run_splitter),
    5850        }
    5951
  • fedd/fedd/util.py

    redbc841 rf069052  
    3535        else:
    3636            self.load_cert(my_cert)
    37         if trusted_certs != None: self.load_verify_locations(trusted_certs)
    38         self.set_verify(SSL.verify_peer, 10)
     37
     38        # If no trusted certificates are specified, allow unknown CAs.
     39        if trusted_certs:
     40            self.load_verify_locations(trusted_certs)
     41            self.set_verify(SSL.verify_peer, 10)
     42        else:
     43            self.set_verify(SSL.verify_peer, 10,
     44                callback=SSL.cb.ssl_verify_callback_allow_unknown_ca)
    3945
    4046def pack_id(id):
  • fedd/fedd_client.py

    redbc841 rf069052  
    44import os
    55import pwd
    6 
    7 from fedd.fedd_services import *
    8 from fedd.fedd_internal_services import *
    96
    107from fedd import fedid, service_error
     
    177174        Specialize the class for the pre method
    178175        """
    179         self.RequestMessage = globals()["%sRequestMessage" % pre]
    180         self.ResponseMessage = globals()["%sResponseMessage" % pre]
    181176        self.RequestBody="%sRequestBody" % pre
    182177        self.ResponseBody="%sResponseBody" % pre
    183178        self.method = pre
    184179
    185         method_call = getattr(feddServiceLocator().getfeddPortType(),
    186                 self.method, None)
    187         if method_call:
    188             # The pre method is a fedd external service
    189             self.caller = service_caller(self.method, 'getfeddPortType',
    190                     feddServiceLocator, self.RequestMessage, self.RequestBody)
    191         else:
    192             # The pre method is a fedd internal service
    193             self.caller = service_caller(self.method,
    194                     'getfeddInternalPortType', feddInternalServiceLocator,
    195                     self.RequestMessage, self.RequestBody)
    196 
     180        self.caller = service_caller(self.method)
    197181        self.RPCException = fedd_rpc.RPCException
    198182
     
    255239            try:
    256240                context = fedd_ssl_context(cert, trusted)
    257             except SSL.SSLError, e:
     241            except Exception, e:
    258242                # Yes, doing this on message type is not ideal.  The string
    259243                # comes from OpenSSL, so check there is this stops working.
     
    343327        (opts, args) = parser.parse_args()
    344328
    345         if opts.trusted != None:
     329        if opts.trusted:
    346330            if ( not os.access(opts.trusted, os.R_OK) ) :
    347331                sys.exit("Cannot read trusted certificates (%s)" % opts.trusted)
    348         else:
    349             parser.error("--trusted is required")
    350332
    351333        if opts.debug > 0: opts.tracefile=sys.stderr
     
    411393        (opts, args) = parser.parse_args()
    412394
    413         if opts.trusted != None:
     395        if opts.trusted:
    414396            if ( not os.access(opts.trusted, os.R_OK) ) :
    415397                sys.exit("Cannot read trusted certificates (%s)" % opts.trusted)
    416         else:
    417             parser.error("--trusted is required")
    418398
    419399        if opts.debug > 0: opts.tracefile=sys.stderr
     
    471451        (opts, args) = parser.parse_args()
    472452
    473         if opts.trusted != None:
     453        if opts.trusted:
    474454            if ( not os.access(opts.trusted, os.R_OK) ) :
    475455                sys.exit("Cannot read trusted certificates (%s)" % opts.trusted)
    476         else:
    477             parser.error("--trusted is required")
    478456
    479457        if not opts.project :
     
    568546        (opts, args) = parser.parse_args()
    569547
    570         if opts.trusted != None:
     548        if opts.trusted:
    571549            if ( not os.access(opts.trusted, os.R_OK) ) :
    572550                sys.exit("Cannot read trusted certificates (%s)" % opts.trusted)
    573         else:
    574             parser.error("--trusted is required")
    575551
    576552        if opts.debug > 0: opts.tracefile=sys.stderr
     
    674650            parser.error("--testbed is required")
    675651
    676         if opts.trusted != None:
     652        if opts.trusted:
    677653            if ( not os.access(opts.trusted, os.R_OK) ) :
    678654                sys.exit("Cannot read trusted certificates (%s)" % opts.trusted)
    679         else:
    680             parser.error("--trusted is required")
    681655
    682656        if opts.debug > 0: opts.tracefile=sys.stderr
Note: See TracChangeset for help on using the changeset viewer.