Introducing pyvyos: A New Python SDK for VyOS API Interaction

Hello VyOS Community,

I’m thrilled to announce the release of “pyvyos,” a new Python SDK designed to interact seamlessly with the VyOS API. This toolkit simplifies the process of managing VyOS devices programmatically, allowing for efficient configuration and operation handling. Whether you’re automating network tasks, customizing configurations, or exploring new integration possibilities, pyvyos provides a robust, user-friendly platform.

For more details and to start using pyvyos, check out our GitHub repository at GitHub - robertoberto/pyvyos: Python SDK for interacting with VyOS API

Just:

pip install pyvyos

Then

# connect to device
device = VyDevice(hostname=hostname, apikey=apikey, port=port, protocol=protocol, verify=verify)

# update interface
response = device.configure_set(path=["interfaces", "ethernet", "eth0", "address", "192.168.1.1/24"])

# Check for errors and print the result
if not response.error:
    print(response.result)

We welcome feedback, contributions, and suggestions from the community!

Happy networking,

9 Likes

Hi @robertoberto!

Thank you for sharing this exciting news! We greatly appreciate your efforts in developing pyvyos and making it available on GitHub for the community. This opens up a realm of possibilities for network automation, custom configurations, and integration opportunities with VyOS devices.

Once again, thank you for sharing! :raised_hands:

Cheers,
Joe

Hello Joe and the VyOS Community,

I’m delighted to see your positive response to the release of pyvyos. It’s been a rewarding experience to contribute to the community and I’m eager to continue this journey.

As we progress, I’m seeking input from all of you. While pyvyos currently mirrors the commands and operations of the VyOS API, I’m open to expanding its capabilities. Are there any specific functions or features you’d like to see integrated into the SDK? Your suggestions are invaluable for shaping the future of pyvyos and enhancing our network automation toolkit.

Looking forward to your creative and insightful ideas!

Best regards,

Hi,

Since I have the task to automate vyos I will see into your work. I was thinking about cloud-init and ansible modules. The one thing that was open was monitoring. Wasn’t thrilled about purring check_mk agent on vyos Linux. With your SDK I will give it a try with a server based check_mk plugin.

Should work fine since check_mk is also Python based.

Thank you for making this! I have been testing this out for a little bit and I ran into a snag when trying to create DHCP server. I noticed that _api_request has a list for path, but I don’t think it accommodates for some services or vxlan that need to be passed in one payload like the following.

[{"op": "set","path":["interfaces","vxlan","vxlan1","remote","203.0.113.99"]}, {"op": "set","path":["interfaces","vxlan","vxlan1","vni","1"]}]

it is entirely possible I am not using configure_set properly to accomplish this. wouldn’t there have to be lists of lists of paths? if that makes sense.

Thank you for bringing this to our attention, xTITUS_MAXIMUSx. We greatly appreciate your report and the detailed explanation of the issue encountered with handling complex configurations through the API. Your contribution is invaluable in improving PyVyos for everyone.

If you or anyone in the community is interested in contributing to the resolution of this issue, we encourage you to fork the project and submit a pull request with the proposed enhancement. Your expertise and insights would be highly beneficial to the project.

Alternatively, if there are no community contributions in the next few days, I will take it upon myself to address this issue. We aim to ensure PyVyos meets the needs of its users and adheres to the best practices in API interaction.

For ongoing updates and discussion regarding this issue, please follow the thread at: Enhancement to API for Supporting List of Operations in Complex Configurations · Issue #1 · robertoberto/pyvyos · GitHub.

Thank you once again for your contribution and for supporting the PyVyos project.

I have submitted a PR for this enhancement. Let me know if there needs to be any tweaks. :slight_smile:

1 Like