power/pve_test.py

27 lines
606 B
Python
Raw Normal View History

2024-10-08 23:28:29 +00:00
import config
from proxmoxer import ProxmoxAPI
pve_host = config.PVE_HOST
pve_user = config.PVE_USER
pve_pass = config.PVE_PASS
pve_node = 'c530'
proxmox = ProxmoxAPI(pve_host, user=pve_user, password=pve_pass, verify_ssl=False)
all_nodes = proxmox.nodes.get()
def shutdown_pve():
try:
2024-10-09 20:35:42 +00:00
proxmox.nodes(pve_node).status.post(command='shutdown')
2024-10-08 23:28:29 +00:00
print("Node is shutting down.")
except Exception as e:
print(e)
for node in all_nodes:
name = node['node']
node_status = proxmox.nodes(name).status.get()
print(f"Node {name} Status: {node_status}")
2024-10-09 20:21:46 +00:00
shutdown_pve()