Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into cli_auto_questions
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Jul 18, 2023
2 parents b4315b1 + bd024b8 commit ef7ca5e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
24 changes: 23 additions & 1 deletion rust/agama-dbus-server/src/network/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl NetworkState {
mod tests {
use uuid::Uuid;

use super::{BaseConnection, Connection, EthernetConnection, NetworkState};
use super::*;
use crate::network::error::NetworkStateError;

#[test]
Expand Down Expand Up @@ -186,6 +186,23 @@ mod tests {
let error = state.remove_connection("eth0").unwrap_err();
assert!(matches!(error, NetworkStateError::UnknownConnection(_)));
}

#[test]
fn test_is_loopback() {
let base = BaseConnection {
id: "eth0".to_string(),
..Default::default()
};
let conn = Connection::Ethernet(EthernetConnection { base });
assert!(!conn.is_loopback());

let base = BaseConnection {
id: "lo".to_string(),
..Default::default()
};
let conn = Connection::Loopback(LoopbackConnection { base });
assert!(conn.is_loopback());
}
}

/// Network device
Expand Down Expand Up @@ -264,6 +281,11 @@ impl Connection {
pub fn is_removed(&self) -> bool {
self.base().status == Status::Removed
}

/// Determines whether it is a loopback interface.
pub fn is_loopback(&self) -> bool {
matches!(self, Connection::Loopback(_))
}
}

#[derive(Debug, Default, Clone)]
Expand Down
6 changes: 3 additions & 3 deletions rust/agama-dbus-server/src/network/nm/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl<'a> NetworkManagerAdapter<'a> {
///
/// * `conn`: connection
fn is_writable(conn: &Connection) -> bool {
matches!(conn, Connection::Loopback(_))
!conn.is_loopback()
}
}

Expand All @@ -46,10 +46,10 @@ impl<'a> Adapter for NetworkManagerAdapter<'a> {
}
if conn.is_removed() {
if let Err(e) = self.client.remove_connection(conn.uuid()).await {
log::error!("Could not remove the connection {}: {}", conn.uuid(), e);
log::error!("Could not remove the connection {}: {}", conn.id(), e);
}
} else if let Err(e) = self.client.add_or_update_connection(conn).await {
log::error!("Could not add/update the connection {}: {}", conn.uuid(), e);
log::error!("Could not add/update the connection {}: {}", conn.id(), e);
}
}
});
Expand Down
7 changes: 7 additions & 0 deletions rust/package/agama-cli.changes
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ Tue Jul 18 13:32:04 UTC 2023 - Josef Reidinger <[email protected]>
- Add to CLI "questions" subcommand with mode option to set
interactive and non-interactive mode (gh#openSUSE/agama#668)

-------------------------------------------------------------------
Mon Jul 17 13:36:56 UTC 2023 - Imobach Gonzalez Sosa <[email protected]>

- Fix the logic to decide which network connections to write
due to a bug introduced in gh#openSUSE/agama#662
(gh#openSUSE/agama#667).

-------------------------------------------------------------------
Mon Jul 17 09:16:38 UTC 2023 - Josef Reidinger <[email protected]>

Expand Down

0 comments on commit ef7ca5e

Please sign in to comment.