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>
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>
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>
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>
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>
Adds two missing execution paths when the `network_name` is provided and
when there are not VMIs to collect.
Signed-off-by: Javier Cano Cano <jcanocan@redhat.com>
It refactors fixtures: `add_group` and `add_host` to improve fixtures
reusability in further scenarios.
Signed-off-by: Javier Cano Cano <jcanocan@redhat.com>
Change the license of the collection to Apache 2.0 to be compliant with
the CNCF licensing requirements.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
It adds unit tests for the render_template function. These test cases
cover all cases for non-mandatory fields in the VM template.
Signed-off-by: Javier Cano Cano <jcanocan@redhat.com>
Add the running parameter to kubevirt_vm_info from which the
wait_condition is derived from when parameter wait is set to
yes.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Adds a test to assert deletion options are the expected.
Refactors python fixtures to reuse common fields in both create and
delete tests.
Signed-off-by: Javier Cano Cano <jcanocan@redhat.com>
To properly wait for a state change in the kubevirt_vm module the
wait_condition needs to adapted to the state of running.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Cleanup the YAML passed to the k8s module so it conforms to yaml output
you would expect from yaml.dump. Also refactor the tests to get rid of
duplicate definitions and make use of pytest.mark.parametrize and
yaml.dump.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Adds unit test to assert VM label and field selectors work as expected.
Refactors python fixtures to reuse defaults and avoid code duplication.
Signed-off-by: Javier Cano Cano <jcanocan@redhat.com>
This changes the inventory plugin so that it sets the ansible_connection
to winrm if it detected a Windows host. If it did not detect a Windows
host the ansible_connection is no longer set, so Ansible falls back to
its default value of ssh. The detection of SSH services for hosts using
winrm is disabled.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Add a test file for the inventory plugin with some basic unit tests.
This file can be used to add more tests in the future.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Reorganize unit tests so the directory structure looks like the
structure used in most other collections.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Cleanup the existing unit tests and move them to pytest. By using pytest
it becomes easier to add new tests for existing functionality in the
collection.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Add tox configuration that allows to build a venv for development and to
format source files. To make use of it add appropriate Makefile targets.
Drop unneeded requirements from requirements.txt and
test-requirements.txt and add needed requirements.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Update the requirements throughout the project to be in sync and to
reflect the current state of dependencies.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
This adds the kubevirt_vm_info module, which returns the same results as
the kubevirt_vm module, but is limited to read-only functionality.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
This removes the unnecessary whitespace from the rendered VirtualMachine
template and adds a unit test for it.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
By allowing to specify DataVolume templates VMs with persistent storage
can be created using the kubevirt_vm module.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
By allowing to specify the template spec unnecessary abstraction is
avoided.
The following module args are replaced by the 'spec' arg:
- termination_grace_period
- interfaces
- networks
- volumes
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Use InstancetypeMatchers and PreferenceMatchers directly instead of
providing multiple arguments to prevent unnecessary abstraction.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
The workflows committed in the first commit were missing the
installation of required dependencies and other fixes.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>