Calling Bird2 from Python script fails
Maria Matejka
maria.matejka at nic.cz
Sat Dec 3 15:34:56 CET 2022
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 --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2839 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://trubka.network.cz/pipermail/bird-users/attachments/20221203/2dd3a9fe/attachment.p7s>
More information about the Bird-users
mailing list