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