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>
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>
Python 3.10 is no longer supported by ansible-core milestone, so this
excludes it from the test matrices.
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>
Python 3.10 is no longer supported by ansible-core devel, so this
excludes it from the test matrices.
Signed-off-by: Felix Matouschek <fmatouschek@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>
Bump the versions of installed software components during the e2e test setup
to the latest stable releases.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Swap the order of commands in hack/e2e-setup.sh, so it becomes possible
to run 'make cluster-down` when the kind/kubectl binaries are missing.
Signed-off-by: Felix Matouschek <fmatouschek@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>
Drop the vendored document fragments from kubernetes.core to slightly
enhance the documented options and to allow changing the license of the
collection.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Fix the assertion that was introduced in
2521e8ba24 by removing the superfluous 'd'
at the end of the variable names.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Assert there are no or expected changes in verify.yml of the kubevirt_vm
integration test. This is necessary since in downstream tests the
kubemacpool operator might add annotations to the VM which can trigger a
changed result.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
This changes the runme.sh of the kubevirt_vm integration tests to retry
the connection to the VM until a login is possible. This is necessary
since it is not possible with Ansible alone to retry a task in case the
connection failed with the unreachable status. This can happen when the
sshd of the VM already accepts connections but a login is not yet
possible because the VM is still booting up.
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Bump the tested ansible-core versions in integration.yml to the
latest supported versions (2.15-2.17).
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Bump the tested ansible-core versions in integration.yml to the latest
supported versions (2.15-2.17).
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>