Giter Site home page Giter Site logo

proxmoxer's Introduction

Proxmoxer: A wrapper for Proxmox REST API

master branch: master_build_status master_coverage_status pypi_version pypi_downloads

develop branch: develop_build_status develop_coverage_status

What does it do and what's different?

Proxmoxer is a wrapper around the Proxmox REST API v2. Works with Proxmox Virtual Environment (PVE) and Proxmox Mail Gateway (PMG) API.

It was inspired by slumber, but it is dedicated only to Proxmox. It allows not only REST API use over HTTPS, but the same api over ssh and pvesh utility.

Like Proxmoxia, it dynamically creates attributes which responds to the attributes you've attempted to reach.

Installation

To use the 'https' backend, install requests

To use the 'ssh_paramiko' backend, install paramiko

Short usage information

The first thing to do is import the proxmoxer library and create ProxmoxAPI instance.

This will connect by default to PVE through the 'https' backend.

To define service to PVE or PMG, include service option into script:

Define PVE connection:

Define PMG connection:

You can also setup API Tokens which allow tighter access controls. API Tokens are also stateless, so they much better for long-lived programs that might have the standard username/password authentication timeout. API tokens can be created through the web UI or through the API.

For SSH access, it is possible to use pre-prepared public/private key authentication and ssh-agent.

Note: the 'https' backend needs the 'requests' library, the 'ssh_paramiko' backend needs the 'paramiko' library, and the 'openssh' backend needs the 'openssh_wrapper' library installed.

Queries are exposed via the access methods get, post, put and delete. For convenience two synonyms are available: create for post, and set for put.

Using the paths from the Proxmox REST API v2, you can create API calls using the access methods above.

same code can be rewritten in the next way:

As a demonstration of the flexibility of usage of this library, the following lines accomplish the equivalent function:

Some more examples:

Listing VMs: .. code-block:: python

for vm in proxmox.cluster.resources.get(type='vm'):

print("{0}. {1} => {2}" .format(vm['vmid'], vm['name'], vm['status']))

Listing contents of the local storage on the proxmox_node node (method 1): .. code-block:: python

node = proxmox.nodes('proxmox_node') pprint(node.storage('local').content.get())

Listing contents of the local storage on the proxmox_node node (method 2): .. code-block:: python

node = proxmox.nodes.proxmox_node() pprint(node.storage.local.content.get())

creating a new lxc container:

The same lxc container can be created with options set in a dictionary. This approach allows adding ssh-public-keys without getting syntax errors.

Uploading a template:

Downloading rrd CPU image data to a file:

Example of usage of logging:

Example of PMG usage:

Changelog

1.1.1 (2020-06-23)

  • Bugfix (https): correctly renew ticket in the session, not just the auth (John Hollowell)

1.1.0 (2020-05-22)

  • Addition (https): Added API Token authentication (John Hollowell)
  • Improvement (https): user/password authentication refreshes ticket to prevent expiration (CompileNix and John Hollowell)
  • Bugfix (ssh_paramiko): Handle empty stderr from ssh connections (morph027)
  • DEPRECATED (https): using auth_token and csrf_token (ProxmoxHTTPTicketAuth) is now deprecated. Either pass the auth_token as the password or use the API Tokens.

1.0.4 (2020-01-24)

  • Improvement (https): Added timeout to authentication (James Lin)
  • Improvement (https): Handle AnyEvent::HTTP status codes gracefully (Georges Martin)
  • Improvement (https): Advanced error message with error code >=400 (ssi444)
  • Bugfix (ssh): Fix pvesh output format for version > 5.3 (timansky)
  • Transfered development to proxmoxer organization

1.0.3 (2018-09-10)

1.0.2 (2017-12-02)

  • Tarball repackaged with tests

1.0.1 (2017-12-02)

  • LICENSE file now included in tarball
  • Added verify_ssl parameter to ProxmoxHTTPAuth (Walter Doekes)

1.0.0 (2017-11-12)

0.2.5 (2017-02-12)

0.2.4 (2016-05-02)

0.2.3 (2016-01-20)

0.2.2 (2016-01-19)

0.2.1 (2015-05-02)

0.2.0 (2015-03-21)

  • Https will now raise AuthenticationError when appropriate. (scap1784)
  • Preliminary python 3 compatibility. (wdoekes)
  • Additional example. (wdoekes)

0.1.7 (2014-11-16)

  • Added ignore of "InsecureRequestWarning: Unverified HTTPS request is being made..." warning while using https (requests) backend.

0.1.4 (2013-06-01)

  • Added logging
  • Added openssh backend
  • Tests are reorganized

0.1.3 (2013-05-30)

  • Added next tests
  • Bugfixes

0.1.2 (2013-05-27)

  • Added first tests
  • Added support for travis and coveralls
  • Bugfixes

0.1.1 (2013-05-13)

  • Initial try.

proxmoxer's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.