Skip to content

This is the CNI plugin impl by rust for containerd create CNI network

License

Notifications You must be signed in to change notification settings

jokemanfire/rust-cni

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is the CNI plugin impl by rust for container create CNI network

todo

  • Need Cached in CNI
  • Need Tests
  • Need Validate in CNI
  • Wrap as lib

example

use std::{fs::File, io};
use rust_cni::cni::Libcni;
use netns_rs::NetNs;
use nix::sched::setns;

fn create_ns() -> Result<NetNs, String> {
    let ns = NetNs::new("ns_name").unwrap();
    println!("{:?}", ns.path());
    Ok(ns)
}

fn main() {
    let ns = create_ns().unwrap();
    let mut cni = Libcni::new();
    cni.load_default_conf();
    let _ = cni.add_lo_network();

    let id = "test".to_string();
    let path = ns.path().to_string_lossy().to_string();
    let _ = cni.setup(id.clone(), path.clone());

    let mut name = String::new();
    io::stdin().read_line(&mut name).expect("error");

    println!("try to remove --------------------");
    let _ = cni.remove(id.clone(), path.clone());
    let _ = ns.remove();
}

ref

About

This is the CNI plugin impl by rust for containerd create CNI network

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages