Search in sources :

Example 1 with HostWithProtocolAndPortAddressValidation

use of org.ovirt.engine.ui.uicommonweb.validation.HostWithProtocolAndPortAddressValidation in project ovirt-engine by oVirt.

the class ClusterModel method validate.

public boolean validate() {
    validateName();
    getDataCenter().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
    getCustomPropertySheet().setIsValid(getCustomPropertySheet().validate());
    setValidTab(TabName.CLUSTER_POLICY_TAB, getCustomPropertySheet().getIsValid());
    final IValidation[] versionValidations = new IValidation[] { new NotEmptyValidation() };
    getVersion().validateSelectedItem(versionValidations);
    getManagementNetwork().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
    getRngHwrngSourceRequired().setIsValid(true);
    boolean validService = true;
    if (getEnableOvirtService().getIsAvailable() && getEnableGlusterService().getIsAvailable()) {
        validService = getEnableOvirtService().getEntity() || getEnableGlusterService().getEntity();
    }
    getGlusterHostAddress().validateEntity(new IValidation[] { new NotEmptyValidation() });
    getGlusterHostPassword().validateEntity(new IValidation[] { new NotEmptyValidation() });
    if (!validService) {
        setMessage(ConstantsManager.getInstance().getConstants().clusterServiceValidationMsg());
    } else if (getIsImportGlusterConfiguration().getEntity() && getGlusterHostAddress().getIsValid() && getGlusterHostPassword().getIsValid() && !isFingerprintVerified()) {
        setMessage(ConstantsManager.getInstance().getConstants().fingerprintNotVerified());
    } else {
        setMessage(null);
    }
    if (getSpiceProxyEnabled().getEntity()) {
        getSpiceProxy().validateEntity(new IValidation[] { new HostWithProtocolAndPortAddressValidation() });
    } else {
        getSpiceProxy().setIsValid(true);
    }
    setValidTab(TabName.CONSOLE_TAB, getSpiceProxy().getIsValid());
    if (getSerialNumberPolicy().getSelectedSerialNumberPolicy() == SerialNumberPolicy.CUSTOM) {
        getSerialNumberPolicy().getCustomSerialNumber().validateEntity(new IValidation[] { new NotEmptyValidation() });
    } else {
        getSerialNumberPolicy().getCustomSerialNumber().setIsValid(true);
    }
    getMacPoolModel().validate();
    boolean generalTabValid = getName().getIsValid() && getDataCenter().getIsValid() && getCPU().getIsValid() && getManagementNetwork().getIsValid() && getVersion().getIsValid() && validService && getGlusterHostAddress().getIsValid() && getRngHwrngSourceRequired().getIsValid() && getGlusterHostPassword().getIsValid() && (!getIsImportGlusterConfiguration().getEntity() || (getGlusterHostAddress().getIsValid() && getGlusterHostPassword().getIsValid() && getSerialNumberPolicy().getCustomSerialNumber().getIsValid() && isFingerprintVerified()));
    setValidTab(TabName.GENERAL_TAB, generalTabValid);
    if (getVersion().getSelectedItem() != null) {
        if (AsyncDataProvider.getInstance().isMigrationPoliciesSupported(getVersion().getSelectedItem()) && MigrationBandwidthLimitType.CUSTOM.equals(getMigrationBandwidthLimitType().getSelectedItem())) {
            getCustomMigrationNetworkBandwidth().validateEntity(new IValidation[] { new NotNullIntegerValidation(0, Integer.MAX_VALUE) });
        } else {
            getCustomMigrationNetworkBandwidth().setIsValid(true);
        }
    }
    final boolean migrationTabValid = getMigrationBandwidthLimitType().getIsValid() && getCustomMigrationNetworkBandwidth().getIsValid();
    setValidTab(TabName.MIGRATION_TAB, migrationTabValid);
    boolean macPoolTabValid = getMacPoolModel().getIsValid();
    setValidTab(TabName.MAC_POOL_TAB, macPoolTabValid);
    ValidationCompleteEvent.fire(getEventBus(), this);
    return generalTabValid && macPoolTabValid && getCustomPropertySheet().getIsValid() && getSpiceProxy().getIsValid() && migrationTabValid;
}
Also used : IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) HostWithProtocolAndPortAddressValidation(org.ovirt.engine.ui.uicommonweb.validation.HostWithProtocolAndPortAddressValidation) NotNullIntegerValidation(org.ovirt.engine.ui.uicommonweb.validation.NotNullIntegerValidation) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation)

Example 2 with HostWithProtocolAndPortAddressValidation

use of org.ovirt.engine.ui.uicommonweb.validation.HostWithProtocolAndPortAddressValidation in project ovirt-engine by oVirt.

the class PoolModelBehaviorBase method validate.

@Override
public boolean validate() {
    boolean isNew = getModel().getIsNew();
    int maxAllowedVms = getMaxVmsInPool();
    int assignedVms = getModel().getAssignedVms().asConvertible().integer();
    int futureNumOfDesktops = (isNew ? 0 : assignedVms) + getModel().getNumOfDesktops().getEntity();
    getModel().getNumOfDesktops().validateEntity(new IValidation[] { new NotEmptyValidation(), new LengthValidation(4), new IntegerValidation(isNew ? 1 : 0, isNew ? maxAllowedVms : maxAllowedVms - assignedVms) });
    getModel().getPrestartedVms().validateEntity(new IValidation[] { new NotEmptyValidation(), new IntegerValidation(0, futureNumOfDesktops) });
    getModel().getMaxAssignedVmsPerUser().validateEntity(new IValidation[] { new NotEmptyValidation(), new IntegerValidation(1, futureNumOfDesktops) });
    getModel().setValidTab(TabName.GENERAL_TAB, getModel().isValidTab(TabName.GENERAL_TAB) && getModel().getName().getIsValid() && getModel().getNumOfDesktops().getIsValid() && getModel().getPrestartedVms().getIsValid() && getModel().getMaxAssignedVmsPerUser().getIsValid());
    getModel().setValidTab(TabName.POOL_TAB, true);
    if (getModel().getSpiceProxyEnabled().getEntity()) {
        getModel().getSpiceProxy().validateEntity(new IValidation[] { new HostWithProtocolAndPortAddressValidation() });
    } else {
        getModel().getSpiceProxy().setIsValid(true);
    }
    return super.validate() && getModel().getName().getIsValid() && getModel().getNumOfDesktops().getIsValid() && getModel().getPrestartedVms().getIsValid() && getModel().getMaxAssignedVmsPerUser().getIsValid() && getModel().getSpiceProxy().getIsValid();
}
Also used : HostWithProtocolAndPortAddressValidation(org.ovirt.engine.ui.uicommonweb.validation.HostWithProtocolAndPortAddressValidation) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) IntegerValidation(org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation)

Aggregations

HostWithProtocolAndPortAddressValidation (org.ovirt.engine.ui.uicommonweb.validation.HostWithProtocolAndPortAddressValidation)2 NotEmptyValidation (org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation)2 IValidation (org.ovirt.engine.ui.uicommonweb.validation.IValidation)1 IntegerValidation (org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation)1 LengthValidation (org.ovirt.engine.ui.uicommonweb.validation.LengthValidation)1 NotNullIntegerValidation (org.ovirt.engine.ui.uicommonweb.validation.NotNullIntegerValidation)1