Changeset 2c6128f for fedd


Ignore:
Timestamp:
Nov 5, 2008 1:37:28 AM (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:
9c166cf
Parents:
01308c9
Message:

Add support for a real fedkit tar file rather than the ad hoc script stuff.

Location:
fedd
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • fedd/fedd_client.py

    r01308c9 r2c6128f  
    123123                type="string", help="Use this username instead of the uid")
    124124
     125class fedd_split_opts(fedd_create_opts):
     126    def __init__(self, access_keys, add_key_callback=None,
     127            add_cert_callback=None):
     128        fedd_create_opts.__init__(self, access_keys, add_key_callback,
     129                add_cert_callback)
     130        self.add_option('-t','--fedkit', action='store_true', dest='fedkit',
     131                default=False,
     132                help="get output suitable for federation kit install")
     133
     134
    125135class fedd_access_opts(fedd_create_opts):
    126136    def __init__(self, access_keys, node_descs, add_key_callback=None,
     
    605615        access_keys = []
    606616        # Process the options using the customized option parser defined above
    607         parser = fedd_create_opts(access_keys, self.add_ssh_key,
     617        parser = fedd_split_opts(access_keys, self.add_ssh_key,
    608618                self.add_x509_cert)
    609619
     
    619629
    620630        if opts.cert != None: cert = opts.cert
     631        else: cert = None
    621632
    622633        if cert == None:
     
    650661                'description': { 'ns2description': exp_desc },
    651662                'master': opts.master,
     663                'include_fedkit': opts.fedkit,
    652664                }
    653665
  • fedd/fedd_experiment_control.py

    r01308c9 r2c6128f  
    4545    Thred safe.
    4646    """
    47     scripts = ["fed_bootstrap", "federate.sh", "smbmount.FreeBSD.pl",
    48         "smbmount.Linux.pl", "make_hosts", "fed-tun.pl", "fed-tun.ucb.pl",
    49         "fed_evrepeater", "rc.accounts.patch"]
    5047   
    5148    class thread_pool:
     
    152149        Intialize the various attributes, most from the config object
    153150        """
    154         self.scripts = fedd_experiment_control_local.scripts
    155151        self.thread_with_rv = fedd_experiment_control_local.pooled_thread
    156152        self.thread_pool = fedd_experiment_control_local.thread_pool
     
    190186            self.state_filename = config.get("experiment_control",
    191187                    "experiment_state_file")
    192             self.scripts_dir = config.get("experiment_control",
    193                     "federation_script_dir")
    194188            self.splitter_url = config.get("experiment_control", "splitter_url")
     189            self.fedkit = config.get("experiment_control", "fedkit")
    195190        else:
    196191            self.debug = False
    197192            self.state_filename = None
    198             self.scripts_dir = "/users/faber/testbed/federation"
    199193            self.splitter_url = None
     194            self.fedkit = None
    200195
    201196        # XXX
     
    214209
    215210        self.def_expstart = \
    216                 "sudo -H /bin/sh FEDDIR/fed_bootstrap >& /tmp/federate";
    217         self.def_mexpstart = "sudo -H FEDDIR/make_hosts FEDDIR/hosts";
     211                "sudo -H /bin/sh /usr/local/federation/bin/federate.sh >& " +\
     212                "/tmp/federate";
     213        self.def_mexpstart = "sudo -H /usr/local/federation/bin/make_hosts " +\
     214                "FEDDIR/hosts";
    218215        self.def_gwstart = \
    219                 "sudo -H FEDDIR/fed-tun.pl -f GWCONF>& /tmp/bridge.log";
     216                "sudo -H /usr/local/federation/bin/fed-tun.pl -f GWCONF>& " +\
     217                "/tmp/bridge.log";
    220218        self.def_mgwstart = \
    221                 "sudo -H FEDDIR/fed-tun.pl -f GWCONF >& /tmp/bridge.log";
     219                "sudo -H /usr/local/federation/bin/fed-tun.pl -f GWCONF >& " +\
     220                "/tmp/bridge.log";
    222221        self.def_gwimage = "FBSD61-TUNNEL2";
    223222        self.def_gwtype = "pc";
     
    233232                        "Cannot read sshpubkey")
    234233
    235         # Set the logging level to the value passed in.  The getattr slieght of
    236         # hand finds the logging level constant corrersponding to the string.
    237         # We're a little paranoid to avoid user mayhem.
    238         if config.has_option("experiment_control", "log_level"):
    239             try:
    240                 level = int(getattr(logging,
    241                     config.get("experiment_control", "log_level").upper(),-1))
    242 
    243                 if  logging.DEBUG <= level <= logging.CRITICAL:
    244                     self.log.setLevel(level)
    245                 else:
    246                     self.log.error("Bad experiment_log value: %s" % \
    247                             config.get("experiment_control", "log_level"))
    248 
    249             except ValueError:
    250                 self.log.error("Bad experiment_log value: %s" % \
    251                         config.experiment_log)
     234        set_log_level(config, "experiment_control", self.log)
    252235
    253236        # Grab saved state.  OK to do this w/o locking because it's read only
     
    256239        if self.state_filename:
    257240            self.read_state()
    258 
    259         # Confirm federation scripts in the right place
    260         for s in self.scripts:
    261             if not os.path.exists(self.scripts_dir + "/" + s):
    262                 raise service_error(service_error.server_config,
    263                         "%s/%s not in local script dir" % (self.scripts_dir, s))
    264241
    265242        # Dispatch tables
     
    408385            return True
    409386
    410     def ship_scripts(self, host, user, dest_dir):
    411         """
    412         Copy the federation scripts (fedkit) to the a federant.
    413         """
    414         if self.ssh_cmd(user, host, "mkdir -p %s" % dest_dir):
    415             for s in self.scripts:
    416                 if not self.scp_file("%s/%s" % (self.scripts_dir, s),
    417                         user, host, dest_dir):
    418                     return False
    419             return True
    420         else:
    421             return False
    422 
    423387    def ship_configs(self, host, user, src_dir, dest_dir):
    424388        """
     
    520484                        "%s/%s" % (proj_dir, f)):
    521485                    return False
    522             if not self.ship_scripts(host, user, proj_dir):
    523                 return False
    524486            if not self.ship_configs(host, user, "%s/%s" % (tmpdir, tb),
    525487                    proj_dir):
     
    545507                        "%s/%s" % (proj_dir, f)):
    546508                    return False
    547             if not self.ship_scripts(host, user, proj_dir):
    548                 return False
    549509            if not self.ship_configs(host, user, "%s/%s" % (tmpdir, tb),
    550510                    proj_dir):
     
    593553                        "%s/%s" % (proj_dir, f)):
    594554                    return False
    595             if not self.ship_scripts(host, user, proj_dir):
    596                 return False
    597555            if not self.ship_configs(host, user, "%s/%s" % (tmpdir, tb),
    598556                    proj_dir):
     
    916874                'description' : { 'ns2description': desc },
    917875                'master': master,
     876                'include_fedkit': bool(self.fedkit)
    918877            }
    919878
     
    960919        subsittuted line by line.
    961920        """
    962         def __init__(self, eid, tmpdir):
     921        def __init__(self, eid, tmpdir, fedkit):
    963922            self.begin_testbed = re.compile("^#\s+Begin\s+Testbed\s+\((\w+)\)")
    964923            self.end_testbed = re.compile("^#\s+End\s+Testbed\s+\((\w+)\)")
     
    978937            self.eid = eid
    979938            self.tmpdir = tmpdir
     939            self.fedkit = fedkit
    980940
    981941        def __call__(self, line, master, allocated, tbparams):
     
    1038998                        line = re.sub("GWSTART", gwstart, line)
    1039999                        line = re.sub("EXPSTART", expstart, line)
    1040                     # XXX: does `` embed without doing enything else?
    10411000                    line = re.sub("GWCONF", "FEDDIR`hostname`.gw.conf", line)
    10421001                    line = re.sub("PROJDIR", "/proj/%s/" % project, line)
     
    10441003                    line = re.sub("FEDDIR", "/proj/%s/exp/%s/tmp/" % \
    10451004                            (project, self.eid), line)
     1005                    if self.fedkit:
     1006                        line = re.sub("FEDKIT", os.path.basename(self.fedkit),
     1007                                line)
    10461008                    print >>self.testbed_file, line
    10471009                return True
     
    10771039    class gateways:
    10781040        def __init__(self, eid, master, tmpdir, gw_pubkey,
    1079                 gw_secretkey, copy_file):
     1041                gw_secretkey, copy_file, fedkit):
    10801042            self.begin_gateways = \
    10811043                    re.compile("^#\s+Begin\s+gateways\s+\((\w+)\)")
     
    10921054
    10931055            self.copy_file = copy_file
     1056            self.fedkit = fedkit
    10941057
    10951058
     
    11161079            seer_control = "%s%s" % \
    11171080                    (tbparams[gw].get('control', "control"), sdomain)
    1118             remote_script_dir = "/proj/%s/exp/%s/tmp" % ( dproject, eid)
    1119             local_script_dir = "/proj/%s/exp/%s/tmp" % ( sproject, eid)
     1081
     1082            if self.fedkit:
     1083                remote_script_dir = "/usr/local/federation/bin"
     1084                local_script_dir = "/usr/local/federation/bin"
     1085            else:
     1086                remote_script_dir = "/proj/%s/exp/%s/tmp" % ( dproject, eid)
     1087                local_script_dir = "/proj/%s/exp/%s/tmp" % ( sproject, eid)
     1088
     1089            local_key_dir = "/proj/%s/exp/%s/tmp" % ( sproject, eid)
     1090            remote_conf_dir = "/proj/%s/exp/%s/tmp" % ( dproject, eid)
    11201091            tunnel_cfg = tbparams[gw].get("tun", "false")
    11211092
     
    11531124            print >>gwconfig, "LocalExperiment: %s/%s" % (sproject, eid)
    11541125            print >>gwconfig, "RemoteConfigFile: %s/%s" % \
    1155                     (remote_script_dir, remote_conf_file)
     1126                    (remote_conf_dir, remote_conf_file)
    11561127            print >>gwconfig, "Peer: %s%s" % (desthost, ddomain)
    1157             print >>gwconfig, "Pubkeys: %s/%s" % (local_script_dir, pubkey)
    1158             print >>gwconfig, "Privkeys: %s/%s" % (local_script_dir, privkey)
     1128            print >>gwconfig, "Pubkeys: %s/%s" % (local_key_dir, pubkey)
     1129            print >>gwconfig, "Privkeys: %s/%s" % (local_key_dir, privkey)
    11591130            gwconfig.close()
    11601131
     
    14541425       
    14551426        if self.splitter_url:
     1427            self.log.debug("Calling remote splitter at %s" % self.splitter_url)
    14561428            split_data = self.remote_splitter(self.splitter_url, file_content,
    14571429                    master)
    14581430        else:
    14591431            tclcmd = [self.tclsh, self.tcl_splitter, '-s', '-x',
    1460                 str(self.muxmax), '-m', master, pid, gid, eid, tclfile]
     1432                str(self.muxmax), '-m', master]
     1433
     1434            if self.fedkit:
     1435                tclcmd.append('-k')
     1436
     1437            tclcmd.extend([pid, gid, eid, tclfile])
     1438
     1439            self.log.debug("running local splitter %s", " ".join(tclcmd))
    14611440            tclparser = Popen(tclcmd, stdout=PIPE)
    14621441            split_data = tclparser.stdout
     
    14671446
    14681447        # Objects to parse the splitter output (defined above)
    1469         parse_current_testbed = self.current_testbed(eid, tmpdir)
     1448        parse_current_testbed = self.current_testbed(eid, tmpdir, self.fedkit)
    14701449        parse_allbeds = self.allbeds(self.get_access)
    14711450        parse_gateways = self.gateways(eid, master, tmpdir,
    1472                 gw_pubkey_base, gw_secretkey_base, self.copy_file)
     1451                gw_pubkey_base, gw_secretkey_base, self.copy_file, self.fedkit)
    14731452        parse_vtopo = self.shunt_to_string("^#\s+Begin\s+Vtopo",
    14741453                    "^#\s+End\s+Vtopo")
     
    15231502        # Copy tarfiles and rpms needed at remote sites into a staging area
    15241503        try:
     1504            if self.fedkit:
     1505                parse_tarfiles.list.append(self.fedkit)
    15251506            for t in parse_tarfiles.list:
    15261507                if not os.path.exists("%s/tarfiles" % tmpdir):
  • fedd/fedd_split.py

    r01308c9 r2c6128f  
    3535    def emit(self, record): pass
    3636
    37 fl = logging.getLogger("fedd.experiment_control")
     37fl = logging.getLogger("fedd.splitter")
    3838fl.addHandler(nullHandler())
    3939
     
    4646            self.debug = config.getboolean("splitter", "debug")
    4747            self.muxmax = config.getint("splitter", "muxmax", 3)
     48            self.tclsh = config.get("splitter", "tclsh",
     49                    "/usr/local/bin/otclsh")
     50            self.tcl_splitter = config.get("splitter", "tcl_splitter",
     51                    "/usr/testbed/lib/ns2ir/parse.tcl")
    4852        else:
    4953            self.debug = False
    5054            self.muxmax = 3
     55            self.tclsh = "/usr/local/bin/otclsh"
     56            self.tcl_splitter = "/usr/testbed/lib/ns2ir/parse.tcl"
    5157
    5258        self.log = logging.getLogger("fedd.splitter")
    53         self.tclsh = "/usr/local/bin/otclsh"
    54         self.tcl_splitter = "/usr/testbed/lib/ns2ir/parse.tcl"
    5559        self.trace_file = sys.stderr
    5660
     61        set_log_level(config, "splitter", self.log)
    5762        # Dispatch tables
    5863        self.soap_services = {\
     
    116121            raise service_error(service_error.req, "No master testbed label")
    117122       
     123        include_fedkit = req.get('include_fedkit', None)
     124        if include_fedkit == None:
     125            raise service_error(service_error.req,
     126                    "No federation kit inclusion directive")
     127       
    118128       
    119129        tclcmd = [self.tclsh, self.tcl_splitter, '-s', '-x',
    120             str(self.muxmax), '-m', master, pid, gid, eid, tclfile]
     130            str(self.muxmax), '-m', master]
     131        if include_fedkit: tclcmd.append('-k')
     132        tclcmd.extend([pid, gid, eid, tclfile])
     133        self.log.debug("Calling splitter %s" % " ".join(tclcmd))
    121134        tclparser = Popen(tclcmd, stdout=PIPE)
    122135
  • fedd/fedd_types.xsd

    r01308c9 r2c6128f  
    480480      <xsd:element name="description" type="tns:experimentDescriptionType"/>
    481481      <xsd:element name="master" type="xsd:string"/>
     482      <xsd:element name="include_fedkit" type="xsd:bool"/>
    482483    </xsd:sequence>
    483484  </xsd:complexType>
  • fedd/fedd_util.py

    r01308c9 r2c6128f  
    44import subprocess
    55import tempfile
     6import logging
    67
    78from M2Crypto import SSL, X509, EVP
     
    394395
    395396    return handler
     397
     398def set_log_level(config, sect, log):
     399    """ Set the logging level to the value passed in sect of config."""
     400    # The getattr sleight of hand finds the logging level constant
     401    # corrersponding to the string.  We're a little paranoid to avoid user
     402    # mayhem.
     403    if config.has_option(sect, "log_level"):
     404        level_str = config.get(sect, "log_level")
     405        try:
     406            level = int(getattr(logging, level_str.upper(), -1))
     407
     408            if  logging.DEBUG <= level <= logging.CRITICAL:
     409                log.setLevel(level)
     410            else:
     411                log.error("Bad experiment_log value: %s" % level_str)
     412
     413        except ValueError:
     414            log.error("Bad experiment_log value: %s" % level_str)
     415
Note: See TracChangeset for help on using the changeset viewer.