source: fedd/federation/containers_access.py @ e48d8eb

Last change on this file since e48d8eb was c261c0f, checked in by Ted Faber <faber@…>, 12 years ago

Moving to new name and creating real federation connections

  • Property mode set to 100644
File size: 2.9 KB
RevLine 
[6a50b78]1#!/usr/local/bin/python
2
3import os,sys
4import stat # for chmod constants
5import re
6import random
7import string
8import copy
9import pickle
10import logging
11import subprocess
12import traceback
13
14from threading import *
15from M2Crypto.SSL import SSLError
16
17from emulab_access import access as emulab_access
18
19from util import *
20from deter import fedid, generate_fedid
21from authorizer import authorizer, abac_authorizer
22from service_error import service_error
23from remote_service import xmlrpc_handler, soap_handler, service_caller
24from proof import proof as access_proof
25
26import httplib
27import tempfile
28from urlparse import urlparse
29
30from deter import topdl
31import list_log
[c261c0f]32import containers_segment
[6a50b78]33
34
35# Make log messages disappear if noone configures a fedd logger
36class nullHandler(logging.Handler):
37    def emit(self, record): pass
38
39fl = logging.getLogger("fedd.access")
40fl.addHandler(nullHandler())
41
42class access(emulab_access):
43    """
44    The implementation of access control based on mapping users to projects.
45
46    Users can be mapped to existing projects or have projects created
47    dynamically.  This implements both direct requests and proxies.
48    """
49
50    max_name_len = 19
51
52    def __init__(self, config=None, auth=None):
53        """
54        Initializer.  Pulls parameters out of the ConfigParser's access section.
55        """
56        emulab_access.__init__(self, config, auth)
57
[c261c0f]58        self.containerize = config.get('access', 'containerize')
59
[6a50b78]60        # Segment creation is where most of the differences are.
[c261c0f]61        self.start_segment = containers_segment.start_segment
62        self.stop_segment = containers_segment.stop_segment
63        self.info_segment = containers_segment.info_segment
[6a50b78]64
65    # These are subroutines for StartSegment
66    def generate_ns2(self, topo, expfn, softdir, connInfo):
67        """
68        Benito is expecting a topdl file, so this routine is misnamed.  It does
[c261c0f]69        clean up the topdl, removing elements containers doesn't understand and
[6a50b78]70        writing out the file.
71        """
72        # Main line of generate_ns2
73        t = topo.clone()
74
75        # Weed out the things we aren't going to instantiate: Segments, portal
76        # substrates, and portal interfaces.  (The copy in the for loop allows
77        # us to delete from e.elements in side the for loop).  While we're
78        # touching all the elements, we also adjust paths from the original
79        # testbed to local testbed paths
80        for e in [e for e in t.elements]:
81            if isinstance(e, topdl.Segment):
82                t.elements.remove(e)
[c261c0f]83            if not isinstance(e, topdl.Computer): continue
84            if e.get_attribute('portal'):
85                e.set_attribute('containers:node_type', 'embedded_pnode')
[6a50b78]86            # Fix software paths
87            for s in getattr(e, 'software', []):
88                s.location = re.sub("^.*/", softdir, s.location)
89
90        t.substrates = [ s.clone() for s in t.substrates ]
91        t.incorporate_elements()
92
[c261c0f]93        # Write it out
[6a50b78]94        expfile = topdl.topology_to_xml(t, top='experiment')
95        try:
96            f = open(expfn, "w")
97            print >>f, expfile
98            f.close()
99        except EnvironmentError:
100            raise service_error(service_error.internal,
101                    "Cannot write experiment file %s: %s" % (expfn,e))
Note: See TracBrowser for help on using the repository browser.