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
 

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!