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

Adding or Removing Labels to/from a bond or interface is not working #2

Open
siraether opened this issue Oct 19, 2017 · 4 comments
Open

Comments

@siraether
Copy link

While attempting to add network labels to either a bond or single interface I receive an error that states the network labels cannot be null. Below is the code I am trying to run:

   - name: Add VM Networks to Bond1
      ovirt_host_networks:
        auth: "{{ ovirt_auth }}"
        name: "hostname"
        interface: bond1
        networks:
          - name: int_network_001
          - name: int_network_002
          - name: prd_network_001
          - name: prd_network_002
        labels:
          - INT
          - PRD
        check: true
        save: true

This is the error I receive and output of the task being run:

TASK [Add VM Networks to bond1 ***NOT WORKING RH CASE 01951442***] ***********************************************************************************************************************
task path: /home/u105294/rhv-ansible/playbooks/hostNetworks_001.yml:27
Using module file /usr/lib/python2.7/site-packages/ansible/modules/cloud/ovirt/ovirt_host_networks.py
<hostname> ESTABLISH SSH CONNECTION FOR USER: root
<hostname> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/home/u105294/.ssh/ssc-rhv.pem"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/home/u105294/.ansible/cp/8a8bc20f83 hostname '/bin/sh -c '"'"'echo ~ && sleep 0'"'"''
<hostname> (0, '/root\n', '')
<hostname> ESTABLISH SSH CONNECTION FOR USER: root
<hostname> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/home/u105294/.ssh/ssc-rhv.pem"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/home/u105294/.ansible/cp/8a8bc20f83 hostname '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-tmp-1508408575.19-279527621527071 `" && echo ansible-tmp-1508408575.19-279527621527071="` echo /root/.ansible/tmp/ansible-tmp-1508408575.19-279527621527071 `" ) && sleep 0'"'"''
<hostname> (0, 'ansible-tmp-1508408575.19-279527621527071=/root/.ansible/tmp/ansible-tmp-1508408575.19-279527621527071\n', '')
<hostname> PUT /tmp/tmpirMbz_ TO /root/.ansible/tmp/ansible-tmp-1508408575.19-279527621527071/ovirt_host_networks.py
<hostname> SSH: EXEC sftp -b - -C -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/home/u105294/.ssh/ssc-rhv.pem"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/home/u105294/.ansible/cp/8a8bc20f83 '[hostname]'
<hostname> (0, 'sftp> put /tmp/tmpirMbz_ /root/.ansible/tmp/ansible-tmp-1508408575.19-279527621527071/ovirt_host_networks.py\n', '')
<hostname> ESTABLISH SSH CONNECTION FOR USER: root
<hostname> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/home/u105294/.ssh/ssc-rhv.pem"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/home/u105294/.ansible/cp/8a8bc20f83 hostname '/bin/sh -c '"'"'chmod u+x /root/.ansible/tmp/ansible-tmp-1508408575.19-279527621527071/ /root/.ansible/tmp/ansible-tmp-1508408575.19-279527621527071/ovirt_host_networks.py && sleep 0'"'"''
<hostname> (0, '', '')
<hostname> ESTABLISH SSH CONNECTION FOR USER: root
<hostname> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/home/u105294/.ssh/ssc-rhv.pem"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/home/u105294/.ansible/cp/8a8bc20f83 -tt hostname '/bin/sh -c '"'"'/usr/bin/python /root/.ansible/tmp/ansible-tmp-1508408575.19-279527621527071/ovirt_host_networks.py; rm -rf "/root/.ansible/tmp/ansible-tmp-1508408575.19-279527621527071/" > /dev/null 2>&1 && sleep 0'"'"''
<hostname> (0, '\r\n{"msg": "Fault reason is \\"Operation Failed\\". Fault detail is \\"[Nic Label cannot have null label., Attribute: labels[].label]\\". HTTP response code is 400.", "failed": true, "exception": "Traceback (most recent call last):\\n  File \\"/tmp/ansible_KlIOzd/ansible_module_ovirt_host_networks.py\\", line 339, in main\\n    ] if networks else None,\\n  File \\"/tmp/ansible_KlIOzd/ansible_modlib.zip/ansible/module_utils/ovirt.py\\", line 719, in action\\n    getattr(entity_service, action)(**kwargs)\\n  File \\"/usr/lib64/python2.7/site-packages/ovirtsdk4/services.py\\", line 30153, in setup_networks\\n    return self._internal_action(action, \'setupnetworks\', None, headers, query, wait)\\n  File \\"/usr/lib64/python2.7/site-packages/ovirtsdk4/service.py\\", line 290, in _internal_action\\n    return future.wait() if wait else future\\n  File \\"/usr/lib64/python2.7/site-packages/ovirtsdk4/service.py\\", line 53, in wait\\n    return self._code(response)\\n  File \\"/usr/lib64/python2.7/site-packages/ovirtsdk4/service.py\\", line 287, in callback\\n    self._check_fault(response)\\n  File \\"/usr/lib64/python2.7/site-packages/ovirtsdk4/service.py\\", line 123, in _check_fault\\n    self._raise_error(response, body)\\n  File \\"/usr/lib64/python2.7/site-packages/ovirtsdk4/service.py\\", line 109, in _raise_error\\n    raise error\\nError: Fault reason is \\"Operation Failed\\". Fault detail is \\"[Nic Label cannot have null label., Attribute: labels[].label]\\". HTTP response code is 400.\\n", "invocation": {"module_args": {"bond": null, "name": "hostname", "labels": ["INT", "PRD"], "poll_interval": 3, "state": "present", "nested_attributes": [], "networks": [{"name": "int_network_001"}, {"name": "int_network_002"}, {"name": "prd_network_001"}, {"name": "prd_network_002"}], "fetch_nested": false, "timeout": 180, "interface": "bond1", "save": true, "check": true, "wait": true}}}\r\n', 'Shared connection to hostname closed.\r\n')
The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_KlIOzd/ansible_module_ovirt_host_networks.py", line 339, in main
    ] if networks else None,
  File "/tmp/ansible_KlIOzd/ansible_modlib.zip/ansible/module_utils/ovirt.py", line 719, in action
    getattr(entity_service, action)(**kwargs)
  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/services.py", line 30153, in setup_networks
    return self._internal_action(action, 'setupnetworks', None, headers, query, wait)
  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/service.py", line 290, in _internal_action
    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 287, 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 "Operation Failed". Fault detail is "[Nic Label cannot have null label., Attribute: labels[].label]". HTTP response code is 400.

fatal: [hostname]: FAILED! => {
    "changed": false, 
    "failed": true, 
    "invocation": {
        "module_args": {
            "bond": null, 
            "check": true, 
            "fetch_nested": false, 
            "interface": "bond1", 
            "labels": [
                "INT", 
                "PRD"
            ], 
            "name": "hostname", 
            "nested_attributes": [], 
            "networks": [
                {
                    "name": "int_network_001"
                }, 
                {
                    "name": "int_network_002"
                }, 
                {
                    "name": "prd_network_001"
                }, 
                {
                    "name": "prd_network_002"
                }
            ], 
            "poll_interval": 3, 
            "save": true, 
            "state": "present", 
            "timeout": 180, 
            "wait": true
        }
    }, 
    "msg": "Fault reason is \"Operation Failed\". Fault detail is \"[Nic Label cannot have null label., Attribute: labels[].label]\". HTTP response code is 400."
}

The labels do exist within RHV-M and can be added manually via the RHV-M Interface.

@machacekondra
Copy link
Owner

@siraether Thanks a lot for opening the issue.

I've successfully reproduced the issue.
To workaround currently you can just removed the labels and use just networks parameter, if it's not a problem for you. So this should work for you:

  - name: Add VM Networks to Bond1
      ovirt_host_networks:
        auth: "{{ ovirt_auth }}"
        name: "hostname"
        interface: bond1
        networks:
          - name: int_network_001
          - name: int_network_002
          - name: prd_network_001
          - name: prd_network_002
        check: true
        save: true

Just a small comment, that the correct github project to open issue at is:

https://github.com/ansible/ansible/issues

Also, one small question, do you use this module directly from upstream Ansible, or do you use package ovirt-ansible-roles package from RHV 4.1.7 channel?

@machacekondra
Copy link
Owner

@siraether I've posted a patch upstream:

ansible/ansible#31969

The fix should be available in Ansible 2.4.2. I would welcome if you can try and get feedback.
If you need help with how to test, I can send you information. Thanks.

@siraether
Copy link
Author

@machacekondra I am using the package from the RHV 4.1 channel.

@siraether
Copy link
Author

@machacekondra

thank you for verifying the issue. We have removed the Labels parameter and the task is running fine now. We will look into testing against 2.4.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants