Search in sources :

Example 16 with AuditLogType

use of org.ovirt.engine.core.common.AuditLogType in project ovirt-engine by oVirt.

the class UserEventNotifierListModel method manageEvents.

public void manageEvents() {
    EventNotificationModel model = new EventNotificationModel();
    setWindow(model);
    model.setTitle(ConstantsManager.getInstance().getConstants().addEventNotificationTitle());
    model.setHelpTag(HelpTag.add_event_notification);
    // $NON-NLS-1$
    model.setHashName("add_event_notification");
    ArrayList<EventNotificationEntity> eventTypes = ApplicationModeHelper.getModeSpecificEventNotificationTypeList();
    Map<EventNotificationEntity, HashSet<AuditLogType>> availableEvents = AsyncDataProvider.getInstance().getAvailableNotificationEvents();
    Translator translator = EnumTranslator.getInstance();
    ArrayList<SelectionTreeNodeModel> list = new ArrayList<>();
    Collection<EventSubscriber> items = getItems() == null ? new ArrayList<EventSubscriber>() : getItems();
    for (EventNotificationEntity eventType : eventTypes) {
        SelectionTreeNodeModel stnm = new SelectionTreeNodeModel();
        stnm.setTitle(eventType.toString());
        stnm.setDescription(translator.translate(eventType));
        list.add(stnm);
        for (AuditLogType logtype : availableEvents.get(eventType)) {
            SelectionTreeNodeModel eventGrp = new SelectionTreeNodeModel();
            String description;
            try {
                description = translator.translate(logtype);
            } catch (MissingResourceException e) {
                description = logtype.toString();
            }
            eventGrp.setTitle(logtype.toString());
            eventGrp.setDescription(description);
            eventGrp.setParent(list.get(list.size() - 1));
            eventGrp.setIsSelectedNotificationPrevent(true);
            eventGrp.setIsSelectedNullable(false);
            for (EventSubscriber es : items) {
                if (es.getEventUpName().equals(logtype.toString())) {
                    eventGrp.setIsSelectedNullable(true);
                    break;
                }
            }
            list.get(list.size() - 1).getChildren().add(eventGrp);
            eventGrp.setIsSelectedNotificationPrevent(false);
        }
        if (list.get(list.size() - 1).getChildren().size() > 0) {
            list.get(list.size() - 1).getChildren().get(0).updateParentSelection();
        }
    }
    model.setEventGroupModels(list);
    if (!StringHelper.isNullOrEmpty(getEntity().getEmail())) {
        model.getEmail().setEntity(getEntity().getEmail());
    } else if (items.size() > 0) {
        model.getEmail().setEntity(items.iterator().next().getMethodAddress());
    }
    model.setOldEmail(model.getEmail().getEntity());
    // $NON-NLS-1$
    UICommand tempVar = UICommand.createDefaultOkUiCommand("OnSave", this);
    model.getCommands().add(tempVar);
    // $NON-NLS-1$
    UICommand tempVar2 = UICommand.createCancelUiCommand("Cancel", this);
    model.getCommands().add(tempVar2);
}
Also used : SelectionTreeNodeModel(org.ovirt.engine.ui.uicommonweb.models.common.SelectionTreeNodeModel) EventSubscriber(org.ovirt.engine.core.common.businessentities.EventSubscriber) AuditLogType(org.ovirt.engine.core.common.AuditLogType) EventNotificationEntity(org.ovirt.engine.core.common.EventNotificationEntity) MissingResourceException(java.util.MissingResourceException) ArrayList(java.util.ArrayList) EnumTranslator(org.ovirt.engine.ui.uicompat.EnumTranslator) Translator(org.ovirt.engine.ui.uicompat.Translator) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) HashSet(java.util.HashSet)

Example 17 with AuditLogType

use of org.ovirt.engine.core.common.AuditLogType in project ovirt-engine by oVirt.

the class UpdateVmCommand method logNoDeviceToHotUnplug.

private void logNoDeviceToHotUnplug(List<VmDevice> vmMemoryDevices) {
    final AuditLogType message = vmMemoryDevices.isEmpty() ? AuditLogType.NO_MEMORY_DEVICE_TO_HOT_UNPLUG : AuditLogType.NO_SUITABLE_MEMORY_DEVICE_TO_HOT_UNPLUG;
    if (!vmMemoryDevices.isEmpty()) {
        final int originalMemoryMb = oldVm.getMemSizeMb();
        addCustomValue(AUDIT_LOG_OLD_MEMORY_MB, String.valueOf(originalMemoryMb));
        addCustomValue(AUDIT_LOG_NEW_MEMORY_MB, String.valueOf(getParameters().getVm().getMemSizeMb()));
        final String unplugOptions = vmMemoryDevices.stream().filter(VmDeviceCommonUtils::isMemoryDeviceHotUnpluggable).map(device -> VmDeviceCommonUtils.getSizeOfMemoryDeviceMb(device).get()).map(deviceSize -> String.format("%dMB (%dMB)", deviceSize, memoryAfterHotUnplug(originalMemoryMb, deviceSize))).collect(Collectors.joining(", "));
        addCustomValue(AUDIT_LOG_MEMORY_HOT_UNPLUG_OPTIONS, unplugOptions);
    }
    auditLogDirector.log(this, message);
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) EngineException(org.ovirt.engine.core.common.errors.EngineException) Provider(org.ovirt.engine.core.common.businessentities.Provider) RngDeviceParameters(org.ovirt.engine.core.common.action.RngDeviceParameters) VmTemplateDao(org.ovirt.engine.core.dao.VmTemplateDao) VmNicDao(org.ovirt.engine.core.dao.network.VmNicDao) Base64(org.apache.commons.codec.binary.Base64) VmStaticDao(org.ovirt.engine.core.dao.VmStaticDao) CommandContext(org.ovirt.engine.core.bll.context.CommandContext) ActionType(org.ovirt.engine.core.common.action.ActionType) VmDeviceCommonUtils(org.ovirt.engine.core.common.utils.VmDeviceCommonUtils) Map(java.util.Map) VmNic(org.ovirt.engine.core.common.businessentities.network.VmNic) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl) DisplayType(org.ovirt.engine.core.common.businessentities.DisplayType) VmWatchdogValidator(org.ovirt.engine.core.bll.validator.VmWatchdogValidator) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) VmBase(org.ovirt.engine.core.common.businessentities.VmBase) HotSetNumberOfCpusParameters(org.ovirt.engine.core.common.action.HotSetNumberOfCpusParameters) VmPayload(org.ovirt.engine.core.common.businessentities.VmPayload) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) Set(java.util.Set) NetworkDao(org.ovirt.engine.core.dao.network.NetworkDao) StandardCharsets(java.nio.charset.StandardCharsets) Label(org.ovirt.engine.core.common.businessentities.Label) ProviderType(org.ovirt.engine.core.common.businessentities.ProviderType) LabelDao(org.ovirt.engine.core.dao.LabelDao) VdcObjectType(org.ovirt.engine.core.common.VdcObjectType) GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) QuotaConsumptionParameter(org.ovirt.engine.core.bll.quota.QuotaConsumptionParameter) QuotaSanityParameter(org.ovirt.engine.core.bll.quota.QuotaSanityParameter) QueryType(org.ovirt.engine.core.common.queries.QueryType) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) ResourceManager(org.ovirt.engine.core.vdsbroker.ResourceManager) Guid(org.ovirt.engine.core.compat.Guid) ReplacementUtils(org.ovirt.engine.core.utils.ReplacementUtils) ArrayList(java.util.ArrayList) VmNumaNodeOperationParameters(org.ovirt.engine.core.common.action.VmNumaNodeOperationParameters) VmDeviceGeneralType(org.ovirt.engine.core.common.businessentities.VmDeviceGeneralType) VmPropertiesUtils(org.ovirt.engine.core.common.utils.customprop.VmPropertiesUtils) UpdateVm(org.ovirt.engine.core.common.validation.group.UpdateVm) CpuPinningValidator.isCpuPinningValid(org.ovirt.engine.core.bll.validator.CpuPinningValidator.isCpuPinningValid) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog) Pair(org.ovirt.engine.core.common.utils.Pair) LockingGroup(org.ovirt.engine.core.common.locks.LockingGroup) Scope(org.ovirt.engine.core.common.action.LockProperties.Scope) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) EngineError(org.ovirt.engine.core.common.errors.EngineError) VmCommonUtils(org.ovirt.engine.core.common.utils.VmCommonUtils) VM(org.ovirt.engine.core.common.businessentities.VM) InClusterUpgradeValidator(org.ovirt.engine.core.bll.validator.InClusterUpgradeValidator) VDSCommandType(org.ovirt.engine.core.common.vdscommands.VDSCommandType) MigrationSupport(org.ovirt.engine.core.common.businessentities.MigrationSupport) IconValidator(org.ovirt.engine.core.bll.validator.IconValidator) HotUnplugMemoryWithoutVmUpdateParameters(org.ovirt.engine.core.common.action.HotUnplugMemoryWithoutVmUpdateParameters) UsbPolicy(org.ovirt.engine.core.common.businessentities.UsbPolicy) WatchdogParameters(org.ovirt.engine.core.common.action.WatchdogParameters) VmType(org.ovirt.engine.core.common.businessentities.VmType) Date(java.util.Date) VmDynamicDao(org.ovirt.engine.core.dao.VmDynamicDao) ProviderDao(org.ovirt.engine.core.dao.provider.ProviderDao) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) VmCpuCountHelper(org.ovirt.engine.core.common.utils.VmCpuCountHelper) HugePageUtils(org.ovirt.engine.core.common.utils.HugePageUtils) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) VmDeviceDao(org.ovirt.engine.core.dao.VmDeviceDao) QuotaClusterConsumptionParameter(org.ovirt.engine.core.bll.quota.QuotaClusterConsumptionParameter) Version(org.ovirt.engine.core.compat.Version) VmDevicesMonitoring(org.ovirt.engine.core.vdsbroker.monitoring.VmDevicesMonitoring) GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) IconUtils(org.ovirt.engine.core.bll.utils.IconUtils) DiskVmElementDao(org.ovirt.engine.core.dao.DiskVmElementDao) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) List(java.util.List) VmRngDevice(org.ovirt.engine.core.common.businessentities.VmRngDevice) VmValidator(org.ovirt.engine.core.bll.validator.VmValidator) AuditLogType(org.ovirt.engine.core.common.AuditLogType) FeatureSupported(org.ovirt.engine.core.common.FeatureSupported) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId) VmDeviceType(org.ovirt.engine.core.common.utils.VmDeviceType) QuotaVdsDependent(org.ovirt.engine.core.bll.quota.QuotaVdsDependent) ArchitectureType(org.ovirt.engine.core.common.businessentities.ArchitectureType) LockProperties(org.ovirt.engine.core.common.action.LockProperties) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) UpdateVmVersionParameters(org.ovirt.engine.core.common.action.UpdateVmVersionParameters) Inject(javax.inject.Inject) MemoryUtils(org.ovirt.engine.core.bll.memory.MemoryUtils) NetworkHelper(org.ovirt.engine.core.bll.network.cluster.NetworkHelper) CollectionUtils(org.apache.commons.collections.CollectionUtils) Network(org.ovirt.engine.core.common.businessentities.network.Network) Config(org.ovirt.engine.core.common.config.Config) VmInitToOpenStackMetadataAdapter(org.ovirt.engine.core.common.utils.VmInitToOpenStackMetadataAdapter) AuditLogDirector(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector) HotSetAmountOfMemoryParameters(org.ovirt.engine.core.common.action.HotSetAmountOfMemoryParameters) LeaseVDSParameters(org.ovirt.engine.core.common.vdscommands.LeaseVDSParameters) DateTime(org.ovirt.engine.core.compat.DateTime) GraphicsParameters(org.ovirt.engine.core.common.action.GraphicsParameters) AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) PermissionSubject(org.ovirt.engine.core.bll.utils.PermissionSubject) ActionGroup(org.ovirt.engine.core.common.businessentities.ActionGroup) VmNumaNodeDao(org.ovirt.engine.core.dao.VmNumaNodeDao) PlugAction(org.ovirt.engine.core.common.action.PlugAction) VmManagementParametersBase(org.ovirt.engine.core.common.action.VmManagementParametersBase) Collections(java.util.Collections) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus) AuditLogType(org.ovirt.engine.core.common.AuditLogType)

Example 18 with AuditLogType

use of org.ovirt.engine.core.common.AuditLogType in project ovirt-engine by oVirt.

the class InitVdsOnUpCommand method getAuditLogTypeValue.

@Override
public AuditLogType getAuditLogTypeValue() {
    AuditLogType type = AuditLogType.UNASSIGNED;
    if (getCluster().supportsVirtService()) {
        if (!connectPoolSucceeded) {
            type = AuditLogType.CONNECT_STORAGE_POOL_FAILED;
        } else if (getVds().isPmEnabled() && fenceSucceeded) {
            type = AuditLogType.VDS_FENCE_STATUS;
        } else if (getVds().isPmEnabled() && !fenceSucceeded) {
            type = AuditLogType.VDS_FENCE_STATUS_FAILED;
        } else if (haMaintenanceFailed) {
            type = AuditLogType.VDS_ACTIVATE_MANUAL_HA;
        }
        // Check first if PM is enabled on the cluster level
        if (getVds().isFencingEnabled()) {
            if (getVds().isPmEnabled()) {
                if (!vdsProxyFound) {
                    this.addCustomValue("Reason", MessageBundler.getMessage(AuditLogType.VDS_ALERT_FENCE_NO_PROXY_HOST));
                    auditLogDirector.log(this, AuditLogType.VDS_ALERT_FENCE_TEST_FAILED);
                } else if (!fenceSucceeded) {
                    this.addCustomValue("Reason", fenceStatusResult.getMessage());
                    auditLogDirector.log(this, AuditLogType.VDS_ALERT_FENCE_TEST_FAILED);
                }
            } else {
                auditLogDirector.log(this, AuditLogType.VDS_ALERT_FENCE_IS_NOT_CONFIGURED);
            }
        }
    }
    return type;
}
Also used : AuditLogType(org.ovirt.engine.core.common.AuditLogType)

Example 19 with AuditLogType

use of org.ovirt.engine.core.common.AuditLogType in project ovirt-engine by oVirt.

the class CertificationValidityChecker method checkCertificate.

private boolean checkCertificate(X509Certificate cert, AuditLogType alertExpirationEventType, AuditLogType alertAboutToExpireEventType, AuditLogType warnAboutToExpireEventType, VDS host) {
    Date expirationDate = cert.getNotAfter();
    Date certWarnTime = getExpirationDate(expirationDate, ConfigValues.CertExpirationWarnPeriodInDays);
    Date certAlertTime = getExpirationDate(expirationDate, ConfigValues.CertExpirationAlertPeriodInDays);
    Date now = new Date();
    AuditLogType eventType = null;
    if (now.compareTo(expirationDate) > 0) {
        eventType = alertExpirationEventType;
    } else if (now.compareTo(certAlertTime) > 0) {
        eventType = alertAboutToExpireEventType;
    } else if (now.compareTo(certWarnTime) > 0) {
        eventType = warnAboutToExpireEventType;
    }
    if (eventType != null) {
        AuditLogable event = new AuditLogableImpl();
        event.addCustomValue("ExpirationDate", new SimpleDateFormat("yyyy-MM-dd").format(expirationDate));
        if (host != null) {
            event.setVdsName(host.getName());
            event.setVdsId(host.getId());
        }
        auditLogDirector.log(event, eventType);
        return false;
    }
    return true;
}
Also used : AuditLogType(org.ovirt.engine.core.common.AuditLogType) AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 20 with AuditLogType

use of org.ovirt.engine.core.common.AuditLogType in project ovirt-engine by oVirt.

the class UpdateVmInterfaceCommand method getAuditLogTypeValue.

@Override
public AuditLogType getAuditLogTypeValue() {
    if (getSucceeded()) {
        if (oldIface.isLinked() != getInterface().isLinked()) {
            AuditLogType customValue = getInterface().isLinked() ? AuditLogType.NETWORK_UPDATE_VM_INTERFACE_LINK_UP : AuditLogType.NETWORK_UPDATE_VM_INTERFACE_LINK_DOWN;
            addCustomValue("LinkState", MessageBundler.getMessage(customValue));
        } else {
            addCustomValue("LinkState", " ");
        }
        return AuditLogType.NETWORK_UPDATE_VM_INTERFACE;
    }
    return AuditLogType.NETWORK_UPDATE_VM_INTERFACE_FAILED;
}
Also used : AuditLogType(org.ovirt.engine.core.common.AuditLogType)

Aggregations

AuditLogType (org.ovirt.engine.core.common.AuditLogType)23 AuditLogable (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable)8 AuditLogableImpl (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)5 AuditLogDirector (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector)4 AuditLogableBase (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableBase)3 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)2 StandardCharsets (java.nio.charset.StandardCharsets)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 MissingResourceException (java.util.MissingResourceException)1 Objects (java.util.Objects)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1