1
0
mirror of https://gitlab.com/libvirt/libvirt-python.git synced 2025-11-25 12:23:48 +03:00
Commit Graph

620 Commits

Author SHA1 Message Date
Pavel Hrdina
7178a63e23 fix indentation
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-10-05 08:35:37 +02:00
Pavel Hrdina
c982604ef8 indent labels by one space
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-10-05 08:35:30 +02:00
Pavel Hrdina
862a94aebf cleanup functions definition
Follow the libvirt hacking guide and make the code consistent.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-10-05 08:35:15 +02:00
Pavel Hrdina
a7d71b769d Move utils and shared code into libvirt-utils
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-10-05 08:35:05 +02:00
Pavel Hrdina
46b9507905 drop unnecessary goto
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-10-05 08:34:55 +02:00
Pavel Hrdina
adeeda2089 remove useless check for NULL before Py_XDECREF
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-10-05 08:34:49 +02:00
Pavel Hrdina
448295ed5e refactor the function to not override python exceptions
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-10-05 08:34:40 +02:00
Pavel Hrdina
b822286095 update virDomainGetVcpus xml API description
Python api returns a tuple with the vcpus information.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-10-05 08:20:28 +02:00
Daniel Veillard
1d7df3c97c Release of libvirt-python-1.2.20 v1.2.20 2015-10-02 16:17:06 +02:00
Luyao Huang
3a97b3212d generator: fix build fail with old xml lib
https://bugzilla.redhat.com/show_bug.cgi?id=1222795#c6

if build libvirt-python with some old xml lib (python-pyxml),
build will fail and error like this:

      File "generator.py", line 139, in start
        if "string" in attrs:
      File "/usr/local/lib/python2.7/site-packages/_xmlplus/sax/xmlreader.py" \
        , line 316, in __getitem__
        return self._attrs[name]
    KeyError: 0

This is an old issue and have been mentioned in commit 3ae0a76d.
There is no __contains__ in class AttributesImpl, python will use
__getitem__ in this place, so we will get error.
Let's use 'YYY in XXX.keys()' to avoid this issue.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
2015-09-21 12:04:59 +02:00
Luyao Huang
51b841fa5b examples: small fix for nodestats.py example
Add nodestats.py in MANIFEST.in and add a
small description for nodestats.py in README

Signed-off-by: Luyao Huang <lhuang@redhat.com>
v1.2.19
2015-08-26 18:02:44 -04:00
Jiri Denemark
5a6b2c9839 Check return value of PyList_Append
libvirt_virDomainGetSecurityLabelList called PyList_Append without
checking its return value. While looking at it I noticed the function
did not properly check several other return values either so I fixed
them all.

https://bugzilla.redhat.com/show_bug.cgi?id=1249511

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-08-03 13:55:54 +02:00
Jiri Denemark
d2c44eb80a Post-release version bump to 1.2.19
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-08-03 13:51:30 +02:00
Daniel Veillard
5037e17b13 Forgot to bump version to 1.2.18 2015-08-03 17:55:14 +08:00
Peter Krempa
0a59630a34 iothread: Fix crash if virDomainGetIOThreadInfo returns error
The cleanup portion of libvirt_virDomainGetIOThreadInfo would try to
clean the returned structures but the count of iothreads was set to -1.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1248295
v1.2.18
2015-07-30 09:32:28 +02:00
Michal Privoznik
fa21f3d927 examples: Introduce nodestats example
So, this is an exercise to show libvirt capabilities. Firstly, for
each host NUMA nodes some statistics are printed out, i.e. total
memory and free memory. Then, for each running domain, that has memory
strictly bound to certain host nodes, a small statistics of how much
memory it takes is printed out too. For instance:

        # ./examples/nodestats.py
        NUMA stats
        NUMA nodes:     0       1       2       3
        MemTotal:       3950    3967    3937    3943
        MemFree:        66      56      42      41
        Domain 'fedora':
                Overall memory: 1536 MiB
        Domain 'fedora22':
                Overall memory: 2048 MiB
        Domain 'fedora21':
                Overall memory: 1024 MiB nodes 0-1
                Node 0: 1024 MiB nodes 0-1
        Domain 'gentoo':
                Overall memory: 4096 MiB nodes 0-3
                Node 0: 1024 MiB nodes 0
                Node 1: 1024 MiB nodes 1
                Node 2: 1024 MiB nodes 2
                Node 3: 1024 MiB nodes 3

We can see 4 host NUMA nodes, all of them having roughly 4GB of RAM.
Yeah, all of them has nearly all the memory consumed. Then, there are
four domains running. For instance, domain 'fedora' has 1.5GB memory
which is not pinned onto any specific host NUMA node. Domain 'gentoo' on
the other hand has 4GB memory and has 4 NUMA nodes which are pinned 1:1
to host nodes.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-07-17 11:42:44 +02:00
Pavel Boldin
9896626b82 virPyDictToTypedParams: packing lists of values
Pack a list or a tuple of values passed to a Python method to the
multi-value parameter.
v1.2.17
2015-06-29 11:41:41 +02:00
Martin Kletzander
7acf1422c5 Revert "Change livbirt version to 1.3.0 for the next release"
This reverts commit 751e016f09.

Since Admin API was deferred for a release and the minor version bump
didn't happen, it must not happen in libvirt-python either, for
compatibility reasons.
2015-06-28 11:36:21 +08:00
Martin Kletzander
751e016f09 Change livbirt version to 1.3.0 for the next release
Since the background for Admin API is merged upstream, we are bumping
the minor release version as discussed previously

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-06-16 14:02:56 +02:00
Jiri Denemark
d3e2aff6a7 Provide symbolic names for typed parameters
https://bugzilla.redhat.com/show_bug.cgi?id=1222795

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-06-08 11:28:52 +02:00
Jiri Denemark
cc72783dde Post-release version bump to 1.2.17 2015-06-05 11:35:52 +02:00
Daniel P. Berrange
1ecf4724dc Include tests in MANIFEST
The unit tests were missing from the tar.gz archives due to not
being listed in the MANIFEST.in file

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2015-06-01 10:20:45 +01:00
Jim Fehlig
7211c4aaa3 Fix duplicate entries in AUTHORS
The generated AUTHORS file contains many duplicates.  If an author
has N commits, there will be N entries for the author in AUTHORS.
Check if an author already exists in the list before appending.
While at it, add a .mailmap (derived from libivrt's .mailmap) to
futher tidy the generated AUTHORS list.
v1.2.16
2015-05-28 14:50:51 -06:00
Guido Günther
06e8ea4702 Sort tuples on both items
In order to achieve reproducible builds[0] we want the items within
enums always generated in the same order so sort on both items in the
tuple.

[0] https://wiki.debian.org/ReproducibleBuilds/About
2015-05-20 19:03:04 +02:00
Guido Günther
25448b07b1 Simplify sorting
funcs.keys() can't be None, only the empty array
2015-05-20 19:03:02 +02:00
Guido Günther
49118f6d95 Sort dictionary keys
In order to achive reproducible builds[0] we want functions and enums
always generated in the same order.

[0] https://wiki.debian.org/ReproducibleBuilds/About
2015-05-20 19:02:47 +02:00
Peter Krempa
71c1cdb134 examples: Add example to make guest agent lifecycle event useful
This example allows to use the guest agent event and metadata to track
vCPU count set via the guest agent (agent-based onlining/offlining) and
keep it persistent accross domain restarts.

The daemon listens for the agent lifecycle event, and if it's received
it looks into doman's metadata to see whether a desired count was set
and issues the guest agent command.
2015-05-11 10:53:06 +02:00
Peter Krempa
36737505c4 Post-release version bump to 1.2.16 2015-05-11 10:48:51 +02:00
Victor Stinner
0584ac3f29 libvirt-python: add classifiers to setup.py
Add the Python 3 classifier, needed by the caniusepython3 tool to check
if dependencies of a projects are Python 3 compatible:

    https://caniusepython3.com/
v1.2.15
2015-04-22 16:45:14 +01:00
Victor Stinner
b98b3f6bf3 Add tox.ini to run tests on Python 2.6, 2.7 & 3.4 2015-04-22 16:45:13 +01:00
Victor Stinner
4e7a8bd3b3 sanitytest.py parameters are now optional
When called without parameters, sanitytest.py doesn't touch sys.path and
locates itself the patch to the libvirt-api.xml file using pkg-config.

This change makes possible to run sanitytest.py from tox.
2015-04-22 16:43:03 +01:00
Ján Tomko
cd2d02ab0d Implement the DEVICE_ADDED event 2015-04-15 18:48:23 +02:00
Jiri Denemark
17330a8314 Post-release version bump to 1.2.15
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-04-02 10:50:46 +02:00
Pavel Hrdina
0be1f5e31a Expose virDomainInterfacesAddresses to python binding
examples/Makefile.am:
  * Add new file domipaddrs.py

examples/README:
  * Add documentation for the python example

libvirt-override-api.xml:
  * Add new symbol for virDomainInterfacesAddresses

libvirt-override.c:
  * Hand written python api

Example:
  $ python examples/domipaddrs.py qemu:///system f18
    Interface  MAC address          Protocol     Address
    vnet0      52:54:00:20:70:3d    ipv4         192.168.105.240/16

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
v1.2.14
2015-03-28 11:21:56 +01:00
Ján Tomko
e1e9b27096 Rename virDomainGetIOThreadsInfo to virDomainGetIOThreadInfo 2015-03-26 16:48:18 +01:00
Ján Tomko
c58b696a56 Rename virDomainIOThreadsInfoFree to virDomainIOThreadInfoFree 2015-03-26 16:44:23 +01:00
Pavel Hrdina
52c6643404 Post-release version bump to 1.2.14
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-03-19 14:18:21 +01:00
John Ferlan
b5c3aa95f3 Support virDomainPinIOThread
Support the libvirt_virDomainSetIOThreads method using code that mimics
the existing libvirt_virDomainPinVcpuFlags method

The following is a sample session assuming guest 'iothr-gst' has IOThreads
configured (it's currently running, too)

>>> import libvirt
>>> con=libvirt.open("qemu:///system")
>>> dom=con.lookupByName('iothr-gst')
>>> dom.ioThreadsInfo()
[(1, [False, False, True, False]), (2, [False, False, False, True]), (3, [True, True, True, True])]
>>> cpumap=(True,True,True,False)
>>> dom.pinIOThread(3,cpumap)
0
>>> print dom.ioThreadsInfo()
[(1, [False, False, True, False]), (2, [False, False, False, True]), (3, [True, True, True, False])]
>>>

merge
2015-03-11 15:03:31 -04:00
John Ferlan
d9b519c21a Support virDomainGetIOThreadsInfo and virDomainIOThreadsInfoFree
Add support for the libvirt_virDomainGetIOThreadsInfo method. This
code mostly follows the libvirt_virDomainGetVcpuPinInfo method, but
also takes some from the libvirt_virNodeGetCPUMap method with respect
to building the cpumap into the returned tuple rather than two separate
tuples which vcpu pinning generates

Assuming two domains, one with IOThreads defined (eg, 'iothr-gst') and
one without ('noiothr-gst'), execute the following in an 'iothr.py' file:

import libvirt
con=libvirt.open("qemu:///system")
dom=con.lookupByName('iothr-gst')
print dom.ioThreadsInfo()
dom2=con.lookupByName('noiothr-gst')
print dom2.ioThreadsInfo()

$ python iothr.py
[(1, [False, False, True, False]), (2, [False, False, False, True]), (3, [True, True, True, True])]
[]
$
2015-03-11 15:02:18 -04:00
Ján Tomko
713ed9d570 Clarify description for virNodeGetSecurityModel
s/host/hypervisor/ to match the wording used by the C binding.

https://bugzilla.redhat.com/show_bug.cgi?id=1198518
2015-03-05 16:08:51 +01:00
Daniel P. Berrange
9ef9794a3e Post-release version bump to 1.2.13 v1.2.13 2015-01-27 14:07:10 +00:00
Pavel Hrdina
1180fa9893 sanitytest: fix mapping test for virDomainDefineXMLFlags
The libvirt API has in the name "virDomain" but it's correctly mapped
into "virConnect" class. Create an exception in the sanity test.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
v1.2.12
2015-01-19 16:16:10 +01:00
Eric Blake
ab6eb69f8d build: make it easier to backport event ids
In some cases, it is very easy for downstream distros to backport
enum values without requiring a .so bump.  Keying the conditional
code off of the upstream version where the enum value was added
is not ideal, because downstream then has to patch that the feature
is available in their build that still reports an earlier version
number.  For example, if RHEL 7 backports events from 1.2.11 into
a build based on 1.2.8, building the python bindings would warn:

libvirt-override.c: In function ‘libvirt_virConnectDomainEventRegisterAny’:
libvirt-override.c:6653:5: warning: enumeration value ‘VIR_DOMAIN_EVENT_ID_TUNABLE’ not handled in switch [-Wswitch]
     switch ((virDomainEventID) eventID) {
          ^
	  libvirt-override.c:6653:5: warning: enumeration value ‘VIR_DOMAIN_EVENT_ID_AGENT_LIFECYCLE’ not handled in switch [-Wswitch]

The solution is simple - use feature-based probes instead of
version probes.  Since we already scrape the XML API document of
whatever libvirt build we are binding, and that XML already
documents any downstream enum additions, we can use those as the
features for gating conditional compilation.

* generator.py (enum): Track event id names.
(buildStubs): Output define wrappers for events.
* libvirt-override.c
(libvirt_virConnectDomainEventBalloonChangeCallback)
(libvirt_virConnectDomainEventPMSuspendDiskCallback)
(libvirt_virConnectDomainEventDeviceRemovedCallback)
(libvirt_virConnectDomainEventTunableCallback)
(libvirt_virConnectDomainEventAgentLifecycleCallback)
(libvirt_virConnectDomainEventRegisterAny): Use them.

Signed-off-by: Eric Blake <eblake@redhat.com>
2015-01-15 09:14:50 -07:00
Michal Privoznik
1598bd7dd5 Bump version to 1.2.12 for new dev cycle
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-12-16 14:09:25 +01:00
Richard W.M. Jones
e3da7ade42 Add c_pointer method to classes.
This returns the raw C pointer to the underlying object, eg:

  conn = libvirt.open(None)
  print "0x%x" % conn.c_pointer()   # returns virConnectPtr of the connection
  dom = conn.lookupByName("test")
  print "0x%x" % dom.c_pointer()    # returns virDomainPtr of the domain

The reason behind this is to allow us to transparently pass Python dom
objects through the libguestfs Python API.

https://bugzilla.redhat.com/show_bug.cgi?id=1075164
v1.2.11
2014-12-11 11:21:36 +00:00
Tomoki Sekiyama
8b0e955d95 override: iterate virDomainFSInfo.devAliases using ndevAliases
Currently devAliases in virDomainFSInfo struct are iterated as a
NULL-terminated list, but that is not guaranteed. It should use
ndevAliases which stores the number of the items in devAliases.

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
2014-12-02 09:13:57 +01:00
Pavel Hrdina
39f19f0a2d fix examples
The dhcpleases example had an old usage of print function. The formating
of leases record was also wrong.

The event-test example had an old usage of exceptions.

It's mainly to make examples compatible with python3.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2014-12-01 17:34:31 +01:00
Peter Krempa
acc47bcb71 event: Add bindings for agent lifecycle event
Also add the example.
2014-11-24 17:53:12 +01:00
Tomoki Sekiyama
c6def1bf95 override: Implement bindings for virDomainGetFSInfo as domain.fsInfo
Implement the function which returns a list of tuples, that contains members
of virDomainFSInfo struct.

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
2014-11-24 17:30:49 +01:00
Luyao Huang
3d1d3fd52a Add dict check for setTime and allow pass 'seconds' parameter
When pass None or a empty dictionary to time, it will report
error. This commit allows a one-element dictionary which contains
just 'seconds' field, which results in the same as passing 0 for
'nseconds' field. Moreover, dict is checked for unknown fields.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-11-11 15:58:12 +01:00