コード例 #1
0
  @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);
  }
コード例 #2
0
  @Override
  public void runFailedAutoStartVMs(List<Guid> vmIds) {
    for (Guid vmId : vmIds) {
      // Alert that the virtual machine failed:
      AuditLogableBase event = new AuditLogableBase();
      event.setVmId(vmId);
      auditLogDirector.log(event, AuditLogType.HA_VM_FAILED);

      log.info(
          "Highly Available VM went down. Attempting to restart. VM Name '{}', VM Id '{}'",
          event.getVmName(),
          vmId);
    }

    haAutoStartVmsRunner.addVmsToRun(vmIds);
  }