Skip to content

Commit

Permalink
Remove options and mode from the ControllerConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Dec 1, 2023
1 parent 15fa021 commit 2052bf6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 32 deletions.
46 changes: 23 additions & 23 deletions rust/agama-dbus-server/src/network/dbus/interfaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,19 @@ impl Bond {
})
}

/// Updates the connection data in the NetworkSystem.
///
/// * `connection`: Updated connection.
async fn update_connection<'a>(
&self,
connection: MappedMutexGuard<'a, BondConnection>,
) -> zbus::fdo::Result<()> {
let actions = self.actions.lock().await;
let connection = NetworkConnection::Bond(connection.clone());
actions.send(Action::UpdateConnection(connection)).unwrap();
Ok(())
}

/// Updates the controller connection data in the NetworkSystem.
///
/// * `connection`: Updated connection.
Expand Down Expand Up @@ -347,16 +360,11 @@ impl Bond {
}

#[dbus_interface(property)]
pub async fn set_mode(&mut self, mode: String) -> zbus::fdo::Result<()> {
let connection = self.get_bond().await;
let result = self
.update_controller_connection(
connection,
HashMap::from([("mode".to_string(), ControllerConfig::Mode(mode.clone()))]),
)
.await;
self.connection = Arc::new(Mutex::new(result?));
Ok(())
pub async fn set_mode(&mut self, mode: &str) -> zbus::fdo::Result<()> {
let mut connection = self.get_bond().await;
connection.set_mode(mode)?;

self.update_connection(connection).await
}

/// List of bond ports.
Expand All @@ -368,19 +376,11 @@ impl Bond {
}

#[dbus_interface(property)]
pub async fn set_options(&mut self, opts: String) -> zbus::fdo::Result<()> {
let connection = self.get_bond().await;
let result = self
.update_controller_connection(
connection,
HashMap::from([(
"options".to_string(),
ControllerConfig::Options(opts.clone()),
)]),
)
.await;
self.connection = Arc::new(Mutex::new(result.unwrap()));
Ok(())
pub async fn set_options(&mut self, opts: &str) -> zbus::fdo::Result<()> {
let mut connection = self.get_bond().await;
connection.set_options(opts)?;

self.update_connection(connection).await
}

/// List of bond ports.
Expand Down
9 changes: 0 additions & 9 deletions rust/agama-dbus-server/src/network/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,6 @@ impl NetworkState {
let controller = conn.clone();

if let Connection::Bond(ref mut bond) = conn {
if let Some(ControllerConfig::Mode(mode)) = settings.get("mode") {
bond.set_mode(mode)?;
}
if let Some(ControllerConfig::Options(opts)) = settings.get("options") {
bond.set_options(opts.as_str())?;
}

if let Some(ControllerConfig::Ports(ports)) = settings.get("ports") {
let new_ports: Vec<_> = ports
.iter()
Expand Down Expand Up @@ -661,8 +654,6 @@ pub struct BondConfig {
/// Controller config payload for updating a controller's connection (Bond, Bridge)
#[derive(Debug, PartialEq, Clone)]
pub enum ControllerConfig {
Mode(String),
Options(String),
Ports(Vec<String>),
}

Expand Down

0 comments on commit 2052bf6

Please sign in to comment.