summaryrefslogtreecommitdiff
path: root/scripts/vyatta-qos.pl
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2009-06-11 16:55:29 -0700
committerStephen Hemminger <shemminger@lenny.localdomain>2009-10-01 13:51:20 -0700
commit4cd540436f0b946ca6b8206d7166c56094a6e9e4 (patch)
treed91578c7594725bf43c2f53307c60011af46fa77 /scripts/vyatta-qos.pl
parentba4170471de90b2a32abeff6b48ec13461e7f9b1 (diff)
downloadvyatta-cfg-qos-4cd540436f0b946ca6b8206d7166c56094a6e9e4.tar.gz
vyatta-cfg-qos-4cd540436f0b946ca6b8206d7166c56094a6e9e4.zip
Cleanup how qos-policy change detection works
The CLI end: node does work correctly, so don't need to go walking configuration manually Bug 4545 (cherry picked from commit 377896b296827e4d7c3c20debb3487605c45bbe3)
Diffstat (limited to 'scripts/vyatta-qos.pl')
-rwxr-xr-xscripts/vyatta-qos.pl34
1 files changed, 18 insertions, 16 deletions
diff --git a/scripts/vyatta-qos.pl b/scripts/vyatta-qos.pl
index 86b8fe2..e0a1b0f 100755
--- a/scripts/vyatta-qos.pl
+++ b/scripts/vyatta-qos.pl
@@ -192,12 +192,16 @@ sub interfaces_using {
foreach my $name ( getInterfaces() ) {
my $intf = new Vyatta::Interface($name);
next unless $intf;
- $config->setLevel($intf->path() . ' qos-policy');
+ my $level = $intf->path() . ' qos-policy';
+ $config->setLevel($level);
foreach my $direction ($config->listNodes()) {
my $cur = $config->returnValue($direction);
next unless $cur;
- push @inuse, $name if ($cur eq $policy);
+
+ # these are arguments to update_interface()
+ push @inuse, [ $name, $direction, $name ]
+ if ($cur eq $policy);
}
}
return @inuse;
@@ -224,19 +228,17 @@ sub create_policy {
# Configuration changed, reapply to all interfaces.
sub apply_policy {
- my $config = new Vyatta::Config;
-
- while ( my $name = shift ) {
- foreach my $device ( interfaces_using($name) ) {
- my $intf = new Vyatta::Interface($device);
-
- $config->setLevel( $intf->path() );
- foreach my $direction ( $config->listNodes('qos-policy') ) {
- next unless $config->exists("qos-policy $direction $name");
+ my ( $policy, $name ) = @_;
+ my @usedby = interfaces_using($name);
- update_interface( $device, $direction, $name );
- }
- }
+ if (@usedby) {
+ foreach my $args (@usedby) {
+ update_interface( @$args );
+ }
+ } else {
+ # Recheck the policy, might have new errors.
+ my $shaper = make_policy( $policy, $name );
+ exit 1 unless $shaper;
}
}
@@ -245,7 +247,7 @@ sub usage {
usage: vyatta-qos.pl --list-policy direction
vyatta-qos.pl --create-policy policy-type policy-name
vyatta-qos.pl --delete-policy policy-name
- vyatta-qos.pl --apply-policy policy-name
+ vyatta-qos.pl --apply-policy policy-type policy-name
vyatta-qos.pl --update-interface interface direction policy-name
vyatta-qos.pl --delete-interface interface direction
@@ -270,7 +272,7 @@ GetOptions(
"list-policy=s" => \@listPolicy,
"delete-policy=s" => \@deletePolicy,
"create-policy=s{2}" => \@createPolicy,
- "apply-policy=s" => \@applyPolicy,
+ "apply-policy=s{2}" => \@applyPolicy,
) or usage();
delete_interface(@deleteInterface) if ( $#deleteInterface == 1 );