Add Clone

Change-Id: I50628a5abcaa3cad736cb4d325538c246e1c7ba9
1 file changed
tree: 4698df6929e137cb7e6f937cd0ae2138b2e86810
  1. client/
  2. derive/
  3. playbooks/
  4. schema/
  5. .gitignore
  6. .gitreview
  7. .zuul.yaml
  8. Cargo.lock
  9. Cargo.toml
  10. README.md
README.md

OVSDB Rust

A collection of Rust crates for working with the Open vSwitch Database Management Protocol (OVSDB).

License

Overview

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:

CrateDescriptionStatus
ovsdb-schemaRust types and serialization for OVSDBcrates.io
ovsdb-deriveProcedural macros for OVSDB struct generationcrates.io
ovsdb-clientAsync client for the OVSDB protocolcrates.io

Features

  • Complete Type System: Full implementation of OVSDB's type system (atoms, sets, maps)
  • Auto-generated Structs: Derive macros for creating OVSDB-compatible structs
  • Async Client: Modern async client using Tokio and jsonrpsee
  • Multiple Transports: Support for TCP and Unix socket connections
  • Table Monitoring: Real-time monitoring of table changes

Quick Example

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(())
}

Getting Started

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:

Development

Prerequisites

  • Rust 1.75 or newer
  • OVSDB server for testing (see below)

Setting up a test environment

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"

Running tests

cargo test --all

License

This project is licensed under the Apache License, Version 2.0.