From: Dominik Csapak <d.csapak@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH datacenter-manager 1/3] server: api: add 'realms' add point for PVE
Date: Thu, 19 Dec 2024 13:09:18 +0100 [thread overview]
Message-ID: <20241219120920.2046373-4-d.csapak@proxmox.com> (raw)
In-Reply-To: <20241219120920.2046373-1-d.csapak@proxmox.com>
similar to 'scan' where we can scan the realms of a 'not-yet' remote host
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
server/src/api/pve/mod.rs | 52 +++++++++++++++++++++++++++++++++++++--
1 file changed, 50 insertions(+), 2 deletions(-)
diff --git a/server/src/api/pve/mod.rs b/server/src/api/pve/mod.rs
index 7ab529c..81fdf76 100644
--- a/server/src/api/pve/mod.rs
+++ b/server/src/api/pve/mod.rs
@@ -23,7 +23,8 @@ use pdm_api_types::{
use pve_api_types::client::PveClient;
use pve_api_types::{
- ClusterResourceKind, ClusterResourceType, QemuMigratePreconditions, StartQemuMigrationType,
+ ClusterResourceKind, ClusterResourceType, ListRealm, QemuMigratePreconditions,
+ StartQemuMigrationType,
};
use super::resources::{map_pve_lxc, map_pve_node, map_pve_qemu, map_pve_storage};
@@ -41,7 +42,11 @@ pub const ROUTER: Router = Router::new()
#[sortable]
const SUBDIRS: SubdirMap = &sorted!([
("remotes", &REMOTES_ROUTER),
- ("scan", &Router::new().post(&API_METHOD_SCAN_REMOTE_PVE))
+ ("scan", &Router::new().post(&API_METHOD_SCAN_REMOTE_PVE)),
+ (
+ "realms",
+ &Router::new().post(&API_METHOD_LIST_REALM_REMOTE_PVE)
+ )
]);
pub const REMOTES_ROUTER: Router = Router::new().match_all("remote", &MAIN_ROUTER);
@@ -1338,3 +1343,46 @@ pub async fn scan_remote_pve(
Ok(remote)
}
+
+#[api(
+ input: {
+ properties: {
+ hostname: {
+ type: String,
+ format: &HOST_OPTIONAL_PORT_FORMAT,
+ description: "Hostname (with optional port) of the target remote",
+ },
+ fingerprint: {
+ type: String,
+ description: "Fingerprint of the target remote.",
+ optional: true,
+ },
+ },
+ },
+ access: {
+ permission:
+ &Permission::Privilege(&["/"], PRIV_SYS_MODIFY, false),
+ },
+)]
+/// Scans the given connection info for pve cluster information
+pub async fn list_realm_remote_pve(
+ hostname: String,
+ fingerprint: Option<String>,
+) -> Result<Vec<ListRealm>, Error> {
+ // dummy remote to connect
+ let remote = Remote {
+ ty: RemoteType::Pve,
+ id: String::new(),
+ nodes: vec![PropertyString::new(NodeUrl {
+ hostname,
+ fingerprint,
+ })],
+ authid: "root@pam".parse()?,
+ token: String::new(),
+ };
+
+ let client = connection::make_pve_client(&remote)?;
+ let list = client.list_domains().await?;
+
+ Ok(list)
+}
--
2.39.5
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
next prev parent reply other threads:[~2024-12-19 12:09 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-19 12:09 [pdm-devel] [PATCH yew-widget-toolkit/proxmox-api-types/pdm] overhaul remote wizard Dominik Csapak
2024-12-19 12:09 ` [pdm-devel] [PATCH yew-widget-toolkit 1/1] widget: input panel: use correct column for custom childs Dominik Csapak
2024-12-19 12:22 ` [pdm-devel] applied: " Thomas Lamprecht
2024-12-19 12:09 ` [pdm-devel] [PATCH proxmox-api-types 1/1] add /access/domains GET call Dominik Csapak
2024-12-19 12:22 ` [pdm-devel] applied: " Thomas Lamprecht
2024-12-19 12:09 ` Dominik Csapak [this message]
2024-12-19 12:09 ` [pdm-devel] [PATCH datacenter-manager 2/3] pdm-client: expose `ListRealm` type Dominik Csapak
2024-12-19 12:09 ` [pdm-devel] [PATCH datacenter-manager 3/3] ui: restructure wizard to have a better flow Dominik Csapak
2024-12-19 12:31 ` [pdm-devel] applied: [PATCH yew-widget-toolkit/proxmox-api-types/pdm] overhaul remote wizard Thomas Lamprecht
2024-12-19 12:35 ` Dominik Csapak
2024-12-19 12:40 ` Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241219120920.2046373-4-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pdm-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox