Async P4Runtime/gNMI Framework
Project description
🐟 Finsy P4Runtime Framework
Finsy is a P4Runtime controller framework written in Python using asyncio.
import asyncio
import finsy as fy
async def main():
async with fy.Switch("sw1", "127.0.0.1:50001") as sw1:
print(sw1.p4info)
asyncio.run(main())
Multiple Switches
With Finsy, you can write a P4Runtime controller that manages multiple switches.
Each switch is managed by an async ready_handler
function. Your ready_handler
function can read or
update various P4Runtime entities in the switch. It can also create tasks to listen for
packets or digests.
async def ready_handler(sw: fy.Switch):
await sw.delete_all()
await sw.insert(fy.P4MulticastGroupEntry(1, replicas=[1, 2, 3, 255]))
async for packet in sw.packet_iterator():
print(packet)
Use the SwitchOptions
class to specify each switch's settings, including the p4info/p4blob and ready_handler. Use the Controller
class to drive multiple switch connections. Each switch will call back
into your ready_handler function after the P4Runtime connection is established.
from pathlib import Path
options = fy.SwitchOptions(
p4info=Path("example.p4info.txt"),
p4blob=Path("example.json"),
ready_handler=ready_handler,
)
controller = fy.Controller([
fy.Switch("sw1", "127.0.0.1:50001", options),
fy.Switch("sw2", "127.0.0.1:50002", options),
fy.Switch("sw3", "127.0.0.1:50003", options),
])
asyncio.run(controller.run())
For more examples, see the examples directory.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file finsy-0.2.0.tar.gz
.
File metadata
- Download URL: finsy-0.2.0.tar.gz
- Upload date:
- Size: 154.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e87f83a51e75b09946125eb226e5d2bf2c4837a114348a9cf9b91122bb42348 |
|
MD5 | 02b5b1323774b393f8bb4ba7bdf6a36d |
|
BLAKE2b-256 | b3e5a76df6b145185ffd0f49789ac1e684c29b4936787537be7210a92f34fafd |
File details
Details for the file finsy-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: finsy-0.2.0-py3-none-any.whl
- Upload date:
- Size: 188.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e238d7e79656756b34a8365ad10dfb72d2f5568c45f2548a5a333bd1c9b87f45 |
|
MD5 | bcab98d94d2a63583cfcf418923cfc72 |
|
BLAKE2b-256 | 11b8d4226fff0ab1b19eb743fe8dfd9490e055f1fe4cdc9f323a725771a26631 |