summaryrefslogtreecommitdiff
path: root/generator.py
Commit message (Collapse)AuthorAgeFilesLines
...
* generator: Directly get dict lengthPhilipp Hahn2020-09-011-2/+2
| | | | | | instead of generating a list and then counting the elements. Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Walk only the valuesPhilipp Hahn2020-09-011-2/+2
| | | | | | instead of the keys and then doing a lookup. Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Use dict.item() to walk keys and valuesPhilipp Hahn2020-09-011-12/+7
| | | | | | which saves a lookup of each key. Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Check contained in hashPhilipp Hahn2020-09-011-10/+10
| | | | | | | | | | | directly instead of explicitly requesting only the keys as a list and converting that list to another list. Checking directly for an element to be contained in a hash is much more efficient as this is done using hashing O(1) instead of walking the list in half on average O(n). Signed-off-by: Philipp Hahn <hahn@univention.de> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* generator: Initialize function_classes directlyPhilipp Hahn2020-09-011-3/+3
| | | | Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Remove global declarationsPhilipp Hahn2020-09-011-28/+0
| | | | | | for variables with are not assigned. Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Use string concatenationPhilipp Hahn2020-09-011-15/+15
| | | | | | :%s,\(\w\+\)\s*=\s*\1\s*+,\1 +=, Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Use increment assignmentPhilipp Hahn2020-09-011-3/+3
| | | | | | :%s,\(\w\+\)\s*=\s*\1\s*+,\1 +=, Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Use enumerate()Philipp Hahn2020-09-011-27/+9
| | | | | | instead of manual iteration counting. Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Simplify string concatentaionPhilipp Hahn2020-09-011-6/+2
| | | | | | | by using ''.join() instead of concatenating string fragments in a loop, which is slower as it required re-hashing the string multiple times. Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Use more string formattingPhilipp Hahn2020-09-011-7/+4
| | | | Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Merge now identical if-elif-else casesPhilipp Hahn2020-09-011-92/+10
| | | | | | | | | | | | Commit ca394b9f "generator: Fix parent type" fixed the case for creating `virStorage*` instances, which require a reference to `virConnect`, so the special handling for `._conn` is no longer needed. Commit ee5c856a "Remove legacy libvirtError arguments" removed the different arguments, so all cases are the same now. Signed-off-by: Philipp Hahn <hahn@univention.de> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* generator: Fix return type on failurePhilipp Hahn2020-09-011-2/+2
| | | | | | to return a negative value instead of None for consistency. Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Remove useless sort keyPhilipp Hahn2020-09-011-1/+1
| | | | | | tuples are sorted by first component anyway. Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Remove skipped_modulesPhilipp Hahn2020-09-011-6/+0
| | | | | | Unused. Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Remove dead variable assignmentsPhilipp Hahn2020-09-011-2/+0
| | | | Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Use raw-string for regular expressionPhilipp Hahn2020-09-011-1/+1
| | | | | | | | | | | | | "\(" is not a valid escape sequence for a Python string, but currently is passed on unmodified. This might breaks in the future when new escape sequences are introduced. > generator.py:1001:7: W605 invalid escape sequence '\(' > generator.py:1001:18: W605 invalid escape sequence '\)' Use raw python string instead. Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Convert to 'not in' and 'is not'Philipp Hahn2020-09-011-2/+2
| | | | | | as recommended by pep8 Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Change type of quiet to boolPhilipp Hahn2020-09-011-1/+1
| | | | | | Use `bool` instead of `int`. Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Simplify exception handlingPhilipp Hahn2020-09-011-18/+8
| | | | | | | sys.exc_info() returns a 3-tuple (type, value, traceback), where `value` is the instance captured by `except type as value`. Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Cleanup importsPhilipp Hahn2020-09-011-7/+5
| | | | | | | | Move imports to top Remove unused import string Remove duplicate import os Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Do not use bare exceptPhilipp Hahn2020-09-011-2/+2
| | | | | | as it also catches SystemExit, InterruptedError, SyntaxError and such. Signed-off-by: Philipp Hahn <hahn@univention.de>
* Remove legacy libvirtError argumentsPhilipp Hahn2020-08-061-19/+19
| | | | | | | | | | | | The fields have been deprecated in C with git:f60dc0bc09f09c6817d6706a9edb1579a3e2b2b8 They are only passed to the libvirtError constructor, but not stored for later or used anywhere else. sed -ri '/raise libvirtError/s/, \w+=self(\._dom)?//' *.py Signed-off-by: Philipp Hahn <hahn@univention.de>
* Normalize white spacePhilipp Hahn2020-08-061-297/+313
| | | | | | | indent by 4 spaces one spaces around assignments Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Fix parent typev6.6.0Philipp Hahn2020-07-271-33/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The constructors for virDomain, virStoragePool, virDomainCheckpoint, virDomainSnapshot expect virConnect as their first argument. The current code always uses `self`, which is okay when such an instance is created from a method of virConnect itself, but there are several cases where this is not the case: virDomain.migrate() -> virDomain virDomain.migrate2() -> virDomain virDomain.migrate3() -> virDomain virDomainCheckpoint.getParent() -> virDomainCheckpoint virDomainSnapshot.getParent() -> virDomainSnapshot virStorageVol.storagePoolLookupByVolume() -> virStoragePool > libvirt.py:1850: error: Argument 1 to "virDomain" has incompatible type "virDomain"; expected "virConnect" > libvirt.py:1871: error: Argument 1 to "virDomain" has incompatible type "virDomain"; expected "virConnect" > libvirt.py:1888: error: Argument 1 to "virDomain" has incompatible type "virDomain"; expected "virConnect" > libvirt.py:3422: error: Argument 1 to "virStorageVol" has incompatible type "virStoragePool"; expected "virConnect" > libvirt.py:6835: error: Argument 1 to "virDomainCheckpoint" has incompatible type "virDomainCheckpoint"; expected "virDomain" > libvirt.py:6943: error: Argument 1 to "virDomainSnapshot" has incompatible type "virDomainSnapshot"; expected "virDomain" >>> import libvirt >>> con = libvirt.open('test:///default') >>> dom = con.lookupByName("test") >>> first = dom.checkpointCreateXML("""<domaincheckpoint><name>First</name></domaincheckpoint>""") >>> first.domain() <libvirt.virDomain object at 0x7f728c3b6b80> ^^^^^^ >>> second = dom.checkpointCreateXML("""<domaincheckpoint><name>Second</name></domaincheckpoint>""") >>> parent = second.getParent() >>> parent.domain() <libvirt.virDomainCheckpoint object at 0x7f728c424d30> ^^^^^^^^^^^^^^^^ Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Fix string formattingPhilipp Hahn2020-07-271-1/+1
| | | | | | remove excessive arguments. Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Fix undefined variables filePhilipp Hahn2020-07-271-2/+2
| | | | | | | generator.py:931:15: F821 undefined name 'file' generator.py:951:15: F821 undefined name 'file' Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Fix typosRadostin Stoyanov2020-07-171-7/+7
| | | | Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
* generator: Fix SyntaxWarningCole Robinson2020-07-051-1/+1
| | | | | | | | | | | | $ ./setup.py build running build /usr/bin/pkg-config --print-errors --atleast-version=0.9.11 libvirt /usr/bin/python3 generator.py libvirt /usr/share/libvirt/api/libvirt-api.xml generator.py:1562: SyntaxWarning: "is" with a literal. Did you mean "=="? if classname is "virStorageVol": ... Signed-off-by: Cole Robinson <crobinso@redhat.com>
* virStream: Use larger buffer for sendAll/recvAll methodsMichal Privoznik2020-07-031-0/+6
| | | | | | | | | | | | | | | | | | | | There are four methods which receive/send entire stream (sendAll(), recvAll(), sparseSendAll() and sparseRecvAll()). All these have an intermediary buffer which is either filled by incoming stream and passed to a user provided callback to handle the data, or the other way round - user fills it with data they want to send and the buffer is handed over to virStream. But the buffer is incredibly small which leads to smaller packets being sent and thus increased overhead. What we can do is to use the same buffer as their C counterparts do (e.g. virStreamSendAll()) - they all use VIR_NET_MESSAGE_LEGACY_PAYLOAD_MAX long buffer (which is the maximum size of a stream packet we send) - this is almost exactly 256KiB (it's 256KiB - 24B for the header). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
* Add overrides for network port UUID getter/lookup methodsDaniel P. Berrangé2020-01-031-0/+3
| | | | | | | The generator creates broken code for all these methods. Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* Drop support for python 2Daniel P. Berrangé2019-12-041-1/+1
| | | | | | | | | 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>
* generator.py: add mapping for VIR_DOMAIN_QEMU_AGENT_COMMAND_*Pavel Hrdina2019-11-281-0/+6
| | | | | | | | | | | | | | | | | | Libvirt commit <95f5ac9ae52455e9da47afc95fa31c9456ac27ae> changed the VIR_DOMAIN_QEMU_AGENT_COMMAND_* enum values to use different enum values instead of direct numbers. We need to translate it back. Traceback (most recent call last): File "generator.py", line 2143, in <module> qemuBuildWrappers(sys.argv[1]) File "generator.py", line 2008, in qemuBuildWrappers items.sort(key=lambda i: (int(i[1]), i[0])) File "generator.py", line 2008, in <lambda> items.sort(key=lambda i: (int(i[1]), i[0])) ValueError: invalid literal for int() with base 10: 'VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_BLOCK' Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
* Custom impl for virConnectSetIdentity which can't be generatedDaniel P. Berrangé2019-09-201-0/+1
| | | | | Reviewed-by: Pavel Hrdina <phrdina@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* generator: fix constructor for virNetworkPortDaniel P. Berrangé2019-09-121-0/+13
| | | | | | | | | | The virNetworkPort class is passed both the virNetwork parent python class and the virNetworkPort C object. This needs special handling in the generator, similar to how virDomainSnapshots are dealt with. Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* Implement virDomainGetGuestInfoMichal Privoznik2019-08-291-0/+1
| | | | | Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
* Add virDomainCheckpoint APIsEric Blake2019-07-291-4/+27
| | | | | | | | | 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>
* generator: fix naming of getter APIs for virNetworkPortDaniel P. Berrangé2019-06-201-0/+3
| | | | Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* Add support for virNetworkPort object & APIsDaniel P. Berrangé2019-06-201-2/+23
| | | | | | | | | Define the various rules in the generator to wire up methods into the virNetwork class and create the new virNetworkPort class. Reviewed-by: Pavel Hrdina <phrdina@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* generator.py: typo fixEric Blake2019-02-071-1/+1
| | | | Signed-off-by: Eric Blake <eblake@redhat.com>
* Implement API binding for virDomainSetIOThreadParamsJohn Ferlan2018-11-201-0/+1
| | | | | | | | Similar to libvirt_virDomainBlockCopy (and migration API's). Create the code for the new API. Signed-off-by: John Ferlan <jferlan@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
* Fix bugs in nwfilter binding APIsDaniel P. Berrangé2018-06-281-1/+4
| | | | | | | 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>
* Add support for nwfilter binding objects / apisDaniel P. Berrangé2018-06-281-3/+30
| | | | Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* Add support for virNodeGetSEVInfoErik Skultety2018-06-141-0/+1
| | | | | | | | | | This binding allows to query the AMD's SEV firmware for various platform specific things, like a PDH certificate and a certificate chain to establish a trusted connection with the firmware. Because the API uses typed params, it's exempted from generation. Signed-off-by: Erik Skultety <eskultet@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* Add support for virDomainGetLaunchSecurityInfoErik Skultety2018-06-141-0/+1
| | | | | | | | | Libvirt recently introduced support for getting launch security parameters, most notably AMD SEV VM memory measurement. This API can't be generated as it's using typed parameters which we need to allocate. Signed-off-by: Erik Skultety <eskultet@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* Add support for virConnectBaselineHypervisorCPUJiri Denemark2018-06-011-0/+1
| | | | | | | | | | The python bindings for this API cannot be generated because are generator is not capable of handling string arrays (char **) parameters. https://bugzilla.redhat.com/show_bug.cgi?id=1584676 Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* libvirt_qemu/lxc: fix a namespace issueMarc Hartmayer2018-05-161-2/+2
| | | | | | Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com> Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com> Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
* libvirt_qemu/lxc: import 'sys' packageMarc Hartmayer2018-05-161-0/+4
| | | | | | | | | | | This fixes the pylint [1] warning "E: 25,16: Undefined variable 'sys' (undefined-variable)". [1] https://www.pylint.org/ Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com> Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com> Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
* Don't hardcode interpreter pathCédric Bosdonnat2017-11-301-1/+1
| | | | | | | | 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>
* Introduce virDomainMigrateGetMaxDowntime APIJohn Ferlan2017-08-261-0/+1
| | | | Introduce wrapper for virDomainMigrateGetMaxDowntime