commit | 57f864dfdad66b1746686a8b74b4dfa2cc3fa9b8 | [log] [tgz] |
---|---|---|
author | Mohammed Naser <mnaser@vexxhost.com> | Wed Mar 12 16:34:19 2025 -0400 |
committer | Mohammed Naser <mnaser@vexxhost.com> | Wed Mar 12 16:34:19 2025 -0400 |
tree | 4698df6929e137cb7e6f937cd0ae2138b2e86810 | |
parent | 3415a2a8f1f3b89fa2dcf7f57298d6f59dd35701 [diff] |
Add Clone Change-Id: I50628a5abcaa3cad736cb4d325538c246e1c7ba9
A collection of Rust crates for working with the Open vSwitch Database Management Protocol (OVSDB).
This repository provides a complete Rust implementation of the OVSDB protocol as defined in RFC7047. It's structured as a monorepo containing the following crates:
Crate | Description | Status |
---|---|---|
ovsdb-schema | Rust types and serialization for OVSDB | |
ovsdb-derive | Procedural macros for OVSDB struct generation | |
ovsdb-client | Async client for the OVSDB protocol |
use ovsdb_derive::ovsdb_object; use ovsdb_client::{rpc, schema::MonitorRequest}; use std::collections::HashMap; #[ovsdb_object] struct NbGlobal { name: Option<String>, nb_cfg: Option<i64>, } #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { // Connect to an OVSDB server let client = rpc::connect_tcp("127.0.0.1:6641").await?; // Set up monitoring for the NB_Global table let mut requests = HashMap::new(); requests.insert( "NB_Global".to_owned(), MonitorRequest { columns: Some(vec!["name".to_owned(), "nb_cfg".to_owned()]), ..Default::default() }, ); // Start monitoring let initial = client.monitor("OVN_Northbound", None, requests).await?; println!("Initial state: {:?}", initial); // Subscribe to updates let mut stream = client.subscribe_to_method("update").await?; while let Some(update) = stream.next().await { if let Ok(update) = update { println!("Received update: {:?}", update); } } Ok(()) }
To use these crates in your project, add the following to your Cargo.toml
:
[dependencies] ovsdb-schema = "0.1.0" ovsdb-derive = "0.1.0" ovsdb-client = "0.1.0"
See the individual crate directories for more detailed documentation:
For development and testing, you can run an OVSDB server using Docker:
docker run -it --rm -p 6641:6641 registry.atmosphere.dev/library/ovn-central:main \ /bin/bash -c "mkdir /etc/ovn; /root/ovnkube.sh nb-ovsdb"
cargo test --all
This project is licensed under the Apache License, Version 2.0.