import logging
import os

from desktop_env.providers.base import VMManager

logger = logging.getLogger("desktopenv.providers.proxmox.ProxmoxVMManager")
logger.setLevel(logging.INFO)


class ProxmoxVMManager(VMManager):
    """
    Simplified VM manager for Proxmox.

    Unlike VMware/VirtualBox, Proxmox VMs are pre-created on the server.
    This manager does not handle VM provisioning, downloading, or local
    registry management. The VM ID is passed directly via --path_to_vm.
    """

    def __init__(self, registry_path=""):
        pass

    def initialize_registry(self, **kwargs):
        pass

    def add_vm(self, vm_path, **kwargs):
        pass

    def delete_vm(self, vm_path, **kwargs):
        pass

    def occupy_vm(self, vm_path, pid, **kwargs):
        pass

    def list_free_vms(self, **kwargs):
        return []

    def check_and_clean(self, **kwargs):
        pass

    def get_vm_path(self, os_type="Windows", region=None, screen_size=(1920, 1080), **kwargs):
        """Return the VM ID from environment variable or default.

        For Proxmox, the VM is pre-created. The VM ID should be passed
        via --path_to_vm argument. This method is only called when
        --path_to_vm is not provided.
        """
        vmid = os.environ.get("PROXMOX_VM_ID", "102")
        logger.info(f"Using Proxmox VM ID: {vmid}")
        return vmid
