properly configure a new channel port for a host (work only with a clean slate for now)
This commit is contained in:
49
brocade/examples/main.rs
Normal file
49
brocade/examples/main.rs
Normal file
@@ -0,0 +1,49 @@
|
||||
use std::net::{IpAddr, Ipv4Addr};
|
||||
|
||||
use brocade::BrocadeClient;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
env_logger::init();
|
||||
|
||||
let ip = IpAddr::V4(Ipv4Addr::new(10, 0, 0, 250));
|
||||
let switch_addresses = vec![ip];
|
||||
|
||||
let brocade = BrocadeClient::init(&switch_addresses, "admin", "password", None)
|
||||
.await
|
||||
.expect("Brocade client failed to connect");
|
||||
|
||||
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!("--------------");
|
||||
let channel_name = "HARMONY_LAG";
|
||||
println!("Clearing port channel '{channel_name}'...");
|
||||
|
||||
brocade.clear_port_channel(channel_name).await.unwrap();
|
||||
|
||||
println!("Cleared");
|
||||
|
||||
println!("--------------");
|
||||
println!("Finding next available channel...");
|
||||
|
||||
let channel_id = brocade.find_available_channel_id().await.unwrap();
|
||||
println!("Channel id: {channel_id}");
|
||||
|
||||
println!("--------------");
|
||||
let channel_name = "HARMONY_LAG";
|
||||
let ports = vec!["1/1/3".to_string()];
|
||||
println!("Creating port channel '{channel_name}' with ports {ports:?}'...");
|
||||
|
||||
brocade
|
||||
.create_port_channel(channel_name, channel_id, &ports)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
println!("Created");
|
||||
}
|
||||
Reference in New Issue
Block a user