Working on an initial configuration script that can be uploaded to a switch through winbox and applied upon reset of configuration. The script has some variables at the top to build out the vlan database, settings and so on. Everything in the script works except adding the pvid to the ether ports. There is some strange behavior on a selector, but only when its being used with a set on the port command.
Lines 59 and 60 work as expected and assign the ports to the bridge.
# Assign Ports to Bridge
:foreach i in=[/interface/find default-name~"ether"] do={ /interface/bridge/port/add bridge=$BridgeName interface=$i }
:foreach i in=[/interface/find default-name~"sfp"] do={ /interface/bridge/port/add bridge=$BridgeName interface=$i }
Lines 68 and 69 uses the same selector, but skips “ether1” and includes “sfp-sfpplus1”
Hardware I’m testing on is a CRS328-24P-4S+ running 7.11.2 with the firmware matching. I have attached the script if anyone is interested. InitialConfiguration.rsc (2.51 KB)
The correct way is something like this:
:if ($ConfigAccess) do={
:foreach ifIndex in=[/interface find where default-name~“ether”] do={
:local ifName [/interface get $ifIndex name]
/interface bridge port set [find where bridge=$BridgeName and interface=$ifName] pvid=$AccessVLAN frame-types=admit-only-untagged-and-priority-tagged
}
}
I suspect the “:if ($ConfigAccess = true)” is the cause… if $ConfigAccess is not defined with a type of bool, that won’t work. Note the difference in @rextended version where it will “cast” any type to a bool vs explicitly looking for boolean “true” in the variable.
It’s one thing to write a complaint needlessly.
It loses meaning, indeed it becomes ridiculous for those who write it, if the reason is not explained.
My goal was to force you to pay attention to the answer, I don’t make perfect scripts either,
but it’s ridiculous if someone complains about it without explaining why and how it should have been done…
I truly have nothing but respect for the knowledge you possess, where I feel there could be a change is in the initial interactions you have with individuals. Starting with words like vomit as to what someone is trying to accomplish is generally looked at as insulting. I had a genuine question, did not understand that the index was being returned and not the name, you provided an answer, which i am grateful for and have learned from, but the initial interaction was interpreted as insulting. Do you care, probably not, do I care if you care, not really either.
Again, thank you for your assistance and look forward to learning more from the plethora of scripts you have graced the community with.
Don’t worry, I’m not offended, there are other things that offend me…
As I was telling you, by drawing attention at the beginning, the user are more likely to understand what is written next, for various reasons that I won’t list now