private static VDSReturnValue createGetVGInfoReturnValue(List<LUNs> luns) {
    VDSReturnValue returnValue = new VDSReturnValue();
    returnValue.setSucceeded(true);
    returnValue.setReturnValue(luns);

    return returnValue;
  }
Exemplo n.º 2
0
 @Override
 protected void perform() {
   VDSReturnValue returnValue =
       runVdsCommand(VDSCommandType.Thaw, new VdsAndVmIDVDSParametersBase(getVdsId(), getVmId()));
   setActionReturnValue(returnValue.getReturnValue());
   setSucceeded(returnValue.getSucceeded());
 }
  private void createImageForMemoryDump() {
    VDSReturnValue retVal =
        Backend.getInstance()
            .getResourceManager()
            .RunVdsCommand(
                VDSCommandType.CreateImage,
                new CreateImageVDSCommandParameters(
                    storagePool.getId(),
                    storageDomainId,
                    memoryDumpImageGroupId,
                    vm.getTotalMemorySizeInBytes(),
                    getVolumeTypeForDomain(),
                    VolumeFormat.RAW,
                    memoryDumpVolumeId,
                    ""));

    if (!retVal.getSucceeded()) {
      throw new EngineException(
          EngineError.VolumeCreationError, "Failed to create image for memory!");
    }

    Guid taskId =
        enclosingCommand.persistAsyncTaskPlaceHolder(CREATE_IMAGE_FOR_MEMORY_DUMP_TASK_KEY);
    Guid guid =
        enclosingCommand.createTask(
            taskId,
            retVal.getCreationInfo(),
            enclosingCommand.getActionType(),
            VdcObjectType.Storage,
            storageDomainId);
    enclosingCommand.getTaskIdList().add(guid);
  }
  /**
   * Retrieve a storage domain using a specified storage domain ID.
   *
   * @param storageDomainId the domain's ID
   * @return the storage domain
   */
  @SuppressWarnings("unchecked")
  protected StorageDomain getStorageDomainById(Guid storageDomainId) {
    VDSReturnValue returnValue;

    try {
      returnValue =
          executeHSMGetStorageDomainInfo(
              new HSMGetStorageDomainInfoVDSCommandParameters(
                  getParameters().getVdsId(), storageDomainId));
    } catch (RuntimeException e) {
      log.error(
          "Could not get info for storage domain ID: '{}': {}", storageDomainId, e.getMessage());
      log.debug("Exception", e);
      return null;
    }

    Pair<StorageDomainStatic, SANState> result =
        (Pair<StorageDomainStatic, SANState>) returnValue.getReturnValue();
    StorageDomainStatic storageDomainStatic = result.getFirst();
    storageDomainStatic.setStorageType(getParameters().getStorageType());

    StorageDomain storageDomain = new StorageDomain();
    storageDomain.setStorageStaticData(storageDomainStatic);

    return storageDomain;
  }
  @Override
  protected void executeCommand() {
    List<VM> vms = getVmDao().getAllRunningForVds(getVdsId());
    Collections.sort(vms, Collections.reverseOrder(new VmsComparer()));
    List<Guid> autoStartVmIdsToRerun = new ArrayList<>();
    for (VM vm : vms) {
      if (vm.isAutoStartup()) {
        autoStartVmIdsToRerun.add(vm.getId());
      }
      VDSReturnValue returnValue =
          runVdsCommand(
              VDSCommandType.SetVmStatus,
              new SetVmStatusVDSCommandParameters(vm.getId(), VMStatus.Down, VmExitStatus.Error));
      // Write that this VM was shut down by host reboot or manual fence
      if (returnValue != null && returnValue.getSucceeded()) {
        logSettingVmToDown(getVds().getId(), vm.getId());
      }

      runInternalActionWithTasksContext(
          VdcActionType.ProcessDownVm, new ProcessDownVmParameters(vm.getId(), true));
    }

    runVdsCommand(
        VDSCommandType.UpdateVdsVMsCleared,
        new UpdateVdsVMsClearedVDSCommandParameters(getVdsId()));
    if (!autoStartVmIdsToRerun.isEmpty()) {
      haAutoStartVmsRunner.addVmsToRun(autoStartVmIdsToRerun);
    }
    setSucceeded(true);
  }
  private void createImageForVmMetaData() {
    VDSReturnValue retVal =
        Backend.getInstance()
            .getResourceManager()
            .RunVdsCommand(
                VDSCommandType.CreateImage,
                new CreateImageVDSCommandParameters(
                    storagePool.getId(),
                    storageDomainId,
                    vmConfImageGroupId,
                    MemoryUtils.META_DATA_SIZE_IN_BYTES,
                    VolumeType.Sparse,
                    VolumeFormat.COW,
                    vmConfVolumeId,
                    ""));

    if (!retVal.getSucceeded()) {
      throw new EngineException(
          EngineError.VolumeCreationError, "Failed to create image for vm configuration!");
    }

    Guid taskId = enclosingCommand.persistAsyncTaskPlaceHolder(CREATE_IMAGE_FOR_VM_TASK_KEY);
    Guid guid =
        enclosingCommand.createTask(
            taskId, retVal.getCreationInfo(), enclosingCommand.getActionType());
    enclosingCommand.getTaskIdList().add(guid);
  }
 private void expectGetDeviceList() {
   VDSReturnValue returnValue = new VDSReturnValue();
   returnValue.setSucceeded(true);
   returnValue.setReturnValue(setUpLunsFromDeviceList());
   when(vdsBrokerFrontendMock.runVdsCommand(
           eq(VDSCommandType.GetDeviceList), any(GetDeviceListVDSCommandParameters.class)))
       .thenReturn(returnValue);
 }
 private void mockAttachStorageDomainVdsCommand() {
   VDSReturnValue returnValue = new VDSReturnValue();
   returnValue.setSucceeded(true);
   when(vdsBrokerFrontend.runVdsCommand(
           eq(VDSCommandType.AttachStorageDomain),
           any(AttachStorageDomainVDSCommandParameters.class)))
       .thenReturn(returnValue);
 }
 protected VDSBrokerFrontend expectRemove(VDSBrokerFrontend vdsBroker) {
   VDSReturnValue ret = new VDSReturnValue();
   ret.setSucceeded(true);
   when(vdsBroker.RunVdsCommand(
           eq(VDSCommandType.RemoveVG), any(RemoveVGVDSCommandParameters.class)))
       .thenReturn(ret);
   return vdsBroker;
 }
 protected VDSBrokerFrontend expectFormat(VDSBrokerFrontend vdsBroker, boolean failure) {
   VDSReturnValue ret = new VDSReturnValue();
   ret.setSucceeded(!failure);
   when(vdsBroker.RunVdsCommand(
           eq(VDSCommandType.FormatStorageDomain),
           any(FormatStorageDomainVDSCommandParameters.class)))
       .thenReturn(ret);
   return vdsBroker;
 }
Exemplo n.º 11
0
  /** Execution shall perform a call to VDSM to set the SLA parameters. */
  @Override
  protected void executeCommand() {
    VDSReturnValue vdsReturnValue =
        runVdsCommand(
            VDSCommandType.UpdateVmPolicy,
            new UpdateVmPolicyVDSParams(
                getVm().getRunOnVds(), getVmId(), getParameters().getCpuLimit()));

    setSucceeded(vdsReturnValue.getSucceeded());
  }
 private void mockGetStorageDomainInfoVdsCommand(StorageDomainStatic storageDomain) {
   Pair<StorageDomainStatic, Guid> pairResult = new Pair<>(storageDomain, null);
   VDSReturnValue returnValueForGetStorageDomainInfo = new VDSReturnValue();
   returnValueForGetStorageDomainInfo.setSucceeded(true);
   returnValueForGetStorageDomainInfo.setReturnValue(pairResult);
   when(vdsBrokerFrontend.runVdsCommand(
           eq(VDSCommandType.HSMGetStorageDomainInfo),
           any(HSMGetStorageDomainInfoVDSCommandParameters.class)))
       .thenReturn(returnValueForGetStorageDomainInfo);
 }
  private VDSReturnValue createGetStorageDomainInfoReturnValue() {
    VDSReturnValue returnValue = new VDSReturnValue();
    returnValue.setSucceeded(true);

    StorageDomain storageDomain = new StorageDomain();
    storageDomain.setId(storageDomainId);

    Pair<StorageDomainStatic, Object> pair = new Pair<>(storageDomain.getStorageStaticData(), null);
    returnValue.setReturnValue(pair);

    return returnValue;
  }
 @Override
 protected void executeQueryCommand() {
   ArrayList<StorageDomain> returnValue = new ArrayList<>();
   VDSReturnValue vdsReturnValue =
       runVdsCommand(
           VDSCommandType.HSMGetStorageDomainsList,
           new HSMGetStorageDomainsListVDSCommandParameters(
               getParameters().getId(),
               Guid.Empty,
               null,
               getParameters().getStorageDomainType(),
               getParameters().getPath()));
   if (vdsReturnValue.getSucceeded()) {
     ArrayList<Guid> guidsFromIrs = (ArrayList<Guid>) vdsReturnValue.getReturnValue();
     HashSet<Guid> guidsFromDb = new HashSet<>();
     if (guidsFromIrs.size() > 0) {
       List<StorageDomain> domainsInDb = storageDomainDao.getAll();
       for (StorageDomain domain : domainsInDb) {
         guidsFromDb.add(domain.getId());
       }
       for (Guid domainId : guidsFromIrs) {
         if (!guidsFromDb.contains(domainId)) {
           Pair<StorageDomainStatic, Guid> domainFromIrs =
               (Pair<StorageDomainStatic, Guid>)
                   runVdsCommand(
                           VDSCommandType.HSMGetStorageDomainInfo,
                           new HSMGetStorageDomainInfoVDSCommandParameters(
                               getParameters().getId(), domainId))
                       .getReturnValue();
           StorageDomain domain = new StorageDomain();
           domain.setStorageStaticData(domainFromIrs.getFirst());
           domain.setStoragePoolId(domainFromIrs.getSecond());
           if (getParameters().getStorageFormatType() == null
               || getParameters().getStorageFormatType() == domain.getStorageFormat()) {
             if (getParameters().getStorageType() != null
                 && domain.getStorageType().getValue()
                     != getParameters().getStorageType().getValue()) {
               log.warn(
                   "The storage type of domain {} has been changed from {} to {}",
                   domain.getStorageName(),
                   domain.getStorageType().toString(),
                   getParameters().getStorageType().toString());
               domain.setStorageType(getParameters().getStorageType());
             }
             returnValue.add(domain);
           }
         }
       }
     }
     getQueryReturnValue().setReturnValue(returnValue);
   }
 }
Exemplo n.º 15
0
 /**
  * gets VM full information for the given list of VMs
  *
  * @param vmsToUpdate
  * @return
  */
 protected Map[] getVmInfo(List<String> vmsToUpdate) {
   // TODO refactor commands to use vdsId only - the whole vds object here is useless
   VDS vds = new VDS();
   vds.setId(vdsManager.getVdsId());
   Map[] result = {};
   VDSReturnValue vdsReturnValue =
       getResourceManager()
           .runVdsCommand(
               VDSCommandType.FullList, new FullListVDSCommandParameters(vds, vmsToUpdate));
   if (vdsReturnValue.getSucceeded()) {
     result = (Map[]) (vdsReturnValue.getReturnValue());
   }
   return result;
 }
Exemplo n.º 16
0
 protected void getDowntime() {
   if (FeatureSupported.migrateDowntime(getVm().getVdsGroupCompatibilityVersion())) {
     try {
       VDSReturnValue retVal =
           runVdsCommand(
               VDSCommandType.MigrateStatus,
               new MigrateStatusVDSCommandParameters(getDestinationVdsId(), getVmId()));
       if (retVal != null) {
         actualDowntime = (Integer) retVal.getReturnValue();
       }
     } catch (EngineException e) {
       migrationErrorCode = e.getErrorCode();
     }
   }
 }
 private String createVG() {
   VDSReturnValue returnValue =
       runVdsCommand(
           VDSCommandType.CreateVG,
           new CreateVGVDSCommandParameters(
               getVds().getId(),
               getStorageDomain().getId(),
               getParameters().getLunIds(),
               getParameters().isForce()));
   String volumeGroupId =
       (String)
           ((returnValue.getReturnValue() instanceof String)
               ? returnValue.getReturnValue()
               : null);
   return volumeGroupId;
 }
  private void mockBackend(boolean succeeded, EngineError errorCode) {
    doReturn(backend).when(cmd).getBackend();
    doNothing().when(cmd).startSubStep();
    doReturn(asyncTaskToBeReturned).when(cmd).handleTaskReturn(asyncTaskToBeReturned);
    doNothing().when(cmd).updateBricksWithTaskID(asyncTaskToBeReturned);

    VDSReturnValue vdsReturnValue = new VDSReturnValue();
    vdsReturnValue.setReturnValue(asyncTaskToBeReturned);
    vdsReturnValue.setSucceeded(succeeded);
    if (!succeeded) {
      vdsReturnValue.setVdsError(new VDSError(errorCode, ""));
    }
    when(vdsBrokerFrontend.runVdsCommand(
            eq(VDSCommandType.StartRemoveGlusterVolumeBricks),
            argThat(anyGlusterVolumeRemoveBricksVDSParameters())))
        .thenReturn(vdsReturnValue);
  }
Exemplo n.º 19
0
 private void disconnectStorageByType(
     StorageType storageType, List<StorageServerConnections> connections) {
   StorageHelperDirector.getInstance()
       .getItem(storageType)
       .prepareDisconnectHostFromStoragePoolServers(getParameters(), connections);
   VDSReturnValue vdsReturnValue =
       runVdsCommand(
           VDSCommandType.DisconnectStorageServer,
           new StorageServerConnectionManagementVDSParameters(
               getVds().getId(), getStoragePool().getId(), storageType, connections));
   setSucceeded(vdsReturnValue.getSucceeded());
   if (!vdsReturnValue.getSucceeded()) {
     StorageHelperDirector.getInstance()
         .getItem(storageType)
         .isConnectSucceeded(
             (HashMap<String, String>) vdsReturnValue.getReturnValue(), connections);
   }
 }
Exemplo n.º 20
0
  private static VDSReturnValue runVdsCommand(
      VDSCommandType vdsCommandType,
      VdsIdVDSCommandParametersBase params,
      Guid storagePoolId,
      CommandBase<?> cmd,
      boolean performFailover) {
    Set<Guid> executedHosts = new HashSet<>();
    VDSReturnValue returnValue = null;
    if (params.getVdsId() == null) {
      chooseHostForExecution(params, storagePoolId, cmd, Collections.emptyList());
      if (params.getVdsId() == null) {
        throw new EngineException(
            EngineError.RESOURCE_MANAGER_VDS_NOT_FOUND,
            "No host was found to perform the operation");
      }
    }

    int attempts = 0;
    while (attempts <= Config.<Integer>getValue(ConfigValues.HsmCommandFailOverRetries)) {
      try {
        attempts++;
        returnValue = getBackend().getResourceManager().runVdsCommand(vdsCommandType, params);
        if (returnValue != null && returnValue.getSucceeded()) {
          return returnValue;
        }
      } catch (EngineException e) {
        returnValue = e.getVdsReturnValue();
      }

      executedHosts.add(params.getVdsId());

      if (!performFailover || (returnValue != null && !returnValue.isCanTryOnDifferentVds())) {
        break;
      }

      chooseHostForExecution(params, storagePoolId, cmd, executedHosts);

      if (params.getVdsId() == null) {
        break;
      }
    }

    return VdsHandler.handleVdsResult(returnValue);
  }
  /*
   * (non-Javadoc)
   * @see org.ovirt.engine.core.bll.CommandBase#executeCommand()
   */
  @Override
  protected void executeCommand() {
    VDSReturnValue returnValue =
        Backend.getInstance()
            .getResourceManager()
            .RunVdsCommand(
                VDSCommandType.ListGlusterVolumes,
                new GlusterBaseVDSCommandParameters(getVdsGroup().getstorage_pool_id().getValue()));

    // Get the return value from VDS command and put it into the return value of the BLL command
    ArrayList<GlusterVolumeEntity> list = new ArrayList<GlusterVolumeEntity>();
    for (GlusterVolumeEntity glusterVolumeEntity :
        (GlusterVolumeEntity[]) returnValue.getReturnValue()) {
      list.add(glusterVolumeEntity);
    }
    getReturnValue().setActionReturnValue(list);

    setSucceeded(returnValue.getSucceeded());
  }
  /** Test query execution */
  private void internalExecuteQuery() {
    // Run 'GetDeviceList' command
    VDSReturnValue returnValue = new VDSReturnValue();
    returnValue.setSucceeded(true);
    returnValue.setReturnValue(lunsInput);
    when(vdsBrokerFrontendMock.RunVdsCommand(
            eq(VDSCommandType.GetDeviceList), any(GetDeviceListVDSCommandParameters.class)))
        .thenReturn(returnValue);

    // Return 'lunsFromDb'
    when(lunDaoMock.getAll()).thenReturn(lunsFromDb);

    // Execute command
    getQuery().executeQueryCommand();

    // Assert the query's results
    List<LUNs> lunsActual = getQuery().getQueryReturnValue().getReturnValue();

    assertEquals(lunsExpected, lunsActual);
  }
Exemplo n.º 23
0
  @Override
  protected void executeVmCommand() {
    VDSReturnValue vdsReturnValue =
        resourceManager.runVdsCommand(VDSCommandType.MigrateBroker, getParameters());
    VM vm = getVmDao().get(getParameters().getVmId());

    if (vdsReturnValue.getSucceeded()) {
      resourceManager.AddAsyncRunningVm(getParameters().getVmId());
      resourceManager.InternalSetVmStatus(vm, VMStatus.MigratingFrom);
      vm.setMigratingToVds(getParameters().getDstVdsId());
      vmManager.update(vm.getDynamicData());
      getVDSReturnValue().setReturnValue(VMStatus.MigratingFrom);
    } else {
      log.error("Failed Vm migration");
      getVDSReturnValue().setSucceeded(false);
      getVDSReturnValue().setReturnValue(vm.getStatus());
      getVDSReturnValue().setVdsError(vdsReturnValue.getVdsError());
      getVDSReturnValue().setExceptionString(vdsReturnValue.getExceptionString());
      getVDSReturnValue().setExceptionObject(vdsReturnValue.getExceptionObject());
    }
  }
Exemplo n.º 24
0
  @Override
  protected void executeCommand() {
    VDSReturnValue returnValue =
        runVdsCommand(
            VDSCommandType.StopGlusterVolumeGeoRepSession,
            new GlusterVolumeGeoRepSessionVDSParameters(
                upServer.getId(),
                getGeoRepSession().getMasterVolumeName(),
                getGeoRepSession().getSlaveHostName(),
                getGeoRepSession().getSlaveVolumeName(),
                getGeoRepSession().getUserName(),
                getParameters().isForce()));

    setSucceeded(returnValue.getSucceeded());
    if (getSucceeded()) {
      getGeoRepSession().setStatus(GeoRepSessionStatus.STOPPED);
      getGlusterGeoRepDao().updateSession(getGeoRepSession());
    } else {
      handleVdsError(
          AuditLogType.GEOREP_SESSION_STOP_FAILED, returnValue.getVdsError().getMessage());
    }
  }
  @Override
  protected void executeCommand() {
    VDSReturnValue returnValue =
        runVdsCommand(
            VDSCommandType.ResetGlusterVolumeOptions,
            new ResetGlusterVolumeOptionsVDSParameters(
                upServer.getId(),
                getGlusterVolumeName(),
                getParameters().getVolumeOption(),
                getParameters().isForceAction()));
    setSucceeded(returnValue.getSucceeded());

    if (getSucceeded()) {

      if (getParameters().getVolumeOption() != null
          && !(getParameters().getVolumeOption().getKey().isEmpty())) {
        GlusterVolumeOptionEntity entity =
            getGlusterVolume().getOption(getParameters().getVolumeOption().getKey());
        isResetAllOptions = false;
        if (entity != null) {
          removeOptionInDb(entity);
          String optionValue = entity.getValue();
          getParameters().getVolumeOption().setValue(optionValue != null ? optionValue : "");
          addCustomValue(GlusterConstants.OPTION_KEY, getParameters().getVolumeOption().getKey());
          addCustomValue(
              GlusterConstants.OPTION_VALUE, getParameters().getVolumeOption().getValue());
        }
      } else {
        for (GlusterVolumeOptionEntity option : getGlusterVolume().getOptions()) {
          removeOptionInDb(option);
        }
        isResetAllOptions = true;
      }
    } else {
      handleVdsError(
          AuditLogType.GLUSTER_VOLUME_OPTIONS_RESET_FAILED, returnValue.getVdsError().getMessage());
      return;
    }
  }
  /*
   * (non-Javadoc)
   *
   * @see org.ovirt.engine.core.bll.CommandBase#executeCommand()
   */
  @Override
  protected void executeCommand() {
    // set the gluster volume name for audit purpose
    setGlusterVolumeName(volume.getName());

    if (volume.getTransportTypes() == null || volume.getTransportTypes().isEmpty()) {
      volume.addTransportType(TransportType.TCP);
    }

    // GLUSTER access protocol is enabled by default
    volume.addAccessProtocol(AccessProtocol.GLUSTER);
    if (!volume.getAccessProtocols().contains(AccessProtocol.NFS)) {
      volume.disableNFS();
    }

    VDSReturnValue returnValue =
        runVdsCommand(
            VDSCommandType.CreateGlusterVolume,
            new CreateGlusterVolumeVDSParameters(upServer.getId(), volume));
    setSucceeded(returnValue.getSucceeded());

    if (!getSucceeded()) {
      handleVdsError(
          AuditLogType.GLUSTER_VOLUME_CREATE_FAILED, returnValue.getVdsError().getMessage());
      return;
    }

    // Volume created successfully. Insert it to database.
    GlusterVolumeEntity createdVolume = (GlusterVolumeEntity) returnValue.getReturnValue();
    setVolumeType(createdVolume);
    setBrickOrder(createdVolume.getBricks());
    addVolumeToDb(createdVolume);

    // set all options of the volume
    setVolumeOptions(createdVolume);

    getReturnValue().setActionReturnValue(createdVolume.getId());
  }
  /**
   * Create StorageDomain objects according to the specified VG-IDs list.
   *
   * @param vgIDs the VG-IDs list
   * @return storage domains list
   */
  @SuppressWarnings("unchecked")
  protected List<StorageDomain> getStorageDomainsByVolumeGroupIds(List<String> vgIDs) {
    List<StorageDomain> storageDomains = new ArrayList<>();

    // Get existing PhysicalVolumes.
    List<String> existingLunIds = Entities.getIds(getLunDao().getAll());

    for (String vgID : vgIDs) {
      VDSReturnValue returnValue;
      try {
        returnValue =
            executeGetVGInfo(new GetVGInfoVDSCommandParameters(getParameters().getVdsId(), vgID));
      } catch (RuntimeException e) {
        log.error("Could not get info for VG ID: '{}': {}", vgID, e.getMessage());
        log.debug("Exception", e);
        continue;
      }

      ArrayList<LUNs> luns = (ArrayList<LUNs>) returnValue.getReturnValue();
      List<String> lunIdsOnStorage = Entities.getIds(luns);
      if (CollectionUtils.containsAny(lunIdsOnStorage, existingLunIds)) {
        log.info("There are existing luns in the system which are part of VG id '{}'", vgID);
        continue;
      }

      // Get storage domain ID by a representative LUN
      LUNs lun = luns.get(0);
      Guid storageDomainId = lun.getStorageDomainId();

      // Get storage domain using GetStorageDomainInfo
      StorageDomain storageDomain = getStorageDomainById(storageDomainId);
      if (storageDomain != null) {
        storageDomains.add(storageDomain);
      }
    }
    return storageDomains;
  }
  @Override
  protected void executeCommand() {
    if (UpdateStorageDomainsInDb()) {
      // setting storage pool status to maintenance
      StoragePool storagePool = getStoragePool();
      getCompensationContext().snapshotEntity(storagePool);
      TransactionSupport.executeInNewTransaction(
          new TransactionMethod<Object>() {
            @Override
            public Object runInTransaction() {
              getStoragePool().setStatus(StoragePoolStatus.Maintenance);
              getStoragePool().setStoragePoolFormatType(masterStorageDomain.getStorageFormat());
              DbFacade.getInstance().getStoragePoolDao().update(getStoragePool());
              getCompensationContext().stateChanged();
              StoragePoolStatusHandler.poolStatusChanged(
                  getStoragePool().getId(), getStoragePool().getStatus());
              return null;
            }
          });

      // Following code performs only read operations, therefore no need for new transaction
      boolean result = false;
      retVal = null;
      for (VDS vds : getAllRunningVdssInPool()) {
        setVds(vds);
        for (Guid storageDomainId : getParameters().getStorages()) {
          // now the domain should have the mapping
          // with the pool in db
          StorageDomain storageDomain =
              DbFacade.getInstance()
                  .getStorageDomainDao()
                  .getForStoragePool(storageDomainId, getStoragePool().getId());
          StorageHelperDirector.getInstance()
              .getItem(storageDomain.getStorageType())
              .connectStorageToDomainByVdsId(storageDomain, getVds().getId());
        }
        retVal = addStoragePoolInIrs();
        if (!retVal.getSucceeded()
            && retVal.getVdsError().getCode() == VdcBllErrors.StorageDomainAccessError) {
          log.warnFormat("Error creating storage pool on vds {0} - continuing", vds.getName());
          continue;
        } else {
          // storage pool creation succeeded or failed
          // but didn't throw exception
          result = retVal.getSucceeded();
          break;
        }
      }

      setSucceeded(result);
      if (!result) {
        if (retVal != null && retVal.getVdsError().getCode() != null) {
          throw new VdcBLLException(
              retVal.getVdsError().getCode(), retVal.getVdsError().getMessage());
        } else {
          // throw exception to cause rollback and stop the
          // command
          throw new VdcBLLException(VdcBllErrors.ENGINE_ERROR_CREATING_STORAGE_POOL);
        }
      }
    }

    // Create pool phase completed, no rollback is needed here, so compensation information needs to
    // be cleared!
    TransactionSupport.executeInNewTransaction(
        new TransactionMethod<Void>() {
          @Override
          public Void runInTransaction() {
            getCompensationContext().resetCompensation();
            return null;
          }
        });
    freeLock();
    // if create succeeded activate
    if (getSucceeded()) {
      ActivateStorageDomains();
    }
  }
 private VDSReturnValue getVDSReturnValue() {
   VDSReturnValue returnValue = new VDSReturnValue();
   returnValue.setSucceeded(true);
   returnValue.setReturnValue(expectedServers);
   return returnValue;
 }
  private void connectAndRefreshAllUpHosts(final boolean commandSucceeded) {
    if (isLastMaster || !commandSucceeded) {
      log.warn(
          "skipping connect and refresh for all hosts, last master '{}', command status '{}'",
          isLastMaster,
          commandSucceeded);
      return;
    }

    List<Callable<Void>> tasks = new ArrayList<>();
    for (final VDS vds : getAllRunningVdssInPool()) {
      tasks.add(
          () -> {
            try {
              if (!connectVdsToNewMaster(vds)) {
                log.warn(
                    "failed to connect vds '{}' to the new master '{}'",
                    vds.getId(),
                    getNewMasterStorageDomainId());
                return null;
              }

              List<StoragePoolIsoMap> storagePoolIsoMap =
                  storagePoolIsoMapDao.getAllForStoragePool(getStoragePool().getId());
              try {
                runVdsCommand(
                    VDSCommandType.ConnectStoragePool,
                    new ConnectStoragePoolVDSCommandParameters(
                        vds,
                        getStoragePool(),
                        getNewMasterStorageDomainId(),
                        storagePoolIsoMap,
                        true));
              } catch (EngineException ex) {
                if (EngineError.StoragePoolUnknown == ex.getVdsError().getCode()) {
                  VDSReturnValue returnVal =
                      runVdsCommand(
                          VDSCommandType.ConnectStoragePool,
                          new ConnectStoragePoolVDSCommandParameters(
                              vds,
                              getStoragePool(),
                              getNewMasterStorageDomainId(),
                              storagePoolIsoMap));
                  if (!returnVal.getSucceeded()) {
                    log.error(
                        "Post reconstruct actions (connectPool) did not complete on host '{}' in the pool. error {}",
                        vds.getId(),
                        returnVal.getVdsError().getMessage());
                  }
                } else {
                  log.error(
                      "Post reconstruct actions (refreshPool)"
                          + " did not complete on host '{}' in the pool. error {}",
                      vds.getId(),
                      ex.getMessage());
                }
              }
            } catch (Exception e) {
              log.error(
                  "Post reconstruct actions (connectPool,refreshPool,disconnect storage)"
                      + " did not complete on host '{}' in the pool: {}",
                  vds.getId(),
                  e.getMessage());
              log.debug("Exception", e);
            }
            return null;
          });
    }
    ThreadPoolUtil.invokeAll(tasks);
  }