Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add virt_domain_facts module #54640

Open
wants to merge 3 commits into
base: devel
from

Conversation

Projects
None yet
3 participants
@chrisred
Copy link

commented Mar 30, 2019

SUMMARY

Retrieve facts about a libvirt domain (VM). Facts are generated from the XML configuration of the domain, with some use of a libvirt API "stats" method to collect extra details about disk images.

Attempts were made to avoid unnecessary nesting in the returned JSON to keep it simple to access.

As the facts are parsed from the XML config of the domain the keys returned could differ slightly between each domain. However a key for each main config "item" is always present to provide a stable set of return values.

Related to #27905 about issues with the existing virt modules. @gthieleb requested "facts" support.

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME

virt_domain_facts

ADDITIONAL INFORMATION

Output snippet

lab-ln-kvm1 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python", 
        "virt_domains": {
            "test1": {
                "cpu": "2", 
                "disk": [
                    {
                        "address_bus": "0x00", 
                        "address_domain": "0x0000", 
                        "address_function": "0x0", 
                        "address_slot": "0x07", 
                        "address_type": "pci", 
                        "device": "disk", 
                        "driver_cache": "none", 
                        "driver_io": "native", 
                        "driver_name": "qemu", 
                        "driver_type": "qcow2", 
                        "source_allocation": 18673373184, 
                        "source_capacity": 26843545600, 
                        "source_file": "/mnt/vhd/test1.qcow2", 
                        "source_physical": 18673369088, 
                        "target_bus": "virtio", 
                        "target_dev": "vda", 
                        "type": "file"
                    }
                ], 
                "floppy": [],
                <snip...>
            }
        }, 
        "virt_domains_live": null
    }, 
    "changed": false
}
Chris Redit
@ansibot

This comment has been minimized.

Copy link
Contributor

commented Mar 30, 2019

The test ansible-test sanity --test pylint [explain] failed with 1 error:

lib/ansible/modules/cloud/misc/virt_domain_facts.py:231:25: ansible-bad-import-from Import MutableMapping from ansible.module_utils.common._collections_compat instead of collections

The test ansible-test sanity --test ansible-doc --python 2.6 [explain] failed with 1 error:

lib/ansible/modules/cloud/misc/virt_domain_facts.py:0:0: has a documentation error formatting or is missing documentation.

The test ansible-test sanity --test compile --python 2.6 [explain] failed with 1 error:

lib/ansible/modules/cloud/misc/virt_domain_facts.py:207:65: SyntaxError: parent = {element.tag: {k: v[0] if len(v) == 1 else v for k, v in dd.items()}}

The test ansible-test sanity --test import --python 2.7 [explain] failed with 1 error:

lib/ansible/modules/cloud/misc/virt_domain_facts.py:127:0: ImportError: No module named libvirt

The test ansible-test sanity --test import --python 2.6 [explain] failed with 1 error:

lib/ansible/modules/cloud/misc/virt_domain_facts.py:207:65: SyntaxError: invalid syntax

The test ansible-test sanity --test import --python 3.5 [explain] failed with 1 error:

lib/ansible/modules/cloud/misc/virt_domain_facts.py:127:0: ImportError: No module named 'libvirt'

The test ansible-test sanity --test import --python 3.6 [explain] failed with 1 error:

lib/ansible/modules/cloud/misc/virt_domain_facts.py:127:0: ModuleNotFoundError: No module named 'libvirt'

The test ansible-test sanity --test import --python 3.7 [explain] failed with 1 error:

lib/ansible/modules/cloud/misc/virt_domain_facts.py:127:0: ModuleNotFoundError: No module named 'libvirt'

The test ansible-test sanity --test import --python 3.8 [explain] failed with 1 error:

lib/ansible/modules/cloud/misc/virt_domain_facts.py:127:0: ModuleNotFoundError: No module named 'libvirt'

The test ansible-test sanity --test validate-modules [explain] failed with 3 errors:

lib/ansible/modules/cloud/misc/virt_domain_facts.py:0:0: E305 DOCUMENTATION.author: Invalid author for dictionary value @ data['author']. Got 'Chris Redit'
lib/ansible/modules/cloud/misc/virt_domain_facts.py:0:0: E319 RETURN.virt_domains_live.contains: required key not provided @ data['virt_domains_live']['contains']. Got None
lib/ansible/modules/cloud/misc/virt_domain_facts.py:0:0: E321 Exception attempting to import module for argument_spec introspection, 'No module named 'libvirt''

click here for bot help

Chris Redit
@ansibot

This comment has been minimized.

Copy link
Contributor

commented Apr 8, 2019

@TimothyVandenbrande @UnderGreen @cheese @drybjed @flaper87 @helldorado @joshainglis @karmab @machacekondra @mnecas @mwperina @ryansb

As a maintainer of a module in the same namespace this new module has been submitted to, your vote counts for shipits. Please review this module and add shipit if you would like to see it merged.

click here for bot help

@resmo resmo self-requested a review Apr 9, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.