503 Commits

Author SHA1 Message Date
Felix Matouschek
68ec51982c e2e-setup: Use virt-operator to deploy common-instancetypes
Use the bundled common-instancetypes deployed by virt-operator instead
of deploying common-instancetypes manually.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
2024-08-14 14:56:03 +02:00
Felix Matouschek
ddd31183ba chore(renovate): Add renovate config
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>
2024-08-14 14:38:39 +02:00
kubevirt-bot
aa75843f16 Update changelog for release 2.0.0
Signed-off-by: kubevirt-bot <kubevirtbot@redhat.com>
2.0.0
2024-07-17 10:05:43 +00:00
kubevirt-bot
d1e83e4dc3 Merge pull request #125 from 0xFelix/bump-version-2.0.0
chore: Bump version to 2.0.0
2024-07-17 11:38:57 +02:00
Felix Matouschek
29a74c492e chore: Bump version to 2.0.0
Bump version and add changelog with release summary.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
2024-07-17 11:30:16 +02:00
kubevirt-bot
f7361548ab Merge pull request #124 from 0xFelix/run-strategy
feat(kubevirt_vm): Add support for RunStrategy
2024-07-16 13:08:55 +02:00
Felix Matouschek
c1f651d972 feat(kubevirt_vm): Add support for RunStrategy
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>
2024-07-16 10:20:09 +02:00
kubevirt-bot
6bc7607826 Merge pull request #122 from 0xFelix/cleanups2
Several small cleanups
2024-07-12 14:05:06 +02:00
Felix Matouschek
25c38134a3 doc(README): Update supported kubernetes.core versions
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
2024-07-12 11:09:23 +02:00
Felix Matouschek
501bd3d52f cleanup(kubevirt_vm): Simplify tests
Simplify kubevirt_vm tests by not using fixtures if not needed.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
2024-07-12 11:09:23 +02:00
Felix Matouschek
a2de465d1f cleanup(kubevirt_vm_info): Simplify tests
Simplify kubevirt_vm_info tests by not using fixtures if not needed.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
2024-07-12 11:09:23 +02:00
Felix Matouschek
7495c34766 cleanup,doc(inventory): Add missing docstring
Add missing docstring for the _connections_compatibility method.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
2024-07-12 11:09:23 +02:00
Felix Matouschek
9029574f7c cleanup(inventory): Mark methods as private
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>
2024-07-12 11:09:23 +02:00
kubevirt-bot
54bbdb4d73 Merge pull request #119 from 0xFelix/fix-cacheable
fix(inventory): Fix inventory source caching
2024-07-12 11:09:05 +02:00
Felix Matouschek
c55763b5aa cleanup(inventory,tests): Remove dependency on addict
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>
2024-07-12 10:34:13 +02:00
Felix Matouschek
060ac97b68 fix(inventory): Fix inventory source caching
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>
2024-07-12 10:32:24 +02:00
kubevirt-bot
5b23a3b966 Merge pull request #121 from lyarwood/owners-make-jcanocan-an-approver
chore(OWNERS): make jcanocan an approver
2024-07-12 09:45:05 +02:00
Lee Yarwood
285a4eb059 chore(OWNERS): make jcanocan an approver
Signed-off-by: Lee Yarwood <lyarwood@redhat.com>
2024-07-11 17:30:14 +01:00
Felix Matouschek
a228fe2c26 cleanup(inventory): Rename default hostname method
Rename method get_default_host_name to get_default_hostname.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
2024-07-11 15:28:32 +02:00
Felix Matouschek
c4570b2089 cleanup(inventory): Use dicts where possible
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>
2024-07-11 12:07:09 +02:00
Felix Matouschek
033f373c94 fix(inventory): Align versions for connections compatibility
Align the version in which backwards compatibility for the connections
parameter will be removed.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
2024-07-11 12:07:09 +02:00
kubevirt-bot
8363d79ddd Merge pull request #117 from 0xFelix/drop-connections
cleanup(inventory): Drop support for multiple connections
2024-07-11 10:47:05 +02:00
Felix Matouschek
fd9c30103d cleanup(inventory): Drop support for multiple connections
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>
2024-07-10 15:32:40 +02:00
Felix Matouschek
2e9d6cec15 cleanup(kubevirt_auth_options): Remove incorrect statement
Remove incorrect statement about a feature being added in a certain
version.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
2024-07-10 15:32:40 +02:00
Felix Matouschek
c279ba5fba chore(yamllint): Exclude .tox/ and .venv/
Do not lint files in .tox/ and .venv/ which are out of our control.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
2024-07-10 15:32:40 +02:00
kubevirt-bot
7049570c68 Update changelog for release 1.5.0
Signed-off-by: kubevirt-bot <kubevirtbot@redhat.com>
1.5.0
2024-07-10 13:21:44 +00:00
kubevirt-bot
8799c56c5d Merge pull request #120 from 0xFelix/prepare-release
Prepare release 1.5.0
2024-07-10 15:15:04 +02:00
Felix Matouschek
463142c280 chore: Prepare release 1.5.0
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
2024-07-10 14:21:34 +02:00
Felix Matouschek
ff6a067c84 feat(inventory): Deprecate connections parameter
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>
2024-07-10 13:45:11 +02:00
kubevirt-bot
f6a43206a6 Merge pull request #114 from 0xFelix/vm-vmi-2
feat,test(inventory): Support listing stopped VMs and major rework of unit tests
2024-07-03 16:24:57 +02:00
kubevirt-bot
107caf256e Merge pull request #118 from 0xFelix/drop-jinja-dep
cleanup(kubevirt_vm): Drop dependency on Jinja2
2024-07-03 16:18:56 +02:00
Felix Matouschek
5e1271b609 chore(inventory): Add examples for stopped VMs
Add examples that show how to use the collection with stopped VMs.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
2024-07-03 16:04:51 +02:00
Felix Matouschek
f3b40ffdbd test(inventory): Add integration test for stopped VMs
Add an integration test that ensures that the inventory supports looking up
stopped VMs.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
2024-07-03 16:04:51 +02:00
Felix Matouschek
3d501de002 test(inventory): Add blackbox unit test for stopped VMs
Add a blackbox unit test that ensures that the inventory supports looking up
stopped VMs.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
2024-07-03 16:04:51 +02:00
Felix Matouschek
be65833724 cleanup(tests): Major rework of inventory unit tests
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>
2024-07-03 16:04:51 +02:00
Felix Matouschek
a94eda613f feat(inventory): Support stopped VMs
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>
2024-07-03 16:04:47 +02:00
Felix Matouschek
c096f069e3 cleanup(kubevirt_vm): Drop dependency on Jinja2
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>
2024-07-03 14:40:50 +02:00
kubevirt-bot
665981c23b Merge pull request #116 from jcanocan/add-coverage-test
Add documentation running coverage analysis.
2024-07-01 16:40:53 +02:00
Javier Cano Cano
a6ef7e9a5a Add documentation running coverage analysis.
It documents how the coverage analyzer can be used to create a test
coverage report.

Signed-off-by: Javier Cano Cano <jcanocan@redhat.com>
2024-07-01 16:25:04 +02:00
Felix Matouschek
8ae9a395e9 cleanup(inventory): Consolidate fetching resources with K8SClient
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>
2024-07-01 11:56:04 +02:00
Felix Matouschek
01a0e535e2 cleanup(inventory): Move set_composable_vars to bottom of file
This suits the control flow a bit better and helps refactoring the
inventory plugin.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
2024-07-01 11:56:04 +02:00
Felix Matouschek
63a03d75b2 cleanup(inventory): Rename GetVmiOptions to InventoryOptions
... 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>
2024-07-01 11:56:04 +02:00
Felix Matouschek
241ca75b28 cleanup(inventory): Make methods more robust
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>
2024-07-01 11:55:50 +02:00
Felix Matouschek
83bcffedd7 cleanup(inventory): Drop unneeded connection_plugin and transport
These two variables seem to be unused and removing them did not have any
effect.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
2024-07-01 11:54:43 +02:00
Felix Matouschek
4b70e0471f cleanup(inventory): Apply pylint suggestions
Make pylint happy by applying some simple suggestions.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
2024-07-01 11:54:43 +02:00
kubevirt-bot
d604a314a4 Merge pull request #115 from 0xFelix/small-improvements-2
Several minor improvements
2024-07-01 11:42:53 +02:00
Felix Matouschek
1bcef9c64d cleanup: Sync galaxy.yml with requirements.yml
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
2024-06-27 16:14:12 +02:00
Felix Matouschek
1630cddc44 cleanup,test(modules): Cleanup module unit tests
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>
2024-06-27 16:08:51 +02:00
Felix Matouschek
52d4b4c731 cleanup: Sync kind version in integration yaml
Use kind v0.23.0 in integration.yml and hack/e2e-setup.sh.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
2024-06-27 16:01:38 +02:00
Felix Matouschek
e2f55848c1 ci: Check if tree is clean before running other jobs
Run make format and check if the tree is still clean before running
other CI jobs.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
2024-06-27 16:01:38 +02:00