// Undeploy the VApp if necessary
if (vApp.isDeployed()) {
try {
UndeployVAppParams params = UndeployVAppParams.builder()
.undeployPowerAction(UndeployVAppParams.PowerAction.SHUTDOWN).build();
Task undeployTask = vAppApi.undeploy(vAppUrn, params);
taskDoneEventually(undeployTask);
} catch (Exception e) {
// keep going; cleanup as much as possible
logger.warn(e, "Continuing cleanup after error undeploying VApp %s", vApp.getName());
}