/**
   * @param vdbName the vdb name
   * @param vdbVersion the vdb version
   * @throws Exception if undeploying vdb fails
   */
  public void undeployVdb(String vdbName, int vdbVersion) throws Exception {
    this.admin.deleteVDB(appendVdbExtension(vdbName), vdbVersion);
    ITeiidVdb vdb = getVdb(vdbName);

    refreshVDBs();

    if (vdb == null) {

    } else {
      this.eventManager.notifyListeners(
          ExecutionConfigurationEvent.createUnDeployVDBEvent(vdb.getName()));
    }
  }
    private void waitForVDBLoad(String vdbName) throws Exception {
      int timeoutInSecs = 30; // time out after 30secs

      long waitUntil = System.currentTimeMillis() + timeoutInSecs * 1000;
      if (timeoutInSecs < 0) {
        waitUntil = Long.MAX_VALUE;
      }
      boolean first = true;
      do {
        // Pause 5 sec before subsequent attempts
        if (!first) {
          try {
            Thread.sleep(5000);
          } catch (InterruptedException e) {
            break;
          }
        } else {
          first = false;
        }
        // Get the VDB using admin API
        ITeiidVdb vdb = getVdb(vdbName);
        // Determine if VDB is loading, or whether to wait
        if (vdb != null) {
          // return if no models in VDB, or VDB has errors (done loading)
          if (vdb.hasModels() || vdb.hasFailed() || vdb.wasRemoved() || vdb.isActive()) {
            refresh();
            return;
          }
          // If the VDB Status is LOADING, but a validity error was found - return
          if (vdb.isLoading() && !vdb.getValidityErrors().isEmpty()) {
            refresh();
            return;
          }
        } else {
          refresh();
          return;
        }
      } while (System.currentTimeMillis() < waitUntil);
      refresh();
      return;
    }