Repository: ansible/ansible

Issue:
vmware/vca_vapp: Improve error reporting when catalog cannot be found
_From @kaneda-fr on May 9, 2016 11:30_

##### ISSUE TYPE
- Bug Report
- ~~Feature Idea~~
##### COMPONENT NAME

cloud/vmware/vca_vapp.py 
##### ANSIBLE VERSION

```
ansible 2.1.0.0 (stable-2.1 2c8715178f)
```
##### CONFIGURATION
##### OS / ENVIRONMENT

N/A
##### SUMMARY

When an incorrect catalog name is provided, `module.vca.create_vapp` on line 184 will return false and next line with `module.vca.block_until_completed(task)` will fail.
##### STEPS TO REPRODUCE

Use an incorrect catalog name in your playbook
##### EXPECTED RESULTS

Error reporting could be improved to indicate the reason for the error. 
##### ACTUAL RESULTS

<!--- What actually happened? If possible run with high verbosity (-vvvv) -->

```
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
  File "/var/folders/ws/r0hq3mp13hj6bz9gy0tkwt580000gr/T/ansible_MJF6FG/ansible_module_vca_vapp.py", line 282, in <module>
    main()
  File "/var/folders/ws/r0hq3mp13hj6bz9gy0tkwt580000gr/T/ansible_MJF6FG/ansible_module_vca_vapp.py", line 263, in main
    create(module)
  File "/var/folders/ws/r0hq3mp13hj6bz9gy0tkwt580000gr/T/ansible_MJF6FG/ansible_module_vca_vapp.py", line 188, in create
    module.vca.block_until_completed(task)
  File "/usr/local/lib/python2.7/site-packages/pyvcloud/vcloudair.py", line 959, in block_until_completed
    progress = task.get_Progress()
AttributeError: 'bool' object has no attribute 'get_Progress'
```


_Copied from original issue: ansible/ansible-modules-extras#2189_


Discussion:
_From @ansibot on August 4, 2016 19:19_

<!-- @kaneda-fr: Thanks for filing this feature idea! -->

@chrrrles ping, this issue is waiting for your response.
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)

<!--- boilerplate: issue_bug_new --->

_From @ansibot on September 13, 2016 2:48_

@chrrrles, ping. This issue is still waiting on your response.
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)

<!--- boilerplate: issue_renotify_maintainer --->

_From @ansibot on October 6, 2016 18:3_

@jctanner, ping. This issue is still waiting on your response.
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)

<!--- boilerplate: issue_renotify_maintainer --->

_From @ansibot on November 13, 2016 10:0_

@chrrrles, ping. This issue is still waiting on your response.
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)

<!--- boilerplate: issue_renotify_maintainer --->

_From @ansibot on December 6, 2016 21:53_

This repository has been locked. All new issues and pullrequests should be filed in https://github.com/ansible/ansible

Please read through the <a href="http://docs.ansible.com/ansible/dev_guide/repomerge.html#move-issues-and-prs-to-new-repo">repomerge</a> page in the dev guide. The guide contains links to tools which automatically move your issue or pullrequest to the ansible/ansible repo.

<!-- boilerplate: repomerge -->
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/modules/cloud/vmware/vca_vapp.py b/lib/ansible/modules/cloud/vmware/vca_vapp.py
--- a/lib/ansible/modules/cloud/vmware/vca_vapp.py
+++ b/lib/ansible/modules/cloud/vmware/vca_vapp.py
@@ -189,6 +189,9 @@ def create(module):
                                   catalog_name, network_name, network_mode,
                                   vm_name, vm_cpus, vm_memory, deploy, poweron)
 
+    if task is False:
+        module.fail('Failed to create vapp: ' + vapp_name)
+        
     module.vca.block_until_completed(task)
 
 def delete(module):


Test patch: