コード例 #1
0
  private void logFailedStorageConnections(Map<String, String> returnValue) {
    StringBuilder failedDomainNames = new StringBuilder();
    String namesSeparator = ",";
    for (Entry<String, String> result : returnValue.entrySet()) {
      if (!"0".equals(result.getValue())) {
        List<StorageDomain> domains =
            DbFacade.getInstance()
                .getStorageDomainDao()
                .getAllByConnectionId(new Guid(result.getKey()));
        if (!domains.isEmpty()) {
          for (StorageDomain domain : domains) {
            if (failedDomainNames.length() > 0) {
              failedDomainNames.append(namesSeparator);
            }
            failedDomainNames.append(domain.getStorageName());
          }
        }
      }
    }

    if (failedDomainNames.length() > 0) {
      AuditLogableBase logable = new AuditLogableBase(getParameters().getVdsId());
      logable.addCustomValue("failedStorageDomains", failedDomainNames.toString());
      auditLogDirector.log(logable, AuditLogType.VDS_STORAGES_CONNECTION_FAILED);
    }
  }
コード例 #2
0
  protected static void reportUnsupportedVnicProfileFeatures(
      VM vm,
      VmNic nic,
      VnicProfile vnicProfile,
      List<VNIC_PROFILE_PROPERTIES> unsupportedFeatures) {

    if (unsupportedFeatures.isEmpty()) {
      return;
    }

    AuditLogableBase event = new AuditLogableBase();
    event.setVmId(vm.getId());
    event.setVdsGroupId(vm.getVdsGroupId());
    event.setCustomId(nic.getId().toString());
    event.setCompatibilityVersion(vm.getVdsGroupCompatibilityVersion().toString());
    event.addCustomValue("NicName", nic.getName());
    event.addCustomValue("VnicProfile", vnicProfile == null ? null : vnicProfile.getName());
    String[] unsupportedFeatureNames = new String[unsupportedFeatures.size()];
    for (int i = 0; i < unsupportedFeatures.size(); i++) {
      unsupportedFeatureNames[i] = unsupportedFeatures.get(i).getFeatureName();
    }

    event.addCustomValue("UnsupportedFeatures", StringUtils.join(unsupportedFeatureNames, ", "));
    AuditLogDirector.log(event, AuditLogType.VNIC_PROFILE_UNSUPPORTED_FEATURES);
  }
コード例 #3
0
  private void logChangedDisplayNetwork(
      VDS host,
      Collection<Network> engineHostNetworks,
      Collection<VdsNetworkInterface> engineInterfaces) {

    if (isVmRunningOnHost(host.getId())) {
      final Network engineDisplayNetwork =
          findDisplayNetwork(host.getVdsGroupId(), engineHostNetworks);

      if (engineDisplayNetwork == null) {
        return;
      }

      final IsNetworkOnInterfacePredicate isNetworkOnInterfacePredicate =
          new IsNetworkOnInterfacePredicate(engineDisplayNetwork.getName());
      final VdsNetworkInterface vdsmDisplayInterface =
          LinqUtils.firstOrNull(host.getInterfaces(), isNetworkOnInterfacePredicate);
      final VdsNetworkInterface engineDisplayInterface =
          LinqUtils.firstOrNull(engineInterfaces, isNetworkOnInterfacePredicate);
      final DisplayInterfaceEqualityPredicate displayIneterfaceEqualityPredicate =
          new DisplayInterfaceEqualityPredicate(engineDisplayInterface);
      if (vdsmDisplayInterface == null // the display interface is't on host anymore
          || !displayIneterfaceEqualityPredicate.eval(vdsmDisplayInterface)) {
        final AuditLogableBase loggable = new AuditLogableBase(host.getId());
        auditLogDirector.log(loggable, AuditLogType.NETWORK_UPDATE_DISPLAY_FOR_HOST_WITH_ACTIVE_VM);
      }
    }
  }
コード例 #4
0
 public static String resolveStepMessage(StepEnum stepName, Map<String, String> values) {
   String stepMessage = getInstance().getStepMessage(stepName);
   if (stepMessage != null) {
     return AuditLogDirector.resolveMessage(stepMessage, values);
   } else {
     return stepName.name();
   }
 }
コード例 #5
0
 public static String resolveJobMessage(VdcActionType actionType, Map<String, String> values) {
   String jobMessage = getInstance().getJobMessage(actionType);
   if (jobMessage != null) {
     return AuditLogDirector.resolveMessage(jobMessage, values);
   } else {
     return actionType.name();
   }
 }
コード例 #6
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);
    }
  }
コード例 #7
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);
        }
      }
    }
  }
コード例 #8
0
 @Override
 public void run() {
   ExternalSchedulerDiscoveryResult discoveryResult =
       ExternalSchedulerFactory.getInstance().runDiscover();
   if (discoveryResult != null) {
     updateDB(discoveryResult);
     log.info("PolicyUnits updated");
   } else {
     AuditLogableBase loggable = new AuditLogableBase();
     AuditLogDirector.log(loggable, AuditLogType.FAILED_TO_CONNECT_TO_SCHEDULER_PROXY);
     markAllExternalPoliciesAsDisabled();
     log.warn("Discovery returned empty result, disabled external policy units");
   }
 }
コード例 #9
0
  @Override
  public void runColdRebootVms(List<Guid> vmIds) {
    for (Guid vmId : vmIds) {
      AuditLogableBase event = new AuditLogableBase();
      event.setVmId(vmId);
      auditLogDirector.log(event, AuditLogType.COLD_REBOOT_VM_DOWN);

      log.info(
          "VM is down as a part of cold reboot process. Attempting to restart. VM Name '{}', VM Id '{}",
          event.getVmName(),
          vmId);
    }

    coldRebootAutoStartVmsRunner.addVmsToRun(vmIds);
  }
コード例 #10
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);
  }
コード例 #11
0
  private void endCommandOperations() {
    for (VdcActionParametersBase p : getParameters().getImagesParameters()) {
      Guid diskId = ((AddImageFromScratchParameters) p).getDiskInfo().getId();
      if (p.getTaskGroupSuccess()) {

        StorageDomainOvfInfo storageDomainOvfInfoDb = getStorageDomainOvfInfoDao().get(diskId);

        if (storageDomainOvfInfoDb == null
            || storageDomainOvfInfoDb.getStatus() != StorageDomainOvfInfoStatus.DISABLED) {
          continue;
        }

        getBackend()
            .endAction(
                p.getCommandType(),
                p,
                getContext().clone().withoutCompensationContext().withoutExecutionContext());
        storageDomainOvfInfoDb.setStatus(StorageDomainOvfInfoStatus.OUTDATED);
        getStorageDomainOvfInfoDao().update(storageDomainOvfInfoDb);
      } else {
        getBackend()
            .endAction(
                p.getCommandType(),
                p,
                getContext()
                    .clone()
                    .withoutCompensationContext()
                    .withoutExecutionContext()
                    .withoutLock());
        addCustomValue("DiskId", diskId.toString());
        AuditLogDirector.log(this, AuditLogType.CREATE_OVF_STORE_FOR_STORAGE_DOMAIN_FAILED);
      }
    }

    // if we'd have the possibility to know whether we failed because of failure to acquire locks as
    // there's an
    // update in progress, we could
    // try again (avoid setSucceeded(true) in that scenario).
    VdcReturnValueBase returnValue =
        runInternalActionWithTasksContext(
            VdcActionType.ProcessOvfUpdateForStorageDomain,
            createProcessOvfUpdateForDomainParams(),
            null);
    getReturnValue().getInternalVdsmTaskIdList().addAll(returnValue.getInternalVdsmTaskIdList());

    setSucceeded(true);
  }
コード例 #12
0
  private void logUnsynchronizedNetworks(VDS host, Map<String, Network> networks) {
    List<String> networkNames = new ArrayList<>();

    for (VdsNetworkInterface iface : host.getInterfaces()) {
      Network network = networks.get(iface.getNetworkName());

      NetworkImplementationDetails networkImplementationDetails =
          networkImplementationDetailsUtils.calculateNetworkImplementationDetails(iface, network);

      if (networkImplementationDetails != null
          && !networkImplementationDetails.isInSync()
          && networkImplementationDetails.isManaged()) {
        networkNames.add(iface.getNetworkName());
      }
    }

    if (!networkNames.isEmpty()) {
      AuditLogableBase logable = new AuditLogableBase(host.getId());
      logable.addCustomValue("Networks", StringUtils.join(networkNames, ","));
      auditLogDirector.log(logable, AuditLogType.VDS_NETWORKS_OUT_OF_SYNC);
    }
  }