Bug 1491004

Summary: [ovirt-ansible-roles] ovirt-vm-infra: Unclear error when user use non-existing template
Product: Red Hat Enterprise Virtualization Manager Reporter: Petr Kubica <pkubica>
Component: ovirt-ansible-rolesAssignee: Ondra Machacek <omachace>
Status: CLOSED ERRATA QA Contact: Petr Kubica <pkubica>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 4.1.5CC: mgoldboi, mperina, omachace, pstehlik
Target Milestone: ovirt-4.2.2   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: ovirt-ansible-vm-infra-1.1.5 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-05-15 18:00:33 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Infra RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Petr Kubica 2017-09-12 18:05:40 UTC
Description of problem:
When user make a typo in name of template, he will get unclear error about what actually happen:

it looks like an error in module/role than typo in template name

The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_10Z312/ansible_module_ovirt_vms.py", line 965, in main
    clone_permissions=module.params['clone_permissions'],
  File "/tmp/ansible_10Z312/ansible_modlib.zip/ansible/module_utils/ovirt.py", line 574, in create
    **kwargs
  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/services.py", line 27375, in add
    return self._internal_add(vm, headers, query, wait)
  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/service.py", line 223, in _internal_add
    return future.wait() if wait else future
  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/service.py", line 53, in wait
    return self._code(response)
  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/service.py", line 220, in callback
    self._check_fault(response)
  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/service.py", line 123, in _check_fault
    self._raise_error(response, body)
  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/service.py", line 109, in _raise_error
    raise error
Error: Fault reason is "Incomplete parameters". Fault detail is "Vm [template.id|name] required for add". HTTP response code is 400.

failed: [pk-rh35.rhev.lab.eng.brq.redhat.com] (item={'_ansible_parsed': True, 'changed': False, '_ansible_no_log': True, u'ansible_job_id': u'530946568109.30392', u'started': 1, '_ansible_item_result': True, 'item': {u'profile': {u'cluster': u'Default', u'cores': 1, u'template': u'template3', u'memory': u'4GiB'}, u'tag': u'vm', u'name': u'vm-02'}, u'finished': 0, u'results_file': u'/root/.ansible_async/530946568109.30392'}) => {
    "ansible_job_id": "530946568109.30392", 
    "attempts": 1, 
    "changed": false, 
    "failed": true, 
    "finished": 1, 
    "invocation": {
        "module_args": {
            "boot_devices": null, 
            "cd_iso": null, 
            "clone": false, 
            "clone_permissions": false, 
            "cloud_init": {
                "authorized_ssh_keys": "", 
                "host_name": "vm-02.__omit_place_holder__e9f8fdd321ca696c55143bbd6b356b7feec6bab4", 
                "root_password": "__omit_place_holder__e9f8fdd321ca696c55143bbd6b356b7feec6bab4", 
                "user_name": "root"
            }, 
            "cloud_init_nics": [], 
            "cluster": "Default", 
            "comment": null, 
            "cpu_cores": 1, 
            "cpu_shares": null, 
            "cpu_sockets": null, 
            "delete_protected": null, 
            "description": null, 
            "disks": [], 
            "fetch_nested": false, 
            "force": false, 
            "high_availability": null, 
            "host": null, 
            "id": null, 
            "initrd_path": null, 
            "instance_type": null, 
            "kernel_params": null, 
            "kernel_path": null, 
            "memory": "4GiB", 
            "memory_guaranteed": null, 
            "name": "vm-02", 
            "nested_attributes": [], 
            "nics": [], 
            "operating_system": null, 
            "poll_interval": 3, 
            "serial_policy": null, 
            "serial_policy_value": null, 
            "state": "present", 
            "stateless": null, 
            "sysprep": null, 
            "template": "template3", 
            "template_version": null, 
            "timeout": 600, 
            "timezone": null, 
            "type": null, 
            "use_latest_template_version": null, 
            "wait": true
        }
    }, 
    "item": {
        "ansible_job_id": "530946568109.30392", 
        "changed": false, 
        "finished": 0, 
        "item": {
            "name": "vm-02", 
            "profile": {
                "cluster": "Default", 
                "cores": 1, 
                "memory": "4GiB", 
                "template": "template3"
            }, 
            "tag": "vm"
        }, 
        "results_file": "/root/.ansible_async/530946568109.30392", 
        "started": 1
    }, 
    "msg": "Fault reason is \"Incomplete parameters\". Fault detail is \"Vm [template.id|name] required for add\". HTTP response code is 400.", 
    "stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_10Z312/ansible_module_ovirt_vms.py\", line 1062, in <module>\n    main()\n  File \"/tmp/ansible_10Z312/ansible_module_ovirt_vms.py\", line 1058, in main\n    connection.close(logout='token' not in module.params['auth'])\nKeyError: 'auth'\n", 
    "stderr_lines": [
        "Traceback (most recent call last):", 
        "  File \"/tmp/ansible_10Z312/ansible_module_ovirt_vms.py\", line 1062, in <module>", 
        "    main()", 
        "  File \"/tmp/ansible_10Z312/ansible_module_ovirt_vms.py\", line 1058, in main", 
        "    connection.close(logout='token' not in module.params['auth'])", 
        "KeyError: 'auth'"
    ]
}



Version-Release number of selected component (if applicable):
ovirt-ansible-roles-1.0.3-1.el7ev.noarch
ansible-2.3.2.0-2.el7.noarch

Comment 1 Ondra Machacek 2017-09-13 08:40:28 UTC
The problem is here:

 https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/cloud/ovirt/ovirt_vms.py#L602

We need to raise an exception when the template isn't found otherwise, we try to pass 'None' template.

Comment 2 Ondra Machacek 2017-10-25 10:25:31 UTC
Will be fixed in Ansible 2.5.

Comment 4 Martin Perina 2018-01-10 13:21:11 UTC
This will be fixed by ansible-2.5.0, so moving to 4.2.3

Comment 5 Petr Kubica 2018-03-07 14:39:03 UTC
Verified in
ansible-2.5.0-0.3.rc1.el7ae.noarch
ovirt-ansible-vm-infra-1.1.5-1.el7ev.noarch

Comment 10 errata-xmlrpc 2018-05-15 18:00:33 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2018:1534

Comment 11 Franta Kust 2019-05-16 13:06:07 UTC
BZ<2>Jira Resync