blob: 2b5b05ac1f041d9ca6a81b8c87bed3d700003eb6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#!/usr/bin/perl
use lib "/opt/vyatta/share/perl5/";
use VyattaConfig;
use VyattaMisc;
use NetAddr::IP;
use Getopt::Long;
GetOptions("check-prefix-boundry=s" => \$prefix,
"not-exists=s" => \$notexists,
"exists=s" => \$exists,
);
if (defined $prefix) { check_prefix_boundry($prefix); }
if (defined $notexists) { check_not_exists($notexists); }
if (defined $exists) { check_exists($exists); }
exit 0;
sub check_prefix_boundry() {
my $prefix = shift;
my $net, $cidr;
$net = new NetAddr::IP $prefix;
$cidr = $net->network();
if ( "$cidr" ne "$prefix" ) {
print "Your prefix must fall on a natural network boundry. Did you mean $cidr?\n";
exit 1;
}
exit 0;
}
sub check_exists() {
my $node = shift;
my $config = new VyattaConfig;
if ( $config->exists("$node") ) {
exit 0;
}
exit 1;
}
sub check_not_exists() {
my $node = shift;
my $config = new VyattaConfig;
if (! $config->exists("$node") ) {
exit 0;
}
exit 1;
}
|