diff --git a/brocade/src/fast_iron.rs b/brocade/src/fast_iron.rs index 5a3474e..c3eb374 100644 --- a/brocade/src/fast_iron.rs +++ b/brocade/src/fast_iron.rs @@ -1,7 +1,8 @@ use super::BrocadeClient; use crate::{ BrocadeInfo, Error, ExecutionMode, InterSwitchLink, InterfaceInfo, MacAddressEntry, - PortChannelId, PortOperatingMode, parse_brocade_mac_address, shell::BrocadeShell, + PortChannelId, PortOperatingMode, SecurityLevel, parse_brocade_mac_address, + shell::BrocadeShell, }; use async_trait::async_trait; @@ -209,4 +210,18 @@ impl BrocadeClient for FastIronClient { info!("[Brocade] Port-channel '{channel_name}' cleared."); Ok(()) } + + async fn enable_snmp(&self, user_name: &str, auth: &str, des: &str) -> Result<(), Error> { + let commands = vec![ + "configure terminal".into(), + "snmp-server view ALL 1 included".into(), + "snmp-server group public v3 priv read ALL".into(), + format!("snmp-server user {user_name} groupname public auth md5 {auth} priv des {des}"), + "exit".into(), + ]; + self.shell + .run_commands(commands, ExecutionMode::Regular) + .await?; + Ok(()) + } } diff --git a/brocade/src/lib.rs b/brocade/src/lib.rs index c0b5b70..32ca31f 100644 --- a/brocade/src/lib.rs +++ b/brocade/src/lib.rs @@ -237,6 +237,15 @@ pub trait BrocadeClient: std::fmt::Debug { ports: &[PortLocation], ) -> Result<(), Error>; + /// Enables Simple Network Management Protocol (SNMP) server for switch + /// + /// # Parameters + /// + /// * `user_name`: The user name for the snmp server + /// * `auth`: The password for authentication process for verifying the identity of a device + /// * `des`: The Data Encryption Standard algorithm key + async fn enable_snmp(&self, user_name: &str, auth: &str, des: &str) -> Result<(), Error>; + /// Removes all configuration associated with the specified Port-Channel name. /// /// This operation should be idempotent; attempting to clear a non-existent @@ -300,6 +309,11 @@ fn parse_brocade_mac_address(value: &str) -> Result { Ok(MacAddress(bytes)) } +#[derive(Debug)] +pub enum SecurityLevel { + AuthPriv(String), +} + #[derive(Debug)] pub enum Error { NetworkError(String), diff --git a/brocade/src/network_operating_system.rs b/brocade/src/network_operating_system.rs index f4db713..bfb45ed 100644 --- a/brocade/src/network_operating_system.rs +++ b/brocade/src/network_operating_system.rs @@ -8,7 +8,7 @@ use regex::Regex; use crate::{ BrocadeClient, BrocadeInfo, Error, ExecutionMode, InterSwitchLink, InterfaceInfo, InterfaceStatus, InterfaceType, MacAddressEntry, PortChannelId, PortOperatingMode, - parse_brocade_mac_address, shell::BrocadeShell, + SecurityLevel, parse_brocade_mac_address, shell::BrocadeShell, }; #[derive(Debug)] @@ -330,4 +330,18 @@ impl BrocadeClient for NetworkOperatingSystemClient { info!("[Brocade] Port-channel '{channel_name}' cleared."); Ok(()) } + + async fn enable_snmp(&self, user_name: &str, auth: &str, des: &str) -> Result<(), Error> { + let commands = vec![ + "configure terminal".into(), + "snmp-server view ALL 1 included".into(), + "snmp-server group public v3 priv read ALL".into(), + format!("snmp-server user {user_name} groupname public auth md5 {auth} priv des {des}"), + "exit".into(), + ]; + self.shell + .run_commands(commands, ExecutionMode::Regular) + .await?; + Ok(()) + } } diff --git a/harmony/src/infra/brocade.rs b/harmony/src/infra/brocade.rs index 774c8f8..0cac5ed 100644 --- a/harmony/src/infra/brocade.rs +++ b/harmony/src/infra/brocade.rs @@ -121,7 +121,7 @@ mod tests { use async_trait::async_trait; use brocade::{ BrocadeClient, BrocadeInfo, Error, InterSwitchLink, InterfaceInfo, InterfaceStatus, - InterfaceType, MacAddressEntry, PortChannelId, PortOperatingMode, + InterfaceType, MacAddressEntry, PortChannelId, PortOperatingMode, SecurityLevel, }; use harmony_types::switch::PortLocation; @@ -279,6 +279,10 @@ mod tests { async fn clear_port_channel(&self, _channel_name: &str) -> Result<(), Error> { todo!() } + + async fn enable_snmp(&self, user_name: &str, auth: &str, des: &str) -> Result<(), Error> { + todo!() + } } impl FakeBrocadeClient {