51 lines
1.3 KiB
Rust
51 lines
1.3 KiB
Rust
use std::str::FromStr;
|
|
|
|
use brocade::{BrocadeOptions, PortOperatingMode};
|
|
use harmony::{
|
|
infra::brocade::BrocadeSwitchConfig,
|
|
inventory::Inventory,
|
|
modules::brocade::{BrocadeSwitchAuth, BrocadeSwitchScore, SwitchTopology},
|
|
};
|
|
use harmony_macros::ip;
|
|
use harmony_types::{id::Id, switch::PortLocation};
|
|
|
|
fn get_switch_config() -> BrocadeSwitchConfig {
|
|
let mut options = BrocadeOptions::default();
|
|
options.ssh.port = 2222;
|
|
let auth = BrocadeSwitchAuth {
|
|
username: "admin".to_string(),
|
|
password: "password".to_string(),
|
|
};
|
|
|
|
BrocadeSwitchConfig {
|
|
ips: vec![ip!("127.0.0.1")],
|
|
auth,
|
|
options,
|
|
}
|
|
}
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
let switch_score = BrocadeSwitchScore {
|
|
port_channels_to_clear: vec![
|
|
Id::from_str("17").unwrap(),
|
|
Id::from_str("19").unwrap(),
|
|
Id::from_str("18").unwrap(),
|
|
],
|
|
ports_to_configure: vec![
|
|
(PortLocation(2, 0, 17), PortOperatingMode::Trunk),
|
|
(PortLocation(2, 0, 19), PortOperatingMode::Trunk),
|
|
(PortLocation(1, 0, 18), PortOperatingMode::Trunk),
|
|
],
|
|
};
|
|
|
|
harmony_cli::run(
|
|
Inventory::autoload(),
|
|
SwitchTopology::new(get_switch_config()).await,
|
|
vec![Box::new(switch_score)],
|
|
None,
|
|
)
|
|
.await
|
|
.unwrap();
|
|
}
|