Last change
on this file since 2043 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
|
Rev | Line | |
---|
[861] | 1 | #!/usr/bin/perl |
---|
| 2 | |
---|
| 3 | use strict; |
---|
| 4 | use warnings; |
---|
| 5 | use LATMOS::Accounts; |
---|
| 6 | use Getopt::Long; |
---|
| 7 | use Pod::Usage; |
---|
| 8 | |
---|
| 9 | =head1 NAME |
---|
| 10 | |
---|
[1322] | 11 | la-sql-exchange-ip - Exchange IP between two host |
---|
[861] | 12 | |
---|
| 13 | =head1 SYNOPSIS |
---|
| 14 | |
---|
[1322] | 15 | la-sql-exchange-ip ip1 ip2 |
---|
[861] | 16 | |
---|
[1322] | 17 | Example : la-sql-exchange-ip 172.1.2.3 192.168.3.2 |
---|
[861] | 18 | |
---|
| 19 | =cut |
---|
| 20 | |
---|
| 21 | GetOptions( |
---|
| 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 | |
---|
| 33 | Use this configuration directory instead of the default one. |
---|
| 34 | |
---|
| 35 | =item -b|--base basename |
---|
| 36 | |
---|
| 37 | Query this specific base instead of the default one. |
---|
| 38 | |
---|
| 39 | =back |
---|
| 40 | |
---|
| 41 | =cut |
---|
| 42 | |
---|
| 43 | my $LA = LATMOS::Accounts->new($config, noacl => 1); |
---|
[1044] | 44 | my $labase = $LA->base($base); |
---|
[861] | 45 | $labase && $labase->load or die "Cannot load base"; |
---|
| 46 | |
---|
| 47 | $labase->unexported(1); |
---|
| 48 | |
---|
| 49 | my ($from, $to) = @ARGV or pod2usage(); |
---|
| 50 | |
---|
| 51 | if ($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.