summaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorBob Gilligan <gilligan@vyatta.com>2009-07-14 17:14:24 -0700
committerBob Gilligan <gilligan@vyatta.com>2009-07-14 17:18:18 -0700
commitec080f996602d4932d31563550e8287647fb05b7 (patch)
tree2ab4e4989cdb514d4bc2b428cb88d87ff1eccf79 /templates
parent814fa975cd96520b31746bfbca6c502b35ba89a3 (diff)
downloadvyatta-cfg-quagga-ec080f996602d4932d31563550e8287647fb05b7.tar.gz
vyatta-cfg-quagga-ec080f996602d4932d31563550e8287647fb05b7.zip
Bugfix 4708: Re-structure to avoid using "update" in non-leaf valueless nodes.
This change cleans up the bridging configuration, uses the new COMMIT_ACTION environment variable, and avoids using state files to pass information between templates.
Diffstat (limited to 'templates')
-rw-r--r--templates/interfaces/ethernet/node.tag/bridge-group/bridge/node.def5
-rw-r--r--templates/interfaces/ethernet/node.tag/bridge-group/cost/node.def2
-rw-r--r--templates/interfaces/ethernet/node.tag/bridge-group/node.def63
-rw-r--r--templates/interfaces/ethernet/node.tag/bridge-group/priority/node.def2
-rw-r--r--templates/interfaces/ethernet/node.tag/vif/node.tag/bridge-group/bridge/node.def5
-rw-r--r--templates/interfaces/ethernet/node.tag/vif/node.tag/bridge-group/cost/node.def2
-rw-r--r--templates/interfaces/ethernet/node.tag/vif/node.tag/bridge-group/node.def65
-rw-r--r--templates/interfaces/ethernet/node.tag/vif/node.tag/bridge-group/priority/node.def2
8 files changed, 102 insertions, 44 deletions
diff --git a/templates/interfaces/ethernet/node.tag/bridge-group/bridge/node.def b/templates/interfaces/ethernet/node.tag/bridge-group/bridge/node.def
index 3e562f7f..a4014a29 100644
--- a/templates/interfaces/ethernet/node.tag/bridge-group/bridge/node.def
+++ b/templates/interfaces/ethernet/node.tag/bridge-group/bridge/node.def
@@ -1,6 +1,9 @@
type: txt
+
help: Set this interface to a bridge-group
+
commit:expression: exec \
"/opt/vyatta/sbin/vyatta-interfaces.pl --dev=$VAR(@) --check=bridge"
+
allowed: /opt/vyatta/sbin/vyatta-interfaces.pl --show=bridge
-delete: echo $VAR(@) > /tmp/bridge-no.$PPID
+
diff --git a/templates/interfaces/ethernet/node.tag/bridge-group/cost/node.def b/templates/interfaces/ethernet/node.tag/bridge-group/cost/node.def
index ef2d9940..f90f4769 100644
--- a/templates/interfaces/ethernet/node.tag/bridge-group/cost/node.def
+++ b/templates/interfaces/ethernet/node.tag/bridge-group/cost/node.def
@@ -1,4 +1,6 @@
type: u32
+
help: Set the path cost for this port
+
comp_help: possible completions:
<0-2147483647> Set port cost
diff --git a/templates/interfaces/ethernet/node.tag/bridge-group/node.def b/templates/interfaces/ethernet/node.tag/bridge-group/node.def
index fbff9acd..5ea9da19 100644
--- a/templates/interfaces/ethernet/node.tag/bridge-group/node.def
+++ b/templates/interfaces/ethernet/node.tag/bridge-group/node.def
@@ -1,25 +1,46 @@
help: Add this interface to a bridge group
-create: sudo brctl addif $VAR(./bridge/@) $VAR(../@);
-update:expression: "false"; \
- "Delete previous bridge group first"
+end:
+ ethif=$VAR(../@)
+ oldbridge=`/opt/vyatta/sbin/vyatta-cli-expand-var.pl \$\(/interfaces/ethernet/$ethif/bridge-group/bridge/@\)`
+ newbridge="$VAR(./bridge/@)"
+
+ if [ ${COMMIT_ACTION} = 'SET' ]; then
+ if [ -z "$newbridge" ]; then
+ echo "Must specify bridge name."
+ exit 1
+ else
+ echo "Adding interface $ethif to bridge $newbridge."
+ sudo brctl addif $newbridge $ethif;
+
+ if [ -n "$VAR(./cost/@)" ]; then
+ sudo brctl setpathcost $newbridge $ethif $VAR(./cost/@);
+ fi;
+ if [ -n "$VAR(./priority/@)" ]; then
+ sudo brctl setportprio $newbridge $ethif $VAR(./priority/@);
+ fi
+ fi
+ elif [ ${COMMIT_ACTION} = 'DELETE' ]; then
+ echo "Removing interface $ethif from bridge $oldbridge."
+ sudo brctl delif $oldbridge $ethif
+ else
+ if [ -z "$newbridge" ]; then
+ echo "Must specify bridge name."
+ exit 1
+ else
+ if [ "$oldbridge" != "$newbridge" ]; then
+ echo "Removing interface $ethif from bridge $oldbridge and adding it to $newbridge."
+ sudo brctl delif $oldbridge $ethif
+ sudo brctl addif $newbridge $ethif
+ fi
+ if [ -n "$VAR(./cost/@)" ]; then
+ sudo brctl setpathcost $newbridge $ethif $VAR(./cost/@)
+ fi
+ if [ -n "$VAR(./priority/@)" ]; then
+ sudo brctl setportprio $newbridge $ethif $VAR(./priority/@)
+ fi
+ fi
+ fi
+ exit 0
-delete: touch /tmp/eth-$VAR(../@)-bridge.$PPID;
-end: if [ -f "/tmp/eth-$VAR(../@)-bridge.$PPID" ]; then
- rm -f /tmp/eth-$VAR(../@)-bridge.$PPID;
- brno=$(cat /tmp/bridge-no.$PPID);
- sudo brctl delif $brno $VAR(../@);
- rm -f /tmp/bridge-no.$PPID;
- else
- if [ -z "$VAR(./bridge/@)" ]; then
- echo "Must set the bridge interface";
- exit 1;
- fi;
- if [ -n "$VAR(./cost/@)" ]; then
- sudo brctl setpathcost $VAR(./bridge/@) $VAR(../@) $VAR(./cost/@);
- fi;
- if [ -n "$VAR(./priority/@)" ]; then
- sudo brctl setportprio $VAR(./bridge/@) $VAR(../@) $VAR(./priority/@);
- fi;
- fi;
diff --git a/templates/interfaces/ethernet/node.tag/bridge-group/priority/node.def b/templates/interfaces/ethernet/node.tag/bridge-group/priority/node.def
index 8688c394..5c11ec4f 100644
--- a/templates/interfaces/ethernet/node.tag/bridge-group/priority/node.def
+++ b/templates/interfaces/ethernet/node.tag/bridge-group/priority/node.def
@@ -1,4 +1,6 @@
type: u32
+
help: Set the path priority for this port
+
comp_help: possible completions:
<0-255> Set port priority
diff --git a/templates/interfaces/ethernet/node.tag/vif/node.tag/bridge-group/bridge/node.def b/templates/interfaces/ethernet/node.tag/vif/node.tag/bridge-group/bridge/node.def
index b340ac5b..a4014a29 100644
--- a/templates/interfaces/ethernet/node.tag/vif/node.tag/bridge-group/bridge/node.def
+++ b/templates/interfaces/ethernet/node.tag/vif/node.tag/bridge-group/bridge/node.def
@@ -1,6 +1,9 @@
type: txt
+
help: Set this interface to a bridge-group
+
commit:expression: exec \
"/opt/vyatta/sbin/vyatta-interfaces.pl --dev=$VAR(@) --check=bridge"
+
allowed: /opt/vyatta/sbin/vyatta-interfaces.pl --show=bridge
-delete: echo $VAR(@) > /tmp/vifbridge-no.$PPID \ No newline at end of file
+
diff --git a/templates/interfaces/ethernet/node.tag/vif/node.tag/bridge-group/cost/node.def b/templates/interfaces/ethernet/node.tag/vif/node.tag/bridge-group/cost/node.def
index ef2d9940..f90f4769 100644
--- a/templates/interfaces/ethernet/node.tag/vif/node.tag/bridge-group/cost/node.def
+++ b/templates/interfaces/ethernet/node.tag/vif/node.tag/bridge-group/cost/node.def
@@ -1,4 +1,6 @@
type: u32
+
help: Set the path cost for this port
+
comp_help: possible completions:
<0-2147483647> Set port cost
diff --git a/templates/interfaces/ethernet/node.tag/vif/node.tag/bridge-group/node.def b/templates/interfaces/ethernet/node.tag/vif/node.tag/bridge-group/node.def
index 7e33b9d5..b36ad085 100644
--- a/templates/interfaces/ethernet/node.tag/vif/node.tag/bridge-group/node.def
+++ b/templates/interfaces/ethernet/node.tag/vif/node.tag/bridge-group/node.def
@@ -1,25 +1,48 @@
help: Add this interface to a bridge group
-create: sudo brctl addif $VAR(./bridge/@) $VAR(../../@).$VAR(../@);
-update:expression: "false"; \
- "Delete previous bridge group first"
+end:
+ eth=$VAR(../../@)
+ vif=$VAR(../@)
+ ethif=$eth.$vif
+ oldbridge=`/opt/vyatta/sbin/vyatta-cli-expand-var.pl \$\(/interfaces/ethernet/$eth/vif/$vif/bridge-group/bridge/@\)`
+ newbridge="$VAR(./bridge/@)"
+
+ if [ ${COMMIT_ACTION} = 'SET' ]; then
+ if [ -z "$newbridge" ]; then
+ echo "Must specify bridge name."
+ exit 1
+ else
+ echo "Adding interface $ethif to bridge $newbridge."
+ sudo brctl addif $newbridge $ethif;
+
+ if [ -n "$VAR(./cost/@)" ]; then
+ sudo brctl setpathcost $newbridge $ethif $VAR(./cost/@);
+ fi;
+ if [ -n "$VAR(./priority/@)" ]; then
+ sudo brctl setportprio $newbridge $ethif $VAR(./priority/@);
+ fi
+ fi
+ elif [ ${COMMIT_ACTION} = 'DELETE' ]; then
+ echo "Removing interface $ethif from bridge $oldbridge."
+ sudo brctl delif $oldbridge $ethif
+ else
+ if [ -z "$newbridge" ]; then
+ echo "Must specify bridge name."
+ exit 1
+ else
+ if [ "$oldbridge" != "$newbridge" ]; then
+ echo "Removing interface $ethif from bridge $oldbridge and adding it to $newbridge."
+ sudo brctl delif $oldbridge $ethif
+ sudo brctl addif $newbridge $ethif
+ fi
+ if [ -n "$VAR(./cost/@)" ]; then
+ sudo brctl setpathcost $newbridge $ethif $VAR(./cost/@)
+ fi
+ if [ -n "$VAR(./priority/@)" ]; then
+ sudo brctl setportprio $newbridge $ethif $VAR(./priority/@)
+ fi
+ fi
+ fi
+ exit 0
-delete: touch /tmp/eth-$VAR(../@)-bridge.$PPID;
-end: if [ -f "/tmp/eth-$VAR(../@)-bridge.$PPID" ]; then
- rm -f /tmp/eth-$VAR(../@)-bridge.$PPID;
- brno=$(cat /tmp/vifbridge-no.$PPID);
- sudo brctl delif $brno $VAR(../../@).$VAR(../@);
- rm -f /tmp/bridge-no.$PPID;
- else
- if [ -z "$VAR(./bridge/@)" ]; then
- echo "Must set the bridge interface";
- exit 1;
- fi;
- if [ -n "$VAR(./cost/@)" ]; then
- sudo brctl setpathcost $VAR(./bridge/@) $VAR(../../@).$VAR(../@) $VAR(./cost/@);
- fi;
- if [ -n "$VAR(./priority/@)" ]; then
- sudo brctl setportprio $VAR(./bridge/@) $VAR(../../@).$VAR(../@) $VAR(./priority/@);
- fi;
- fi;
diff --git a/templates/interfaces/ethernet/node.tag/vif/node.tag/bridge-group/priority/node.def b/templates/interfaces/ethernet/node.tag/vif/node.tag/bridge-group/priority/node.def
index 8688c394..5c11ec4f 100644
--- a/templates/interfaces/ethernet/node.tag/vif/node.tag/bridge-group/priority/node.def
+++ b/templates/interfaces/ethernet/node.tag/vif/node.tag/bridge-group/priority/node.def
@@ -1,4 +1,6 @@
type: u32
+
help: Set the path priority for this port
+
comp_help: possible completions:
<0-255> Set port priority