go-junos icon indicating copy to clipboard operation
go-junos copied to clipboard

Filter for one particular interface

Open MaxBear opened this issue 7 years ago • 11 comments

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/>",

MaxBear avatar Aug 02 '18 13:08 MaxBear

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?

scottdware avatar Aug 03 '18 13:08 scottdware

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 ?

MaxBear avatar Aug 03 '18 14:08 MaxBear

I find you can do:

name

MaxBear avatar Aug 03 '18 14:08 MaxBear

<get-interface-information><interface-name>...</interface-name></get-interface-information>

MaxBear avatar Aug 03 '18 14:08 MaxBear

I will see about adding this feature/option. Should have something ready after the weekend :)

scottdware avatar Aug 04 '18 13:08 scottdware

I will see about adding this feature/option. Should have something ready after the weekend :)

scottdware avatar Aug 04 '18 13:08 scottdware

@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")

scottdware avatar Aug 07 '18 17:08 scottdware

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 ?

MaxBear avatar Aug 07 '18 20:08 MaxBear

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.

scottdware avatar Aug 08 '18 11:08 scottdware

If you can fix it, that will be great, thanks !

MaxBear avatar Aug 08 '18 18:08 MaxBear

Sure thing!

Sent with GitHawk

scottdware avatar Aug 09 '18 20:08 scottdware