Proxmox API - getting information for specific cluster

spacemancw

New Member
Feb 2, 2024
4
0
1
I am currently using the Corsinvest.ProxmoxVE.Api powershell module to do API calls to Proxmox to get all nodes and all VMs which I then publish on an internal web site for engineers to see.

One challenge I have is looking at Cluster information.
I use the 'Get-PveClusterStatus' to get the name of cluster(s) .. and that is using the API endpoint '/cluster/status'

My command is as follows :
Code:
$clusterData = (Get-PveClusterStatus).response.data

and that output of $clusterData looks like:

Code:
type    : cluster
quorate : 1
name    : PVECLUSTER01
nodes   : 5
id      : cluster
version : 19


type   : node
nodeid : 1
local  : 0
level  :
online : 1
ip     : 10.180.8.22
id     : node/sfpmx04
name   : sfpmx04


level  :
name   : sfpmx06
online : 1
id     : node/sfpmx06
ip     : 10.180.8.8
type   : node
nodeid : 3
local  : 0


And in JSON format it looks like this :
Code:
[
  {
    "id": "cluster",
    "version": 19,
    "name": "PVECLUSTER01",
    "nodes": 5,
    "quorate": 1,
    "type": "cluster"
  },
  {
    "level": "",
    "id": "node/sfpmx04",
    "ip": "10.180.8.22",
    "online": 1,
    "name": "sfpmx04",
    "type": "node",
    "local": 0,
    "nodeid": 1
  },
  {
    "nodeid": 3,
    "local": 0,
    "type": "node",
    "name": "sfpmx06",
    "online": 1,
    "id": "node/sfpmx06",
    "ip": "10.180.8.8",
    "level": ""
  }
]



This is fine when there is only one cluster. I can get the the cluster name and node names with :

Code:
$clusterName = ($clusterData | where {$_.type -eq "cluster"}).name
$nodeNames = ($clusterdata | where {$_.type -eq "node"}).name

However if I have more than one cluster, the output of $clusterData would be cluster, nodes, cluster nodes.
So basically

PVECLUSTER01
sfpmx04
sfpmx06
PVECLUSTER02
sfpmx07
sfpmx08
sfpmx049

This output is one array. Each is a separate item in the array and has a 'type' of cluster or node. But there is no identifier on a node to say which cluster it belongs to.

So I was thinking to get around that, I would first get the clusters, the way I got $clusterName above, and then say for each $cluster in $clustername use an API endpoint that points at a specific cluster, if there is such a thing .. but I cannot find it.

the endpoint could be

'/cluster/status/$cluster'
of
'/cluster/status/$clusterID'

This isn't a question about the Corsinvest.ProxmoxVE.Api module. I can use raw API calls to endpoints if I can get help finding the right endpoint.

thanks
 
This isn't a question about the Corsinvest.ProxmoxVE.Api module. I can use raw API calls to endpoints if I can get help finding the right endpoint.
PVE does not currently provide single pane of glass management for multiple clusters, therefor there is no API endpoint to request information about multiple clusters. That mashed array is produced by Cosinvest. Likely, by sending individual API requests to each cluster that you have defined somewhere.

To answer your question - there is no endpoint that can help you in API. Your question is indeed about the module and should be directed to module authors. Perhaps, in a form of a bug.


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
I am currently using the Corsinvest.ProxmoxVE.Api powershell module to do API calls to Proxmox to get all nodes and all VMs which I then publish on an internal web site for engineers to see.

One challenge I have is looking at Cluster information.
I use the 'Get-PveClusterStatus' to get the name of cluster(s) .. and that is using the API endpoint '/cluster/status'

My command is as follows :
Code:
$clusterData = (Get-PveClusterStatus).response.data

and that output of $clusterData looks like:

Code:
type    : cluster
quorate : 1
name    : PVECLUSTER01
nodes   : 5
id      : cluster
version : 19


type   : node
nodeid : 1
local  : 0
level  :
online : 1
ip     : 10.180.8.22
id     : node/sfpmx04
name   : sfpmx04


level  :
name   : sfpmx06
online : 1
id     : node/sfpmx06
ip     : 10.180.8.8
type   : node
nodeid : 3
local  : 0


And in JSON format it looks like this :
Code:
[
  {
    "id": "cluster",
    "version": 19,
    "name": "PVECLUSTER01",
    "nodes": 5,
    "quorate": 1,
    "type": "cluster"
  },
  {
    "level": "",
    "id": "node/sfpmx04",
    "ip": "10.180.8.22",
    "online": 1,
    "name": "sfpmx04",
    "type": "node",
    "local": 0,
    "nodeid": 1
  },
  {
    "nodeid": 3,
    "local": 0,
    "type": "node",
    "name": "sfpmx06",
    "online": 1,
    "id": "node/sfpmx06",
    "ip": "10.180.8.8",
    "level": ""
  }
]



This is fine when there is only one cluster. I can get the the cluster name and node names with :

Code:
$clusterName = ($clusterData | where {$_.type -eq "cluster"}).name
$nodeNames = ($clusterdata | where {$_.type -eq "node"}).name

However if I have more than one cluster, the output of $clusterData would be cluster, nodes, cluster nodes.
So basically

PVECLUSTER01
sfpmx04
sfpmx06
PVECLUSTER02
sfpmx07
sfpmx08
sfpmx049

This output is one array. Each is a separate item in the array and has a 'type' of cluster or node. But there is no identifier on a node to say which cluster it belongs to.

So I was thinking to get around that, I would first get the clusters, the way I got $clusterName above, and then say for each $cluster in $clustername use an API endpoint that points at a specific cluster, if there is such a thing .. but I cannot find it.

the endpoint could be

'/cluster/status/$cluster'
of
'/cluster/status/$clusterID'

This isn't a question about the Corsinvest.ProxmoxVE.Api module. I can use raw API calls to endpoints if I can get help finding the right endpoint.

thanks
https://raw.githack.com/Corsinvest/cv4pve-api-powershell/master/doc/index.html
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!