Changeset 7583a62 for fedd


Ignore:
Timestamp:
Nov 17, 2008 6:49:56 PM (16 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:
159a447
Parents:
d81971a
Message:

another checkpoint

Location:
fedd
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • fedd/fedd_access.py

    rd81971a r7583a62  
    857857                if users:
    858858                    msg['project']['user'] = users
    859                 print msg
     859                if self.allocate_project.release_project:
     860                    msg = { 'ReleaseProjectRequestBody' : msg}
     861                    self.allocate_project.release_project(msg)
    860862            self.write_state()
    861863            return { 'allocID': req['allocID'] }
  • fedd/fedd_allocate_project.py

    rd81971a r7583a62  
    2020from fedd_internal_services import *
    2121from fedd_util import *
     22import fixed_key
    2223import parse_detail
    2324from service_error import *
     
    5051                '/usr/testbed/sbin/newproj')
    5152        self.mkproj = config.get('access', 'mkproj', '/usr/testbed/sbin/mkproj')
     53        self.rmproj = config.get('access', 'rmproj', '/usr/testbed/sbin/rmproj')
    5254        self.addpubkey = config.get('access', 'addpubkey',
    5355                '/usr/testbed/sbin/taddpubkey')
     
    5658        self.log = logging.getLogger("fedd.allocate.local")
    5759        set_log_level(config, "access", self.log)
     60        fixed_key_db = config.get("access", "fixed_keys", None)
     61        fixed_project_db = config.get("access", "fixed_projects", None)
     62        if fixed_key_db:
     63            try:
     64                self.fixed_keys = fixed_key.read_db(fixed_key_db)
     65            except:
     66                log.debug("Can't read fixed_key_db from %s" % fixed_key_db)
     67        else:
     68            self.fixed_keys = set()
     69
     70        if fixed_project_db:
     71            try:
     72                f = open(fixed_project_db, "r")
     73                for line in f:
     74                    self.fixed_projects.add(line.rstrip())
     75                f.close()
     76            except:
     77                log.debug("Can't read fixed_project_db from %s" % \
     78                        fixed_project_db)
     79        else:
     80            self.fixed_projects = set()
     81
    5882
    5983        # Internal services are SOAP only
     
    6690                StaticProjectRequestMessage.typecode,\
    6791                self.static_project, StaticProjectResponseMessage,\
    68                 "StaticProjectResponseBody")\
     92                "StaticProjectResponseBody"),\
     93                #"ReleaseProject": make_soap_handler(\
     94                #ReleaseProjectRequestMessage.typecode,\
     95                #self.release_project, ReleaseProjectResponseMessage,\
     96                #"ReleaseProjectResponseBody")\
    6997                }
    7098        self.xmlrpc_services = { }
     
    242270            for sk in [ k['sshPubkey'] for k in u.get('access', []) \
    243271                    if k.has_key('sshPubkey')]:
    244                 cmds.append((self.addpubkey, '-w', '-u', name, '-k', sk))
     272                cmds.append((self.wap, self.addpubkey, '-w', \
     273                        '-u', name, '-k', sk))
    245274       
    246275
     
    274303        return { 'project': req['StaticProjectRequestBody']['project']}
    275304
     305    def release_project(self, req, fedid=None):
     306        """
     307        Remove user keys from users and delete dynamic projects.
     308
     309        Only keys not in the set of fixed keys are deleted. and there are
     310        similar protections for projects.
     311        """
     312
     313        cmds = []
     314        pname = None
     315        users = []
     316
     317        print "release %s" % req
     318        try:
     319            if req['ReleaseProjectRequestBody']['project'].has_key('name'):
     320                pname = req['ReleaseProjectRequestBody']['project']\
     321                        ['name']['localname']
     322            if req['ReleaseProjectRequestBody']['project'].has_key('user'):
     323                users = req['ReleaseProjectRequestBody']['project']['user']
     324        except KeyError:
     325            raise service_error(service_error.req, "Badly formed request")
     326
     327        for u in users:
     328            try:
     329                name = u['userID']['localname']
     330            except KeyError:
     331                raise service_error(service_error.req, "Badly formed user")
     332            for sk in [ k['sshPubkey'] for k in u.get('access', []) \
     333                    if k.has_key('sshPubkey')]:
     334                if (name, sk) not in self.fixed_keys:
     335                    cmds.append((self.wap, self.addpubkey, '-R', '-w', \
     336                            '-u', name, '-k', sk))
     337        if pname and pname not in fixed_projects:
     338            cmds.append((self.wap, self.rmproj, pname))
     339
     340        # Run the commands
     341        rc = 0
     342        for cmd in cmds:
     343            self.log.debug("[release_project]: %s" % ' '.join(cmd))
     344            if not self.debug:
     345                try:
     346                    rc = subprocess.call(cmd)
     347                except OSError, e:
     348                    print "Release project subprocess creation error "+ \
     349                                    "[%s] (%s)" %  (cmd[0], e.strerror)
     350                    raise service_error(service_error.internal,
     351                            "Release project subprocess creation error "+ \
     352                                    "[%s] (%s)" %  (cmd[0], e.strerror))
     353
     354            if rc != 0:
     355                raise service_error(service_error.internal,
     356                        "Release project subprocess error " +\
     357                                "[%s] (%d)" % (cmd[0], rc))
     358
     359        return { 'project': req['ReleaseProjectRequestBody']['project']}
     360
    276361def make_proxy(method, req_name, req_alloc, resp_name):
    277362    """
     
    383468        self.log = logging.getLogger("fedd.allocate.remote")
    384469        set_log_level(config, "access", self.log)
    385         #self.dynamic_project = fedd_allocate_project_remote.dynamic_project
    386         #self.static_project = fedd_allocate_project_remote.static_project
     470        self.release_project = None
Note: See TracChangeset for help on using the changeset viewer.