Calling Bird2 from Python script fails
Ross Tajvar
ross at tajvar.io
Sun Dec 11 23:08:28 CET 2022
Anything more automation-friendly would be welcome! A better socket
interface, Python lib, Ansible module, all great.
On Sat, Dec 3, 2022 at 9:50 AM Maria Matejka via Bird-users <
bird-users at trubka.network.cz> wrote:
> Hello!
> > On Mon, Nov 28, 2022 at 03:08:59PM +0000, Stavros Konstantaras via
> > Bird-users wrote:
> >> And after closing the output file I proceed on calling subprocess with
> >> the "birdc configure" command.
> >
> > You might consider sending the command directly to the control socket,
> > e.g. (no error handling!):
> >
> > ```python
> > import socket
> >
> > with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as sock:
> > sock.connect('/run/bird/bird.ctl')
> > sock.send(b'configure\n')
> > # Assumption your config is under /etc/bird.conf
> > assert sock.recv(4096) == b'0002-Reading configuration from
> > /etc/bird.conf\n0003 Reconfigured\n'
> > ```
>
> This is horrible, yet understandable.
>
> I hope we manage to include some machine-friendly control socket
> implementation in BIRD 3. It's gonna be based on CBOR format, hopefully
> distributed also with client Python libs, and if nobody in our team gets
> too angry with me for writing such a code, maybe also with an Ansible
> module allowing to write a nice-looking YAML definition.
>
> Take this as my personal hopes … yet if you wanna say ±1 or whatever
> else to this, feel free to respond.
>
> Maria
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://trubka.network.cz/pipermail/bird-users/attachments/20221211/3802feb2/attachment.htm>
More information about the Bird-users
mailing list