WEB API for Proxmox 9 HA rules

Robert Dahlem

Active Member
May 7, 2018
21
1
43
62
Hi,

I'm trying to convert my HA playbooks from HA groups to HA rules. I'm using the API as described under https://pve.proxmox.com/pve-docs/api-viewer/index.html

Let's begin with asking about existing rules. I have one rule which was created by the automatic conversion from HA groups to HA rules.

pvesh get /cluster/ha/rules gives me:
Code:
┌──────────────┐
│ rule         │
╞══════════════╡
│ ha-group-all │
└──────────────┘
and pvesh get /cluster/ha/rules/ha-group-all gives me:
Code:
┌──────┬───────────────┐
│ key  │ value         │
╞══════╪═══════════════╡
│ rule │ ha-group-all  │
├──────┼───────────────┤
│ type │ node-affinity │
└──────┴───────────────┘
but how do I get the actual rule contents like enabled, state, strict, HA resources, nodes and comment? And how about updating the values?

Also, it seems that rules have names (like "ha-group-all"), but where do I see the names in the Web UI? How do I identify a rule create in the Web UI when using the API?

In the past I could add a resource to a group by POSTing to /cluster/ha/resources with sid and group. The documentation still mentions group but there are no groups anymore.

Is there an updated version of the API documentation?

Regards,
Robert
 
Hi!

Also, it seems that rules have names (like "ha-group-all"), but where do I see the names in the Web UI? How do I identify a rule create in the Web UI when using the API?
There is currently no way to see the rule names in the web UI. I think the main reason for this was to kind of abstract away working with these IDs in the web UI for users, while they are still manageable via the API. One way to identify the rule would be through a comment. If you create the rule through the API, you can set the name/ID of the rule and then use that.

In the past I could add a resource to a group by POSTing to /cluster/ha/resources with sid and group. The documentation still mentions group but there are no groups anymore.
You have to think a bit differently about rules than you did about groups. For groups, you had a 1:1 mapping from resources to groups, which is why you could say "put resource A in group X". Since a resource can belong to multiple rules, the mental model changes a bit and you instead define a list of resources for a rule. The direction changes. So you'd POST to /cluster/ha/rules with a list of resources or PUT to /cluster/ha/rules/{rule} to update the list of resources of a rule.
 
Last edited: