コード例 #1
0
  private AsyncTaskManager(CommandCoordinator coco) {
    this.coco = coco;
    _tasks = new ConcurrentHashMap<>();

    SchedulerUtil scheduler = Injector.get(SchedulerUtilQuartzImpl.class);
    scheduler.scheduleAFixedDelayJob(
        this,
        "timerElapsed",
        new Class[] {},
        new Object[] {},
        Config.<Integer>getValue(ConfigValues.AsyncTaskPollingRate),
        Config.<Integer>getValue(ConfigValues.AsyncTaskPollingRate),
        TimeUnit.SECONDS);

    scheduler.scheduleAFixedDelayJob(
        this,
        "cacheTimerElapsed",
        new Class[] {},
        new Object[] {},
        Config.<Integer>getValue(ConfigValues.AsyncTaskStatusCacheRefreshRateInSeconds),
        Config.<Integer>getValue(ConfigValues.AsyncTaskStatusCacheRefreshRateInSeconds),
        TimeUnit.SECONDS);
    _cacheTimeInMinutes =
        Config.<Integer>getValue(ConfigValues.AsyncTaskStatusCachingTimeInMinutes);
  }
コード例 #2
0
  @Test
  public void testGeneralQuotaLimitations() throws Exception {
    // Set new Quota definition.
    Quota quota = new Quota();
    Guid quotaId = Guid.NewGuid();
    quota.setId(quotaId);
    quota.setStoragePoolId(FixturesTool.STORAGE_POOL_NFS);
    quota.setQuotaName("Watson");
    quota.setDescription("General quota");
    quota.setThresholdVdsGroupPercentage(
        Config.<Integer>GetValue(ConfigValues.QuotaThresholdVdsGroup));
    quota.setThresholdStoragePercentage(
        Config.<Integer>GetValue(ConfigValues.QuotaThresholdStorage));
    quota.setGraceVdsGroupPercentage(Config.<Integer>GetValue(ConfigValues.QuotaGraceVdsGroup));
    quota.setGraceStoragePercentage(Config.<Integer>GetValue(ConfigValues.QuotaGraceStorage));
    setQuotaGlobalLimitations(quota);
    quota.setQuotaVdsGroups(getQuotaVdsGroup(null));
    quota.setQuotaStorages(getQuotaStorage(null));
    dao.save(quota);

    Quota quotaEntity = dao.getById(quota.getId());

    assertNotNull(quotaEntity);
    assertEquals(quotaEntity, quota);
    assertEquals(quotaEntity.getStoragePoolName(), "rhel6.NFS");
    assertEquals(quotaEntity.getQuotaEnforcementType(), QuotaEnforcementTypeEnum.DISABLED);
  }
コード例 #3
0
 private static boolean isBelowPctThreshold(final storage_domains domain) {
   storage_domain_dynamic dynamic = domain.getStorageDynamicData();
   return (dynamic != null
       && dynamic.getfreeDiskInGB()
           > Config.<Integer>GetValue(ConfigValues.FreeSpaceCriticalLowInGB)
       && dynamic.getfreeDiskPercent() > Config.<Integer>GetValue(ConfigValues.FreeSpaceLow));
 }
コード例 #4
0
 @Test
 public void testGetValue() {
   // Verify that values for 3.0 and 3.2 are from DB (since the entries are present in
   // fixtures.xml)
   // and for 3.1, it's the default value from annotation in ConfigValues.
   // 3.0 -> false, 3.1 -> true, 3.2 -> true
   Assert.assertFalse(Config.<Boolean>getValue(ConfigValues.NonVmNetworkSupported, "3.0"));
   Assert.assertTrue(Config.<Boolean>getValue(ConfigValues.NonVmNetworkSupported, "3.1"));
   Assert.assertTrue(Config.<Boolean>getValue(ConfigValues.NonVmNetworkSupported, "3.2"));
 }
コード例 #5
0
 /**
  * Determines whether [is high availability value legal] [the specified value].
  *
  * @param value The value.
  * @param reasons The reasons.
  * @return <c>true</c> if [is vm priority value legal] [the specified value]; otherwise,
  *     <c>false</c>.
  */
 public static boolean isVmPriorityValueLegal(int value, List<String> reasons) {
   boolean res = false;
   if (value >= 0 && value <= Config.<Integer>getValue(ConfigValues.VmPriorityMaxValue)) {
     res = true;
   } else {
     reasons.add(EngineMessage.VM_OR_TEMPLATE_ILLEGAL_PRIORITY_VALUE.toString());
     reasons.add(
         String.format(
             "$MaxValue %1$s", Config.<Integer>getValue(ConfigValues.VmPriorityMaxValue)));
   }
   return res;
 }
コード例 #6
0
  public static Map<String, String> createStructFromConnection(
      final StorageServerConnections connection, final StoragePool storagePool) {
    // for information, see _connectionDict2ConnectionInfo in vdsm/storage/hsm.py
    DefaultValueMap con = new DefaultValueMap();
    con.put("id", connection.getid(), Guid.Empty.toString());
    con.put("connection", connection.getconnection(), "");
    con.put("tpgt", connection.getportal(), "");
    con.put("port", connection.getport(), "");
    con.put("iqn", connection.getiqn(), "");
    con.put("user", connection.getuser_name(), "");
    con.put("password", connection.getpassword(), "");
    con.putIfNotEmpty("ifaceName", connection.getIface());

    // storage_pool can be null when discovering iscsi send targets or when connecting
    // through vds which has no storage pool
    if (storagePool == null
        || Config.<Boolean>getValue(
            ConfigValues.AdvancedNFSOptionsEnabled,
            storagePool.getcompatibility_version().getValue())) {
      // For mnt_options, vfs_type, and protocol_version - if they are null
      // or empty we should not send a key with an empty value
      con.putIfNotEmpty("mnt_options", connection.getMountOptions());
      con.putIfNotEmpty("vfs_type", connection.getVfsType());
      if (connection.getNfsVersion() != null) {
        con.put("protocol_version", connection.getNfsVersion().getValue());
      }
      con.putIfNotEmpty("timeout", connection.getNfsTimeo());
      con.putIfNotEmpty("retrans", connection.getNfsRetrans());
    }
    return con;
  }
コード例 #7
0
  private void addVmsToPool(Guid poolId) {
    int subsequentFailedAttempts = 0;
    int vmPoolMaxSubsequentFailures =
        Config.<Integer>getValue(ConfigValues.VmPoolMaxSubsequentFailures);

    for (int i = 0; i < getParameters().getVmsCount(); i++) {
      String currentVmName = generateUniqueVmName();
      VdcReturnValueBase returnValue =
          runInternalAction(
              VdcActionType.AddVmAndAttachToPool,
              buildAddVmAndAttachToPoolParameters(poolId, currentVmName),
              createAddVmStepContext(currentVmName));

      if (returnValue != null
          && !returnValue.getSucceeded()
          && !returnValue.getCanDoActionMessages().isEmpty()) {
        for (String msg : returnValue.getCanDoActionMessages()) {
          if (!getReturnValue().getCanDoActionMessages().contains(msg)) {
            getReturnValue().getCanDoActionMessages().add(msg);
          }
        }
        addVmsSucceeded = false;
        subsequentFailedAttempts++;
      } else { // Succeed on that , reset subsequentFailedAttempts.
        subsequentFailedAttempts = 0;
        vmsAdded = true;
      }
      // if subsequent attempts failure exceeds configuration value , abort the loop.
      if (subsequentFailedAttempts == vmPoolMaxSubsequentFailures) {
        AuditLogableBase logable = new AuditLogableBase();
        auditLogDirector.log(logable, AuditLogType.USER_VM_POOL_MAX_SUBSEQUENT_FAILURES_REACHED);
        break;
      }
    }
  }
コード例 #8
0
  private int getMaximumMigrationDowntime() {
    if (getVm().getMigrationDowntime() != null) {
      return getVm().getMigrationDowntime();
    }

    return Config.getValue(ConfigValues.DefaultMaximumMigrationDowntime);
  }
 /*
  * (non-Javadoc)
  *
  * @see
  * org.springframework.ldap.core.support.DirContextAuthenticationStrategy
  * #setupEnvironment(java.util.Hashtable, java.lang.String,
  * java.lang.String)
  */
 @Override
 public void setupEnvironment(Hashtable env, String userDn, String password)
     throws NamingException {
   env.put(Context.SECURITY_AUTHENTICATION, GSS_API_AUTHENTICATION);
   String qopValue = Config.<String>GetValue(ConfigValues.SASL_QOP);
   env.put("javax.security.sasl.qop", qopValue);
 }
コード例 #10
0
 /**
  * get the return value and wait for the reply with default host connection timeout. We need to
  * assure that this thread is released after a timeout so the blocking call for get is overridden
  * here and delegated to the get(long timeout, TimeUnit unit)
  *
  * @return {@link VDSReturnValue}
  */
 @Override
 public VDSReturnValue get() {
   try {
     return get(Config.<Integer>GetValue(ConfigValues.vdsTimeout), TimeUnit.SECONDS);
   } catch (TimeoutException e) {
     return getVDSReturnValue();
   }
 }
コード例 #11
0
 protected boolean CheckStorageDomainNameLengthValid() {
   boolean result = true;
   if (getStorageDomain().getstorage_name().length()
       > Config.<Integer>GetValue(ConfigValues.StorageDomainNameSizeLimit)) {
     addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_NAME_LENGTH_IS_TOO_LONG);
     result = false;
   }
   return result;
 }
コード例 #12
0
  protected void executeHttpMethod(final T method) {
    int responseCode = -1;
    VdsManager manager = ResourceManager.getInstance().getVdsManager(getParameters().getVdsId());
    final HttpClient httpclient = manager.getVdsProxy().getHttpClient();
    try {
      FutureTask<Integer> futureTask =
          new FutureTask(
              new Callable<Integer>() {
                @Override
                public Integer call() throws Exception {
                  return httpclient.executeMethod(method);
                }
              });
      Future<Integer> f = ThreadPoolUtil.execute(futureTask);
      if (f.get(Config.<Integer>getValue(getConfigValueTimeLimitForOperation()), TimeUnit.MINUTES)
          == null) {
        responseCode = futureTask.get();
      }
    } catch (InterruptedException e) {
      throw new RuntimeException(e);
    } catch (Exception e) {
      log.debug("Exception", e);
      throw createNetworkException(e);
    }

    if (responseCode == getSuccessCode()) {
      Guid createdTask =
          Guid.createGuidFromString(processResponseHeaderValue(getMethod(), "Task-Id", null));
      getVDSReturnValue()
          .setCreationInfo(
              new AsyncTaskCreationInfo(
                  createdTask, getCreatedTaskType(), getParameters().getStoragePoolId()));
      handleOkResponse();
      getVDSReturnValue().setSucceeded(true);
      return;
    }

    processResponseHeaderValue(getMethod(), "Content-type", "application/json");

    String response;
    try {
      response = getMethod().getResponseBodyAsString();
    } catch (Exception e) {
      throw createNetworkException(e);
    }

    Map<String, Object> resultMap = null;
    try {
      resultMap = new ObjectMapper().readValue(response, HashMap.class);
      status = new StatusOnlyReturnForXmlRpc(resultMap);
    } catch (Exception e) {
      throwVdsErrorException("failed to parse response " + response, EngineError.GeneralException);
    }

    proceedProxyReturnValue();
  }
コード例 #13
0
ファイル: AddVdsCommand.java プロジェクト: oVirt/ovirt-engine
 private void addVdsStaticToDb() {
   getParameters()
       .getVdsStaticData()
       .setServerSslEnabled(Config.<Boolean>getValue(ConfigValues.EncryptHostCommunication));
   vdsStaticDao.save(getParameters().getVdsStaticData());
   getCompensationContext().snapshotNewEntity(getParameters().getVdsStaticData());
   setVdsIdRef(getParameters().getVdsStaticData().getId());
   addFenceAgents();
   setVds(null);
 }
コード例 #14
0
  private static boolean shouldPerformRecoveryOnType(String type) {
    Map<String, String> allowedRecoveryTypesFromConfig =
        Config.<Map<String, String>>getValue(ConfigValues.AutoRecoveryAllowedTypes);
    String isAllowed = allowedRecoveryTypesFromConfig.get(type);
    if (isAllowed != null) {
      return Boolean.parseBoolean(isAllowed);
    }

    return true;
  }
コード例 #15
0
 /** Should be called by backend, schedules the execution as configured. */
 void initialize() {
   log.info("Start initializing " + getClass().getSimpleName());
   SchedulerUtilQuartzImpl.getInstance()
       .scheduleACronJob(
           this,
           "onTimer",
           new Class<?>[] {},
           new Object[] {},
           Config.<String>getValue(ConfigValues.AutoRecoverySchedule));
   log.info("Finished initializing " + getClass().getSimpleName());
 }
コード例 #16
0
  /**
   * This method is called upon the bean creation as part of the management Service bean life cycle.
   */
  @Override
  @PostConstruct
  public void create() {

    try {
      // This must be done before starting to sample the hosts status from VDSM since the sampling
      // will turn such host from Reboot to NonResponsive
      loadService(PmHealthCheckManager.class);
      loadService(EngineBackupAwarenessManager.class);
      CommandCoordinatorUtil.initAsyncTaskManager();
      loadService(ResourceManager.class);
      OvfDataUpdater.getInstance().initOvfDataUpdater();
      ThreadPoolUtil.execute(
          new Runnable() {
            @Override
            public void run() {
              MacPoolPerDcSingleton.getInstance().initialize();
            }
          });
      StoragePoolStatusHandler.init();

      GlusterJobsManager.init();

      try {
        log.info("Init VM custom properties utilities");
        VmPropertiesUtils.getInstance().init();
      } catch (InitializationException e) {
        log.error("Initialization of vm custom properties failed.", e);
      }

      try {
        log.info("Init device custom properties utilities");
        DevicePropertiesUtils.getInstance().init();
      } catch (InitializationException e) {
        log.error("Initialization of device custom properties failed.", e);
      }

      loadService(SchedulingManager.class);

      SessionDataContainer.getInstance().cleanupEngineSessionsOnStartup();

      loadService(HostDeviceManager.class);
      loadService(DwhHeartBeat.class);

      if (Config.<Boolean>getValue(ConfigValues.AffinityRulesEnforcementManagerEnabled)) {
        loadService(AffinityRulesEnforcementManager.class);
      }

      loadService(CertificationValidityChecker.class);
    } catch (Exception ex) {
      log.error("Failed to initialize backend", ex);
      throw ex;
    }
  }
コード例 #17
0
ファイル: RunVmValidator.java プロジェクト: jtux270/translate
  protected ValidationResult validateMemorySize(VM vm) {
    final ConfigValues configKey =
        getOsRepository().get64bitOss().contains(vm.getOs())
            ? ConfigValues.VM64BitMaxMemorySizeInMB
            : ConfigValues.VM32BitMaxMemorySizeInMB;
    final int maxSize = Config.getValue(configKey, vm.getVdsGroupCompatibilityVersion().getValue());
    if (vm.getMemSizeMb() > maxSize) {
      return new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_MEMORY_EXCEEDS_SUPPORTED_LIMIT);
    }

    return ValidationResult.VALID;
  }
コード例 #18
0
  private StoragePoolStatusHandler scheduleTimeout() {
    Class[] argTypes = new Class[0];
    Object[] args = new Object[0];
    Integer timeout =
        Config.<Integer>GetValue(ConfigValues.StoragePoolNonOperationalResetTimeoutInMin);

    timerId =
        getScheduler()
            .scheduleAOneTimeJob(this, "onTimeout", argTypes, args, timeout, TimeUnit.MINUTES);

    return this;
  }
コード例 #19
0
ファイル: AddVdsCommand.java プロジェクト: oVirt/ovirt-engine
 /**
  * getInstalledVdsIdIfExists
  *
  * <p>Communicate with host by SSH session and gather vdsm-id if exist
  *
  * @param client - already connected ssh client
  */
 private String getInstalledVdsIdIfExists(SSHClient client) {
   try {
     ByteArrayOutputStream out = new ConstraintByteArrayOutputStream(256);
     client.executeCommand(
         Config.<String>getValue(ConfigValues.GetVdsmIdByVdsmToolCommand), null, out, null);
     return new String(out.toByteArray(), StandardCharsets.UTF_8);
   } catch (Exception e) {
     log.warn("Failed to initiate vdsm-id request on host: {}", e.getMessage());
     log.debug("Exception", e);
     return null;
   }
 }
コード例 #20
0
  private String getTimeZoneForVm(VM vm) {
    if (!StringUtils.isEmpty(vm.getTimeZone())) {
      return vm.getTimeZone();
    }

    // else fallback to engine config default for given OS type
    if (osRepository.isWindows(vm.getOs())) {
      return Config.<String>getValue(ConfigValues.DefaultWindowsTimeZone);
    } else {
      return "Etc/GMT";
    }
  }
コード例 #21
0
 private void addCpuPinning(final String compatibilityVersion) {
   final String cpuPinning = vm.getCpuPinning();
   if (StringUtils.isNotEmpty(cpuPinning)
       && Boolean.TRUE.equals(
           Config.<Boolean>getValue(ConfigValues.CpuPinningEnabled, compatibilityVersion))) {
     final Map<String, Object> pinDict = new HashMap<String, Object>();
     for (String pin : cpuPinning.split("_")) {
       final String[] split = pin.split("#");
       pinDict.put(split[0], split[1]);
     }
     createInfo.put(VdsProperties.cpuPinning, pinDict);
   }
 }
コード例 #22
0
ファイル: AddVdsCommand.java プロジェクト: oVirt/ovirt-engine
 private void addVdsDynamicToDb() {
   VdsDynamic vdsDynamic = new VdsDynamic();
   vdsDynamic.setId(getParameters().getVdsStaticData().getId());
   // TODO: oVirt type - here oVirt behaves like power client?
   if (getParameters().isPending()) {
     vdsDynamic.setStatus(VDSStatus.PendingApproval);
   } else if (getParameters().isProvisioned()) {
     vdsDynamic.setStatus(VDSStatus.InstallingOS);
   } else if (Config.<Boolean>getValue(ConfigValues.InstallVds)) {
     vdsDynamic.setStatus(VDSStatus.Installing);
   }
   vdsDynamicDao.save(vdsDynamic);
   getCompensationContext().snapshotNewEntity(vdsDynamic);
 }
コード例 #23
0
  @Test
  public void testSpecificQuotaLimitations() throws Exception {
    // Set new Quota definition.
    Quota quota = new Quota();
    Guid quotaId = Guid.NewGuid();
    quota.setId(quotaId);
    quota.setStoragePoolId(FixturesTool.STORAGE_POOL_NFS);
    quota.setQuotaName("Watson");
    quota.setDescription("Specific quota");
    quota.setThresholdVdsGroupPercentage(
        Config.<Integer>GetValue(ConfigValues.QuotaThresholdVdsGroup));
    quota.setThresholdStoragePercentage(
        Config.<Integer>GetValue(ConfigValues.QuotaThresholdStorage));
    quota.setGraceVdsGroupPercentage(Config.<Integer>GetValue(ConfigValues.QuotaGraceVdsGroup));
    quota.setGraceStoragePercentage(Config.<Integer>GetValue(ConfigValues.QuotaGraceStorage));
    quota.setQuotaVdsGroups(getQuotaVdsGroup(getSpecificQuotaVdsGroup(quotaId)));
    quota.setQuotaStorages(getQuotaStorage(getSpecificQuotaStorage(quotaId)));
    dao.save(quota);

    Quota quotaEntity = dao.getById(quota.getId());
    assertNotNull(quotaEntity);
    assertEquals(quotaEntity, quota);
  }
コード例 #24
0
  private Boolean getMigrateCompressed() {
    if (FeatureSupported.migrationCompression(getVm().getVdsGroupCompatibilityVersion())) {
      if (getVm().getMigrateCompressed() != null) {
        return getVm().getMigrateCompressed();
      }

      if (getVdsGroup().getMigrateCompressed() != null) {
        return getVdsGroup().getMigrateCompressed();
      }

      return Config.getValue(ConfigValues.DefaultMigrationCompression);
    }

    return null;
  }
コード例 #25
0
  private Boolean getAutoConverge() {
    if (FeatureSupported.autoConvergence(getVm().getVdsGroupCompatibilityVersion())) {
      if (getVm().getAutoConverge() != null) {
        return getVm().getAutoConverge();
      }

      if (getVdsGroup().getAutoConverge() != null) {
        return getVdsGroup().getAutoConverge();
      }

      return Config.getValue(ConfigValues.DefaultAutoConvergence);
    }

    return null;
  }
コード例 #26
0
  protected T getMethod() {
    if (method == null) {
      VdsStatic vdsStatic = getAndSetVdsStatic();

      Pair<String, URL> urlInfo =
          XmlRpcUtils.getConnectionUrl(
              vdsStatic.getHostName(),
              vdsStatic.getPort(),
              "",
              Config.<Boolean>getValue(ConfigValues.EncryptHostCommunication));

      method = concreteCreateMethod(urlInfo.getFirst());
    }

    return method;
  }
コード例 #27
0
  @Override
  protected boolean validate() {
    boolean retVal = super.validate();

    if (retVal) {
      StoragePool storagePool =
          DbFacade.getInstance().getStoragePoolDao().getForVds(getParameters().getVdsId());

      if (storagePool == null) {
        addValidationMessage(EngineMessage.NETWORK_CLUSTER_HAVE_NOT_EXISTING_DATA_CENTER_NETWORK);
        retVal = false;
      } else {
        setStoragePool(storagePool);
      }

      if (retVal
          && getStorageDomain().getStorageType() == StorageType.LOCALFS
          && !storagePool.isLocal()) {
        addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_STORAGE_POOL_IS_NOT_LOCAL);
        retVal = false;
      }

      if (retVal && storagePool.getStatus() != StoragePoolStatus.Uninitialized) {
        retVal = checkMasterDomainIsUp();
      }

      // we limit RHEV-H local storage to its persistence mount - /data/images/rhev/
      if (retVal && this.getVds().isOvirtNode()) {

        StorageServerConnections conn =
            DbFacade.getInstance()
                .getStorageServerConnectionDao()
                .get(getParameters().getStorageDomain().getStorage());

        String rhevhLocalFSPath = Config.<String>getValue(ConfigValues.RhevhLocalFSPath);
        if (!conn.getConnection().equals(rhevhLocalFSPath)) {
          addValidationMessage(EngineMessage.RHEVH_LOCALFS_WRONG_PATH_LOCATION);
          addValidationMessageVariable("path", rhevhLocalFSPath);
          retVal = false;
        }
      }
    }
    return retVal;
  }
コード例 #28
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);
  }
コード例 #29
0
  private void cleanZombieTasks() {
    long maxTime =
        DateTime.getNow()
            .addMinutes(
                -1 * Config.<Integer>getValue(ConfigValues.AsyncTaskZombieTaskLifeInMinutes))
            .getTime();
    for (SPMTask task : _tasks.values()) {

      if (task.getParameters().getDbAsyncTask().getStartTime().getTime() < maxTime) {
        AuditLogableBase logable = Injector.injectMembers(new AuditLogableBase());
        logable.addCustomValue(
            "CommandName", task.getParameters().getDbAsyncTask().getActionType().toString());
        logable.addCustomValue(
            "Date", task.getParameters().getDbAsyncTask().getStartTime().toString());

        // if task is not finish and not unknown then it's in running
        // status
        if (task.getLastTaskStatus().getStatus() != AsyncTaskStatusEnum.finished
            && task.getLastTaskStatus().getStatus() != AsyncTaskStatusEnum.unknown) {
          // mark it as a zombie task, Will result in failure of the command
          task.setZombieTask(true);
          auditLogDirector.log(logable, AuditLogType.TASK_STOPPING_ASYNC_TASK);

          log.info(
              "Cleaning zombie tasks: Stopping async task '{}' that started at '{}'",
              task.getParameters().getDbAsyncTask().getActionType(),
              task.getParameters().getDbAsyncTask().getStartTime());

          task.stopTask(true);
        } else {
          auditLogDirector.log(logable, AuditLogType.TASK_CLEARING_ASYNC_TASK);

          log.info(
              "Cleaning zombie tasks: Clearing async task '{}' that started at '{}'",
              task.getParameters().getDbAsyncTask().getActionType(),
              task.getParameters().getDbAsyncTask().getStartTime());

          task.clearAsyncTask(true);
        }
      }
    }
  }
コード例 #30
0
ファイル: VmsMonitoring.java プロジェクト: nirs/ovirt-engine
  protected void processExternallyManagedVms() {
    // Fetching for details from the host
    // and marking the VMs for addition
    List<String> vmsToQuery = new ArrayList<>(externalVms.size());
    for (Pair<VM, VmInternalData> pair : externalVms) {
      vmsToQuery.add(pair.getSecond().getVmDynamic().getId().toString());
    }
    if (!vmsToQuery.isEmpty()) {
      // Query VDSM for VMs info, and creating a proper VMStatic to be used when importing them
      Map[] vmsInfo = getVmInfo(vmsToQuery);
      for (Map vmInfo : vmsInfo) {
        Guid vmId = Guid.createGuidFromString((String) vmInfo.get(VdsProperties.vm_guid));
        VmStatic vmStatic = new VmStatic();
        vmStatic.setId(vmId);
        vmStatic.setCreationDate(new Date());
        vmStatic.setVdsGroupId(vdsManager.getVdsGroupId());
        String vmNameOnHost = (String) vmInfo.get(VdsProperties.vm_name);

        if (StringUtils.equals(
            Config.<String>getValue(ConfigValues.HostedEngineVmName), vmNameOnHost)) {
          // its a hosted engine VM -> import it and skip the external VM phase
          importHostedEngineVM(vmInfo);
          continue;
        } else {
          vmStatic.setName(String.format(EXTERNAL_VM_NAME_FORMAT, vmNameOnHost));
          vmStatic.setOrigin(OriginType.EXTERNAL);
        }

        vmStatic.setNumOfSockets(
            VdsBrokerObjectsBuilder.parseIntVdsProperty(vmInfo.get(VdsProperties.num_of_cpus)));
        vmStatic.setMemSizeMb(
            VdsBrokerObjectsBuilder.parseIntVdsProperty(vmInfo.get(VdsProperties.mem_size_mb)));
        vmStatic.setSingleQxlPci(false);

        externalVmsToAdd.add(vmStatic);
        log.info(
            "Importing VM '{}' as '{}', as it is running on the on Host, but does not exist in the engine.",
            vmNameOnHost,
            vmStatic.getName());
      }
    }
  }