refactor brocade to support different shell versions (e.g. FastIron vs NOS)
All checks were successful
Run Check Script / check (pull_request) Successful in 1m13s

This commit is contained in:
Ian Letourneau
2025-10-07 21:27:45 -04:00
parent 45e0de2097
commit 77e09436a9
13 changed files with 973 additions and 634 deletions

View File

@@ -1,24 +1,29 @@
use std::net::{IpAddr, Ipv4Addr};
use brocade::BrocadeClient;
use harmony_types::switch::PortLocation;
#[tokio::main]
async fn main() {
env_logger::init();
let ip = IpAddr::V4(Ipv4Addr::new(10, 0, 0, 250));
let ip = IpAddr::V4(Ipv4Addr::new(10, 0, 0, 250)); // old brocade @ ianlet
// let ip = IpAddr::V4(Ipv4Addr::new(192, 168, 55, 101)); // brocade @ sto1
let switch_addresses = vec![ip];
let brocade = BrocadeClient::init(&switch_addresses, "admin", "password", None)
let brocade = brocade::init(&switch_addresses, 22, "admin", "password", None)
.await
.expect("Brocade client failed to connect");
let version = brocade.version().await.unwrap();
println!("Version: {version:?}");
println!("--------------");
println!("Showing MAC Address table...");
let mac_adddresses = brocade.show_mac_address_table().await.unwrap();
println!("VLAN\tMAC\t\t\tPORT");
for mac in mac_adddresses {
println!("{}\t{}\t{}", mac.vlan, mac.mac_address, mac.port_name);
println!("{}\t{}\t{}", mac.vlan, mac.mac_address, mac.port);
}
println!("--------------");
@@ -37,11 +42,11 @@ async fn main() {
println!("--------------");
let channel_name = "HARMONY_LAG";
let ports = vec!["1/1/3".to_string()];
let ports = [PortLocation(1, 1, 3), PortLocation(1, 1, 4)];
println!("Creating port channel '{channel_name}' with ports {ports:?}'...");
brocade
.create_port_channel(channel_name, channel_id, &ports)
.create_port_channel(channel_id, channel_name, &ports)
.await
.unwrap();