Wrapper that was developed in order to manage libvirt virtual machines
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
virt_wrapper-0.10.2.tar.gz
(15.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file virt_wrapper-0.10.2.tar.gz.
File metadata
- Download URL: virt_wrapper-0.10.2.tar.gz
- Upload date:
- Size: 15.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb339711450aecf2d1b24f1d3a696fd821ec70550f20f31b9ac8022cb2da1b72
|
|
| MD5 |
f3dca8f5b01e27cd75bd0ffcabcc1fd8
|
|
| BLAKE2b-256 |
4846e9af57eb5dbbd5c2996cd0d6de5572727040f22765f26e121a76aa72d48e
|
File details
Details for the file virt_wrapper-0.10.2-py3-none-any.whl.
File metadata
- Download URL: virt_wrapper-0.10.2-py3-none-any.whl
- Upload date:
- Size: 21.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
563a8d1c9751a5877eec39e75bb05e5a79db069f9dba33dbfd5ab44749989f7d
|
|
| MD5 |
d003815bd80781701a591e27c2b0204a
|
|
| BLAKE2b-256 |
08baad910d4da6a0534bb407a2dc968cabf60167429650d09081a1f9e20f12a2
|