source: fedd/federation/benito_access.py @ 6a50b78

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

Initial benito plug in. Fixed bug pickling topdl as well

  • Property mode set to 100644
File size: 2.7 KB
Line 
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
32import benito_segment
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
58        # Segment creation is where most of the differences are.
59        self.start_segment = benito_segment.start_segment
60        self.stop_segment = benito_segment.stop_segment
61        self.info_segment = benito_segment.info_segment
62
63    # These are subroutines for StartSegment
64    def generate_ns2(self, topo, expfn, softdir, connInfo):
65        """
66        Benito is expecting a topdl file, so this routine is misnamed.  It does
67        clean up the topdl, removing elements benito doesn't understand and
68        writing out the file.
69        """
70        # Main line of generate_ns2
71        t = topo.clone()
72
73        # Weed out the things we aren't going to instantiate: Segments, portal
74        # substrates, and portal interfaces.  (The copy in the for loop allows
75        # us to delete from e.elements in side the for loop).  While we're
76        # touching all the elements, we also adjust paths from the original
77        # testbed to local testbed paths
78        for e in [e for e in t.elements]:
79            if isinstance(e, topdl.Segment):
80                t.elements.remove(e)
81            # Fix software paths
82            for s in getattr(e, 'software', []):
83                s.location = re.sub("^.*/", softdir, s.location)
84
85        t.substrates = [ s.clone() for s in t.substrates ]
86        t.incorporate_elements()
87
88        # Convert to ns and write it out
89        expfile = topdl.topology_to_xml(t, top='experiment')
90        try:
91            f = open(expfn, "w")
92            print >>f, expfile
93            f.close()
94        except EnvironmentError:
95            raise service_error(service_error.internal,
96                    "Cannot write experiment file %s: %s" % (expfn,e))
Note: See TracBrowser for help on using the repository browser.