Use the bundled common-instancetypes deployed by virt-operator instead
of deploying common-instancetypes manually.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Add renovate configuration to automatically update used software
versions in e2e-setup and the github actions used by this repository.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
This change adds support for setting the RunStrategy of a VM.
Depending on the value set the wait condition for the VM is adjusted.
For the values Always, RerunOnFailure or Once the wait condition will
wait for the VM to run and be ready. For the value Halted the wait
condition will wait for the VM to not exist. For the value Manual
the wait condition is not set.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Mark all methods of the inventory which should be private with a underscore
prefix in their name.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Replace the remaining uses of addict's Dict with ResourceField of the
Kubernetes client. This allows to drop the dependency on addict.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Fix inventory source caching by separating the fetching of objects and
populating the inventory. This way objects can be fetched from the K8S
API or from a configured cached and the cache related parameters on the
plugin now actually work.
The inventory source cache was tested with the ansible.builtin.jsonfile
cache plugin and 100k hosts (~2G JSON file). Though it took a noticeable
amount of time for the inventory plugin to run it worked fine and no
failures could be observed.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Use dicts instead of ResourceFields where possible to allow
easier serialization/deserialization of objects fetched from the K8S
API.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Align the version in which backwards compatibility for the connections
parameter will be removed.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
The support for connections to multiple clusters in the inventory
plugin is dropped to better align with user expectations and how other
inventories work. If inventories of multiple clusters are needed the
inventory can be run multiple times with different configurations.
This also helps to clean up the code and make it simpler.
For now this adds a compatibility helper so that configurations with a
single connection entry remain supported and a warning is emitted.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Deprecate the connections parameter of the inventory plugin. For now
this adds only a warning message while keeping the functionality.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Rework the inventory unit tests by splitting up
tests/unit/plugins/inventory/test_kubevirt.py into multiple files,
by trying to simplify the test code and making it more robust and by
using appropriate fixtures. This also adds new tests or test cases to
improve code coverage. Tests that work from the black box perspective
are now located in a subdirectory.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
This enables the inventory to list stopped VMs by refactoring
the add_from_namespace method. The method is now looking up the related
VM and VMIs for a host and adds all status attributes of both objects
to the host's vars. To distinguish the origin of vars an appropriate
prefix (vm_ or vmi_) is applied to their name. The inventory now supports
hosts comprising just a VM (stopped), just a VMI or both.
This changes some of the hostvars previously reported by the inventory
plugin:
Dropped:
- object_type
- cluster_name
Now prefixed with vm_ or vmi_ according to the origin:
- labels
- annotations
- resource_version
- uid
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Drop the dependency on Jinja2 in the kubevirt_vm module by using dicts
to construct a VM instead of rendering jinja templates internally.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
This consolidates fetching of resources with K8SClient by introducing
the get_resources method, which is can be called by getters for certain
kinds of objects.
The former get_vmis_for_namespace method, which contains the main logic
of the inventory is renamed to populate_inventory_from_namespace.
This refactors the following getters:
- get_available_namespaces
- get_ssh_services_for_namespace
This introduces the following getters:
- get_vms_for_namespace (to be used in the following commit)
- get_vmis_for_namespace
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
... and ensure base_domain is always initialized with the cluster
domain. This is done in preparation for a major refactoring of the
inventory plugin.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Make the logic in the following methods more robust and add type hints
where appropriate.
- get_host_from_service
- get_port_from_service
- is_windows
- setup
- fetch_objects
- set_ansible_host_and_port
- set_composable_vars
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Improve syntax in module unit tests and use only mocker instead of a
combination of mocker and monkeypatch.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>