summaryrefslogtreecommitdiff
path: root/generator.py
Commit message (Collapse)AuthorAgeFilesLines
* override: domain: Implement override for virDomainFDAssociatev9.0.0Peter Krempa2023-01-121-0/+1
| | | | | | | | The bindings generator can't generate proper bindings for FD passing so the bindings need to be implemented manually both the python wrapper and the C backend. Signed-off-by: Peter Krempa <pkrempa@redhat.com>
* Add an override impl for virDomainRestoreParams and virDomainSaveParamsv8.4.0Michal Privoznik2022-05-131-0/+2
| | | | Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* generator: introduce ability to selectively generate codeDaniel P. Berrangé2022-04-211-2/+8
| | | | | | | | Currently we always generate both the C code and Python code at the same time. To cope with following changes to the build process, we want to be able to generate C and Python separately. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* generator: rename methods for code generationDaniel P. Berrangé2022-04-211-4/+4
| | | | | | The names make it clearer exactly what is being generated by each. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* generator: split function skip logic out of C generatorDaniel P. Berrangé2022-04-211-29/+55
| | | | | | | | | | | | | | The python generator needs to know whether certain functions were skipped in the C generator. This is achieved by the C generator deleting skipped functions as it runs. This is an unhelpful side effect as it makes it impossible to run the python generator without first running the C generator. This refactors buildStubs to get rid of the global side effects it has, by providing some helper functions for buildWrappers to use. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* generator: split function type validation out of C generatorDaniel P. Berrangé2022-04-211-29/+62
| | | | | | | | | | | As a side effect of generating the C code, the buildStubs methods checks for various unsupported types and reports errors. This is an undesirable side effect, if we want to skip C code generation. Splitting function type validation out into a separate method allows better reuse. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* generator: split loading of APIs out from writing stubsDaniel P. Berrangé2022-04-211-4/+9
| | | | | | | | | | The buildStubs method has a side effect of loading and parsing the API XML files, which the buildWrappers method then relies on. Splitting API loading into a separate method will facilitate running only the buildWrappers method in future. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* generator: merge python wrapper generator methodsDaniel P. Berrangé2022-04-211-231/+71
| | | | | | | Instead of having three separate methods for generating python wrappers, merge them all together. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* generator: refactor buildWrappers to make it more genericDaniel P. Berrangé2022-04-211-8/+33
| | | | | | | Prepare for using buildWrappers to generate code for the QEMU / LXC APIs too. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* generator: simplify some repeated code patternsDaniel P. Berrangé2022-04-211-56/+17
| | | | | | | | Now that we're using common data structures for all the main libvirt, QEMU and LXC APIs, several of the functions have code duplication that can be eliminated. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* generator: use single function for registering all enumsDaniel P. Berrangé2022-04-211-18/+7
| | | | | | | Now that we only use a single dict for tracking all enums, we only need a single function for registering them. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* generator: use single dict for tracking all enumsDaniel P. Berrangé2022-04-211-8/+6
| | | | | | | | A single invokation of the generator only handles processing of one libvirt API module, so there is no need to use separate dicts for tracking enums. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* generator: use single function for registering all functionsDaniel P. Berrangé2022-04-211-39/+11
| | | | | | | Now that we only use a single dict for tracking all functions, we only need a single function for registering them. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* generator: use single dict for tracking all skipped functionsDaniel P. Berrangé2022-04-211-34/+8
| | | | | | | | A single invokation of the generator only handles processing of one libvirt API module, so there is no need to use separate dicts for tracking skipped functions. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* generator: use single dict for tracking all functionsDaniel P. Berrangé2022-04-211-14/+12
| | | | | | | | A single invokation of the generator only handles processing of one libvirt API module, so there is no need to use separate dicts for tracking functions. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* Implement virDomainQemuMonitorCommandWithFiles() overrideMichal Privoznik2022-03-101-0/+1
| | | | | | | | | | | With libvirt-8.2.0 there's a new API: virDomainQemuMonitorCommandWithFiles(). Since the API has both input and output arguments we need to provide an alternative implementation. Moreover, since FD passing works only on UNIX-like systems we can query the returned FDs for their flags and construct mode for python File object. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* Add an override impl for virDomainSetLaunchSecurityStatev8.0.0Daniel P. Berrangé2022-01-051-0/+1
| | | | Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* Add new autostart API for node devicesJonathon Jongsma2021-09-211-0/+1
| | | | | | | Provide a manual override for the virNodeDeviceGetAutostart() API modeled on what's done for the network and storage APIs. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
* generator.py: Untangle virNodeDevice name fixupv7.3.0Michal Privoznik2021-04-151-8/+9
| | | | | | | | | The way that virNodeDevice method name fixup is written makes it hard to find via grep (matching the virNodeDevice prefix and then matching only the operation like "Get", "Lookup", ...). Expand the string matching to match the pattern of other cases. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* generator.py: Fix method names for new virNodeDevice*() APIsMichal Privoznik2021-04-151-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In the 7.3.0 release we are going to have three new public APIs: virNodeDeviceDefineXML() virNodeDeviceUndefine() virNodeDeviceCreate() The first one is slightly problematic, because it takes virConnectPtr argument and thus our generator wants to put its wrapper under virConnect python class, which is correct, but what's incorrect is the name it chooses for the method: defineXML(). Such method already exists and wraps virDomainDefineXML() around. Also, the name is rather confusing anyway - it's missing the 'nodeDevice' prefix. Fortunately, the fix is easy - add another case into nameFixup(). The story with virNodeDeviceCreate() is similar. Except, this time the class in which the method was put is correct. But the name is still wrong, because our generator matched 'virNodeDeviceCreate' thinking it's the good old virNodeDeviceCreateXML() API and "fixed" the name of the method to nodeDeviceCreate(). Luckily, virNodeDeviceUndefine() is just fine. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* Add impl override for virDomainGetMessagesDaniel P. Berrangé2021-02-151-0/+1
| | | | Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* Implement virDomainAuthorizedSSHKeys{Get,Set}Michal Privoznik2020-11-191-0/+2
| | | | | | | | Both APIs work with string lists (the getter returns it, the setter gets keys to set from it) -> represent that as a python list. The rest is kept as is in C. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* fix constructor param name for virDomainSnapshot / virDomainCheckpointDaniel P. Berrangé2020-10-061-1/+1
| | | | | | | Fixes 7f021c21d6a091ca33615852d6061e75b2500f3f Resolves https://gitlab.com/libvirt/libvirt-python/-/issues/4 Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* generator: Work around type changev6.8.0Philipp Hahn2020-09-011-3/+2
| | | | | | | a variable should not change its type. Signed-off-by: Philipp Hahn <hahn@univention.de> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* generator: Add PEP 484 type annotationsPhilipp Hahn2020-09-011-49/+55
| | | | Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Merge common code of print_function_wrapperPhilipp Hahn2020-09-011-20/+15
| | | | Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Merge code for __init__ genrationPhilipp Hahn2020-09-011-11/+5
| | | | Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Expand tuple to names in for loopPhilipp Hahn2020-09-011-4/+2
| | | | | | Assign tuple to multiple loop variables for better readability Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: break lines in generated codePhilipp Hahn2020-09-011-14/+28
| | | | | | | to be closes to pep8 which makes reading the generated code easier and reduces the number of issues found by flake8. Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Use empty string instead of NonePhilipp Hahn2020-09-011-14/+14
| | | | | | for better type checking: both are bool()==False, but None is not str. Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Convert to defaultdict()Philipp Hahn2020-09-011-20/+7
| | | | | | | | for nested dictionaries allows to remove the case distinction for "first" from "all other" cases. Signed-off-by: Philipp Hahn <hahn@univention.de> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* generator: Move funcs_failed into buildStubs()Philipp Hahn2020-09-011-7/+1
| | | | | | The variables are local to that funcion Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Convert list() to set()Philipp Hahn2020-09-011-23/+24
| | | | | | | tuple() and list() are sequences, while dict() and set() are hash-based, which is more efficient for contains(). Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Convert dict() to set()Philipp Hahn2020-09-011-24/+24
| | | | | | Python has a native type for set()s. Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Simplify boolean conditionPhilipp Hahn2020-09-011-15/+15
| | | | | | no need to compare with None or empty string. Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Simplify loop breakPhilipp Hahn2020-09-011-8/+4
| | | | Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Simplify sortingPhilipp Hahn2020-09-011-15/+6
| | | | | | Use sorted(..., key=...) instead of using explicit list.sort() Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Fixed writing cached=NonePhilipp Hahn2020-09-011-1/+1
| | | | Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Store arguments and return as tuplePhilipp Hahn2020-09-011-63/+67
| | | | | | instead of list. Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Expand tuple to names in for loopPhilipp Hahn2020-09-011-26/+26
| | | | | | Assign tuple to multiple loop variables for better readability Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Initialize with empty stringsPhilipp Hahn2020-09-011-12/+13
| | | | | | instead of using None as this has a different type. Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Simplify XML attribute fetchingPhilipp Hahn2020-09-011-29/+11
| | | | | | | | | | | | Use attr.get(key, default) instead. Also use the empty sting "" as the default value instead of "None": Both are "False" when used as a bool()ean, but "None" would require an explicit check for "not None" in many places as str() and None have different types. Signed-off-by: Philipp Hahn <hahn@univention.de> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* generator: Convert in_function to boolPhilipp Hahn2020-09-011-9/+9
| | | | Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Use string formattingPhilipp Hahn2020-09-011-13/+13
| | | | | | instead of sting concatenating. Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Use SAX method namesPhilipp Hahn2020-09-011-13/+7
| | | | | | | directly instead of using legacy method names from xmllib. Depends: 3740a5e4c701281ac76a55e3f02b1d4221f1f9f0 Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Remove unused SAX content handler methodsPhilipp Hahn2020-09-011-13/+0
| | | | | | | | getmethodname() close() cdata() Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Refactor parser creationPhilipp Hahn2020-09-011-11/+7
| | | | | | to use closing context manager. Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Open file with context managerPhilipp Hahn2020-09-011-6/+4
| | | | Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Use splitlines()Philipp Hahn2020-09-011-11/+2
| | | | | | instead of hand-coded implementation. Signed-off-by: Philipp Hahn <hahn@univention.de>
* generator: Just walk the dictPhilipp Hahn2020-09-011-1/+1
| | | | | | instead of generating a list first. Signed-off-by: Philipp Hahn <hahn@univention.de>