class ProxmoxManager()
def __init__(proxmox_url,
proxmox_user,
proxmox_password,
node,
verify_ssl=False)
Initialize the ProxmoxManager with the required parameters.
Arguments:
proxmox_url
str - The URL of the Proxmox VE server.proxmox_user
str - The username to authenticate with.proxmox_password
str - The password to authenticate with.node
str - The Proxmox VE node to manage.verify_ssl
bool - Whether to verify SSL certificates. Defaults to False.
def write_vm_data()
Write VM data to a CSV file.
This method is usually internal and is used to dump data on range VMs to a CSV file.
def read_vm_data()
Read VM data from a CSV file.
This method is usually internal and is used to load data on range VMs from a CSV file.
def authenticate()
Authenticate with the Proxmox VE host and obtain a ticket and CSRF token.
This method is usually internal and is used to authorize with the PVE host.
Returns:
tuple
- A tuple containing the ticket and CSRF token.
def get_next_vm_id(ticket=None)
Get the next available VMID for clone/create operations.
Arguments:
ticket
str, optional - The authentication ticket.
Returns:
int
- The next available VMID.
def clone_vm(template_id, new_name, new_id)
Clone a VM or template to a new VMID and assign a new name.
Arguments:
template_id
int - The ID of the template to clone.new_name
str - The new name for the cloned VM.new_id
int - The new VMID for the cloned VM.
Returns:
dict
- The response data from the clone operation.
def assign_admin_vm_permissions(vm_id, user)
Assign admin permissions to a user for a given VMID.
Arguments:
vm_id
int - The ID of the VM.user
str - The user to assign admin permissions to.
def set_vm_desc(vm_id, desc)
Set the description (Notes) of a VMID.
Arguments:
vm_id
int - The ID of the VM.desc
str - The description to set for the VM.
def destroy_vm(vmid)
Destroy a VM by its ID.
Arguments:
vmid
int - The ID of the VM to destroy.
def create_user(new_username, new_password, realm, name=None)
Create a new user in the given realm
Arguments:
new_username
str - The username (typically short and lowercase, e.g 'john')new_password
str - The user's new passwordrealm
str - Which realm the user belongs to (typically 'pve' or 'pam' unless your cluster has external authentication sources configured)name
str, optional - Human-readable long name for user (e.g. 'John Doe')
def list_users()
Internal method. Returns data array about active users in the cluster
def check_if_user(find_userid)
Check wether or not given username exists in given realm
Arguments:
find_userid
str - user id to search for (full userid, e.g. 'foo@pve')
def destroy_range()
Destroy all range VMs.
def create_range(ids, user)
Create cloned VMs for a given username.
Arguments:
ids
list - A list of VMIDs to clone.user
str - The username to assign to the cloned VMs. Defaults to None.
def apply_sdn()
Apply SDN settings to the cluster.
def add_subnet_to_vnet(vnet_id, subnet_cidr, subnet_gateway)
Add a subnet to a given VNET ID.
Arguments:
vnet_id
int - The ID of the VNET.subnet_cidr
str - The CIDR notation of the subnet to add.
def destroy_subnet(vnet, subnet_cidr)
Destroy a subnet from a given VNET ID.
Arguments:
vnet
int - The ID of the VNET.subnet_cidr
str - The CIDR notation of the subnet to add.
def set_vm_power_status(vmid, state)
Set the power state of a VM
Arguments:
vmid
int - The ID of the VMstate
str - The desired state of the VM. One of "start", "stop", "reset", "shutdown", "suspend", "resume", or "reboot"
def set_password(user, passw)
Set the password of a user
Arguments:
user
str - The username of the user (include realm, e.g. 'john@pve')passw
str - The new
def snapshot_vm(vmid,
snapshot_name,
description=None,
vmstate=False,
snode=None)
Create a snapshot for a given VMID.
Arguments:
vmid
int - The ID of the VM.snapshot_name
str - The name of the snapshot.description
str, optional - The description of the snapshot.vmstate
bool, optional - Whether to save the VM state (RAM). Defaults to False.snode
str, optional - Node that the VM is on (if different than the API node)