Changeset 05191a6 for fedd/fedd/split.py


Ignore:
Timestamp:
Dec 1, 2008 3:07:40 PM (15 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:
f816079
Parents:
f069052
Message:

All services use authorizer. Global authorization file, shared routine to read simple authorization files. Fixes some more partial state errors in experiment_control.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/fedd/split.py

    rf069052 r05191a6  
    1010from remote_service import xmlrpc_handler, soap_handler
    1111from service_error import *
     12from authorizer import authorizer
    1213
    1314
     
    2324        Intialize the various attributes, most from the config object
    2425        """
    25         if config.has_section("splitter"):
    26             self.debug = config.getboolean("splitter", "debug")
    27             self.muxmax = config.getint("splitter", "muxmax", 3)
    28             self.tclsh = config.get("splitter", "tclsh",
    29                     "/usr/local/bin/otclsh")
    30             self.tcl_splitter = config.get("splitter", "tcl_splitter",
    31                     "/usr/testbed/lib/ns2ir/parse.tcl")
    32         else:
    33             self.debug = False
    34             self.muxmax = 3
    35             self.tclsh = "/usr/local/bin/otclsh"
    36             self.tcl_splitter = "/usr/testbed/lib/ns2ir/parse.tcl"
     26        self.debug = config.getboolean("splitter", "debug")
     27        self.muxmax = config.getint("splitter", "muxmax", 3)
     28        self.tclsh = config.get("splitter", "tclsh",
     29                "/usr/local/bin/otclsh")
     30        self.tcl_splitter = config.get("splitter", "tcl_splitter",
     31                "/usr/testbed/lib/ns2ir/parse.tcl")
     32        access_db = config.get("splitter", "access_db", None)
     33        allow_any = config.getboolean("splitter", "allow_any", False)
    3734
    3835        self.log = logging.getLogger("fedd.splitter")
     
    4138
    4239        set_log_level(config, "splitter", self.log)
     40
     41        if auth:
     42            self.auth= auth
     43        else:
     44            self.auth = authorizer()
     45            self.log.warning("[splitter] No authorizer passed in, " +\
     46                    "using local one")
     47
     48        if access_db and allow_any:
     49            raise service_error(service_error.internal,
     50                    "Cannot specify both an access database and allow_any " +\
     51                            "for splitter")
     52       
     53        if access_db:
     54            try:
     55                read_simple_accessdb(access_db, self.auth, 'split')
     56            except IOError, e:
     57                raise service_error(service_error.internal,
     58                        "Error reading accessDB %s: %s" % (access_db, e))
     59            except ValueError:
     60                raise service_error(service_error.internal, "%s" % e)
     61        elif allow_any:
     62            auth.set_global_attribute("split")
     63
     64
    4365        # Dispatch tables
    4466        self.soap_services = {\
     
    6082        to instantiate them and start it all up.
    6183        """
     84
     85        if not self.auth.check_attribute(fid, 'split'):
     86            raise service_error(service_error.access, "Access Denied")
     87
    6288        try:
    6389            tmpdir = tempfile.mkdtemp(prefix="split-")
Note: See TracChangeset for help on using the changeset viewer.