source: fedkit/active_config.pl @ f8fa72b

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

More ProtoGENI accomodation

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