-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add bootloader section to agama config (jsc#AGM-54)
- Loading branch information
1 parent
6749f1c
commit 5492568
Showing
23 changed files
with
619 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) [2024] SUSE LLC | ||
// | ||
// All Rights Reserved. | ||
// | ||
// This program is free software; you can redistribute it and/or modify it | ||
// under the terms of the GNU General Public License as published by the Free | ||
// Software Foundation; either version 2 of the License, or (at your option) | ||
// any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, but WITHOUT | ||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
// more details. | ||
// | ||
// You should have received a copy of the GNU General Public License along | ||
// with this program; if not, contact SUSE LLC. | ||
// | ||
// To contact SUSE LLC about this file by physical or electronic mail, you may | ||
// find current contact information at www.suse.com. | ||
|
||
//! Implements support for handling the storage settings | ||
pub mod client; | ||
// pub mod http_client; | ||
pub mod http_client; | ||
pub mod model; | ||
pub mod proxies; | ||
pub mod store; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright (c) [2024] SUSE LLC | ||
// | ||
// All Rights Reserved. | ||
// | ||
// This program is free software; you can redistribute it and/or modify it | ||
// under the terms of the GNU General Public License as published by the Free | ||
// Software Foundation; either version 2 of the License, or (at your option) | ||
// any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, but WITHOUT | ||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
// more details. | ||
// | ||
// You should have received a copy of the GNU General Public License along | ||
// with this program; if not, contact SUSE LLC. | ||
// | ||
// To contact SUSE LLC about this file by physical or electronic mail, you may | ||
// find current contact information at www.suse.com. | ||
|
||
//! Implements a client to access Agama's D-Bus API related to Bootloader management. | ||
use zbus::Connection; | ||
|
||
use crate::{ | ||
bootloader::{model::BootloaderSettings, proxies::BootloaderProxy}, | ||
error::ServiceError, | ||
}; | ||
|
||
/// Client to connect to Agama's D-Bus API for Bootloader management. | ||
#[derive(Clone)] | ||
pub struct BootloaderClient<'a> { | ||
bootloader_proxy: BootloaderProxy<'a>, | ||
} | ||
|
||
impl<'a> BootloaderClient<'a> { | ||
pub async fn new(connection: Connection) -> Result<BootloaderClient<'a>, ServiceError> { | ||
let bootloader_proxy = BootloaderProxy::new(&connection).await?; | ||
|
||
Ok(Self { bootloader_proxy }) | ||
} | ||
|
||
pub async fn get_config(&self) -> Result<BootloaderSettings, ServiceError> { | ||
let serialized_string = self.bootloader_proxy.get_config().await?; | ||
let settings = serde_json::from_str(serialized_string.as_str())?; | ||
Ok(settings) | ||
} | ||
|
||
pub async fn set_config(&self, config: &BootloaderSettings) -> Result<(), ServiceError> { | ||
// ignore return value as currently it does not fail and who knows what future brings | ||
// but it should not be part of result and instead transformed to ServiceError | ||
self.bootloader_proxy | ||
.set_config(serde_json::to_string(config)?.as_str()) | ||
.await?; | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (c) [2024] SUSE LLC | ||
// | ||
// All Rights Reserved. | ||
// | ||
// This program is free software; you can redistribute it and/or modify it | ||
// under the terms of the GNU General Public License as published by the Free | ||
// Software Foundation; either version 2 of the License, or (at your option) | ||
// any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, but WITHOUT | ||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
// more details. | ||
// | ||
// You should have received a copy of the GNU General Public License along | ||
// with this program; if not, contact SUSE LLC. | ||
// | ||
// To contact SUSE LLC about this file by physical or electronic mail, you may | ||
// find current contact information at www.suse.com. | ||
|
||
//! Implements a client to access Agama's HTTP API related to Bootloader management. | ||
use crate::base_http_client::BaseHTTPClient; | ||
use crate::bootloader::model::BootloaderSettings; | ||
use crate::ServiceError; | ||
|
||
pub struct BootloaderHTTPClient { | ||
client: BaseHTTPClient, | ||
} | ||
|
||
impl BootloaderHTTPClient { | ||
pub fn new(base: BaseHTTPClient) -> Self { | ||
Self { client: base } | ||
} | ||
|
||
pub async fn get_config(&self) -> Result<BootloaderSettings, ServiceError> { | ||
self.client.get("/bootloader/config").await | ||
} | ||
|
||
pub async fn set_config(&self, config: &BootloaderSettings) -> Result<(), ServiceError> { | ||
self.client.put_void("/bootloader/config", config).await | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright (c) [2024] SUSE LLC | ||
// | ||
// All Rights Reserved. | ||
// | ||
// This program is free software; you can redistribute it and/or modify it | ||
// under the terms of the GNU General Public License as published by the Free | ||
// Software Foundation; either version 2 of the License, or (at your option) | ||
// any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, but WITHOUT | ||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
// more details. | ||
// | ||
// You should have received a copy of the GNU General Public License along | ||
// with this program; if not, contact SUSE LLC. | ||
// | ||
// To contact SUSE LLC about this file by physical or electronic mail, you may | ||
// find current contact information at www.suse.com. | ||
|
||
//! Implements a data model for Bootloader configuration. | ||
use serde::{Deserialize, Serialize}; | ||
|
||
/// Represents a Bootloader | ||
#[derive(Clone, Debug, Serialize, Deserialize, Default, utoipa::ToSchema)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct BootloaderSettings { | ||
pub stop_on_boot_menu: bool, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
//! # D-Bus interface proxy for: `org.opensuse.Agama.Storage1.Bootloader` | ||
//! | ||
//! This code was generated by `zbus-xmlgen` `5.0.1` from D-Bus introspection data. | ||
//! Source: `org.opensuse.Agama.Storage1.bus.xml`. | ||
//! | ||
//! You may prefer to adapt it, instead of using it verbatim. | ||
//! | ||
//! More information can be found in the [Writing a client proxy] section of the zbus | ||
//! documentation. | ||
//! | ||
//! This type implements the [D-Bus standard interfaces], (`org.freedesktop.DBus.*`) for which the | ||
//! following zbus API can be used: | ||
//! | ||
//! * [`zbus::fdo::IntrospectableProxy`] | ||
//! * [`zbus::fdo::ObjectManagerProxy`] | ||
//! * [`zbus::fdo::PropertiesProxy`] | ||
//! | ||
//! Consequently `zbus-xmlgen` did not generate code for the above interfaces. | ||
//! | ||
//! [Writing a client proxy]: https://dbus2.github.io/zbus/client.html | ||
//! [D-Bus standard interfaces]: https://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces, | ||
use zbus::proxy; | ||
#[proxy( | ||
default_service = "org.opensuse.Agama.Storage1", | ||
default_path = "/org/opensuse/Agama/Storage1", | ||
interface = "org.opensuse.Agama.Storage1.Bootloader", | ||
assume_defaults = true | ||
)] | ||
pub trait Bootloader { | ||
/// GetConfig method | ||
fn get_config(&self) -> zbus::Result<String>; | ||
|
||
/// SetConfig method | ||
fn set_config(&self, serialized_config: &str) -> zbus::Result<u32>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright (c) [2024] SUSE LLC | ||
// | ||
// All Rights Reserved. | ||
// | ||
// This program is free software; you can redistribute it and/or modify it | ||
// under the terms of the GNU General Public License as published by the Free | ||
// Software Foundation; either version 2 of the License, or (at your option) | ||
// any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, but WITHOUT | ||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
// more details. | ||
// | ||
// You should have received a copy of the GNU General Public License along | ||
// with this program; if not, contact SUSE LLC. | ||
// | ||
// To contact SUSE LLC about this file by physical or electronic mail, you may | ||
// find current contact information at www.suse.com. | ||
|
||
//! Implements the store for the storage settings. | ||
use crate::base_http_client::BaseHTTPClient; | ||
use crate::error::ServiceError; | ||
|
||
use super::http_client::BootloaderHTTPClient; | ||
use super::model::BootloaderSettings; | ||
|
||
/// Loads and stores the storage settings from/to the HTTP service. | ||
pub struct BootloaderStore { | ||
bootloader_client: BootloaderHTTPClient, | ||
} | ||
|
||
impl BootloaderStore { | ||
pub fn new(client: BaseHTTPClient) -> Result<Self, ServiceError> { | ||
Ok(Self { | ||
bootloader_client: BootloaderHTTPClient::new(client), | ||
}) | ||
} | ||
|
||
pub async fn load(&self) -> Result<BootloaderSettings, ServiceError> { | ||
self.bootloader_client.get_config().await | ||
} | ||
|
||
pub async fn store(&self, settings: &BootloaderSettings) -> Result<(), ServiceError> { | ||
self.bootloader_client.set_config(settings).await?; | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) [2024] SUSE LLC | ||
// | ||
// All Rights Reserved. | ||
// | ||
// This program is free software; you can redistribute it and/or modify it | ||
// under the terms of the GNU General Public License as published by the Free | ||
// Software Foundation; either version 2 of the License, or (at your option) | ||
// any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, but WITHOUT | ||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
// more details. | ||
// | ||
// You should have received a copy of the GNU General Public License along | ||
// with this program; if not, contact SUSE LLC. | ||
// | ||
// To contact SUSE LLC about this file by physical or electronic mail, you may | ||
// find current contact information at www.suse.com. | ||
|
||
pub mod web; |
Oops, something went wrong.