summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2009-03-08 09:34:29 -0700
committerStephen Hemminger <stephen.hemminger@vyatta.com>2009-03-08 13:04:07 -0700
commit2e738a6404c640c2f6e4f54cb9ae19168434fc1d (patch)
treec7615b9722fb43dd4c89f5d5550f1ee21c33c08d
parent8c842f79fa884e9989cc9d024961a1810e56b589 (diff)
downloadvyatta-cfg-qos-2e738a6404c640c2f6e4f54cb9ae19168434fc1d.tar.gz
vyatta-cfg-qos-2e738a6404c640c2f6e4f54cb9ae19168434fc1d.zip
Fold name conflict checking into policy creation
Eliminate need for begin, just check for name conflicts at create.
-rwxr-xr-xscripts/vyatta-qos.pl23
-rw-r--r--templates/qos-policy/node.def1
2 files changed, 12 insertions, 12 deletions
diff --git a/scripts/vyatta-qos.pl b/scripts/vyatta-qos.pl
index 1182089..4a76d60 100755
--- a/scripts/vyatta-qos.pl
+++ b/scripts/vyatta-qos.pl
@@ -17,6 +17,7 @@
use lib "/opt/vyatta/share/perl5";
use Vyatta::Config;
use strict;
+use warnings;
use Getopt::Long;
@@ -82,7 +83,6 @@ sub list_policy {
}
print join( ' ', @nodes ), "\n";
- exit 0;
}
## delete_interface('eth0', 'out')
@@ -97,7 +97,7 @@ sub delete_interface {
} elsif (/^in$/) {
qx(sudo /sbin/tc qdisc del dev "$interface" parent ffff: 2>/dev/null);
} else {
- die "bad direction $direction";
+ croak "bad direction $direction";
}
}
}
@@ -293,10 +293,9 @@ sub delete_policy {
# can't delete active policy
die "Must delete QoS policy from interfaces before deleting rules\n";
}
- exit 0;
}
-sub check_conflict {
+sub name_conflict {
my $config = new Vyatta::Config;
my %other = ();
@@ -304,17 +303,22 @@ sub check_conflict {
foreach my $type ( $config->listNodes() ) {
foreach my $name ( $config->listNodes($type) ) {
my $conflict = $other{$name};
- die "Policy $name used by $conflict and $type\n" if ($conflict);
+ if ($conflict) {
+ warn "Policy $name used by $conflict and $type\n";
+ return $name;
+ }
$other{$name} = $type;
}
}
+ return;
}
sub create_policy {
my ($shaper, $name) = @_;
my $config = new Vyatta::Config;
- # Syntax check
+ exit 1 if name_conflict();
+
make_policy($config, $shaper, $name);
}
@@ -344,8 +348,7 @@ sub apply_changes {
sub usage {
print <<EOF;
-usage: vyatta-qos.pl --check
- vyatta-qos.pl --list-policy
+usage: vyatta-qos.pl --list-policy
vyatta-qos.pl --apply
vyatta-qos.pl --create-policy policy-type policy-name
@@ -362,10 +365,9 @@ my @updateInterface = ();
my @deleteInterface = ();
my @createPolicy = ();
-my ($check, $apply, $start);
+my ($apply, $start);
GetOptions(
- "check" => \$check,
"apply" => \$apply,
"start-interface=s" => \$start,
"update-interface=s{3}" => \@updateInterface,
@@ -377,7 +379,6 @@ GetOptions(
) or usage();
apply_changes() if $apply;
-check_conflict() if $check;
delete_interface(@deleteInterface) if ( $#deleteInterface == 1 );
update_interface(@updateInterface) if ( $#updateInterface == 2 );
diff --git a/templates/qos-policy/node.def b/templates/qos-policy/node.def
index 991b5f5..8651fd7 100644
--- a/templates/qos-policy/node.def
+++ b/templates/qos-policy/node.def
@@ -1,3 +1,2 @@
help: Configure Quality of Service (QOS) policy type
-begin: /opt/vyatta/sbin/vyatta-qos.pl --check
end: /opt/vyatta/sbin/vyatta-qos.pl --apply