NOC:ctwug lobridge fixer
From CTWUG Wiki
Purpose
- renames bridges with the name 'iobridge' to 'lobridge'
- adds a lobridge if it isn't present
- if no ip address is assigned to lobridge, chooses an OSPF ip from the backbone network and adds that to lobridge
Dependencies
None
Script
:foreach iobridge in=[/interface bridge find name=iobridge] do={
/interface bridge set $iobridge name=lobridge;
}
:if ([:len [/interface bridge find name=lobridge]]=0) do={
log info "creating lobridge";
/interface bridge add name=lobridge;
}
:if ([:len [/ip address find interface=lobridge]]=0) do={
:local backbonearea [/routing ospf area get [/routing ospf area find area-id=0.0.0.0] name]
log info ("checking backbonearea (".$backbonearea.")");
:local ospfip ""
:foreach backbone in=[/routing ospf network find area=$backbonearea] do={
:local bbnet [/routing ospf network get $backbone network]
log info ("checking bbnet (".$bbnet.")");
:for i from=0 to=([:len $bbnet] - 1) do={
:if ( [:pick $bbnet $i] = "/") do={
:local tmp [:pick $bbnet 0 $i]
:set bbnet $tmp;
}
}
log info ("checking bbnet (".$bbnet.")");
:set ospfip [/ip address get [/ip address find network=$bbnet] address]
}
:for i from=0 to=([:len $ospfip] - 1) do={
:if ( [:pick $ospfip $i] = "/") do={
:local tmp [:pick $ospfip 0 $i]
:set ospfip $tmp;
}
}
log info ("current ospf ip (".$ospfip.")");
/ip address add address=($ospfip."/32") interface=lobridge
}