From 4cd540436f0b946ca6b8206d7166c56094a6e9e4 Mon Sep 17 00:00:00 2001
From: Stephen Hemminger <stephen.hemminger@vyatta.com>
Date: Thu, 11 Jun 2009 16:55:29 -0700
Subject: 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)
---
 templates/qos-policy/drop-tail/node.def | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'templates/qos-policy/drop-tail/node.def')

diff --git a/templates/qos-policy/drop-tail/node.def b/templates/qos-policy/drop-tail/node.def
index 111bb63..49561c3 100644
--- a/templates/qos-policy/drop-tail/node.def
+++ b/templates/qos-policy/drop-tail/node.def
@@ -3,6 +3,6 @@ type: txt
 help: Set drop tail queue (FIFO) policy
 syntax:expression: pattern $VAR(@) "^[[:alnum:]][-_[:alnum:]]*$"
                    ; "only alpha-numeric policy name allowed"
-create: /opt/vyatta/sbin/vyatta-qos.pl --create-policy "$VAR(.)" "$VAR(@)"
-delete: /opt/vyatta/sbin/vyatta-qos.pl --delete-policy "$VAR(@)"
-end: /opt/vyatta/sbin/vyatta-qos.pl --apply-policy "$VAR(@)"
+create: /opt/vyatta/sbin/vyatta-qos.pl --create-policy $VAR(.) $VAR(@)
+delete: /opt/vyatta/sbin/vyatta-qos.pl --delete-policy $VAR(@)
+end: /opt/vyatta/sbin/vyatta-qos.pl --apply-policy $VAR(.) $VAR(@)
-- 
cgit v1.2.3


From 83aef96b5eefe8c851f3cac7492b71eed3afe51b Mon Sep 17 00:00:00 2001
From: Stephen Hemminger <stephen.hemminger@vyatta.com>
Date: Mon, 15 Jun 2009 11:34:44 -0700
Subject: Fix update (apply-policy) at end

The $VAR(.) is not set on end node, so have to go hunting
for policy type.

Related to Bug 4545
(cherry picked from commit 39712bfaf390a4435218a14308cc6efa1a2d39b8)
---
 scripts/vyatta-qos.pl                          | 25 ++++++++++++++-----------
 templates/qos-policy/drop-tail/node.def        |  2 +-
 templates/qos-policy/fair-queue/node.def       |  2 +-
 templates/qos-policy/network-emulator/node.def |  2 +-
 templates/qos-policy/random-detect/node.def    |  2 +-
 templates/qos-policy/rate-limit/node.def       |  2 +-
 templates/qos-policy/round-robin/node.def      |  2 +-
 templates/qos-policy/traffic-limiter/node.def  |  2 +-
 templates/qos-policy/traffic-shaper/node.def   |  2 +-
 9 files changed, 22 insertions(+), 19 deletions(-)

(limited to 'templates/qos-policy/drop-tail/node.def')

diff --git a/scripts/vyatta-qos.pl b/scripts/vyatta-qos.pl
index e0a1b0f..2576af1 100755
--- a/scripts/vyatta-qos.pl
+++ b/scripts/vyatta-qos.pl
@@ -228,17 +228,20 @@ sub create_policy {
 
 # Configuration changed, reapply to all interfaces.
 sub apply_policy {
-    my ( $policy, $name ) = @_;
-    my @usedby = interfaces_using($name);
-
-    if (@usedby) {
-	foreach my $args (@usedby) {
-	    update_interface( @$args );
+    while (my $name = shift) {
+	my @usedby = interfaces_using($name);
+	if (@usedby) {
+	    foreach my $args (@usedby) {
+		update_interface( @$args );
+	    }
+	} else {
+	    # Recheck the policy, might have new errors.
+	    my $policy = find_policy($name);
+	    die "Unknown policy name $name\n" unless $policy;
+
+	    my $shaper = make_policy( $policy, $name );
+	    exit 1 unless $shaper;
 	}
-    } else {
-	# Recheck the policy, might have new errors.
-	my $shaper = make_policy( $policy, $name );
-	exit 1 unless $shaper;
     }
 }
 
@@ -272,7 +275,7 @@ GetOptions(
     "list-policy=s"      => \@listPolicy,
     "delete-policy=s"    => \@deletePolicy,
     "create-policy=s{2}" => \@createPolicy,
-    "apply-policy=s{2}"  => \@applyPolicy,
+    "apply-policy=s"     => \@applyPolicy,
 ) or usage();
 
 delete_interface(@deleteInterface) if ( $#deleteInterface == 1 );
diff --git a/templates/qos-policy/drop-tail/node.def b/templates/qos-policy/drop-tail/node.def
index 49561c3..1bbb25f 100644
--- a/templates/qos-policy/drop-tail/node.def
+++ b/templates/qos-policy/drop-tail/node.def
@@ -5,4 +5,4 @@ syntax:expression: pattern $VAR(@) "^[[:alnum:]][-_[:alnum:]]*$"
                    ; "only alpha-numeric policy name allowed"
 create: /opt/vyatta/sbin/vyatta-qos.pl --create-policy $VAR(.) $VAR(@)
 delete: /opt/vyatta/sbin/vyatta-qos.pl --delete-policy $VAR(@)
-end: /opt/vyatta/sbin/vyatta-qos.pl --apply-policy $VAR(.) $VAR(@)
+end: /opt/vyatta/sbin/vyatta-qos.pl --apply-policy $VAR(@)
diff --git a/templates/qos-policy/fair-queue/node.def b/templates/qos-policy/fair-queue/node.def
index 15b995a..9af92ed 100644
--- a/templates/qos-policy/fair-queue/node.def
+++ b/templates/qos-policy/fair-queue/node.def
@@ -5,4 +5,4 @@ syntax:expression: pattern $VAR(@) "^[[:alnum:]][-_[:alnum:]]*$"
                    ; "only alpha-numeric policy name allowed"
 create: /opt/vyatta/sbin/vyatta-qos.pl --create-policy $VAR(.) $VAR(@)
 delete: /opt/vyatta/sbin/vyatta-qos.pl --delete-policy $VAR(@)
-end: /opt/vyatta/sbin/vyatta-qos.pl --apply-policy $VAR(.) $VAR(@)"
+end: /opt/vyatta/sbin/vyatta-qos.pl --apply-policy $VAR(@)"
diff --git a/templates/qos-policy/network-emulator/node.def b/templates/qos-policy/network-emulator/node.def
index 2f383f8..9a89c53 100644
--- a/templates/qos-policy/network-emulator/node.def
+++ b/templates/qos-policy/network-emulator/node.def
@@ -5,4 +5,4 @@ syntax:expression: pattern $VAR(@) "^[[:alnum:]][-_[:alnum:]]*$"
                    ; "only alpha-numeric policy name allowed"
 create: /opt/vyatta/sbin/vyatta-qos.pl --create-policy $VAR(.) $VAR(@)
 delete: /opt/vyatta/sbin/vyatta-qos.pl --delete-policy $VAR(@)
-end: /opt/vyatta/sbin/vyatta-qos.pl --apply-policy $VAR(.) $VAR(@)
+end: /opt/vyatta/sbin/vyatta-qos.pl --apply-policy $VAR(@)
diff --git a/templates/qos-policy/random-detect/node.def b/templates/qos-policy/random-detect/node.def
index f6da04a..7dc1caa 100644
--- a/templates/qos-policy/random-detect/node.def
+++ b/templates/qos-policy/random-detect/node.def
@@ -5,4 +5,4 @@ syntax:expression: pattern $VAR(@) "^[[:alnum:]][-_[:alnum:]]*$"
                    ; "only alpha-numeric policy name allowed"
 create: /opt/vyatta/sbin/vyatta-qos.pl --create-policy $VAR(.) $VAR(@)
 delete: /opt/vyatta/sbin/vyatta-qos.pl --delete-policy $VAR(@)
-end: /opt/vyatta/sbin/vyatta-qos.pl --apply-policy $VAR(.) $VAR(@)
+end: /opt/vyatta/sbin/vyatta-qos.pl --apply-policy $VAR(@)
diff --git a/templates/qos-policy/rate-limit/node.def b/templates/qos-policy/rate-limit/node.def
index 6da6f67..57bf98e 100644
--- a/templates/qos-policy/rate-limit/node.def
+++ b/templates/qos-policy/rate-limit/node.def
@@ -5,4 +5,4 @@ syntax:expression: pattern $VAR(@) "^[[:alnum:]][-_[:alnum:]]*$"
                    ; "only alpha-numeric policy name allowed"
 create: /opt/vyatta/sbin/vyatta-qos.pl --create-policy $VAR(.) $VAR(@)
 delete: /opt/vyatta/sbin/vyatta-qos.pl --delete-policy $VAR(@)
-end: /opt/vyatta/sbin/vyatta-qos.pl --apply-policy $VAR(.) $VAR(@)
+end: /opt/vyatta/sbin/vyatta-qos.pl --apply-policy $VAR(@)
diff --git a/templates/qos-policy/round-robin/node.def b/templates/qos-policy/round-robin/node.def
index 6d15978..4427e1a 100644
--- a/templates/qos-policy/round-robin/node.def
+++ b/templates/qos-policy/round-robin/node.def
@@ -5,4 +5,4 @@ syntax:expression: pattern $VAR(@) "^[[:alnum:]][-_[:alnum:]]*$"
                    ; "only alpha-numeric policy name allowed"
 create: /opt/vyatta/sbin/vyatta-qos.pl --create-policy $VAR(.) $VAR(@)
 delete: /opt/vyatta/sbin/vyatta-qos.pl --delete-policy $VAR(@)
-end: /opt/vyatta/sbin/vyatta-qos.pl --apply-policy $VAR(.) $VAR(@)
+end: /opt/vyatta/sbin/vyatta-qos.pl --apply-policy $VAR(@)
diff --git a/templates/qos-policy/traffic-limiter/node.def b/templates/qos-policy/traffic-limiter/node.def
index 38bd516..f8bdf26 100644
--- a/templates/qos-policy/traffic-limiter/node.def
+++ b/templates/qos-policy/traffic-limiter/node.def
@@ -5,4 +5,4 @@ syntax:expression: pattern $VAR(@) "^[[:alnum:]][-_[:alnum:]]*$"
                    ; "only alpha-numeric policy name allowed"
 create: /opt/vyatta/sbin/vyatta-qos.pl --create-policy $VAR(.) $VAR(@)
 delete: /opt/vyatta/sbin/vyatta-qos.pl --delete-policy $VAR(@)
-end: /opt/vyatta/sbin/vyatta-qos.pl --apply-policy $VAR(.) $VAR(@)
+end: /opt/vyatta/sbin/vyatta-qos.pl --apply-policy $VAR(@)
diff --git a/templates/qos-policy/traffic-shaper/node.def b/templates/qos-policy/traffic-shaper/node.def
index 4c7b73c..cd7b07d 100644
--- a/templates/qos-policy/traffic-shaper/node.def
+++ b/templates/qos-policy/traffic-shaper/node.def
@@ -5,4 +5,4 @@ syntax:expression: pattern $VAR(@) "^[[:alnum:]][-_[:alnum:]]*$"
                    ; "only alpha-numeric policy name allowed"
 create: /opt/vyatta/sbin/vyatta-qos.pl --create-policy $VAR(.) $VAR(@)
 delete: /opt/vyatta/sbin/vyatta-qos.pl --delete-policy $VAR(@)
-end: /opt/vyatta/sbin/vyatta-qos.pl --apply-policy $VAR(.) $VAR(@)
+end: /opt/vyatta/sbin/vyatta-qos.pl --apply-policy $VAR(@)
-- 
cgit v1.2.3

