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

54 Commits

Author SHA1 Message Date
Philipp Hahn
bd238713ef sanitytest: no type change
static typing forbids re-declaring a variable with different types.
Rename the variable.

Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-08-06 08:50:37 +02:00
Philipp Hahn
22f2ba37ae sanitytest: Use str.startswith() instead of str[0]
Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-08-06 08:50:37 +02:00
Philipp Hahn
b6ad44257e sanitytest: Use set for tracking used functions
Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-08-06 08:50:37 +02:00
Philipp Hahn
ddf73e40a9 sanitytest: Use 3-tuple for finalklassmap
Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-08-06 08:50:37 +02:00
Philipp Hahn
809b963134 sanitytest: Use 3-tuple for basicklassmap
Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-08-06 08:50:37 +02:00
Philipp Hahn
94c24929e4 sanitytest: Add PEP 484 type annotations
Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-08-06 08:50:37 +02:00
Philipp Hahn
fd8b7733dc sanitytest: Drop Python 2 compatibility
Python 3 only has int, remove the Python 2 long type

Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-08-06 08:50:37 +02:00
Philipp Hahn
ff9575a727 sanitytest: Drop else:pass
useless

Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-08-06 08:50:37 +02:00
Philipp Hahn
6279dbefc2 sanitytest: Do not re-declare set
is a built-in python type

Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-08-06 08:50:37 +02:00
Philipp Hahn
39ffa7f838 sanitytest: Convert type() to isinstance()
Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-08-06 08:50:37 +02:00
Philipp Hahn
8a81fc6f2b sanitytest: Skip type annotations
Teach sanitytest to ignore typing imports

Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-08-06 08:50:37 +02:00
Philipp Hahn
b5f7beb931 sanitytest: Remove unused import
Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-08-06 08:50:37 +02:00
Philipp Hahn
0ca8dc6340 Normalize white space
indent by 4 spaces
one spaces around assignments

Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-08-06 08:50:37 +02:00
Daniel P. Berrangé
7d2715c0dd test: workaround missing VIR_TYPED_PARAM enums in API definition
On Ubuntu 18.04 with libvirt 4.0.0 libvirt-python build fails

running test
/usr/bin/python3 sanitytest.py build/lib.linux-x86_64-3.6 /usr/share/libvirt/api/libvirt-api.xml
Cannot get a value of enum VIR_TYPED_PARAM_BOOLEAN (originally VIR_DOMAIN_BLKIO_PARAM_BOOLEAN)
Cannot get a value of enum VIR_TYPED_PARAM_DOUBLE (originally VIR_DOMAIN_BLKIO_PARAM_DOUBLE)
Cannot get a value of enum VIR_TYPED_PARAM_INT (originally VIR_DOMAIN_BLKIO_PARAM_INT)
...snip...

The code generated for the binding is still correct and so we can just
whitelist this error scenario.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-05-01 13:13:13 +01:00
Daniel P. Berrangé
b22e4f2441 Drop support for python 2
python2 will be end of life by the time of the next
libvirt release. All our supported build targets, including
CentOS7, have a python3 build available.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-12-04 12:14:51 +00:00
Daniel P. Berrangé
6b2b3b7ea2 sanitytest: whitelist 'network' method as having no C impl
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-09-12 16:09:58 +01:00
Eric Blake
358a8640fa Add virDomainCheckpoint APIs
Copies heavily from existing virDomainSnapshot handling, regarding
what special cases the generator has to be taught and what overrides
need to be written.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2019-07-29 13:39:39 -05:00
Daniel P. Berrangé
c4e529ff28 sanitytest: add some special cases for virNetworkPort APIs
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-06-20 14:20:05 +01:00
Daniel P. Berrangé
c1f06dde29 Fix bugs in nwfilter binding APIs
We did not correctly mangle the API names in two cases, and we also
forgot to specialize the lookup method name in the sanity test.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-06-28 12:29:21 +01:00
Daniel P. Berrangé
c682257e6f Blacklist virGetLastError{Code,Domain}
These methods will not be exposed to apps, since we auto raise
all errors.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-06-06 16:49:32 +01:00
Daniel P. Berrangé
b68b3ef399 tests: add special case for virStoragePoolLookupByTargetPath
This new API trips up the sanity test for checking mapping of
all C APIs into Python.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-02-09 13:54:47 +00:00
Cédric Bosdonnat
bedc937cce Don't hardcode interpreter path
This is particularly useful on operating systems that don't ship
Python as part of the base system (eg. FreeBSD) while still working
just as well as it did before on Linux.

Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
2017-11-30 08:48:36 +01:00
Daniel P. Berrange
13b4283d58 Skip sparseRecvAll / sparseSendAll in sanity test
The sanity test check aims to ensure that every function listed in
the Python code maps to a corresponding C function. The Sparse
send/recv methods are special though - we're never calling the
corresponding C APIs, instead we have a pure python impl.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2017-09-18 12:59:42 +01:00
Michal Privoznik
d7e1c976f4 virStream: Introduce virStreamSparse{Recv,Send}All
Yet again, our parser is not capable of generating proper
wrapper. To be fair, this one wold be really tough anyway.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-05-24 13:32:37 +02:00
Wojtek Porczyk
72e237f7b9 Allow for ff callbacks to be called by custom event implementations
The documentation says:
> If the opaque user data requires free'ing when the handle is
> unregistered, then a 2nd callback can be supplied for this purpose.
> This callback needs to be invoked from a clean stack. If 'ff'
> callbacks are invoked directly from the virEventRemoveHandleFunc they
> will likely deadlock in libvirt.

And they did deadlock. In removeTimeout too. Now we supply a custom
function to pick it from the opaque blob and fire.

Signed-off-by: Wojtek Porczyk <woju@invisiblethingslab.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2017-04-04 15:00:27 +01:00
Daniel P. Berrange
69797c4726 Add support for secret event APIs
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2017-01-09 18:07:40 +00:00
Jovanka Gulicoska
58a986984f Python binding for node poll lifecycle events API 2016-08-02 09:55:56 -04:00
Jovanka Gulicoska
7eaab4a6c2 Python binding for storage pool lifecycle events API
Code matches the network event API implementation
2016-06-16 12:25:44 -04: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
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>
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
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
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>
2015-01-19 16:16:10 +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
2014-12-11 11:21:36 +00: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
Martin Kletzander
5346d9d9a3 sanitytest: define long for python version >= 3
Commit c58c7f362a fixed 32-bit python
build but broke build with python3 due to the lack of 'long' in the
newer version of python.  This patch aims to fix it with a simple
string comparison of sys.version and '3'.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-10-07 10:35:10 +02:00
Martin Kletzander
c58c7f362a sanitytest: count with the fact that large enums can be long
On 32-bit systems, one new flag that has the value of 1 << 31, namely
VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS, fails to fit into an
'int' on python and is therefore of type 'long'.  Fix sanitytest to
count with such fact in order to avoid build failures on 32-bit systems.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-10-07 10:08:38 +02:00
Martin Kletzander
09b157076f sanitytest: check for exported enums
We are already collecting list of enums exported and list of enums we
want to have available.  Event though there was an issue with one enum
fixed with 014d9bbaf3, there was no test
for it and this commit tries to fix that.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-10-06 17:20:32 +02:00
Pavel Hrdina
5ead8c1b0c API: Implement bindings for virDomainListGetStats
Implement the function by returning a list of tuples instead the array
of virDomainStatsRecords and store the typed parameters as dict.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2014-09-01 22:12:46 +02:00
Peter Krempa
7edf050a26 API: Skip 'virDomainStatsRecordListFree'
The new API function doesn't make sense to be exported in python. The
bindings will return native types instead of the struct array.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2014-09-01 22:11:56 +02:00
Nehal J Wani
bdb64c7641 Implement new virNetworkGetDHCPLeases API
This API returns a list of DHCP leases for all network interfaces
connected to the given virtual network or limited output just for one
interface if mac is specified.

Example Output:
[{'iface': 'virbr3', 'ipaddr': '192.168.150.181', 'hostname': 'ubuntu14',
    'expirytime': 1403737495L, 'prefix': 24, 'clientid': None,
    'mac': '52:54:00:e8:73:eb', 'iaid': None, 'type': 0},
 {'iface': 'virbr3', 'ipaddr': '2001:db8:ca2:2:1::bd', 'hostname': 'fedora20-test',
    'expirytime': 1403738587L, 'prefix': 64, 'clientid': '00:04:b1:d8:86:42:e1:6a:aa:cf:d5:86:94:23:6f:94:04:cd',
    'mac': '52:54:00:5b:40:98', 'iaid': '5980312', 'type': 1}]

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2014-06-27 10:39:19 +02:00
Michal Privoznik
bcacc418a3 Implement virDomain{Get,Set}Time APIs
While the setter can be generated automatically, the getter is not.
However, it would be a lot easier if they both share the same logic:
a python dictionary to represent the time: dict['seconds'] to
represent seconds, and dict['nseconds'] to represent nanoseconds.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-05-20 17:26:17 +02:00
Tomoki Sekiyama
c5bbd5bd9d override: add virDomainFSFreeze and virDomainFSThaw API
Add binding for the new virDomainFSFreeze and virDomainFSThaw functions
added in libvirt 1.2.5. These require override since these take a list
of mountpoints path string. The methods are named 'fsFreeze' and
'fsThaw'.

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-05-16 15:45:25 +02:00
Daniel P. Berrange
ab2b22aa7d Skip network event callbacks in sanity test
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-12-11 16:39:13 +00:00
Daniel P. Berrange
d499f4a7c1 sanitytest: remove use of string.lower()
Call lower() directly on the string object instance, not
the class

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-12-11 16:14:46 +00:00
Daniel P. Berrange
919bb0cc3b sanitytest: Fix broken comparison between int and string
Python2 was forgiving of a comparison between an int and string
but Python3 gets very upset.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-12-11 16:14:46 +00:00
Daniel P. Berrange
c6dcaef7d9 sanitytest: Fix libvirtError class handling for Python 2.4
The Exception class hiearchy in Python 2.4 reports different
data types than in later Python versions. As a result the
type(libvirt.libvirtError) does not return 'type'. We just
special case handling of this class.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-12-11 16:12:54 +00:00
Doug Goldstein
1f180dde63 test: Invoke print("...") instead of print "..."
The 'print' statement no longer exists in Python 3 and now must be
called as a function. This is compatible down to Python 2.4 as we are
not using any special syntax of the function.
2013-12-09 08:49:56 -06:00
Daniel P. Berrange
4fe9994338 Improve quality of sanitytest check
Validate that every public API method is mapped into the python
and that every python method has a sane C API.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-11-28 13:37:55 +00:00