This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

This module aims to manage KVM hypervisors. For this it use the unix module which allow to manage Unix-like systems, both locally and remotely, in the same by overloading class instances. This module is just a wrapper to the virsh command. It parse outputs of the virsh command (both XML and text). Commands are grouped in childs objects accessible via properties.

Installation

This module is compatible with python2.7 and python 3.*. The module is on PyPi so you can use the pip command for installing it.

For example, to use kvm in a virtualenv:

$ virtualenv env/ --prompt "(myprog)"
$ . ./env/bin/activate
(myprog) $ pip install kvm

Otherwise sources are on github: https://github.com/fmenabe/python-kvm

Usage

You need to import the necessary classes from unix module. An hypervisor is represented by the Hypervisor object and must wrap an object of type unix.Local or unix.Remote. It theorically support any Unix system, but disks manipulations need nbd module to be loaded so it is better to use an unix.linux.Linux host.

>>> from unix import Local, Remote, UnixError
>>> from unix.linux import Linux
>>> import kvm
>>> import json
>>> localhost = kvm.Hypervisor(Linux(Local()))
>>> localhost.hypervisor.nodeinfo()
{'nb_cpu': 1,
 'nb_threads_per_core': 2,
 'memory': 16331936,
 'numa_cells': 1,
 'cpu_model': 'x86_64',
 'nb_cores_per_cpu': 4,
 'nb_cores': 8,
 'cpu_freq': 1340}
>>> localhost.list_domains(all=True)
{'guest1': {'id': -1, 'state': 'shut off'}}
{'guest2': {'id': 1, 'state': 'running'}}
>>> localhost.domain.start('guest1')
# Wait a few seconds for the domain to start.
>>> localhost.domain.state('guest1')
'running'
>>> localhost.domain.id('guest1')
2
>>> print(json.dumps(localhost.domain.conf('guest1'), indent=2))
# json is use for pretty printing the dictionnary containing the
# configuration.
{
  "@type": "kvm",
  "name": "guest1",
  "uuid": "ed68d942-5d4b-7bba-4d74-7d44d73779d3",
  "memory": {
    "@unit": "KiB",
    "#text": "2097152"
  },
  ...
}
>>> localhost.list_networks()
{'default': {'autostart': True, 'persistent': True, 'state': 'active'}}

>>> host = unix.Remote()
>>> host.connect('hypervisor1')
>>> host = kvm.Hypervisor(Linux(host)
>>> host.hypervisor.nodeinfo()
{'cores_per_socket': 12,
 'cpu_frequency': '2200 MHz',
 'cpu_model': 'x86_64',
 'cpu_sockets': 2,
 'cpus': 24,
 'memory_size': '98974432 kB',
 'numa_cells': 1,
 'threads_per_core': 1}
>>> host.list_domains(all=True)
{'guest1': {'id': 1, 'state': 'running'}}
{'guest2': {'id': 2, 'state': 'running'}}
>>> host.domain.shutdown('guest2')
# Wait for the domain to stop.
>>> host.domain.state('guest1')
'shut off'

Releases notes

1.0.4 (2015-07-02)

  • Wrapper to ”virsh” command.

  • Each type (domain, nodedev, net, …) has one command for listing and a property regrouping commands to apply to one element.

  • Properties:
    • hypervisor: generic commands (nodeinfo, capabilities, …)
    • domains: commands for managing a domain
    • nodedev: commands for managing a node device
    • net: commands for managing a vritual network
    • iface: commands for manage an interface
  • Transfrom XML outputs to dictionnaries.

Release History

Release History

1.0.5

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0.4

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
kvm-1.0.5.tar.gz (8.4 kB) Copy SHA256 Checksum SHA256 Source Dec 3, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting