Crate gns3[][src]

GNS3 Server API

This is a very simple crate to interact with the GNS3 server, creating projects, nodes and links automatically.

use gns3::GNS3Server;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // connect to the server
    let mut server = match GNS3Server::new("localhost", 3080) {
        Ok(s) => s,
        Err(e) => {
            eprintln!("Cannot connect to the server: {}", e);
            return Err(e.into());
        }
    };

    // crate a new project
    let project = server.create_project("DocumentationExample")?;

    // get the FRR template
    let frr = server
        .get_templates()?
        .into_iter()
        .filter(|t| t.name == "FRR 7.3.1")
        .next()
        .unwrap();

    // create two nodes
    let node_a = server.create_node("node_a", &frr.id)?;
    let node_b = server.create_node("node_b", &frr.id)?;

    // create the link between them
    server.create_link(&node_a, 0, &node_b, 0)?;

    // start all nodes
    server.start_all_nodes()?;

    Ok(())
}

Structs

GNS3Interface

Interface Information

GNS3Link

Link data

GNS3LinkEndpoint

Endpoint of a link

GNS3Node

Node Information

GNS3Project

Project Information

GNS3Server

GNS3 Server Handle

GNS3Template

GNS3 Template

Enums

Error

GNS3 Error type

GNS3NodeStatus

Project Status

GNS3ProjectStatus

Project Status