Commit Graph

313 Commits

Author SHA1 Message Date
Maya Peretz
dc2df694c7 Source extra_env.sh file if exists in integration tests
Signed-off-by: Maya Peretz <mperetz@redhat.com>
2024-08-27 15:53:37 +03:00
kubevirt-bot
ce22e4f191 Merge pull request #129 from 0xFelix/vmi-info
feat: Add kubevirt_vmi_info module
2024-08-19 11:52:21 +02:00
Felix Matouschek
e98d9a48bd feat: Add kubevirt_vmi_info module
Add the kubevirt_vmi_info module which allows to fetch information about
VirtualMachineInstance(s).

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
2024-08-19 08:22:24 +02:00
Felix Matouschek
cd270e271b cleanup(info): Extract execute_module
Extract the execute_module function from the kubevirt_vm_info module to
make it available for other modules.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
2024-08-19 08:22:02 +02:00
kubevirt-bot
079a8066fb Merge pull request #130 from 0xFelix/test-in-ns
Run integration tests in random namespaces
2024-08-16 10:06:17 +02:00
kubevirt-bot
eea2ec075c Merge pull request #131 from 0xFelix/yamllint-2
cleanup(yamllint): Add yamllint options required by ansible-lint
2024-08-16 09:08:15 +02:00
Felix Matouschek
ae6f5900ea cleanup(yamllint): Add yamllint options required by ansible-lint
Fix ansible-lint warnings by adding required yamllint options.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
2024-08-16 08:58:15 +02:00
Felix Matouschek
713193510a kubevirt_vm_info: Run integration test in random namespace
Run the integration tests for kubevirt_vm_info in a random namespace
and cleanup after the tests finish.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
2024-08-16 08:37:40 +02:00
Felix Matouschek
71ea312cfc kubevirt_vm: Run integration test in random namespace
Run the integration tests for kubevirt_vm in a random namespace
and cleanup after the tests finish.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
2024-08-16 08:37:36 +02:00
Felix Matouschek
00690ebc4c inventory_kubevirt: Run integration test in random namespace
Run the integration tests for inventory_kubevirt in a random namespace
and cleanup after the tests finish.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
2024-08-16 08:37:00 +02:00
kubevirt-bot
c57cd65532 Merge pull request #127 from 0xFelix/use-virt-operator
e2e-setup: Use virt-operator to deploy common-instancetypes
2024-08-15 10:24:08 +02:00
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
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