source: fedkit/active_config.pl @ 6a8a9ec

axis_examplecompt_changesinfo-opsversion-3.01version-3.02
Last change on this file since 6a8a9ec was c3a3fe3, checked in by Ted Faber <faber@…>, 15 years ago

Coordinate parallel starts: wait for remote nodes to configure ssh for access

  • Property mode set to 100644
File size: 3.3 KB
Line 
1#!/usr/bin/perl
2
3use strict;
4
5use gateway_lib;
6
7use IO::File;
8
9use Getopt::Long;
10
11my $ssh_pubkey;
12my $ssh_privkey;
13my $tunnelip;
14my $peer;
15my $fedkit_dir= "/usr/local/federation";
16my $perl = "/usr/bin/perl";
17my $iface_file = "/var/emulab/boot/ifmap";
18my $ssh = "/usr/bin/ssh";
19my $use_file;
20
21my %opts = (
22    'ssh_pubkey=s' => \$ssh_pubkey,
23    'ssh_privkey=s' => \$ssh_privkey,
24    'tunnelip' => \$tunnelip,
25    'peer=s' => \$peer,
26    'fedkit=s' => \$fedkit_dir,
27    'perl=s' => \$perl,
28    'interfaces=s' => \$iface_file,
29    'ssh=s' => \$ssh,
30    'use_file' => \$use_file,
31);
32
33exit(20) unless GetOptions(%opts);
34
35gateway_lib::read_config(gateway_lib::emulab_config_filename(), \%opts)
36    if $use_file;
37
38my $tunnelparam = $tunnelip ? '--tunnelip' : '';
39
40system("$perl -I$fedkit_dir/lib $fedkit_dir/bin/prep_gateway.pl --peer=$peer " .
41    "--ssh_pubkey=$ssh_pubkey $tunnelparam");
42exit(20) if $?;
43
44my $f = new IO::File($iface_file) || die "Can't open $iface_file: $!\n";
45my $ifnum = 0;
46
47print "Waiting for ssh on $peer\n";
48gateway_lib::wait_for_port($peer, 22, 60*60) || 
49    die "ssh never came up on $peer\n";
50print "Making sure ssh permissions are reset\n";
51gateway_lib::testcmd_repeat("$ssh -o \"StrictHostKeyChecking no\" " .
52    "-i $ssh_privkey $peer ls", 5*60);
53
54while (<$f>) {
55    /([[:alnum:]]+)\s+([\d\.]+)/ && do {
56        my ($iface, $addr) = ($1, $2);
57
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 &";
62        system($cmd);
63        die if $?;
64        gateway_lib::bind_tap_to_iface($ifnum, $iface, $addr);
65        $ifnum++;
66    };
67}
68$f->close();
69exit(0);
70
71=pod
72
73=head1 NAME
74
75B<active_config.pl> - Configure an active connectivity gateway under the DETER Federation Architecture
76
77=head1 OPTIONS
78
79=over 8
80
81=item B<fedkit=>I<install_dir>
82
83Directory in which this software is installed.  Generally not needed.
84
85=item B<interfaces=>I<interface table>
86
87A list of interfaces to forward data on of the form:
88
89=begin text
90
91iface ip_addr
92
93=end text
94
95The interface is the operating system name of the interface and the IP address
96is given in standard dotted decimal notation.  Other characters on a line are
97ignored.
98
99=item B<peer=>I<hostname>
100
101The other gateway providing forwarding.
102
103=item B<perl=>I<perl_binary>
104 
105Location of the perl binary.  Usually unneeded.
106
107=item B<ssh=>I<ssh_binary>
108
109The pathname of the ssh binary.  Unusally unnecessary.
110
111=item B<ssh_pubkey=>I<keyfile>
112
113A public to install as authorized.
114
115=item B<ssh_privkey=>I<identity_file>
116
117The identity to use for remote access
118
119=item B<tunnelip>
120
121True if the testbed uses the DETER tunnelip extension to provide external
122connectivity information
123
124=item B<use_file>
125
126If given read additional parameters from the file in
127/proj/I<project>/exp/I<experiment/tmp/I<hostname>.gw/conf where those are the
128current testbed project and experiment and the hostname is before the first
129dot.  The file is option: value.
130
131
132=back
133
134=head1 SYNOPSIS
135
136B<active_config.pl> initiates the active side of the connectivity connection,
137which is to say that it:
138
139=over 4
140
141=item *
142
143Installs local keys and reconfigures that local ssh system to do link layer
144tunneling.
145
146=item *
147
148Starts a tunnel for each interface in the given interface table, both locally
149and remotely.
150
151=back
152
153=head1 AUTHORS
154
155Ted Faber <faber@isi.edu>
156
157=cut
Note: See TracBrowser for help on using the repository browser.