Skip to main content

Smart Proxmox VE API wrapper for automatically managing resources

Project description

ProxmoxManager

Introduction

ProxmoxManager is a smart Python wrapper for Proxmox VE API. It's purpose is to allow easy automatic management for many users with many virtual machines and LCX containers. The idea is that users from external website would unknowingly be registered in Proxmox environment, which will allow them to seamlessly use virtucal machines and containers.

ProxmoxManager is based on proxmoxer library and requires it as a dependency.

Required version of Python: >=3.8

Installation

pip install proxmoxmanager

Use

ProxmoxManager library features a ProxmoxManager class that contains all of the library's functionality. To start using it, you will need to generate public and private API keys with root access.

Creating ProxmoxManager instance:

proxmox_manager = ProxmoxManager(host="example.com:8006", user="root@pam", token_name = "TOKEN_NAME", token_value = "SECRET_VALUE")

ProxmoxManager class contains separate classes for nodes, users, virtual machines and containers, which contain methods needed for managing them.

By calling nodes, users, vms or containers field of ProxmoxManager object you will get a collection of respective objects that behaves like a Python dict and has some additional features.

Example of usage for nodes

Listing all nodes:

proxmox_manager.nodes

Accessing specific node:

proxmox_manager.nodes["node_id"]

Randomly choosing a node (useful for distributing loads evenly):

proxmox_manager.nodes.choose_at_random()

Choose node with most free memory (in %) and get it's id:

id = proxmox_manager.nodes.choose_by_most_free_ram(absolute=False).id

Example of usage for users

Listing all users:

proxmox_manager.users

Creating new user:

proxmox_manager.users.create("username", "password")

Accessing specific user:

proxmox_manager.users["username"]

Getting auth and csrf tokens of user:

proxmox_manager.users["username"].get_tokens("password")

Changing user password:

proxmox_manager.users["username"].change_password("password", "better_new_password")

Deleting user:

proxmox_manager.users["username"].delete()

Example of usage for virtual machines (containers are almost exactly the same)

Listing all VMs:

proxmox_manager.vms

Accessing specific VM:

proxmox_manager.vms["100"]

Check if VM is a template:

proxmox_manager.vms["100"].is_template()

Start VM:

proxmox_manager.vms["100"].start()

Shutdown VM with timeout of 10 seconds after which it will be stopped by force:

proxmox_manager.vms["100"].start(timeout=10)

Add permission for user to use this VM:

proxmox_manager.vms["100"].add_permission(user="username", role="SomeRoleName")

Clone VM to node with most free memory:

proxmox_manager.vms["100"].clone(newid="101", newnode=proxmox_manager.nodes.choose_by_most_free_ram())

Delete VM:

proxmox_manager.vms["100"].delete()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

proxmoxmanager-1.0.2.tar.gz (13.9 kB view hashes)

Uploaded Source

Built Distribution

proxmoxmanager-1.0.2-py3-none-any.whl (19.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page