source: trunk/LATMOS-Accounts/bin/la-sql-exchange-ip @ 1806

Last change on this file since 1806 was 1322, checked in by nanardon, 9 years ago

Add la-sql-exchange-hostname tools, fix some doc

  • Property svn:executable set to *
File size: 1.0 KB
Line 
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5use LATMOS::Accounts;
6use Getopt::Long;
7use Pod::Usage;
8
9=head1 NAME
10
11    la-sql-exchange-ip - Exchange IP between two host
12
13=head1 SYNOPSIS
14
15    la-sql-exchange-ip ip1 ip2
16
17Example : la-sql-exchange-ip 172.1.2.3 192.168.3.2
18
19=cut
20
21GetOptions(
22    'c|config=s'        => \my $config,
23    'b|base=s'          => \my $base,
24    'help'              => sub { pod2usage(0) },
25) or pod2usage();
26
27=head1 OPTIONS
28
29=over 4
30
31=item -c|--config configdir
32
33Use this configuration directory instead of the default one.
34
35=item -b|--base basename
36
37Query this specific base instead of the default one.
38
39=back
40
41=cut
42
43my $LA = LATMOS::Accounts->new($config, noacl => 1);
44my $labase = $LA->base($base);
45$labase && $labase->load or die "Cannot load base";
46
47$labase->unexported(1);
48
49my ($from, $to) = @ARGV or pod2usage();
50
51if ($labase->nethost_exchange_ip($from, $to)) {
52    $labase->commit;
53    print "IP succesfully exchange between $from and $to\n";
54    exit(0);
55} else {
56    warn "Error while exchanging ip\n";
57    exit(1);
58}
Note: See TracBrowser for help on using the repository browser.