#!/usr/bin/perl use strict; use warnings; use LATMOS::Accounts; use Getopt::Long; use Pod::Usage; =head1 NAME la-sql-exchange-ip - Exchange IP between two host =head1 SYNOPSIS la-sql-exchange-ip ip1 ip2 Example : la-sql-exchange-ip 172.1.2.3 192.168.3.2 =cut GetOptions( 'c|config=s' => \my $config, 'b|base=s' => \my $base, 'help' => sub { pod2usage(0) }, ) or pod2usage(); =head1 OPTIONS =over 4 =item -c|--config configdir Use this configuration directory instead of the default one. =item -b|--base basename Query this specific base instead of the default one. =back =cut my $LA = LATMOS::Accounts->new($config, noacl => 1); my $labase = $LA->base($base); $labase && $labase->load or die "Cannot load base"; $labase->unexported(1); my ($from, $to) = @ARGV or pod2usage(); if ($labase->nethost_exchange_ip($from, $to)) { $labase->commit; print "IP succesfully exchange between $from and $to\n"; exit(0); } else { warn "Error while exchanging ip\n"; exit(1); }