[pdm-devel] [PATCH proxmox-datacenter-manager v7 4/7] fake remote: make the fake_remote feature compile again
Lukas Wagner
l.wagner at proxmox.com
Wed Aug 20 14:43:26 CEST 2025
The ClientFactory trait was changed in Wolfgang's multi-client patches,
this commit adapts the fake remote feature to the changes.
Signed-off-by: Lukas Wagner <l.wagner at proxmox.com>
Reviewed-by: Dominik Csapak <d.csapak at proxmox.com>
Tested-by: Dominik Csapak <d.csapak at proxmox.com>
---
Notes:
Changes in v6:
- add missing memhost value for ClusterResource
No changes in v5
No changes in v4
No changes in v3
new in v2
server/src/test_support/fake_remote.rs | 33 +++++++++++++++-----------
1 file changed, 19 insertions(+), 14 deletions(-)
diff --git a/server/src/test_support/fake_remote.rs b/server/src/test_support/fake_remote.rs
index 0161d8e6..02d11f88 100644
--- a/server/src/test_support/fake_remote.rs
+++ b/server/src/test_support/fake_remote.rs
@@ -1,18 +1,22 @@
-use std::{collections::HashMap, time::Duration};
+use std::{collections::HashMap, sync::Arc, time::Duration};
use anyhow::{bail, Error};
+use serde::Deserialize;
+
use pdm_api_types::{remotes::Remote, Authid, ConfigDigest};
use pdm_config::remotes::RemoteConfig;
use proxmox_product_config::ApiLockGuard;
use proxmox_section_config::typed::SectionConfigData;
use pve_api_types::{
- client::PveClient, ClusterMetrics, ClusterMetricsData, ClusterNodeIndexResponse,
- ClusterNodeIndexResponseStatus, ClusterResource, ClusterResourceKind, ClusterResourceType,
- ListTasks, ListTasksResponse, PveUpid, StorageContent,
+ ClusterMetrics, ClusterMetricsData, ClusterNodeIndexResponse, ClusterNodeIndexResponseStatus,
+ ClusterResource, ClusterResourceKind, ClusterResourceType, ListTasks, ListTasksResponse,
+ PveUpid, StorageContent,
};
-use serde::Deserialize;
-use crate::{connection::ClientFactory, pbs_client::PbsClient};
+use crate::{
+ connection::{ClientFactory, PveClient},
+ pbs_client::PbsClient,
+};
#[derive(Deserialize, Clone)]
#[serde(rename_all = "kebab-case")]
@@ -74,8 +78,8 @@ impl FakeRemoteConfig {
#[async_trait::async_trait]
impl ClientFactory for FakeClientFactory {
- fn make_pve_client(&self, _remote: &Remote) -> Result<Box<dyn PveClient + Send + Sync>, Error> {
- Ok(Box::new(FakePveClient {
+ fn make_pve_client(&self, _remote: &Remote) -> Result<Arc<PveClient>, Error> {
+ Ok(Arc::new(FakePveClient {
nr_of_vms: self.config.vms_per_pve_remote,
nr_of_cts: self.config.cts_per_pve_remote,
nr_of_nodes: self.config.nodes_per_pve_remote,
@@ -88,7 +92,7 @@ impl ClientFactory for FakeClientFactory {
&self,
_remote: &Remote,
_target_endpoint: Option<&str>,
- ) -> Result<Box<dyn PveClient + Send + Sync>, Error> {
+ ) -> Result<Arc<PveClient>, Error> {
bail!("not implemented")
}
@@ -96,10 +100,7 @@ impl ClientFactory for FakeClientFactory {
bail!("not implemented")
}
- async fn make_pve_client_and_login(
- &self,
- _remote: &Remote,
- ) -> Result<Box<dyn PveClient + Send + Sync>, Error> {
+ async fn make_pve_client_and_login(&self, _remote: &Remote) -> Result<Arc<PveClient>, Error> {
bail!("not implemented")
}
@@ -118,7 +119,7 @@ struct FakePveClient {
}
#[async_trait::async_trait]
-impl PveClient for FakePveClient {
+impl pve_api_types::client::PveClient for FakePveClient {
async fn cluster_resources(
&self,
_ty: Option<ClusterResourceKind>,
@@ -143,6 +144,7 @@ impl PveClient for FakePveClient {
maxdisk: Some(100 * 1024 * 1024),
maxmem: Some(8 * 1024 * 1024 * 1024),
mem: Some(3 * 1024 * 1024 * 1024),
+ memhost: Some(4 * 1024 * 1024),
name: Some(format!("vm-{vmid}")),
netin: Some(1034),
netout: Some(1034),
@@ -175,6 +177,7 @@ impl PveClient for FakePveClient {
maxcpu: Some(4.),
maxdisk: Some(100 * 1024 * 1024),
maxmem: Some(8 * 1024 * 1024 * 1024),
+ memhost: Some(4 * 1024 * 1024),
mem: Some(3 * 1024 * 1024 * 1024),
name: Some(format!("ct-{vmid}")),
netin: Some(1034),
@@ -208,6 +211,7 @@ impl PveClient for FakePveClient {
maxdisk: Some(100 * 1024 * 1024),
maxmem: Some(8 * 1024 * 1024 * 1024),
mem: Some(3 * 1024 * 1024 * 1024),
+ memhost: None,
name: None,
netin: None,
netout: None,
@@ -240,6 +244,7 @@ impl PveClient for FakePveClient {
maxdisk: Some(100 * 1024 * 1024),
maxmem: None,
mem: None,
+ memhost: None,
name: None,
netin: None,
netout: None,
--
2.47.2
More information about the pdm-devel
mailing list