Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Move logic out of except block #213

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions modules/vcd_vapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,11 @@ def instantiate(self):
response['changed'] = False

try:
self.vdc.get_vapp(vapp_name)
found = self.vdc.get_vapp(vapp_name)
except EntityNotFoundException:
found = None

if not found:
create_vapp_task = self.vdc.instantiate_vapp(
name=vapp_name,
catalog=catalog_name,
Expand Down Expand Up @@ -377,8 +380,11 @@ def create(self):
response['changed'] = False

try:
self.vdc.get_vapp(vapp_name)
found = self.vdc.get_vapp(vapp_name)
except EntityNotFoundException:
found = None

if not found:
create_vapp_task = self.vdc.create_vapp(
name=vapp_name,
description=description,
Expand All @@ -402,8 +408,11 @@ def delete(self):
response['changed'] = False

try:
self.vdc.get_vapp(vapp_name)
found = self.vdc.get_vapp(vapp_name)
except EntityNotFoundException:
found = None

if not found:
response['warnings'] = "Vapp {} is not present.".format(vapp_name)
else:
delete_vapp_task = self.vdc.delete_vapp(
Expand Down
5 changes: 4 additions & 1 deletion modules/vcd_vapp_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,11 @@ def add_vm(self):
response['changed'] = False

try:
self.get_vm()
found = self.get_vm()
except EntityNotFoundException:
found = None

if not found:
spec = {
'source_vm_name': source_vm_name,
'vapp': source_vapp_resource,
Expand Down