source: fedd/federation/deter_impl.py @ 1d913e13

axis_examplecompt_changesinfo-opsversion-2.00version-3.01version-3.02
Last change on this file since 1d913e13 was 3c6dbec, checked in by Ted Faber <faber@…>, 15 years ago

Make space for other access plugins

  • Property mode set to 100644
File size: 2.5 KB
RevLine 
[19cc408]1#!/usr/local/bin/python
2
[3c6dbec]3import emulab_access
[ec4fb42]4from experiment_control import experiment_control_local
5from split import split_local
[05191a6]6from util import read_simple_accessdb
[19cc408]7
[3f6bc5f]8from authorizer import authorizer
9
[7454054]10class deter_impl:
[19cc408]11    """
12    The implementation of access control based on mapping users to projects.
13
14    Users can be mapped to existing projects or have projects created
15    dynamically.  This implements both direct requests and proxies.
16    """
17    # Used by the SOAP caller
18    soap_namespaces = ('http://www.isi.edu/faber/fedd.wsdl',
19            'http://www.isi.edu/faber/fedd_internal.wsdl')
20
[72ed6e4]21    def __init__(self, config=None):
[19cc408]22        """
[ec4fb42]23        Initializer.  Uses the parsed configuration to create appropriate
24        components.
[19cc408]25        """
[72ed6e4]26        self.soap_services = { }
27        self.xmlrpc_services = { }
[3f6bc5f]28        self.auth = authorizer()
[72ed6e4]29
30        if config:
31            self.cert_file = config.get("globals", "cert_file");
32            self.cert_pwd = config.get("globals", "cert_pwd");
33            self.trusted_certs = config.get("globals", "trusted_certs");
[3c6dbec]34            self.access_type = config.get("globals", "access_type", "emulab")
[72ed6e4]35
[05191a6]36            access_db = config.get("globals", "accessdb")
37
38            if access_db:
39                try:
40                    read_simple_accessdb(access_db, self.auth)
41                except IOError, e:
[0b4e272]42                    raise RuntimeError(
[05191a6]43                            "Error reading accessDB %s: %s" % (access_db, e))
[cc8d8e9]44                except ValueError, e:
[0b4e272]45                    raise RuntimeError("%s" % e)
[05191a6]46
[72ed6e4]47            if config.has_section("access"):
[3c6dbec]48                if self.access_type == "emulab":
49                    self.access = emulab_access.access(config, self.auth)
50                else:
51                    raise RuntimeError("Unknown access_type: %s" % \
52                            self.access_type)
[72ed6e4]53                self.soap_services.update(self.access.soap_services) 
54                self.xmlrpc_services.update(self.access.xmlrpc_services) 
55
56            if config.has_section("experiment_control"):
[3f6bc5f]57                self.experiment = \
[ec4fb42]58                        experiment_control_local(config, self.auth)
[5fffd82]59                # Tell the experiment control where local access control is and
[5a6b75b]60                # what testbeds it pertains to.
[c9318dc]61                if getattr(self, 'access', None):
[5a6b75b]62                    for t in self.access.testbed:
63                        self.experiment.local_access[t] = self.access
[5fffd82]64
[72ed6e4]65                self.soap_services.update(self.experiment.soap_services) 
66                self.xmlrpc_services.update(self.experiment.xmlrpc_services) 
[81a7f3f]67                self.get_handler = self.experiment.get_handler
68            else:
[cc8d8e9]69                self.get_handler = None
[72ed6e4]70
[f4f4117]71            if config.has_section("splitter"):
[ec4fb42]72                self.splitter = split_local(config, self.auth)
[f4f4117]73                self.soap_services.update(self.splitter.soap_services) 
74                self.xmlrpc_services.update(self.splitter.xmlrpc_services) 
75
[72ed6e4]76def new_feddservice(config):
[7454054]77    return deter_impl(config)
Note: See TracBrowser for help on using the repository browser.