-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(storage): load storage config for guided proposal #1293
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
39bf93d
chore(rust): update dependencies
joseivanlopez 82d9fe2
feat(rust): set and get storage config
joseivanlopez a497d8b
feat(storage): add conversions to and from JSON schema
joseivanlopez 2e3278b
feat(dbus): add API to set and get storage config
joseivanlopez 0059e2f
fix(rust): import using a single line
joseivanlopez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
|
||
use super::model::{ | ||
Action, BlockDevice, Component, Device, DeviceInfo, DeviceSid, Drive, Filesystem, LvmLv, LvmVg, | ||
Md, Multipath, Partition, PartitionTable, ProposalSettings, ProposalSettingsPatch, | ||
ProposalTarget, Raid, Volume, | ||
Md, Multipath, Partition, PartitionTable, ProposalSettings, ProposalSettingsPatch, Raid, | ||
Volume, | ||
}; | ||
use super::proxies::{ProposalCalculatorProxy, ProposalProxy, Storage1Proxy}; | ||
use super::StorageSettings; | ||
|
@@ -105,73 +105,28 @@ impl<'a> StorageClient<'a> { | |
Ok(self.proposal_proxy.settings().await?.try_into()?) | ||
} | ||
|
||
/// Returns the boot device proposal setting | ||
/// DEPRECATED, use proposal_settings instead | ||
pub async fn boot_device(&self) -> Result<Option<String>, ServiceError> { | ||
let settings = self.proposal_settings().await?; | ||
let boot_device = settings.boot_device; | ||
|
||
if boot_device.is_empty() { | ||
Ok(None) | ||
} else { | ||
Ok(Some(boot_device)) | ||
} | ||
} | ||
|
||
/// Returns the lvm proposal setting | ||
/// DEPRECATED, use proposal_settings instead | ||
pub async fn lvm(&self) -> Result<Option<bool>, ServiceError> { | ||
let settings = self.proposal_settings().await?; | ||
Ok(Some(!matches!(settings.target, ProposalTarget::Disk))) | ||
} | ||
|
||
/// Returns the encryption password proposal setting | ||
/// DEPRECATED, use proposal_settings instead | ||
pub async fn encryption_password(&self) -> Result<Option<String>, ServiceError> { | ||
let settings = self.proposal_settings().await?; | ||
let value = settings.encryption_password; | ||
|
||
if value.is_empty() { | ||
Ok(None) | ||
} else { | ||
Ok(Some(value)) | ||
} | ||
} | ||
|
||
/// Runs the probing process | ||
pub async fn probe(&self) -> Result<(), ServiceError> { | ||
Ok(self.storage_proxy.probe().await?) | ||
} | ||
|
||
/// TODO: remove calculate when CLI will be adapted | ||
pub async fn calculate2(&self, settings: ProposalSettingsPatch) -> Result<u32, ServiceError> { | ||
Ok(self.calculator_proxy.calculate(settings.into()).await?) | ||
/// Set the storage config according to the JSON schema | ||
pub async fn set_config(&self, settings: StorageSettings) -> Result<u32, ServiceError> { | ||
Ok(self | ||
.storage_proxy | ||
.set_config(serde_json::to_string(&settings).unwrap().as_str()) | ||
.await?) | ||
} | ||
|
||
pub async fn calculate_autoyast(&self, settings: &str) -> Result<u32, ServiceError> { | ||
Ok(self.calculator_proxy.calculate_autoyast(settings).await?) | ||
/// Get the storage config according to the JSON schema | ||
pub async fn get_config(&self) -> Result<StorageSettings, ServiceError> { | ||
let serialized_settings = self.storage_proxy.get_config().await?; | ||
let settings = serde_json::from_str(serialized_settings.as_str()).unwrap(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same than above. |
||
Ok(settings) | ||
} | ||
|
||
/// Calculates a new proposal with the given settings. | ||
pub async fn calculate(&self, settings: &StorageSettings) -> Result<u32, ServiceError> { | ||
let mut dbus_settings: HashMap<&str, zbus::zvariant::Value<'_>> = HashMap::new(); | ||
|
||
if let Some(boot_device) = settings.boot_device.clone() { | ||
dbus_settings.insert("BootDevice", zbus::zvariant::Value::new(boot_device)); | ||
} | ||
|
||
if let Some(encryption_password) = settings.encryption_password.clone() { | ||
dbus_settings.insert( | ||
"EncryptionPassword", | ||
zbus::zvariant::Value::new(encryption_password), | ||
); | ||
} | ||
|
||
if let Some(lvm) = settings.lvm { | ||
dbus_settings.insert("LVM", zbus::zvariant::Value::new(lvm)); | ||
} | ||
|
||
Ok(self.calculator_proxy.calculate(dbus_settings).await?) | ||
pub async fn calculate(&self, settings: ProposalSettingsPatch) -> Result<u32, ServiceError> { | ||
Ok(self.calculator_proxy.calculate(settings.into()).await?) | ||
} | ||
|
||
/// Probed devices. | ||
|
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 |
---|---|---|
@@ -1,15 +1,26 @@ | ||
//! Representation of the storage settings | ||
|
||
use crate::install_settings::InstallSettings; | ||
use serde::{Deserialize, Serialize}; | ||
use serde_json::value::RawValue; | ||
|
||
/// Storage settings for installation | ||
#[derive(Debug, Default, Serialize, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct StorageSettings { | ||
/// Whether LVM should be enabled | ||
pub lvm: Option<bool>, | ||
/// Encryption password for the storage devices (in clear text) | ||
pub encryption_password: Option<String>, | ||
/// Boot device to use in the installation | ||
pub boot_device: Option<String>, | ||
#[serde(default)] | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub storage: Option<Box<RawValue>>, | ||
#[serde(default, rename = "legacyAutoyastStorage")] | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub storage_autoyast: Option<Box<RawValue>>, | ||
} | ||
|
||
impl From<&InstallSettings> for StorageSettings { | ||
fn from(install_settings: &InstallSettings) -> Self { | ||
StorageSettings { | ||
storage: install_settings.storage.clone(), | ||
storage_autoyast: install_settings.storage_autoyast.clone(), | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,3 +1,8 @@ | ||
------------------------------------------------------------------- | ||
Wed Jun 26 10:29:05 UTC 2024 - José Iván López González <[email protected]> | ||
|
||
- Set and get storage config (gh#openSUSE/agama#1293). | ||
|
||
------------------------------------------------------------------- | ||
Tue Jun 25 15:16:33 UTC 2024 - Imobach Gonzalez Sosa <[email protected]> | ||
|
||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
np: I know we are kind of in a hurry, but in the future we should drop this call to
unwrap
.