I am trying to write scripts to control my Internal ↔ external traffic.
I got a script working in case a BGP session is anything but established I am disabling the internal ip address where I run OSPF.
I am having issues with the other side because the OSPF neighbor is not present at all (unlike BGP where the session changes to idle for example) when the internal interface is down.
This means that when I check for the neighbor I get a no such item error. The script works when I want to re-enable the ip address, here is the example:
add dont-require-permissions=no name=var1 owner=admin policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="
\n:local new;
\n:set new [/routing ospf neighbor get [find address="192.168.37.1"] state];
\nif (new="Full") do={
\n/ip address enable [find interface=LO173];
\n}"
But if OSPF is down I get an error “no such item”
Hope I have explained myself, let me know if you have any questions. Thanks for your help.
That seems to work only if the neighbor is up, which is not my problem.
In case the neighbor is down, which is what I want to check, I still get the error: no such item.
In other words if the neighbor exist then the statement:
if ([/routing ospf neighbor get [find address="192.168.37.1"] ] != “”)
returns a true vale
if it does not exist it does NOT return a false value but it just throws an error.
I could solve the issue if I could initiate action on errors; is that possible?