go-junos
go-junos copied to clipboard
Filter for one particular interface
First, thanks for fixing the documentation error.
I have another question, if I just want to display one particular interface, how can I filter by interface name instead of getting all the interfaces ? Is there a way to pass in a filter on the following ?
"interface": "<get-interface-information/>",
So, without doing any code modifications, you could just grab all the interfaces with the function like it currently does, and then when iterating over them, look for a particular interface, e.g.:
for _, int := range ifaces.Entries {
if strings.Contains(int.Name, "ge-0/0/1") {
// Do stuff
}
}
Would this suffice, or is there a need to only grab a single one without using the above example?
I can certainly do this. But it is not efficient. I find you can do:
but it will only match physical interface. for logical interface attached to physical interface, it will not work. Is there a way to fix this ?
I find you can do:
<get-interface-information><interface-name>...</interface-name></get-interface-information>
I will see about adding this feature/option. Should have something ready after the weekend :)
I will see about adding this feature/option. Should have something ready after the weekend :)
@MaxBear I just updated this repo with your suggested changes. You can now optionally specify a physical interface, and it will include only that interface, as well as all logical ones tied to it, e.g.:
View("interface", "ge-0/0/0")
Thanks for making the change, Scott. Do you know why when run cli
show interface <logical interface> | display xml
will display one logical interface output. But this will not work for RPC calls ?
Most likely because I have it tied to just a physical interface. I should probably change that so that any interface will work, even logical ones (if you don't need to see the physical). I'll work at fixing that.
If you can fix it, that will be great, thanks !