summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/vyatta-bonding.pl14
-rw-r--r--templates/interfaces/ethernet/node.tag/bond-group/node.def18
2 files changed, 15 insertions, 17 deletions
diff --git a/scripts/vyatta-bonding.pl b/scripts/vyatta-bonding.pl
index b9ea0bcf..3012c5f9 100755
--- a/scripts/vyatta-bonding.pl
+++ b/scripts/vyatta-bonding.pl
@@ -73,9 +73,10 @@ sub get_slaves {
sub add_slave {
my ( $intf, $slave ) = @_;
+ my $sysfs_slaves = "/sys/class/net/$intf/bonding/slaves";
- open my $f, '>', "/sys/class/net/$intf/bonding/slaves"
- or die "$intf is not a bonding interface";
+ open my $f, '>', $sysfs_slaves
+ or die "Can't open $sysfs_slaves: $!";
print {$f} "+$slave\n";
close $f;
@@ -83,9 +84,10 @@ sub add_slave {
sub remove_slave {
my ( $intf, $slave ) = @_;
+ my $sysfs_slaves = "/sys/class/net/$intf/bonding/slaves";
- open my $f, '>', "/sys/class/net/$intf/bonding/slaves"
- or die "$intf is not a bonding interface";
+ open my $f, '>', $sysfs_slaves
+ or die "Can't open $sysfs_slaves: $!";
print {$f} "-$slave\n";
close $f;
@@ -170,8 +172,8 @@ sub add_port {
sub usage {
print "Usage: $0 --dev=bondX --mode={mode}\n";
- print " $0 --dev=bondX --add-port=ethX\n";
- print " $0 --dev=bondX --remove-port=ethX\n";
+ print " $0 --dev=bondX --add=ethX\n";
+ print " $0 --dev=bondX --remove=ethX\n";
print print "modes := ", join( ',', sort( keys %modes ) ), "\n";
exit 1;
diff --git a/templates/interfaces/ethernet/node.tag/bond-group/node.def b/templates/interfaces/ethernet/node.tag/bond-group/node.def
index d2a398a1..f65a9bde 100644
--- a/templates/interfaces/ethernet/node.tag/bond-group/node.def
+++ b/templates/interfaces/ethernet/node.tag/bond-group/node.def
@@ -3,14 +3,10 @@ help: Add this interface to a bonding group
commit:expression: exec \
"/opt/vyatta/sbin/vyatta-interfaces.pl --dev=$VAR(@) --check=bonding"
allowed: /opt/vyatta/sbin/vyatta-interfaces.pl --show=bonding
-end: ethif=$VAR(../@)
- old=`/opt/vyatta/sbin/vyatta-cli-expand-var.pl \$\(/interfaces/ethernet/$ethif/bond-group/@\)`
- new=$VAR(@)
- if [ ${COMMIT_ACTION} = 'SET' ]; then
- sudo ${vyatta_sbindir}/vyatta-bonding.pl --dev=$new --add=$ethif
- elif [ ${COMMIT_ACTION} = 'DELETE' ]; then
- sudo ${vyatta_sbindir}/vyatta-bonding.pl --dev=$new --remove=$ethif
- elif [ "$old" != "$new" ]; then
- sudo ${vyatta_sbindir}/vyatta-bonding.pl --dev=$old --remove=$ethif
- sudo ${vyatta_sbindir}/vyatta-bonding.pl --dev=$new --add=$ethif
- fi
+update: eth=$VAR(../@); new=$VAR(@)
+ old=`/opt/vyatta/sbin/vyatta-cli-expand-var.pl \$\(/interfaces/ethernet/$ethif/bond-group/@\)`
+ if [ -n "$old" ]; then
+ sudo ${vyatta_sbindir}/vyatta-bonding.pl --dev=$old --remove=$ethif
+ fi
+ sudo ${vyatta_sbindir}/vyatta-bonding.pl --dev=$new --add=$ethif
+delete: sudo ${vyatta_sbindir}/vyatta-bonding.pl --dev=$new --remove=$ethif