Commit 9d1a59fd authored by Christian Hesse's avatar Christian Hesse

bridge-port-to-default: get bridge port values into array

parent 2f22e06b
......@@ -13,18 +13,17 @@
:set Len ([ :len $BridgePortTo ] + 1);
}
:foreach Interface in=[ / interface bridge port find where comment!="" ] do={
:foreach Comment in=[ :toarray [ / interface bridge port get $Interface comment ] ] do={
:foreach BridgePort in=[ / interface bridge port find where comment!="" ] do={
:local BridgePortVal [ / interface bridge port get $BridgePort ];
:foreach Comment in=[ :toarray ($BridgePortVal->"comment") ] do={
:if ([ :pick $Comment 0 $Len ] = ($BridgePortTo . ":")) do={
:local InterfaceName [ / interface bridge port get $Interface interface ];
:local BridgeDefault [ :pick $Comment $Len [ :len $Comment ] ];
:local BridgeCurrent [ / interface bridge port get $Interface bridge ];
:if ($BridgeDefault != $BridgeCurrent) do={
:log info ("Changing interface " . $InterfaceName . " to " . $BridgePortTo . " bridge " . $BridgeDefault);
/ interface bridge port set bridge=$BridgeDefault $Interface;
:if ($BridgeDefault != $BridgePortVal->"bridge") do={
:log info ("Changing interface " . $BridgePortVal->"interface" . " to " . $BridgePortTo . " bridge " . $BridgeDefault);
/ interface bridge port set bridge=$BridgeDefault $BridgePort;
/ ip dhcp-client renew [ find where interface=$BridgeDefault ];
} else={
:log debug ("Interface " . $InterfaceName . " already connected to " . $BridgePortTo . " bridge " . $BridgeDefault);
:log debug ("Interface " . $BridgePortVal->"interface" . " already connected to " . $BridgePortTo . " bridge " . $BridgeDefault);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment