api python stop node

edbuschhoff

New Member
Jun 6, 2024
2
0
1
Hey,
I am kind of stuck. I am writing an API with python to migrate vms. This works. Now I try to reboot, or stop a single node:

The one line of code which is supposed to do that is:


proxmox.nodes(source_node).services.post(service='stop')


source_node
is the string of the node. This works when I migrate vms and seems to be ok. Next I try to stop the node with

... service.post(service='stop')

This gives me an error saying that POST is not implemented. But according to the documentation it is.

The URL to the documentation is:

https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/{node}/services/{service}/stop

What is the right statement to stop a node?

Kind regards,

Edwin
 
... service.post(service='stop')
It seems like the line above implies that you set the service to a value of "stop" via a POST call.
The documentation is in the link you provided:
the "services/{service}" only implements GET. The {services} can be one of:
Code:
chrony | corosync | cron | ksmtuned | postfix | pve-cluster | pve-firewall | pve-ha-crm | pve-ha-lrm | 
pvedaemon | pvefw-logger | pveproxy | pvescheduler | pvestatd | spiceproxy | sshd | syslog | systemd-journald 
| systemd-timesyncd

so if you use the API path you referenced in your opening post:

https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/{node}/services/{service}/stop

It should be:
https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/MYNODE/services/ONEOFTHEABOVE/stop

But, as @shanreich pointed out (based on your initial description) you were using wrong API for your needs.


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox