Changeset f8fa72b


Ignore:
Timestamp:
Mar 5, 2010 3:26:09 AM (15 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
Children:
444790d
Parents:
c119839
Message:

More ProtoGENI accomodation

Location:
fedkit
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • fedkit/active_config.pl

    rc119839 rf8fa72b  
    1717my $iface_file = "/var/emulab/boot/ifmap";
    1818my $ssh = "/usr/bin/ssh";
    19 my $use_file;
     19my $ssh_port = 22;
    2020
    2121my %opts = (
     
    2828    'interfaces=s' => \$iface_file,
    2929    'ssh=s' => \$ssh,
     30    'ssh_port=s' => \$ssh_port,
    3031    'use_file' => \$use_file,
    3132);
     
    3334exit(20) unless GetOptions(%opts);
    3435
    35 gateway_lib::read_config(gateway_lib::emulab_config_filename(), \%opts)
     36gateway_lib::read_config(gateway_lib::config_filename(), \%opts)
    3637    if $use_file;
    3738
     
    5657            my ($iface, $addr) = ($1, $2);
    5758
    58             my $cmd = "$ssh -w $ifnum:$ifnum -o \"Tunnel ethernet\" " .
    59                 "-o \"StrictHostKeyChecking no\" -i $ssh_privkey " .
    60                 "$peer perl -I$fedkit_dir/lib $fedkit_dir/bin/setup_bridge.pl " .
    61                 "--tapno=$ifnum --dest=$addr &";
     59            my $cmd = "$ssh -w $ifnum:$ifnum -p $ssh_port " .
     60                "-o \"Tunnel ethernet\" -o \"StrictHostKeyChecking no\" " .
     61                "-i $ssh_privkey $peer perl -I$fedkit_dir/lib ".
     62                "$fedkit_dir/bin/setup_bridge.pl --tapno=$ifnum --dest=$addr &";
    6263            system($cmd);
    6364            die if $?;
  • fedkit/combo.pl

    rc119839 rf8fa72b  
    1818my $iface_file = "/var/emulab/boot/ifmap";
    1919my $ssh = "/usr/bin/ssh";
     20my $ssh_port = 22;
    2021my @ports;
    2122my $use_file;
     
    3233    'port=s' => \@ports,
    3334    'active' => \$active,
     35    'ssh_port=s' => \$ssh_port,
    3436    'use_file' => \$use_file,
    3537);
     
    3739exit(20) unless GetOptions(%opts);
    3840
    39 gateway_lib::read_config(gateway_lib::emulab_config_filename(), \%opts)
    40     if $use_file;
     41if ($use_file) {
     42    gateway_lib::read_config(gateway_lib::config_filename(), \%opts)
     43}
    4144
    4245my $tunnelparam = $tunnelip ? '--tunnelip' : '';
     
    5053        "--peer=$peer --ssh_pubkey=$ssh_pubkey --ssh_privkey=$ssh_privkey " .
    5154        " $tunnelparam --fedkit=$fedkit_dir --perl=$perl " .
    52         "--ssh=$ssh --interfaces=$iface_file");
     55        "--ssh_port=$ssh_port --ssh=$ssh --interfaces=$iface_file");
    5356    exit(20) if $?;
    5457
  • fedkit/federate.pl

    rc119839 rf8fa72b  
    33
    44use strict;
     5
     6use Getopt::Long;
    57
    68use IO::File;
     
    2931my $exp;
    3032my $proj;
     33my $install_smb;
    3134chomp (my $uname = `uname`);
    3235my $smbmount = "smbmount.$uname.pl";
     36
     37GetOptions("install_samba" => \$install_smb);
    3338
    3439# find perl
     
    4146$perl = "perl" unless $perl;
    4247
     48if ($install_smb) {
     49    # fix yum.conf
     50    copy("/etc/yum.conf", "/etc/yum.conf.bak");
     51    my $from = new IO::File("/etc/yum.conf.bak");
     52    my $to = new IO::File(">/etc/yum.conf");
     53    while (<$from>) {
     54        s/download.fedoralegacy.org/fedoralegacy.lsu.edu/g;
     55        print $to $_;
     56    }
     57    $from->close();
     58    $to->close();
     59    # Now, bridging
     60    system('/usr/bin/yum -y install samba-client');
     61}
    4362
    44 $tmcc_p->reader("$TMCC -b status");
    45 while (<$tmcc_p>) {
    46     /ALLOCATED=([^\/]+)\/(\S+)/ && do {
    47         ($proj, $exp) = ($1, $2);
    48         $shared_config_dir = "/proj/$proj/exp/$exp/tmp";
    49         last;
    50     };
    51 }
    52 $tmcc_p->close();
     63if (!-e "$local_config_dir/client.conf" ) {
     64    $tmcc_p->reader("$TMCC -b status");
     65    while (<$tmcc_p>) {
     66        /ALLOCATED=([^\/]+)\/(\S+)/ && do {
     67            ($proj, $exp) = ($1, $2);
     68            $shared_config_dir = "/proj/$proj/exp/$exp/tmp";
     69            last;
     70        };
     71    }
     72    $tmcc_p->close();
    5373
    54 mkdir($local_config_dir);
     74    mkdir($local_config_dir);
    5575
    56 foreach my $fn ("seer.conf", "client.conf", "userconf") {
    57     copy("$shared_config_dir/$fn", $local_config_dir )
    58         if -e "$shared_config_dir/$fn";
     76    foreach my $fn ("seer.conf", "client.conf", "userconf", "hosts") {
     77        copy("$shared_config_dir/$fn", $local_config_dir )
     78            if -e "$shared_config_dir/$fn";
     79    }
    5980}
    6081
     
    7293my $hosts = new IO::File("/etc/hosts") || die "Can't open /etc/hosts:$!\n";
    7394my $new_hosts = new IO::File(">/tmp/hosts") || die "Can't open /tmp/hosts:$!\n";
    74 my $config_hosts = new IO::File("$shared_config_dir/hosts") ||
    75     die "Can't open $shared_config_dir/hosts: $!\n";
     95my $config_hosts = new IO::File("$local_config_dir/hosts") ||
     96    die "Can't open $local_config_dir/hosts: $!\n";
    7697my $has_control = 0;
    7798
     
    112133
    113134if ($services{'userconfig'}) {
    114     $tmcc_p = new IO::Pipe() || die "Can't open pipe for accounts:$!\n";
    115     my $old_accounts = new IO::File(">$local_config_dir/old_accts") ||
    116         die "Can't open $local_config_dir/old_accts: $!\n";
     135    if (!-e "$local_config_dir/old_accts") {
     136        $tmcc_p = new IO::Pipe() || die "Can't open pipe for accounts:$!\n";
     137        my $old_accounts = new IO::File(">$local_config_dir/old_accts") ||
     138            die "Can't open $local_config_dir/old_accts: $!\n";
    117139
    118     $tmcc_p->reader("$TMCC -b accounts");
    119     while (<$tmcc_p>) {
    120         print $old_accounts $_;
     140        $tmcc_p->reader("$TMCC -b accounts");
     141        while (<$tmcc_p>) {
     142            print $old_accounts $_;
     143        }
     144        $tmcc_p->close();
     145        $old_accounts->close();
    121146    }
    122     $tmcc_p->close();
    123     $old_accounts->close();
    124147    print("Updating accounts");
    125148    system("/usr/local/federation/bin/rc.fedaccounts");
  • fedkit/gateway_lib.pm

    rc119839 rf8fa72b  
    2727my $FINDIF = "/usr/local/etc/emulab/findif";
    2828my $TMCC = "/usr/local/etc/emulab/tmcc";
     29
     30# Linux choices
     31my $BRCTL = "/usr/sbin/brctl";
     32my $IPROUTE = "/sbin/ip route ";
    2933
    3034# Takes an ssh config file and a reference to a hash of keys whose values must
     
    176180    }
    177181
    178     system("ifconfig $bridge create");
    179     warn "Cannot create bridge: $?\n" if $?;
    180     foreach my $a (@addr) {
    181         system("ifconfig $iface delete $a");
    182         warn "Cannot delete address $a: $?\n" if $?;
    183     }
    184     system("ifconfig $bridge addm $iface up");
    185     warn "Cannot add intefrace $iface to bridge: $?\n" if $?;
    186     system("ifconfig $bridge addm $tap");
    187     warn "Cannot add intefrace $tap to bridge: $?\n" if $?;
    188     return $?;
     182    my $uname = `uname`;
     183    chomp $uname;
     184
     185    if ($uname =~ /FreeBSD/) {
     186        system("ifconfig $bridge create");
     187        warn "Cannot create bridge: $?\n" if $?;
     188        foreach my $a (@addr) {
     189            system("ifconfig $iface delete $a");
     190            warn "Cannot delete address $a: $?\n" if $?;
     191        }
     192        system("ifconfig $bridge addm $iface up");
     193        warn "Cannot add intefrace $iface to bridge: $?\n" if $?;
     194        system("ifconfig $bridge addm $tap");
     195        warn "Cannot add intefrace $tap to bridge: $?\n" if $?;
     196        return $?;
     197    }
     198    elsif ($uname =~ /Linux/) {
     199        system("$IFCONFIG $iface 0.0.0.0 down");
     200        system("$BRCTL addbr $bridge");
     201        warn "Cannot create bridge: $?\n" if $?;
     202        system("$BRCTL addif $bridge $tap");
     203        system("$BRCTL addif $bridge $iface");
     204        system("$BRCTL stp $bridge off");
     205        system("$IFCONFIG $bridge up");
     206        system("$IFCONFIG $tap up");
     207        system("$IFCONFIG $iface up");
     208        return $?;
     209    }
    189210}
    190211
     
    194215    my $ipipe = new IO::Pipe() || die "Can't create pipe for ifconfig: $!\n";
    195216    my @addr;
     217    my $uname = `uname`;
     218    my $ipre = "inet\\s+([0-9\\.]+)";
     219    chomp $uname;
     220
     221    if ($uname =~ /Linux/) {
     222        $ipre = "inet\\s+addr:\\s*([0-9\\.]+)";
     223    }
    196224
    197225    $ipipe->reader("$IFCONFIG $iface");
    198226    while(<$ipipe>) {
    199         /inet\s+([0-9\.]+)/ && push(@addr, $1);
     227        /$ipre/ && push(@addr, $1);
    200228    }
    201229    $ipipe->close();
     
    207235    my($dest) =@_;
    208236    my $rpipe = new IO::Pipe() || die "Can't create pipe for route: $!\n";
    209 
    210     $rpipe->reader("$ROUTE get $dest");
     237    my $uname = `uname`;
     238    chomp $uname;
     239    my $route;
     240    my $dev_re;
     241
     242    if ($uname =~ /Linux/) {
     243        $route = $IPROUTE;
     244        $dev_re = "\\s+dev\\s+(\\S+)";
     245    }
     246    elsif ($uname =~ /FreeBSD/) {
     247        $route = $ROUTE;
     248        $dev_re = 'interface:\\s*([[:alnum:]]+)';
     249    }
     250
     251
     252    print "$route get $dest\n";
     253    $rpipe->reader("$route get $dest");
    211254    while (<$rpipe>) {
    212         /interface:\s*([[:alnum:]]+)/ && do {
     255        /$dev_re/ && do {
    213256            my $iface = $1;
    214257            $rpipe->close();
     258            print "matched: $iface\n";
    215259            return $iface;
    216260        };
     
    290334
    291335
    292 sub emulab_config_filename {
    293     # Find the configuration file in the usual place, which depends on what
    294     # experiment and project we're in.
     336sub config_filename {
     337    # Find the configuration file in the usual places, if there is one in
     338    # /usr/local/federation/etc, use it, otherwise look in the emulab standard
     339    # filesystems which depends on what experiment and project we're in.
    295340    my $pid;
    296341    my $eid;
    297342    my $filename;
     343    my $fed_dir = "/usr/local/federation/etc/";
     344    my $hn = `hostname`;
     345    chomp $hn;
     346    $hn =~ s/\..*//;
     347
     348    return "$fed_dir/$hn.gw.conf" if -r "$fed_dir/$hn.gw.conf";
     349
    298350    my $tmcd = new IO::Pipe() || die "Can't create pipe: $!\n";
    299351
     
    308360    }
    309361    $tmcd->close();
    310     my $hn = `hostname`;
    311     chomp $hn;
    312     $hn =~ s/\..*//;
    313362    $filename = "/proj/$pid/exp/$eid/tmp/$hn.gw.conf"
    314363        if $pid and $eid;
     
    316365    return $filename;
    317366}
     367
    318368
    319369sub wait_for_port {
  • fedkit/prep_gateway.pl

    rc119839 rf8fa72b  
    66
    77use Getopt::Long;
     8use File::Copy;
     9use IO::File;
    810
    911my $ssh_pubkey;
     
    2022exit(20) unless GetOptions(%opts);
    2123
    22 gateway_lib::read_config(gateway_lib::emulab_config_filename(), \%opts)
    23     if $use_file;
     24if ($use_file) {
     25    gateway_lib::read_config(gateway_lib::config_filename(), \%opts)
     26}
    2427
    25 gateway_lib::set_sshd_params(
    26     { 'GatewayPorts' => 'yes', 'PermitTunnel' => 'yes' } );
    27 system("/etc/rc.d/sshd restart");
     28my $uname = `uname`;
     29chomp $uname;
    2830
    29 gateway_lib::import_key($ssh_pubkey,'/root/.ssh/authorized_keys')
    30     if $ssh_pubkey;
     31if ($uname =~ /Linux/) {
     32    # Right now the only gateway nodes that are Linux nodes are ProtoGENI
     33    # nodes.  They need a bunch of custom updates to get into the 21st century,
     34    # but they are on the network.
     35    if ( -x '/usr/local/federation/bin/sshd' &&
     36            -e '/usr/local/federation/etc/sshd_config') {
     37        # Start our modern sshd if one is there
     38        system("/usr/local/federation/bin/sshd -p 20200 -f " .
     39            "/usr/local/federation/etc/sshd_config");
     40    }
     41    # fix yum.conf
     42    copy("/etc/yum.conf", "/etc/yum.conf.bak");
     43    my $from = new IO::File("/etc/yum.conf.bak");
     44    my $to = new IO::File(">/etc/yum.conf");
     45    while (<$from>) {
     46        s/download.fedoralegacy.org/fedoralegacy.lsu.edu/g;
     47        print $to $_;
     48    }
     49    $from->close();
     50    $to->close();
     51    # Now, bridging
     52    system('/usr/bin/yum -y install bridge-utils');
     53    #and keys
     54    gateway_lib::import_key($ssh_pubkey,'/root/.ssh/authorized_keys')
     55        if $ssh_pubkey;
     56}
     57elsif ($uname =~ /FreeBSD/ ){
     58    gateway_lib::set_sshd_params(
     59        { 'GatewayPorts' => 'yes', 'PermitTunnel' => 'yes' } );
     60    system("/etc/rc.d/sshd restart");
    3161
    32 # Need these to make the Ethernet tap and bridge work.
    33 system("kldload /boot/kernel/bridgestp.ko")
    34     if -r "/boot/kernel/bridgestp.ko";
    35 system("kldload /boot/kernel/if_bridge.ko");
    36 system("kldload /boot/kernel/if_tap.ko");
     62    gateway_lib::import_key($ssh_pubkey,'/root/.ssh/authorized_keys')
     63        if $ssh_pubkey;
     64
     65    # Need these to make the Ethernet tap and bridge work.
     66    system("kldload /boot/kernel/bridgestp.ko")
     67        if -r "/boot/kernel/bridgestp.ko";
     68    system("kldload /boot/kernel/if_bridge.ko");
     69    system("kldload /boot/kernel/if_tap.ko");
     70}
    3771
    3872if ( $tunnelip ) {
Note: See TracChangeset for help on using the changeset viewer.