Skip to main content

Crate eveng

Crate eveng 

Source
Expand description

§eveng.rs

ci crates.io docs.rs

This is an API client for EVE-NG. It implements endpoints documented as part of its REST API, as well as some undocumented endpoints found from interaction with the EVE-NG GUI.

Tested on the Community Edition Version 6.2.0-4.

§Example

use eveng::Client;
use eveng::labs::AddLabRequest;
use eveng::networks::AddNetworkRequest;
use eveng::nodes::AddNodeRequest;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::login("http://localhost", "username", "password").await?;
    let root = client.folder("/")?;

    let lab = root.labs().add(AddLabRequest::new("Test")?).await?;

    let tmpl = client.system().node_template("vios").get().await?;

    let vios1 = lab
        .nodes()
        .add(
            AddNodeRequest::qemu(&tmpl)?
                .name("vios1")
                .position(100, 200)
                .ethernet(2),
        )
        .await?;

    let vios2 = lab
        .nodes()
        .add(
            AddNodeRequest::qemu(&tmpl)?
                .name("vios2")
                .position(200, 200)
                .ethernet(2),
        )
        .await?;

    vios1
        .ethernet(0)
        .connect_to_node(&vios2.ethernet(0))
        .await?;

    let cloud = lab.networks().add(AddNetworkRequest::new("pnet0")).await?;

    vios1.ethernet(1).connect_to_network(&cloud).await?;
    vios2.ethernet(1).connect_to_network(&cloud).await?;

    lab.nodes().start().await?;
    client.logout().await?;

    Ok(())
}

Modules§

folders
Types and clients for managing folders on the EVE-NG instance.
interfaces
Types and clients to manage interfaces of a node.
labs
Types and clients for managing labs within a folder.
networks
Types and clients for managing networks within a lab.
nodes
Types and clients for managing nodes within a lab.
system
Types and client for system-level information about the EVE-NG instance.
templates
Types and clients to manage node templates in an EVE-NG instance.
users
Clients and models for managing users on the EVE-NG instance.

Structs§

Client
Main entry point: A client for the EVE-NG API.
ClientBuilder
A builder to customize Client configuration.

Enums§

Error
Main error type for the EVE-NG API.

Type Aliases§

Result
Result type alias.