summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAn-Cheng Huang <ancheng@vyatta.com>2008-01-29 15:10:59 -0800
committerAn-Cheng Huang <ancheng@vyatta.com>2008-01-29 15:10:59 -0800
commitf2b473bf4b904635b48489203540a644082aada5 (patch)
tree3613a4afda5f169a4ecb346b98fad46f6f9ad2e0
parentea71d73edf181b5f7c9e645cf7e5bc3f0c6a3788 (diff)
downloadvyatta-cluster-f2b473bf4b904635b48489203540a644082aada5.tar.gz
vyatta-cluster-f2b473bf4b904635b48489203540a644082aada5.zip
allow full IP specification (IP/prefix/interface/broadcast) for cluster
resource (service).
-rw-r--r--scripts/VyattaClusterConfig.pm23
1 files changed, 22 insertions, 1 deletions
diff --git a/scripts/VyattaClusterConfig.pm b/scripts/VyattaClusterConfig.pm
index affb3e8..292a7f6 100644
--- a/scripts/VyattaClusterConfig.pm
+++ b/scripts/VyattaClusterConfig.pm
@@ -229,6 +229,27 @@ EOS
return ($str, undef);
}
+sub isValidIPSpec {
+ my $str = shift;
+ my @comps = split /\//, $str;
+ return 0 if ($#comps > 3);
+ return 0 if (!isValidIPv4($comps[0]));
+ # check optional prefix len
+ if (defined($comps[1])) {
+ return 0 if (!($comps[1] =~ m/^\d+$/));
+ return 0 if (($comps[1] > 32) || ($comps[1] < 0));
+ }
+ # check optional interface
+ if (defined($comps[2])) {
+ return 0 if (defined(check_interfaces($comps[2])));
+ }
+ # check optional broadcast addr
+ if (defined($comps[3])) {
+ return 0 if (!isValidIPv4($comps[3]));
+ }
+ return 1;
+}
+
sub isValidIPv4 {
my $str = shift;
return 0 if (!($str =~ m/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/));
@@ -263,7 +284,7 @@ sub haresources {
my @init_services = ();
my @ip_addresses = ();
foreach (@{$hashref->{_service}}) {
- if (!isValidIPv4($_)) {
+ if (!isValidIPSpec($_)) {
if (isValidService($_)) {
push @init_services, $_;
} else {