Skip to content

Commit

Permalink
rust: Change source of the list of actions
Browse files Browse the repository at this point in the history
  • Loading branch information
ancorgs committed Oct 30, 2024
1 parent 2aceec0 commit 5cfbd32
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
10 changes: 8 additions & 2 deletions rust/agama-lib/src/storage/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use super::model::{
Md, Multipath, Partition, PartitionTable, ProposalSettings, ProposalSettingsPatch, Raid,
Volume,
};
use super::proxies::{ProposalCalculatorProxy, ProposalProxy, Storage1Proxy};
use super::proxies::{DevicesProxy, ProposalCalculatorProxy, ProposalProxy, Storage1Proxy};
use super::StorageSettings;
use crate::dbus::get_property;
use crate::error::ServiceError;
Expand All @@ -50,6 +50,7 @@ pub struct StorageClient<'a> {
calculator_proxy: ProposalCalculatorProxy<'a>,
storage_proxy: Storage1Proxy<'a>,
object_manager_proxy: ObjectManagerProxy<'a>,
devices_proxy: DevicesProxy<'a>,
proposal_proxy: ProposalProxy<'a>,
}

Expand All @@ -69,6 +70,11 @@ impl<'a> StorageClient<'a> {
.cache_properties(zbus::CacheProperties::No)
.build()
.await?,
// Same than above, actions are reexported with every call to recalculate
devices_proxy: DevicesProxy::builder(&connection)
.cache_properties(zbus::CacheProperties::No)
.build()
.await?,
connection,
})
}
Expand All @@ -80,7 +86,7 @@ impl<'a> StorageClient<'a> {

/// Actions to perform in the storage devices.
pub async fn actions(&self) -> Result<Vec<Action>, ServiceError> {
let actions = self.proposal_proxy.actions().await?;
let actions = self.devices_proxy.actions().await?;
let mut result: Vec<Action> = Vec::with_capacity(actions.len());

for i in actions {
Expand Down
13 changes: 10 additions & 3 deletions rust/agama-lib/src/storage/proxies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,24 @@ trait ProposalCalculator {
}

#[dbus_proxy(
interface = "org.opensuse.Agama.Storage1.Proposal",
interface = "org.opensuse.Agama.Storage1.Devices",
default_service = "org.opensuse.Agama.Storage1",
default_path = "/org/opensuse/Agama/Storage1/Proposal"
default_path = "/org/opensuse/Agama/Storage1"
)]
trait Proposal {
trait Devices {
/// Actions property
#[dbus_proxy(property)]
fn actions(
&self,
) -> zbus::Result<Vec<std::collections::HashMap<String, zbus::zvariant::OwnedValue>>>;
}

#[dbus_proxy(
interface = "org.opensuse.Agama.Storage1.Proposal",
default_service = "org.opensuse.Agama.Storage1",
default_path = "/org/opensuse/Agama/Storage1/Proposal"
)]
trait Proposal {
/// Settings property
#[dbus_proxy(property)]
fn settings(
Expand Down
4 changes: 2 additions & 2 deletions rust/agama-server/src/storage/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ pub async fn storage_service(dbus: zbus::Connection) -> Result<Router, ServiceEr
.route("/devices/result", get(staging_devices))
.route("/product/volume_for", get(volume_for))
.route("/product/params", get(product_params))
.route("/proposal/actions", get(actions))
.route("/devices/actions", get(actions))
.route("/proposal/usable_devices", get(usable_devices))
.route(
"/proposal/settings",
Expand Down Expand Up @@ -331,7 +331,7 @@ pub struct ProductParams {
/// Gets the actions to perform in the storage devices.
#[utoipa::path(
get,
path = "/proposal/actions",
path = "/devices/actions",
context_path = "/api/storage",
responses(
(status = 200, description = "List of actions", body = Vec<Action>),
Expand Down

0 comments on commit 5cfbd32

Please sign in to comment.