Changeset f8ae7aa


Ignore:
Timestamp:
Mar 23, 2010 1:17:21 PM (15 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
Children:
3e3a5de
Parents:
1627c3d
Message:

Neaten things up a little and support rpms for federation and portal software in protoGENI

Location:
fedd/federation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • fedd/federation/protogeni_access.py

    r1627c3d rf8ae7aa  
    6363                    loc, file = ps[0:2]
    6464                    del ps[0:2]
     65                    if loc == 'rpm':
     66                        loc = None
    6567                    l.append((loc, file))
    6668            return l
  • fedd/federation/proxy_protogeni_segment.py

    r1627c3d rf8ae7aa  
    329329            portal_software, stagingdir, tmpdir):
    330330
     331        # These little functions/functors just make things more readable
     332        class stage_file_type:
     333            def __init__(self, user, host, stagingdir):
     334                self.user = user
     335                self.host = host
     336                self.stagingdir = stagingdir
     337                self.scp = "/usr/bin/scp -i .ssh/id_rsa -o " + \
     338                        "'ForwardX11 no' -o 'StrictHostKeyChecking no' "
     339
     340            def __call__(self, script, file, dest="."):
     341                # If the file is a full pathname, do not use stagingdir
     342                if file.find('/') == -1:
     343                    file = "%s/%s" % (self.stagingdir, file)
     344                print >>script, "%s %s@%s:%s %s" % \
     345                        (self.scp, self.user, self.host, file, dest)
     346
     347        def install_tar(script, loc, base):
     348            tar = "/bin/tar"
     349            mkdir="/bin/mkdir"
     350
     351            print >>script, "%s -p %s" % (mkdir, loc)
     352            print >>script, "%s -C %s -xzf %s" % (tar, loc, base)
     353
     354        def install_rpm(script, base):
     355            rpm = "/bin/rpm"
     356            print >>script, "%s --install %s" % (rpm, base)
     357
    331358        fed_dir = "/usr/local/federation"
    332         ssh = "/usr/bin/ssh -n -i .ssh/id_rsa -o 'ForwardX11 no' -o 'StrictHostKeyChecking no' "
    333         scp = "/usr/bin/scp -i .ssh/id_rsa -o 'ForwardX11 no' -o 'StrictHostKeyChecking no' "
     359        fed_etc_dir = "%s/etc" % fed_dir
     360        fed_bin_dir = "%s/bin" % fed_dir
     361        fed_lib_dir = "%s/lib" % fed_dir
     362
    334363        ifconfig = "/sbin/ifconfig"
    335         tar = "/bin/tar"
    336         mkdir="/bin/mkdir"
     364
     365        stage_file = stage_file_type(user, host, stagingdir)
    337366
    338367        for e in [ e for e in topo.elements if isinstance(e, topdl.Computer)]:
     
    358387                for l, f in federation_software:
    359388                    base = os.path.basename(f)
    360                     print >>script, "%s %s@%s:%s/%s ." % \
    361                             (scp, user, host, stagingdir, base)
    362                     # Make sure that there's a directory there in which to
    363                     # untar.
    364                     print >>script, "%s -p %s" % (mkdir, l)
    365                     print >>script, \
    366                             "%s -C %s -xzf %s" % (tar, l, base)
     389                    stage_file(script, base)
     390                    if l: install_tar(script, l, base)
     391                    else: install_rpm(script, base)
    367392
    368393                for s in e.software:
    369                     # XXX: Just tarfiles for now
    370                     if not (s.location and s.install):
    371                         continue
    372394                    s_base = s.location.rpartition('/')[2]
    373                     print >>script, "%s %s@%s:%s/%s ." % \
    374                             (scp, user, host, stagingdir, s_base)
    375                     # Make sure that there's a directory there in which to
    376                     # untar.
    377                     print >>script, "%s -p %s" % (mkdir, s.install)
    378                     print >>script, \
    379                             "%s -C %s -xzf %s" % (tar, s.install, s_base)
     395                    stage_file(script, s_base)
     396                    if s.install: install_tar(script, s.install, s_base)
     397                    else: install_rpm(script, s_base)
     398
    380399                for f in ('hosts', pubkey, secretkey, 'client.conf',
    381400                        'userconf'):
    382                     print >>script, "%s %s@%s:%s/%s %s/etc" % \
    383                             (scp, user, host, stagingdir, f, fed_dir)
     401                    stage_file(script, f, fed_etc_dir)
    384402                if sshd:
    385                     print >>script, "%s %s@%s:%s %s/bin" % \
    386                             (scp, user, host, sshd, fed_dir)
     403                    stage_file(script, sshd, fed_bin_dir)
    387404                if sshd_config:
    388                     print >>script, "%s %s@%s:%s %s/etc" % \
    389                             (scp, user, host, sshd_config, fed_dir)
     405                    stage_file(script, sshd_config, fed_etc_dir)
     406
    390407                # Look in tmpdir to get the names.  They've all been copied
    391408                # into the (remote) staging dir
    392409                if os.access("%s/%s.gw.conf" % (tmpdir, vname), os.R_OK):
    393                     print >>script, "%s %s@%s:%s/%s.gw.conf %s/etc" % \
    394                             (scp, user, host, stagingdir, vname, fed_dir)
     410                    stage_file(script, "%s.gw.conf" % vname, fed_etc_dir)
    395411
    396412                # Hackery dackery dock: the ProtoGENI python is really ancient.
    397                 # Get a modern version (though packaged for Mandrake (remember
    398                 # Mandrake?  good times, good times)) and install it for SEER.
    399                 python_rpm="python2.4-2.4-1pydotorg.i586.rpm"
    400                 print >>script, "%s %s@%s:%s/%s ." % \
    401                         (scp, user, host, stagingdir, python_rpm)
    402                 print >>script, "rpm --install ./%s" % python_rpm
     413                # A modern version (though packaged for Mandrake (remember
     414                # Mandrake?  good times, good times)) should be in the
     415                # federation_software list, but we need to move rename is for
     416                # SEER.
    403417                print >>script, "rm /usr/bin/python"
    404418                print >>script, "ln /usr/bin/python2.4 /usr/bin/python"
     
    410424                    for l, f in portal_software:
    411425                        base = os.path.basename(f)
    412                         print >>script, "%s %s@%s:%s/%s ." % \
    413                                 (scp, user, host, stagingdir, base)
    414                         print >>script, \
    415                                 "%s -C %s -xzf %s" % (tar, l, base)
     426                        stage_file(script, base)
     427                        if l: install_tar(script, l, base)
     428                        else: install_rpm(script, base)
    416429
    417430                    # Portals never have a user-specified start command
     
    419432                elif node_cmd:
    420433                    # XXX: debug
    421                     print >>script, "sudo perl -I%s/lib %s/bin/import_key.pl /users/%s/.ssh/authorized_keys /root/.ssh/authorized_keys" % (fed_dir, fed_dir, user)
     434                    print >>script, "sudo perl -I%s %simport_key.pl /users/%s/.ssh/authorized_keys /root/.ssh/authorized_keys" % (fed_lib_dir, fed_bin_dir, user)
    422435                    # XXX: debug
    423436                    if e.get_attribute('startup'):
Note: See TracChangeset for help on using the changeset viewer.