source: fedkit/active_config.pl @ 1899afd

axis_examplecompt_changesinfo-opsversion-3.01version-3.02
Last change on this file since 1899afd was 1899afd, checked in by Ted Faber <faber@…>, 14 years ago

Add port waiting. Should be asynchronous now.

  • Property mode set to 100644
File size: 3.2 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";
50
51while (<$f>) {
52    /([[:alnum:]]+)\s+([\d\.]+)/ && do {
53        my ($iface, $addr) = ($1, $2);
54
55        my $cmd = "$ssh -w $ifnum:$ifnum -o \"Tunnel ethernet\" " . 
56            "-o \"StrictHostKeyChecking no\" -i $ssh_privkey " .
57            "$peer perl -I$fedkit_dir/lib $fedkit_dir/bin/setup_bridge.pl " .
58            "--tapno=$ifnum --dest=$addr &";
59        system($cmd);
60        die if $?;
61        gateway_lib::bind_tap_to_iface($ifnum, $iface, $addr);
62        $ifnum++;
63    };
64}
65$f->close();
66exit(0);
67
68=pod
69
70=head1 NAME
71
72B<active_config.pl> - Configure an active connectivity gateway under the DETER Federation Architecture
73
74=head1 OPTIONS
75
76=over 8
77
78=item B<fedkit=>I<install_dir>
79
80Directory in which this software is installed.  Generally not needed.
81
82=item B<interfaces=>I<interface table>
83
84A list of interfaces to forward data on of the form:
85
86=begin text
87
88iface ip_addr
89
90=end text
91
92The interface is the operating system name of the interface and the IP address
93is given in standard dotted decimal notation.  Other characters on a line are
94ignored.
95
96=item B<peer=>I<hostname>
97
98The other gateway providing forwarding.
99
100=item B<perl=>I<perl_binary>
101 
102Location of the perl binary.  Usually unneeded.
103
104=item B<ssh=>I<ssh_binary>
105
106The pathname of the ssh binary.  Unusally unnecessary.
107
108=item B<ssh_pubkey=>I<keyfile>
109
110A public to install as authorized.
111
112=item B<ssh_privkey=>I<identity_file>
113
114The identity to use for remote access
115
116=item B<tunnelip>
117
118True if the testbed uses the DETER tunnelip extension to provide external
119connectivity information
120
121=item B<use_file>
122
123If given read additional parameters from the file in
124/proj/I<project>/exp/I<experiment/tmp/I<hostname>.gw/conf where those are the
125current testbed project and experiment and the hostname is before the first
126dot.  The file is option: value.
127
128
129=back
130
131=head1 SYNOPSIS
132
133B<active_config.pl> initiates the active side of the connectivity connection,
134which is to say that it:
135
136=over 4
137
138=item *
139
140Installs local keys and reconfigures that local ssh system to do link layer
141tunneling.
142
143=item *
144
145Starts a tunnel for each interface in the given interface table, both locally
146and remotely.
147
148=back
149
150=head1 AUTHORS
151
152Ted Faber <faber@isi.edu>
153
154=cut
Note: See TracBrowser for help on using the repository browser.