Authentification to Proxmox VE with API

Valentin1993

New Member
Dec 21, 2017
4
0
1
30
Hello guys,

I'm trying to use Proxmox API in order to manage my nodes cluster from another server.
I read the Proxmox VE wiki but I'm getting an issue with authentification part of Proxmox API.

I'm using proxmoxer and Python.

I wrote this :

#!/usr/bin/python3

from proxmoxer import ProxmoxAPI

def proxmox_authentification () :
proxmox = ProxmoxAPI('172.30.10.140', user='root@pam', password='xxxxx', verify_ssl=False)
return proxmox

for node in proxmox.nodes.get():
for vm in proxmox.nodes(node['node']).openvz.get():
print "{0}. {1} => {2}" .format(vm['vmid'], vm['name'], vm['status'])

But I got this issue :

Traceback (most recent call last):
File "extinction.py", line 5, in <module>
proxmox = ProxmoxAPI('172.30.10.140', user='root', password='xxxxx', verify_ssl=False)
File "/Users/valentinjungbluth/Desktop/DatasystemsCORE3.6/lib/python3.6/site-packages/proxmoxer/core.py", line 106, in __init__
self._backend = importlib.import_module('.backends.%s' % backend, 'proxmoxer').Backend(host, **kwargs)
File "/Users/valentinjungbluth/Desktop/DatasystemsCORE3.6/lib/python3.6/site-packages/proxmoxer/backends/https.py", line 116, in __init__
self.auth = ProxmoxHTTPAuth(self.base_url, user, password, verify_ssl)
File "/Users/valentinjungbluth/Desktop/DatasystemsCORE3.6/lib/python3.6/site-packages/proxmoxer/backends/https.py", line 46, in __init__
raise AuthenticationError("Couldn't authenticate user: {0} to {1}".format(username, base_url + "/access/ticket"))
proxmoxer.backends.https.AuthenticationError: Couldn't authenticate user: root to https://172.30.10.140:8006/api2/json/access/ticket

Did I miss something ? Thank you so much !
 
aside from the fact that your script says python3 but is a python2 script,
it works here without problems. maybe the password you entered is wrong?

edit:

oh and using openvz will also only work for proxmox ve <=3.4
 
It's pretty weird because even if I use Python 2.7, the same script doesn't work with the same authenticate error.

from proxmoxer import ProxmoxAPI

def proxmox_authentification () :
proxmox = ProxmoxAPI(host="172.30.10.140", user="root@pam", password="xxxxx", verify_ssl=False)
return proxmox

The password is correct, the username and the host too.
 
Last edited:
#! /usr/bin/env python
# coding: utf-8

from proxmoxer import ProxmoxAPI

proxmox = ProxmoxAPI(host="172.30.10.140", user="root@pam", password="xxxxxx", verify_ssl=False)

It seems to work. By what I could replace openvz if I use Proxmox version > 3.4 ?
 
Anyway all Python solutions could not work because proxmoxer and al. are developped for proxmox 2.x. So they have all openvz and not lxc implemented. True ?

Finally the best way will be to use pvecm or Curl ?
 

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!