Repository: ansible/ansible-modules-extras

Issue:
ovirt module (start Vm) used by Ansible 2.2.0 and Python 2.7 seems broken
<!--- Verify first that your issue/request is not already reported in GitHub -->
##### ISSUE TYPE

<!--- Pick one below and delete the rest: -->
- Bug Report
- Feature Idea
- Documentation Report

```
Bug report
```
##### ANSIBLE VERSION

<!--- Paste verbatim output from “ansible --version” between quotes below -->

```
2.2.0
```
##### CONFIGURATION

<!---
Mention any settings you have changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables).
-->
##### COMPONTENT NAME

```
ovirt
```
##### OS / ENVIRONMENT

<!---
Mention the OS you are running Ansible from, and the OS you are
managing, or say “N/A” for anything that is not platform-specific.
-->

```
CentOS 7
```
##### SUMMARY

<!--- Explain the problem briefly -->
##### STEPS TO REPRODUCE

<!---
For bugs, show exactly how to reproduce the problem.
For new features, show how the feature would be used.
-->

<!--- Paste example playbooks or commands between quotes below -->

```
- name: starting vm "{{ vm_name }}"
  ovirt:
    instance_name: "{{ vm_name }}"
    state: started
    user: "{{ ovirt_user }}"
    password: "{{ ovirt_password }}"
    url: "{{ ovirt_url }}"
...
```

<!--- You can also paste gist.github.com links for larger files -->
##### EXPECTED RESULTS

<!--- What did you expect to happen when running the steps above? -->
##### ACTUAL RESULTS

<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->

<!--- Paste verbatim command output between quotes below -->

```
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_l42zpO/ansible_module_ovirt.py", line 520, in <module>
    main()
  File "/tmp/ansible_l42zpO/ansible_module_ovirt.py", line 491, in main
    vm_start(c, vmname, hostname, ip, netmask, gateway, domain, dns, rootpw, key)
  File "/tmp/ansible_l42zpO/ansible_module_ovirt.py", line 342, in vm_start
    nics = params.GuestNicsConfiguration(nic_configuration=[nic])
UnboundLocalError: local variable 'nic' referenced before assignment

fatal: [localhost]: FAILED! => {
    "changed": false, 
    "failed": true, 
    "invocation": {
        "module_name": "ovirt"
    }, 
    "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_l42zpO/ansible_module_ovirt.py\", line 520, in <module>\n    main()\n  File \"/tmp/ansible_l42zpO/ansible_module_ovirt.py\", line 491, in main\n    vm_start(c, vmname, hostname, ip, netmask, gateway, domain, dns, rootpw, key)\n  File \"/tmp/ansible_l42zpO/ansible_module_ovirt.py\", line 342, in vm_start\n    nics = params.GuestNicsConfiguration(nic_configuration=[nic])\nUnboundLocalError: local variable 'nic' referenced before assignment\n", 
    "module_stdout": "", 
    "msg": "MODULE FAILURE", 
    "parsed": false
}

```



Discussion:

Resolving patch:
diff --git a/cloud/misc/ovirt.py b/cloud/misc/ovirt.py
--- a/cloud/misc/ovirt.py
+++ b/cloud/misc/ovirt.py
@@ -333,6 +333,7 @@ def vm_start(conn, vmname, hostname=None, ip=None, netmask=None, gateway=None,
     vm = conn.vms.get(name=vmname)
     use_cloud_init = False
     nics = None
+    nic = None
     if hostname or ip or netmask or gateway or domain or dns or rootpw or key:
         use_cloud_init = True
     if ip and netmask and gateway:


Test patch: