Skip to content
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

New storage proposal settings #656

Merged
merged 92 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
e93e79e
Remove dead code
ancorgs May 29, 2023
bf8a1c8
WIP: very preliminary steps to ProposalSettings
ancorgs Jul 10, 2023
ed138ce
WIP: draft for VolumeOutline (instead of templates)
ancorgs Jul 17, 2023
93cd4b1
WIP: D-Bus conversions
joseivanlopez Jul 18, 2023
c3ac9e8
WIP: draft for getting the volume template for a path
ancorgs Jul 19, 2023
11baf61
WIP: D-Bus conversions
joseivanlopez Jul 19, 2023
69c3984
WIP: use VolumeTemplatesBuilder
joseivanlopez Jul 20, 2023
ff69860
WIP: adapt proposal backend
joseivanlopez Jul 20, 2023
aad83cb
WIP: add ProposalSettingsReader
joseivanlopez Jul 20, 2023
d015f34
WIP: Add system_vg_devices
joseivanlopez Jul 21, 2023
88c3309
WIP: to_y2storage conversion
joseivanlopez Jul 21, 2023
f2ad77b
WIP: add missing dbus data
joseivanlopez Jul 21, 2023
32c8090
WIP: remove format_options
joseivanlopez Jul 21, 2023
b233c4c
WIP: minor corrections and a temporary test
ancorgs Jul 21, 2023
88e986a
WIP: some improvements
joseivanlopez Jul 21, 2023
102ab2d
WIP: conversion from y2storage
joseivanlopez Jul 21, 2023
23bac3e
WIP: some fixes
joseivanlopez Jul 21, 2023
cf4e693
WIP: doc code and small fixes
joseivanlopez Jul 24, 2023
7dc224e
WIP: Rubocop
joseivanlopez Jul 24, 2023
9b3a7e0
WIP: Rubocop
joseivanlopez Jul 24, 2023
86b9ef1
Several small fixes
ancorgs Jul 25, 2023
6469521
WIP: reorganizing tests and adding temporary fixes
ancorgs Jul 26, 2023
2f41a60
WIP: more small adaptations
ancorgs Jul 26, 2023
035f4f0
WIP: some fixes
joseivanlopez Jul 26, 2023
bdd1c1a
Tests for conversions to D-Bus
joseivanlopez Jul 26, 2023
aca34ed
Test settings conversion from D-Bus
joseivanlopez Jul 27, 2023
228fc06
WIP: Test volume conversion from D-Bus
joseivanlopez Jul 27, 2023
c57edd2
Update tests for DBus::Storage::Manager and add fixes
ancorgs Aug 8, 2023
f669169
Small modification to the Storage::Manager test
ancorgs Aug 9, 2023
9dd41da
WIP: more tests adaptations and small fixes
ancorgs Aug 10, 2023
02fa693
Rubocop adjustments
ancorgs Aug 14, 2023
5db39de
Fix conversions
joseivanlopez Aug 17, 2023
b28d423
Code style
joseivanlopez Aug 17, 2023
5149822
Relocate tests and minor fixes
joseivanlopez Aug 17, 2023
c042cbc
Fix yardoc
joseivanlopez Aug 17, 2023
389bf34
ToY2Storage tests and some fixes
joseivanlopez Aug 21, 2023
9ede962
More tests and fixes
joseivanlopez Aug 22, 2023
9c3b6cb
Several fixes
joseivanlopez Aug 22, 2023
87d69cf
Tests for volume conversion from Y2Storage
joseivanlopez Aug 23, 2023
eab41d8
Small conversion fix
joseivanlopez Aug 23, 2023
2959194
More conversion tests
joseivanlopez Aug 23, 2023
cb3d031
Rewrite proposal tests
joseivanlopez Aug 23, 2023
dd9b027
Add D-Bus attribute to get the product mount points
joseivanlopez Aug 23, 2023
b1655bc
Add D-Bus tests
joseivanlopez Aug 23, 2023
049f2a9
Avoid unknown space policies
joseivanlopez Aug 23, 2023
a81c12f
Tests for proposal settings reader
joseivanlopez Aug 23, 2023
effeb2a
Some tests for VolumeTemplatsBuilder
ancorgs Aug 24, 2023
6d2ea9a
Add missing mocking
joseivanlopez Aug 24, 2023
b3dfa69
Merge branch 'master' into plane
joseivanlopez Aug 24, 2023
5fcb1cb
Do not memoize volume templates builder
joseivanlopez Aug 24, 2023
a5c37ba
Adapt storage section of config file
joseivanlopez Aug 24, 2023
4f7cd3b
Complete and fix the config file
joseivanlopez Aug 24, 2023
d814b5d
Update D-Bus documentation
joseivanlopez Aug 24, 2023
1d1b5d5
Fix D-Bus method name
joseivanlopez Aug 24, 2023
d0b9db3
doc/dbus: each documented interface goes to a separate .doc.xml file
mvidner Aug 24, 2023
f35db4b
Copy proxy config to the target system
teclator Aug 21, 2023
2e4dcad
Read the current proxy configuration
teclator Aug 21, 2023
1786301
Make install method public
teclator Aug 22, 2023
3a89c89
Added ProxySetup#install unit test
teclator Aug 22, 2023
7ea9c0f
Ensure the read is done out of the chroot
teclator Aug 22, 2023
b92528e
Add the needed packages before installing the software
teclator Aug 23, 2023
bab9875
Move the proxy propose before software proposal is done
teclator Aug 24, 2023
6821ba2
Logger fix and more unit tests
teclator Aug 24, 2023
1b91c24
Enable service in target
teclator Aug 24, 2023
393e021
Added changelog
teclator Aug 28, 2023
f992c17
Merge pull request #711 from openSUSE/proxy_install
teclator Aug 28, 2023
ed12545
weblate-merge-po.yml - fixed PO file validation
lslezak Aug 28, 2023
4ad4cd2
Merge pull request #716 from openSUSE/po_validation_fix
lslezak Aug 28, 2023
82080ec
Update PO files
yast-bot Aug 28, 2023
3e8707e
Fix the connect() function error
imobachgs Aug 11, 2023
6d855b2
Make NetworkSystem generic over the Adapter
imobachgs Aug 11, 2023
ea6cf3b
Allow to inject a different adapter in the NetworkSystem
imobachgs Aug 25, 2023
2835ca5
Write agama-dbus-server integration tests
imobachgs Aug 14, 2023
8f8c5d0
Document a potential bug in the network service
imobachgs Aug 25, 2023
00840d1
Fix NetworkClient to wait for the connection to appear
imobachgs Aug 25, 2023
85ec299
Use a signal to detect when a connection is added
imobachgs Aug 25, 2023
c55edcf
Merge pull request #717 from openSUSE/po_merge_5999537439
lslezak Aug 28, 2023
f22a960
Tests: detect when a service is started
imobachgs Aug 28, 2023
c867656
Run "cargo fmt" happy according to the CI
imobachgs Aug 28, 2023
4dd1ad0
Remove commented (and outdated) code
imobachgs Aug 28, 2023
601135f
Update from code review
imobachgs Aug 28, 2023
e6aff50
Merge pull request #718 from imobachgs/tests
imobachgs Aug 28, 2023
4fa3e39
Mark more texts for translation
lslezak Aug 28, 2023
a7ce2eb
Remove product counter
lslezak Aug 28, 2023
4322aa1
fix wrong name in rake install
jreidinger Aug 28, 2023
6097959
Merge pull request #720 from openSUSE/fix_rake_install
jreidinger Aug 28, 2023
dbad5f9
Merge pull request #719 from openSUSE/add_more_translations
lslezak Aug 28, 2023
67d9a72
Improvements from review
joseivanlopez Aug 28, 2023
cbb6811
Fix some typos
joseivanlopez Aug 29, 2023
7bd1869
Sort requires
joseivanlopez Aug 29, 2023
c9bde61
Make code easier to understand
joseivanlopez Aug 29, 2023
2205da8
Merge branch 'master' into plane
joseivanlopez Aug 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/weblate-merge-po.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:

- name: Validate the PO files
working-directory: ./agama
run: msgfmt --check-format -o /dev/null web/po/*.po
run: ls web/po/*.po | xargs -n1 msgfmt --check-format -o /dev/null

# any changes besides the timestamps in the PO files?
- name: Check changes
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ if ENV["YUPDATE_FORCE"] == "1" || File.exist?("/.packages.initrd") || live_iso?
sh "cp share/dbus.conf /usr/share/dbus-1/agama.conf"

# update the systemd service file
source_file = "share/systemd.service"
source_file = "share/agama.service"
target_file = "/usr/lib/systemd/system/agama.service"

unless FileUtils.identical?(source_file, target_file)
Expand Down
40 changes: 40 additions & 0 deletions doc/dbus/bus/org.opensuse.Agama.Storage1.Proposal.bus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<node name="/org/opensuse/Agama/Storage1/Proposal">
<interface name="org.freedesktop.DBus.Introspectable">
<method name="Introspect">
<arg name="xml_data" direction="out" type="s"/>
</method>
</interface>
<interface name="org.freedesktop.DBus.Properties">
<method name="Get">
<arg name="interface_name" direction="in" type="s"/>
<arg name="property_name" direction="in" type="s"/>
<arg name="value" direction="out" type="v"/>
</method>
<method name="Set">
<arg name="interface_name" direction="in" type="s"/>
<arg name="property_name" direction="in" type="s"/>
<arg name="val" direction="in" type="v"/>
</method>
<method name="GetAll">
<arg name="interface_name" direction="in" type="s"/>
<arg name="value" direction="out" type="a{sv}"/>
</method>
<signal name="PropertiesChanged">
<arg name="interface" type="s"/>
<arg name="changed_properties" type="a{sv}"/>
<arg name="invalidated_properties" type="as"/>
</signal>
</interface>
<interface name="org.opensuse.Agama.Storage1.Proposal">
<property type="s" name="BootDevice" access="read"/>
<property type="b" name="LVM" access="read"/>
<property type="aas" name="SystemVGDevices" access="read"/>
<property type="s" name="EncryptionPassword" access="read"/>
<property type="s" name="EncryptionMethod" access="read"/>
<property type="s" name="EncryptionPBKDFunction" access="read"/>
<property type="s" name="SpacePolicy" access="read"/>
<property type="aa{sv}" name="Volumes" access="read"/>
<property type="aa{sv}" name="Actions" access="read"/>
</interface>
</node>
6 changes: 5 additions & 1 deletion doc/dbus/bus/org.opensuse.Agama.Storage1.bus.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,16 @@
<property type="b" name="IBFT" access="read"/>
</interface>
<interface name="org.opensuse.Agama.Storage1.Proposal.Calculator">
<method name="DefaultVolume">
<arg name="mount_path" direction="in" type="s"/>
<arg name="volume" direction="out" type="a{sv}"/>
</method>
<method name="Calculate">
<arg name="settings" direction="in" type="a{sv}"/>
<arg name="result" direction="out" type="u"/>
</method>
<property type="ao" name="AvailableDevices" access="read"/>
<property type="aa{sv}" name="VolumeTemplates" access="read"/>
<property type="as" name="ProductMountPoints" access="read"/>
<property type="o" name="Result" access="read"/>
</interface>
<interface name="org.opensuse.Agama.Storage1.ZFCP.Manager">
Expand Down
67 changes: 67 additions & 0 deletions doc/dbus/org.opensuse.Agama.Storage1.Proposal.Calculator.doc.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node name="/org/opensuse/Agama/Storage1">
<node name="zfcp_controllers" />
<node name="zfcp_disks" />
<!--
Interface for calculating a new storage proposal.
-->
<interface name="org.opensuse.Agama.Storage1.Proposal.Calculator">
<!--
Gets the default values for a volume with the given mount path.
-->
<method name="DefaultVolume">
<!--
E.g., /home
-->
<arg name="mount_path" direction="in" type="s"/>
<!--
MountPath s
MountOptions as
TargetDevice s
TargetVG s
FsType s
MinSize t (bytes)
MaxSize t (bytes. Optional, max size is considered as unlimited if omitted)
AutoSize b
Snapshots b
Outline a{sv}
Required b
FsTypes as
SupportAutoSize b
SnapshotsConfigurable b
SnapshotsAffectSizes b
SizeRelevantVolumes as
-->
<arg name="volume" direction="out" type="a{sv}"/>
</method>
<!--
Calculates a new proposal.
-->
<method name="Calculate">
<!--
BootDevice s
LVM b
SystemVGDevices as
EncryptionPassword s
EncryptionMethod s
EncryptionPBKDFunction s
SpacePolicy s
SpaceActions a{ss}
Volumes aa{sv}
List of volumes to create. The values for each volume are the same as the values returned
by DefaultVolume method. The Outline (if given) would be ignored.
-->
<arg name="settings" direction="in" type="a{sv}"/>
<arg name="result" direction="out" type="u"/>
</method>
<property type="ao" name="AvailableDevices" access="read"/>
<!--
Relevant mount points for the selected product. Normally, the product defines some specific
values for these mount points (e.g., min and max sizes, file system type, etc).
-->
<property type="as" name="ProductMountPoints" access="read"/>
<property type="o" name="Result" access="read"/>
</interface>

</node>
44 changes: 44 additions & 0 deletions doc/dbus/org.opensuse.Agama.Storage1.Proposal.doc.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<node name="/org/opensuse/Agama/Storage1/Proposal">
<!--
Interfaces with the properties of the calculated proposal.
-->
<interface name="org.opensuse.Agama.Storage1.Proposal">
<property type="s" name="BootDevice" access="read"/>
<property type="b" name="LVM" access="read"/>
<property type="aas" name="SystemVGDevices" access="read"/>
<property type="s" name="EncryptionPassword" access="read"/>
<property type="s" name="EncryptionMethod" access="read"/>
<property type="s" name="EncryptionPBKDFunction" access="read"/>
<property type="s" name="SpacePolicy" access="read"/>
<!--
List of volumes used for calculating the proposal.
Each volume has the following properties:
MountPath s
MountOptions as
TargetDevice s
TargetVG s
FsType s
MinSize t (bytes)
MaxSize t (bytes. Optional, max size is considered as unlimited if omitted)
AutoSize b
Snapshots b
Outline a{sv}
Required b
FsTypes as
SupportAutoSize b
SnapshotsConfigurable b
SnapshotsAffectSizes b
SizeRelevantVolumes as
-->
<property type="aa{sv}" name="Volumes" access="read"/>
<!--
Actions to perform in the system in order to create the volumes.
Each action has the following properties:
Text s
Subvol b
Delete b
-->
<property type="aa{sv}" name="Actions" access="read"/>
</interface>
</node>
4 changes: 2 additions & 2 deletions rust/agama-dbus-server/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use agama_dbus_server::{locale, network::NetworkService, questions};
use agama_dbus_server::{locale, network, questions};

use log::LevelFilter;
use std::future::pending;
Expand Down Expand Up @@ -28,7 +28,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
log::info!("Started questions interface");
let _conn = locale::start_service(ADDRESS).await?;
log::info!("Started locale interface");
NetworkService::start(ADDRESS).await?;
network::start_service(ADDRESS).await?;
log::info!("Started network interface");

// Do other things or go to wait forever
Expand Down
8 changes: 8 additions & 0 deletions rust/agama-dbus-server/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,12 @@ pub use action::Action;
pub use adapter::Adapter;
pub use dbus::NetworkService;
pub use model::NetworkState;
pub use nm::NetworkManagerAdapter;
pub use system::NetworkSystem;

pub async fn start_service(address: &str) -> Result<(), Box<dyn std::error::Error>> {
let adapter = NetworkManagerAdapter::from_system()
.await
.expect("Could not connect to NetworkManager to read the configuration.");
NetworkService::start(address, adapter).await
}
10 changes: 9 additions & 1 deletion rust/agama-dbus-server/src/network/dbus/interfaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use std::net::{AddrParseError, Ipv4Addr};
use zbus::{
dbus_interface,
zvariant::{ObjectPath, OwnedObjectPath},
SignalContext,
};

/// D-Bus interface for the network devices collection
Expand Down Expand Up @@ -126,7 +127,7 @@ impl Connections {
pub async fn add_connection(&mut self, id: String, ty: u8) -> zbus::fdo::Result<()> {
let actions = self.actions.lock().await;
actions
.send(Action::AddConnection(id, ty.try_into()?))
.send(Action::AddConnection(id.clone(), ty.try_into()?))
.await
.unwrap();
Ok(())
Expand Down Expand Up @@ -163,6 +164,13 @@ impl Connections {
actions.send(Action::Apply).await.unwrap();
Ok(())
}

#[dbus_interface(signal)]
pub async fn connection_added(
ctxt: &SignalContext<'_>,
id: &str,
path: &str,
) -> zbus::Result<()>;
}

/// D-Bus interface for a network connection
Expand Down
11 changes: 6 additions & 5 deletions rust/agama-dbus-server/src/network/dbus/service.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Network D-Bus service.
//!
//! This module defines a D-Bus service which exposes Agama's network configuration.
use crate::network::NetworkSystem;
use crate::network::{Adapter, NetworkSystem};
use agama_lib::connection_to;
use std::error::Error;

Expand All @@ -12,13 +12,14 @@ pub struct NetworkService;

impl NetworkService {
/// Starts listening and dispatching events on the D-Bus connection.
pub async fn start(address: &str) -> Result<(), Box<dyn Error>> {
pub async fn start<T: Adapter + std::marker::Send + 'static>(
address: &str,
adapter: T,
) -> Result<(), Box<dyn Error>> {
const SERVICE_NAME: &str = "org.opensuse.Agama.Network1";

let connection = connection_to(address).await?;
let mut network = NetworkSystem::from_network_manager(connection.clone())
.await
.expect("Could not read network state");
let mut network = NetworkSystem::new(connection.clone(), adapter);

async_std::task::spawn(async move {
network
Expand Down
25 changes: 22 additions & 3 deletions rust/agama-dbus-server/src/network/dbus/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,15 @@ impl Tree {
/// Adds a connection to the D-Bus tree.
///
/// * `connection`: connection to add.
pub async fn add_connection(&self, conn: &mut Connection) -> Result<(), ServiceError> {
/// * `notify`: whether to notify the added connection
pub async fn add_connection(
&self,
conn: &mut Connection,
notify: bool,
) -> Result<(), ServiceError> {
let mut objects = self.objects.lock().await;

let orig_id = conn.id().to_owned();
let (id, path) = objects.register_connection(conn);
if id != conn.id() {
conn.set_id(&id)
Expand All @@ -106,6 +112,10 @@ impl Tree {
.await?;
}

if notify {
self.notify_connection_added(&orig_id, &path).await?;
}

Ok(())
}

Expand All @@ -115,7 +125,7 @@ impl Tree {
pub async fn remove_connection(&mut self, id: &str) -> Result<(), ServiceError> {
let mut objects = self.objects.lock().await;
let Some(path) = objects.connection_path(id) else {
return Ok(())
return Ok(());
};
self.remove_connection_on(path.as_str()).await?;
objects.deregister_connection(id).unwrap();
Expand All @@ -127,7 +137,7 @@ impl Tree {
/// * `connections`: list of connections.
async fn add_connections(&self, connections: &mut [Connection]) -> Result<(), ServiceError> {
for conn in connections.iter_mut() {
self.add_connection(conn).await?;
self.add_connection(conn, false).await?;
}

self.add_interface(
Expand Down Expand Up @@ -182,6 +192,15 @@ impl Tree {
let object_server = self.connection.object_server();
Ok(object_server.at(path, iface).await?)
}

/// Notify that a new connection has been added
async fn notify_connection_added(&self, id: &str, path: &str) -> Result<(), ServiceError> {
let object_server = self.connection.object_server();
let iface_ref = object_server
.interface::<_, interfaces::Connections>(CONNECTIONS_PATH)
.await?;
Ok(interfaces::Connections::connection_added(iface_ref.signal_context(), id, path).await?)
}
}

/// Objects paths for known devices and connections
Expand Down
2 changes: 1 addition & 1 deletion rust/agama-dbus-server/src/network/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::{
};
use thiserror::Error;

#[derive(Default)]
#[derive(Default, Clone)]
pub struct NetworkState {
pub devices: Vec<Device>,
pub connections: Vec<Connection>,
Expand Down
Loading
Loading