source: fedkit/active_config.pl @ 358e0b8

axis_examplecompt_changesinfo-opsversion-3.01version-3.02
Last change on this file since 358e0b8 was 55779d4, checked in by Ted Faber <faber@…>, 15 years ago

Supporting nodes connected by transit networks

  • Property mode set to 100644
File size: 3.4 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
44
45print "Waiting for ssh on $peer\n";
46gateway_lib::wait_for_port($peer, 22, 60*60) || 
47    die "ssh never came up on $peer\n";
48print "Making sure ssh permissions are reset\n";
49gateway_lib::testcmd_repeat("$ssh -o \"StrictHostKeyChecking no\" " .
50    "-i $ssh_privkey $peer ls", 5*60);
51
52if (my $f = new IO::File($iface_file)) {
53    my $ifnum = 0;
54    while (<$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();
69}
70else {
71    warn "Can't open $iface_file: $!\n";
72}
73exit(0);
74
75=pod
76
77=head1 NAME
78
79B<active_config.pl> - Configure an active connectivity gateway under the DETER Federation Architecture
80
81=head1 OPTIONS
82
83=over 8
84
85=item B<fedkit=>I<install_dir>
86
87Directory in which this software is installed.  Generally not needed.
88
89=item B<interfaces=>I<interface table>
90
91A list of interfaces to forward data on of the form:
92
93=begin text
94
95iface ip_addr
96
97=end text
98
99The interface is the operating system name of the interface and the IP address
100is given in standard dotted decimal notation.  Other characters on a line are
101ignored.
102
103=item B<peer=>I<hostname>
104
105The other gateway providing forwarding.
106
107=item B<perl=>I<perl_binary>
108 
109Location of the perl binary.  Usually unneeded.
110
111=item B<ssh=>I<ssh_binary>
112
113The pathname of the ssh binary.  Unusally unnecessary.
114
115=item B<ssh_pubkey=>I<keyfile>
116
117A public to install as authorized.
118
119=item B<ssh_privkey=>I<identity_file>
120
121The identity to use for remote access
122
123=item B<tunnelip>
124
125True if the testbed uses the DETER tunnelip extension to provide external
126connectivity information
127
128=item B<use_file>
129
130If given read additional parameters from the file in
131/proj/I<project>/exp/I<experiment/tmp/I<hostname>.gw/conf where those are the
132current testbed project and experiment and the hostname is before the first
133dot.  The file is option: value.
134
135
136=back
137
138=head1 SYNOPSIS
139
140B<active_config.pl> initiates the active side of the connectivity connection,
141which is to say that it:
142
143=over 4
144
145=item *
146
147Installs local keys and reconfigures that local ssh system to do link layer
148tunneling.
149
150=item *
151
152Starts a tunnel for each interface in the given interface table, both locally
153and remotely.
154
155=back
156
157=head1 AUTHORS
158
159Ted Faber <faber@isi.edu>
160
161=cut
Note: See TracBrowser for help on using the repository browser.