Ejemplo n.º 1
0
  @Override
  public void processOnClientIpChange(final Guid vmId, String newClientIp) {
    final AuditLogableBase event = new AuditLogableBase();
    final VmDynamic vmDynamic = DbFacade.getInstance().getVmDynamicDao().get(vmId);
    event.setVmId(vmId);
    event.setUserName(vmDynamic.getConsoleCurrentUserName());

    // in case of empty clientIp we clear the logged in user.
    // (this happened when user close the console to spice/vnc)
    if (StringUtils.isEmpty(newClientIp)) {
      vmDynamic.setConsoleCurrentUserName(null);
      DbFacade.getInstance().getVmDynamicDao().update(vmDynamic);
      auditLogDirector.log(event, AuditLogType.VM_CONSOLE_DISCONNECTED);
    } else {
      auditLogDirector.log(event, AuditLogType.VM_CONSOLE_CONNECTED);
    }
  }
 @Override
 protected boolean isVmNeedsToBeAutoStarted(Guid vmId) {
   VmDynamic vmDynamic = getVmDynamicDao().get(vmId);
   return vmDynamic.getStatus() == VMStatus.Down
       && vmDynamic.getExitStatus() == VmExitStatus.Error;
 }
Ejemplo n.º 3
0
 /**
  * Add or update vmDynamic to save list
  *
  * @param vmDynamic
  */
 protected void addVmDynamicToList(VmDynamic vmDynamic) {
   vmDynamicToSave.put(vmDynamic.getId(), vmDynamic);
 }
Ejemplo n.º 4
0
  private void afterVMsRefreshTreatment() {
    Collection<Guid> movedToDownVms = new ArrayList<>();
    List<Guid> succeededToRunVms = new ArrayList<>();

    // now loop over the result and act
    for (VmAnalyzer vmAnalyzer : vmAnalyzers) {

      // rerun all vms from rerun list
      if (vmAnalyzer.isRerun()) {
        log.error(
            "Rerun VM '{}'. Called from VDS '{}'",
            vmAnalyzer.getDbVm().getId(),
            vdsManager.getVdsName());
        ResourceManager.getInstance()
            .rerunFailedCommand(vmAnalyzer.getDbVm().getId(), vdsManager.getVdsId());
      }

      if (vmAnalyzer.isSuccededToRun()) {
        vdsManager.succeededToRunVm(vmAnalyzer.getDbVm().getId());
        succeededToRunVms.add(vmAnalyzer.getDbVm().getId());
      }

      // Refrain from auto-start HA VM during its re-run attempts.
      if (vmAnalyzer.isAutoVmToRun() && !vmAnalyzer.isRerun()) {
        autoVmsToRun.add(vmAnalyzer.getDbVm().getId());
      }

      // process all vms that their ip changed.
      if (vmAnalyzer.isClientIpChanged()) {
        final VmDynamic vmDynamic = vmAnalyzer.getVdsmVm().getVmDynamic();
        getVdsEventListener().processOnClientIpChange(vmDynamic.getId(), vmDynamic.getClientIp());
      }

      // process all vms that powering up.
      if (vmAnalyzer.isPoweringUp()) {
        getVdsEventListener().processOnVmPoweringUp(vmAnalyzer.getVdsmVm().getVmDynamic().getId());
      }

      if (vmAnalyzer.isMovedToDown()) {
        movedToDownVms.add(vmAnalyzer.getDbVm().getId());
      }

      if (vmAnalyzer.isRemoveFromAsync()) {
        ResourceManager.getInstance().removeAsyncRunningVm(vmAnalyzer.getDbVm().getId());
      }

      if (vmAnalyzer.isHostedEngineUnmanaged()) {
        // @since 3.6 - we take existing HE VM and reimport it
        importHostedEngineVM(
            getVmInfo(
                Collections.singletonList(
                    vmAnalyzer.getVdsmVm().getVmDynamic().getId().toString()))[0]);
      }
    }

    getVdsEventListener().updateSlaPolicies(succeededToRunVms, vdsManager.getVdsId());

    // run all vms that crashed that marked with auto startup
    getVdsEventListener().runFailedAutoStartVMs(autoVmsToRun);

    // process all vms that went down
    getVdsEventListener().processOnVmStop(movedToDownVms, vdsManager.getVdsId());

    getVdsEventListener()
        .refreshHostIfAnyVmHasHostDevices(succeededToRunVms, vdsManager.getVdsId());
  }