Skip to content

Commit ea1c286

Browse files
committed
Add ParentPool struct
To pass around both pool object path and pool UUID together. Signed-off-by: mulhern <[email protected]>
1 parent dee83a8 commit ea1c286

File tree

4 files changed

+38
-16
lines changed

4 files changed

+38
-16
lines changed

src/dbus/blockdev/mod.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use tokio::sync::RwLock;
1212
use zbus::{zvariant::ObjectPath, Connection};
1313

1414
use crate::{
15-
dbus::{consts, Manager},
16-
engine::{DevUuid, Engine, Lockable, PoolUuid},
15+
dbus::{consts, Manager, ParentPool},
16+
engine::{DevUuid, Engine, Lockable},
1717
stratis::StratisResult,
1818
};
1919

@@ -45,7 +45,7 @@ pub async fn register_blockdev<'a>(
4545
connection: &Arc<Connection>,
4646
manager: &Lockable<Arc<RwLock<Manager>>>,
4747
counter: &Arc<AtomicU64>,
48-
pool_uuid: PoolUuid,
48+
pool: ParentPool<'a>,
4949
dev_uuid: DevUuid,
5050
) -> StratisResult<ObjectPath<'a>> {
5151
let path = ObjectPath::try_from(format!(
@@ -57,79 +57,79 @@ pub async fn register_blockdev<'a>(
5757
engine.clone(),
5858
connection,
5959
path.clone(),
60-
pool_uuid,
60+
pool.uuid,
6161
dev_uuid,
6262
)
6363
.await?;
6464
BlockdevR1::register(
6565
engine.clone(),
6666
connection,
6767
path.clone(),
68-
pool_uuid,
68+
pool.uuid,
6969
dev_uuid,
7070
)
7171
.await?;
7272
BlockdevR2::register(
7373
engine.clone(),
7474
connection,
7575
path.clone(),
76-
pool_uuid,
76+
pool.uuid,
7777
dev_uuid,
7878
)
7979
.await?;
8080
BlockdevR3::register(
8181
engine.clone(),
8282
connection,
8383
path.clone(),
84-
pool_uuid,
84+
pool.uuid,
8585
dev_uuid,
8686
)
8787
.await?;
8888
BlockdevR4::register(
8989
engine.clone(),
9090
connection,
9191
path.clone(),
92-
pool_uuid,
92+
pool.uuid,
9393
dev_uuid,
9494
)
9595
.await?;
9696
BlockdevR5::register(
9797
engine.clone(),
9898
connection,
9999
path.clone(),
100-
pool_uuid,
100+
pool.uuid,
101101
dev_uuid,
102102
)
103103
.await?;
104104
BlockdevR6::register(
105105
engine.clone(),
106106
connection,
107107
path.clone(),
108-
pool_uuid,
108+
pool.uuid,
109109
dev_uuid,
110110
)
111111
.await?;
112112
BlockdevR7::register(
113113
engine.clone(),
114114
connection,
115115
path.clone(),
116-
pool_uuid,
116+
pool.uuid,
117117
dev_uuid,
118118
)
119119
.await?;
120120
BlockdevR8::register(
121121
engine.clone(),
122122
connection,
123123
path.clone(),
124-
pool_uuid,
124+
pool.uuid,
125125
dev_uuid,
126126
)
127127
.await?;
128128
BlockdevR9::register(
129129
engine.clone(),
130130
connection,
131131
path.clone(),
132-
pool_uuid,
132+
pool.uuid,
133133
dev_uuid,
134134
)
135135
.await?;

src/dbus/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use zbus::{connection::Builder, Connection};
1010
pub use crate::dbus::{
1111
blockdev::register_blockdev,
1212
manager::Manager,
13+
types::ParentPool,
1314
udev::UdevHandler,
1415
util::{send_fs_background_signals, send_pool_background_signals},
1516
};

src/dbus/pool/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use tokio::sync::RwLock;
1111
use zbus::{zvariant::ObjectPath, Connection};
1212

1313
use crate::{
14-
dbus::{consts, register_blockdev, Manager},
14+
dbus::{consts, register_blockdev, Manager, ParentPool},
1515
engine::{Engine, Lockable, PoolIdentifier, PoolUuid},
1616
stratis::{StratisError, StratisResult},
1717
};
@@ -52,7 +52,7 @@ pub async fn register_pool<'a>(
5252
let mut bd_paths = Vec::new();
5353
let bd_uuids = pool.blockdevs().into_iter().map(|(u, _, _)| u).collect::<Vec<_>>();
5454
for dev_uuid in bd_uuids {
55-
match register_blockdev(engine, connection, manager, counter, pool_uuid, dev_uuid).await {
55+
match register_blockdev(engine, connection, manager, counter, ParentPool { object_path: path.clone(), uuid: pool_uuid}, dev_uuid).await {
5656
Ok(op) => bd_paths.push(op),
5757
Err(_) => {
5858
warn!("Unable to register object path for blockdev with UUID {dev_uuid} belonging to pool {pool_uuid} on the D-Bus");

src/dbus/types.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use std::collections::HashMap;
66

7-
use zbus::zvariant::{signature::Child, Basic, Dict, Signature, Type, Value};
7+
use zbus::zvariant::{signature::Child, Basic, Dict, ObjectPath, Signature, Type, Value};
88

99
use crate::{
1010
dbus::util::result_option_to_tuple,
@@ -279,3 +279,24 @@ impl Basic for PoolUuid {
279279
const SIGNATURE_CHAR: char = 's';
280280
const SIGNATURE_STR: &str = "s";
281281
}
282+
283+
pub struct ParentPool<'a> {
284+
pub object_path: ObjectPath<'a>,
285+
pub uuid: PoolUuid,
286+
}
287+
288+
#[allow(dead_code)]
289+
pub struct OwnedParentPool {
290+
object_path: String,
291+
uuid: PoolUuid,
292+
}
293+
294+
impl ParentPool<'_> {
295+
#[allow(dead_code)]
296+
pub fn to_owned(&self) -> OwnedParentPool {
297+
OwnedParentPool {
298+
object_path: self.object_path.to_string(),
299+
uuid: self.uuid,
300+
}
301+
}
302+
}

0 commit comments

Comments
 (0)