Skip to content

Commit 2052bf6

Browse files
committed
Remove options and mode from the ControllerConfig
1 parent 15fa021 commit 2052bf6

File tree

2 files changed

+23
-32
lines changed

2 files changed

+23
-32
lines changed

rust/agama-dbus-server/src/network/dbus/interfaces.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,19 @@ impl Bond {
317317
})
318318
}
319319

320+
/// Updates the connection data in the NetworkSystem.
321+
///
322+
/// * `connection`: Updated connection.
323+
async fn update_connection<'a>(
324+
&self,
325+
connection: MappedMutexGuard<'a, BondConnection>,
326+
) -> zbus::fdo::Result<()> {
327+
let actions = self.actions.lock().await;
328+
let connection = NetworkConnection::Bond(connection.clone());
329+
actions.send(Action::UpdateConnection(connection)).unwrap();
330+
Ok(())
331+
}
332+
320333
/// Updates the controller connection data in the NetworkSystem.
321334
///
322335
/// * `connection`: Updated connection.
@@ -347,16 +360,11 @@ impl Bond {
347360
}
348361

349362
#[dbus_interface(property)]
350-
pub async fn set_mode(&mut self, mode: String) -> zbus::fdo::Result<()> {
351-
let connection = self.get_bond().await;
352-
let result = self
353-
.update_controller_connection(
354-
connection,
355-
HashMap::from([("mode".to_string(), ControllerConfig::Mode(mode.clone()))]),
356-
)
357-
.await;
358-
self.connection = Arc::new(Mutex::new(result?));
359-
Ok(())
363+
pub async fn set_mode(&mut self, mode: &str) -> zbus::fdo::Result<()> {
364+
let mut connection = self.get_bond().await;
365+
connection.set_mode(mode)?;
366+
367+
self.update_connection(connection).await
360368
}
361369

362370
/// List of bond ports.
@@ -368,19 +376,11 @@ impl Bond {
368376
}
369377

370378
#[dbus_interface(property)]
371-
pub async fn set_options(&mut self, opts: String) -> zbus::fdo::Result<()> {
372-
let connection = self.get_bond().await;
373-
let result = self
374-
.update_controller_connection(
375-
connection,
376-
HashMap::from([(
377-
"options".to_string(),
378-
ControllerConfig::Options(opts.clone()),
379-
)]),
380-
)
381-
.await;
382-
self.connection = Arc::new(Mutex::new(result.unwrap()));
383-
Ok(())
379+
pub async fn set_options(&mut self, opts: &str) -> zbus::fdo::Result<()> {
380+
let mut connection = self.get_bond().await;
381+
connection.set_options(opts)?;
382+
383+
self.update_connection(connection).await
384384
}
385385

386386
/// List of bond ports.

rust/agama-dbus-server/src/network/model.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,6 @@ impl NetworkState {
9494
let controller = conn.clone();
9595

9696
if let Connection::Bond(ref mut bond) = conn {
97-
if let Some(ControllerConfig::Mode(mode)) = settings.get("mode") {
98-
bond.set_mode(mode)?;
99-
}
100-
if let Some(ControllerConfig::Options(opts)) = settings.get("options") {
101-
bond.set_options(opts.as_str())?;
102-
}
103-
10497
if let Some(ControllerConfig::Ports(ports)) = settings.get("ports") {
10598
let new_ports: Vec<_> = ports
10699
.iter()
@@ -661,8 +654,6 @@ pub struct BondConfig {
661654
/// Controller config payload for updating a controller's connection (Bond, Bridge)
662655
#[derive(Debug, PartialEq, Clone)]
663656
pub enum ControllerConfig {
664-
Mode(String),
665-
Options(String),
666657
Ports(Vec<String>),
667658
}
668659

0 commit comments

Comments
 (0)