Reading from stdin

148 views
Skip to first unread message

Todd Mueller

unread,
Aug 22, 2018, 1:16:38 PM8/22/18
to exabgp-users
Question for anyone more clued in than me . . . I am new to ExaBGP. I am a fairly competent Python programmer, but wouldn't classify myself as an expert per se.

Non-blocking reads from stdin is new to me, I don't typically code this type of application. I've managed to cobble together the following code to run commands/get output:

https://gist.github.com/microlinux/cd7ddeff3a715d2fbea827ffca2b4e76

My current need for ExaBGP is relatively simple, I would like to peer with upstream blackhole servers to issue null routes. I need to announce routes and view the outgoing RIB.

Using the aforementioned code, announcing routes seems to work as intended. I issue the command and receive a 'done' response every time.

Where I am running into trouble is when I run the command 'show adj-rib out'. Sometimes I receive a response of 'done', and that's it. There are routes in the RIB, but they don't get captured - I just receive 'done'. Other times, I don't capture any response, even 'done'. Most of the time, however, I am capturing the output as intended.

Through debugging, I have noticed that when this happens, it seems I capture the "missing" output after running another command. Which makes me think there is something wrong with the code that reads stdin.

Any Python experts out there that can point out what I might be doing wrong? I don't discount the possibility my code is horribly out of whack given my lack of experience in this area.

Thanks for any help!

Todd Mueller

unread,
Aug 22, 2018, 3:15:39 PM8/22/18
to exabgp-users
I made a few changes to how stdin is read/processed and that seems to have fixed the problem. I updated my example code in case it's helpful for anyone else.

Thomas Mangin

unread,
Aug 23, 2018, 2:17:08 AM8/23/18
to exabgp...@googlegroups.com
Hello Todd,

Happy to hear that your code is working but I believe it could still fails.

You could look at the following code to see how I suggest reading from ExaBGP:
Sincerely,

Thomas

--
You received this message because you are subscribed to the Google Groups "exabgp-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exabgp-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Todd Mueller

unread,
Aug 23, 2018, 12:27:45 PM8/23/18
to exabgp-users
Thanks for the suggestion, I will check it out!
Reply all
Reply to author
Forward
0 new messages