Changeset 721705e9 for fedd


Ignore:
Timestamp:
Nov 23, 2008 4:37:28 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:
1653a08
Parents:
0b123ff
Message:

Split the service and creation access properly

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/fedd_experiment_control.py

    r0b123ff r721705e9  
    22
    33import os,sys
    4 
    54
    65import re
     
    203202            self.fedkit = None
    204203
    205         # XXX
    206         self.ssh_pubkey_file = "/users/faber/.ssh/id_rsa.pub"
    207         self.ssh_type = "rsa"
     204        self.ssh_pubkey_file = config.get("experiment_control",
     205                "ssh_pubkey_file")
     206        self.ssh_privkey_file = config.get("experiment_control",
     207                "ssh_privkey_file")
     208        # NB for internal master/slave ops, not experiment setup
     209        self.ssh_type = config.get("experiment_control", "sshkeytype", "rsa")
    208210        self.state = { }
    209211        self.state_lock = Lock()
     
    234236        if self.ssh_pubkey_file:
    235237            try:
     238                print "reading %s" % self.ssh_pubkey_file
    236239                f = open(self.ssh_pubkey_file, 'r')
    237240                self.ssh_pubkey = f.read()
     
    240243                raise service_error(service_error.internal,
    241244                        "Cannot read sshpubkey")
     245        else:
     246            raise service_error(service_error.internal,
     247                    "No SSH public key file?")
     248
     249        if not self.ssh_privkey_file:
     250            raise service_error(service_error.internal,
     251                    "No SSH public key file?")
    242252
    243253        set_log_level(config, "experiment_control", self.log)
     
    357367        """
    358368
    359         scp_cmd = [self.scp_exec, file, "%s@%s:%s" % (user, host, dest)]
     369        scp_cmd = [self.scp_exec, '-i', self.ssh_privkey_file, file,
     370                "%s@%s:%s" % (user, host, dest)]
    360371        rv = 0
    361372
     
    378389        only logged.
    379390        """
    380         sh_str = "%s %s@%s %s" % (self.ssh_exec, user, host, cmd)
     391        sh_str = "%s -i %s %s@%s %s" % (self.ssh_exec, self.ssh_privkey_file,
     392                user, host, cmd)
    381393
    382394        try:
     
    802814                    "Unknown testbed: %s" % tb)
    803815
     816        # currently this lumps all users into one service access group
     817        service_keys = [ a for u in user \
     818                for a in u.get('access', []) \
     819                    if a.has_key('sshPubkey')]
     820
     821        if len(service_keys) == 0:
     822            raise service_error(service_error.req,
     823                    "Must have at least one SSH pubkey for services")
     824
     825
    804826        # The basic request
    805827        req = {\
     
    807829                'user':  user,
    808830                'allocID' : { 'localname': 'test' },
    809                 # XXX: need to get service access stright
    810831                'createAccess' : [ { 'sshPubkey' : self.ssh_pubkey } ],
    811                 'serviceAccess' : [ { 'sshPubkey' : self.ssh_pubkey } ]
     832                'serviceAccess' : service_keys
    812833            }
     834
     835        print "service %s" % service_keys
     836        print "ssh pubkey %s" % self.ssh_pubkey
     837        print "ssh pubkey file %s" % self.ssh_pubkey_file
    813838
    814839        if tb == master:
Note: See TracChangeset for help on using the changeset viewer.