lcitool OOP overhaul
This MR is a result of my attempt to extract the package mapping-to-name resolving code from the formatters module to a dedicated module so that it could be reused by the Ansible code and replace the existing YAML task file that does the same but in the Ansible space. It turned out that in order to achieve that the code base has to go through a revamp to be prepared for that change and that's exactly what this MR does.
-
each of our current classes is converted to a singleton which will remove the need on a few places to pass other instances by reference for no apparent reason, it will allow us to initialize the singleton instances when actually needed by the lcitool command
-
each module now exports its own base exception type (which is further subclassed) which is caught at the application level
- this allows us to clean the application code a bit so that the number of try-except blocks is decreased
- we don't have to come up with new error messages on the application level, because the base module exception types hold all the necessary information
- this will let us propagate most generic Exception types which very likely occur during the development process to the Python runtime in the future which in turn will dump tracebacks back to the developer yielding some actually valuable information rather than a concise message glued from several re-raised generic Exception types only giving you "Failed to install host: 'foo'" instead of "KeyError: 'foo'" + traceback
-
lazy data loading was put in place to selected modules (projects, config, inventory) as not all commands need all the data from disk at all times
All of the above combined resulted in a slight lcitool speedup on my Lenovo-T490s:
$ pwd
/home/eskultety/git/libvirt.git/ci
$ time ./helper refresh --lcitool /tmp/lci-master/lcitool > /dev/null
real 0m14.965s
user 0m13.324s
sys 0m1.061s
$ time ./helper refresh --lcitool ~/git/libvirt-ci.git/lcitool > /dev/null
real 0m13.443s
user 0m11.883s
sys 0m1.083s
And of course the behaviour remains unchanged:
$ pwd
/home/eskultety/git/libvirt.git
$ git diff
diff --git a/ci/cirrus/freebsd-12.vars b/ci/cirrus/freebsd-12.vars
index 40a19b5773..f91a7525a5 100644
--- a/ci/cirrus/freebsd-12.vars
+++ b/ci/cirrus/freebsd-12.vars
@@ -2,7 +2,7 @@
#
# $ lcitool variables freebsd-12 libvirt
#
-# https://gitlab.com/libvirt/libvirt-ci/-/commit/1d4e10a04c6a0d29302003244a9dc4dc3c9d06f0
+# https://gitlab.com/libvirt/libvirt-ci/-/commit/82517c79bcc0a5030c5772245e31222d1f9b6308
PACKAGING_COMMAND='pkg'
CCACHE='/usr/local/bin/ccache'
....... ^this context repeats for each ci config file in the libvirt repo