Repository: ansible/ansible

Issue:
VCA_VAPP ERROR/BUG
##### ISSUE TYPE

 - Bug Report

##### COMPONENT NAME

**vca_vapp**

##### ANSIBLE VERSION
```
ansible 2.3.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
  python version = 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]
```

##### OS / ENVIRONMENT

Ubuntu 16.04 X86_64

##### SUMMARY

Im trying to create new VM in a org of Vcloud Director into an existing vdc and vapp.

##### STEPS TO REPRODUCE

<!--- Paste example playbooks or commands between quotes below -->
```
---

 - hosts: localhost
   connection: local
   tasks:

    - name: Creates a new vApp in a VCA instance
      vca_vapp:
        org: 'https://vcloud.asdasd.es/cloud/org/ad'
        vapp_name: 'PRUEBAS'
        vm_cpus: 1
        vm_memory: 1024
        template_name: 'REDHAT6.5'
        vdc_name: 'asd-asdasd'
        vm_name: 'Prueba'
        username: 'asdasd'
        password: '@asd'

```

<!--- You can also paste gist.github.com links for larger files -->

##### EXPECTED RESULTS

The expected results are that the playbook create a new VM in the Vapp.

##### ACTUAL RESULTS

```
The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_bG1XUS/ansible_module_vca_vapp.py", line 290, in <module>
    main()
  File "/tmp/ansible_bG1XUS/ansible_module_vca_vapp.py", line 254, in main
    supports_check_mode=True)
  File "/tmp/ansible_bG1XUS/ansible_modlib.zip/ansible/module_utils/vca.py", line 66, in __init__
  File "/tmp/ansible_bG1XUS/ansible_modlib.zip/ansible/module_utils/vca.py", line 140, in login
  File "/tmp/ansible_bG1XUS/ansible_modlib.zip/ansible/module_utils/vca.py", line 190, in fail
  File "/tmp/ansible_bG1XUS/ansible_modlib.zip/ansible/module_utils/basic.py", line 1993, in fail_json
  File "/tmp/ansible_bG1XUS/ansible_modlib.zip/ansible/module_utils/basic.py", line 1973, in _return_formatted
  File "/tmp/ansible_bG1XUS/ansible_modlib.zip/ansible/module_utils/basic.py", line 414, in remove_values
  File "/tmp/ansible_bG1XUS/ansible_modlib.zip/ansible/module_utils/basic.py", line 414, in <genexpr>
  File "/tmp/ansible_bG1XUS/ansible_modlib.zip/ansible/module_utils/basic.py", line 425, in remove_values
TypeError: Value of unknown type: <class 'requests.models.Response'>, <Response [500]>

fatal: [localhost]: FAILED! => {
    "changed": false, 
    "failed": true, 
    "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_bG1XUS/ansible_module_vca_vapp.py\", line 290, in <module>\n    main()\n  File \"/tmp/ansible_bG1XUS/ansible_module_vca_vapp.py\", line 254, in main\n    supports_check_mode=True)\n  File \"/tmp/ansible_bG1XUS/ansible_modlib.zip/ansible/module_utils/vca.py\", line 66, in __init__\n  File \"/tmp/ansible_bG1XUS/ansible_modlib.zip/ansible/module_utils/vca.py\", line 140, in login\n  File \"/tmp/ansible_bG1XUS/ansible_modlib.zip/ansible/module_utils/vca.py\", line 190, in fail\n  File \"/tmp/ansible_bG1XUS/ansible_modlib.zip/ansible/module_utils/basic.py\", line 1993, in fail_json\n  File \"/tmp/ansible_bG1XUS/ansible_modlib.zip/ansible/module_utils/basic.py\", line 1973, in _return_formatted\n  File \"/tmp/ansible_bG1XUS/ansible_modlib.zip/ansible/module_utils/basic.py\", line 414, in remove_values\n  File \"/tmp/ansible_bG1XUS/ansible_modlib.zip/ansible/module_utils/basic.py\", line 414, in <genexpr>\n  File \"/tmp/ansible_bG1XUS/ansible_modlib.zip/ansible/module_utils/basic.py\", line 425, in remove_values\nTypeError: Value of unknown type: <class 'requests.models.Response'>, <Response [500]>\n", 
    "module_stdout": "", 
    "msg": "MODULE FAILURE", 
    "rc": 0
}

```



Discussion:
cc @privateip
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->

Resolving patch:
diff --git a/lib/ansible/module_utils/vca.py b/lib/ansible/module_utils/vca.py
--- a/lib/ansible/module_utils/vca.py
+++ b/lib/ansible/module_utils/vca.py
@@ -141,7 +141,7 @@ def login(self):
             login_org = self.params['org']
 
         if not self.vca.login(password=password, org=login_org):
-            self.fail('Login to VCA failed', response=self.vca.response)
+            self.fail('Login to VCA failed', response=self.vca.response.content)
 
         try:
             method_name = 'login_%s' % service_type
@@ -150,7 +150,7 @@ def login(self):
         except AttributeError:
             self.fail('no login method exists for service_type %s' % service_type)
         except VcaError as e:
-            self.fail(e.message, response=self.vca.response, **e.kwargs)
+            self.fail(e.message, response=self.vca.response.content, **e.kwargs)
 
     def login_vca(self):
         instance_id = self.params['instance_id']


Test patch: