Skip to main content

Description

Python wrapper for managing virtual infrastructure based on Hyper-V or KVM (libvirt)

Example usage

Get all VMs on particular hypervisor

import asyncio

from virt_wrapper import AuthData, Hypervisor, HypervisorPlatform


async def main():
    async with Hypervisor.create(
        HypervisorPlatform.KVM,  # Or HypervisorPlatform.HYPERV
        host='localhost',
        auth=AuthData('user', 'pass')
    ) as srv:
        for vm in await srv.get_vms():
            print(await vm.get_name())
            
        # Get VM by ID
        vm = await srv.get_vm(vm_id='71e8f28b-0cb5-42f4-95b3-5ffc68738733')
        print(await vm.get_name())


if __name__ == '__main__':
    asyncio.run(main())

Requirements

KVM

  • SSH-key must be imported on target server
  • User must have full access to libvirt
usermod <your_user> -aG libvirt
systemctl restart libvirtd

Hyper-V

  • User must have full access to Hyper-V
  • WinRM must be enabled with this parameters
    • HTTPS
    • Basic auth
# Enables the WinRM service and sets up the HTTP listener
Enable-PSRemoting -Force

# Create HTTPS listener
$httpsParams = @{
    ResourceURI = 'winrm/config/listener'
    SelectorSet = @{
        Transport = "HTTPS"
        Address   = "*"
    }
    ValueSet = @{
        CertificateThumbprint = ""
        Enabled               = $true
    }
}
New-WSManInstance @httpsParams

# Enable basic auth
Set-Item -Path WSMan:\localhost\Service\Auth\Basic -Value $true

# Opens port 5986 for all profiles
$firewallParams = @{
    Action      = 'Allow'
    Description = 'Inbound rule for Windows Remote Management via WS-Management. [TCP 5986]'
    Direction   = 'Inbound'
    DisplayName = 'Windows Remote Management (HTTPS-In)'
    LocalPort   = 5986
    Profile     = 'Any'
    Protocol    = 'TCP'
}
New-NetFirewallRule @firewallParams

Available functions:

  • Managing snapshots
  • Managing virtual disks
  • Managing networks
  • Getting info about VM (state, description, guest OS, etc.)
  • Controling VM (run, shutdown, pause, etc)
  • Export/Import virtual machines
  • Migrating
  • Cloning

Metadata

Release files for virt-wrapper 0.11.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for virt-wrapper 0.11.0
File Size Uploaded Provenance Actions
virt_wrapper-0.11.0.tar.gz 16.9 kB Without provenance Details for virt_wrapper-0.11.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for virt-wrapper 0.11.0
File Interpreter ABI Platform Actions
virt_wrapper-0.11.0-py3-none-any.whl Python 3 none any Details for virt_wrapper-0.11.0-py3-none-any.whl

Total release size: 42.1 kB

Release files / virt_wrapper-0.11.0.tar.gz

Download URL virt_wrapper-0.11.0.tar.gz
Size 16.9 kB
Tags Source
SHA-256 checksum
How to use checksums
4d8cfd90ee5e8f5c5bfd780019c43bc4197996768cc4618639bfaa0389f9b94a
BLAKE2b-256 checksum
How to use checksums
981808df48735ac8e495309d82501cacfb494c39b9b9c2e4d3d77595b151f02d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / virt_wrapper-0.11.0-py3-none-any.whl

Download URL virt_wrapper-0.11.0-py3-none-any.whl
Size 25.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8860d667948f06714a4d8c7d1dfe62f8c538c8d42585361769aea7a099417e53
BLAKE2b-256 checksum
How to use checksums
55aa5c74eb14235ee3b611fa0cbd8917ec48629e039b915530ba4d08ab769550
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for virt-wrapper 0.11.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page