rustmiko

Crates.iorustmiko
lib.rsrustmiko
version0.6.0
sourcesrc
created_at2024-08-21 04:38:03.377599
updated_at2024-09-27 08:41:08.805292
descriptionA Netmiko rewrite for Rust
homepage
repositoryhttps://github.com/Kek5chen/rustmiko
max_upload_size
id1346109
size37,417
willow (Kek5chen)

documentation

README

Rustmiko

(Currently) less compatible, but better typed Netmiko alternative in Rust.

Documentation

Documentation is available on docs.rs.

Compatibility

Type Meaning
Automated Tested, Supported and unit tests exist
Full Tested and fully supported
Partial Tested, but limited usage possible
Buggy No guarantee on anything
Brand Device Support
Cisco Catalyst 2960 Series Full
Juniper EX Series Full
Juniper SRX Series Full

Example

This example will set all ports up on a Cisco Catalyst 2960/CX Series Switch.

fn main() -> anyhow::Result<()> {
	let mut cisco = match CiscoTelnet::connect("192.168.1.101:23", "admin", "admin") {
		Ok(cisco) => {
			println!("Connected successfully");
			cisco
		},
		Err(e) => {
			eprintln!("Failed to connect: {}", e);
			return Ok(());
		},
	};

	{
		let mut config = cisco.enter_config()?;
		for index in 1..=8 {
			let interface = config.get_interface("gi", &[0, index]);
			match config.interface_up(&interface) {
                Ok(_) => println!("Interface {} is now up", interface.name()),
                Err(_) => println!("Failed to set Interface {} up", interface.name())
            }
		}
	}

	if let Err(e) = cisco.save() {
		eprintln!("Failed to save configuration: {e}");
	}

	Ok(())
}

Contributions

Due to the disadvantage of me being a human being, I do not have the ability or resources to own every switch in the entire world to test. I'd be really grateful if more configurations for different switches are added.

Thanks!

Commit count: 30

cargo fmt