use of org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation in project ovirt-engine by oVirt.
the class UnitVmModel method validateHwPart.
public boolean validateHwPart() {
getMigrationDowntime().validateEntity(new IValidation[] { new NotNullIntegerValidation(0, Integer.MAX_VALUE) });
getTotalCPUCores().validateEntity(new IValidation[] { new NotEmptyValidation(), new IntegerValidation(1, behavior.maxCpus), new TotalCpuCoresComposableValidation() });
if (getIsAutoAssign().getEntity() != null && !getIsAutoAssign().getEntity()) {
getDefaultHost().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
} else {
getDefaultHost().setIsValid(true);
}
if (getCpuSharesAmount().getIsAvailable()) {
getCpuSharesAmount().validateEntity(new IValidation[] { new NotEmptyValidation(), new IntegerValidation(0, 262144) });
}
boolean customPropertySheetValid = getCustomPropertySheet().validate();
setValidTab(TabName.CUSTOM_PROPERTIES_TAB, customPropertySheetValid);
if (getSerialNumberPolicy().getSelectedSerialNumberPolicy() == SerialNumberPolicy.CUSTOM) {
getSerialNumberPolicy().getCustomSerialNumber().validateEntity(new IValidation[] { new NotEmptyValidation() });
} else {
getSerialNumberPolicy().getCustomSerialNumber().setIsValid(true);
}
getEmulatedMachine().validateSelectedItem(new IValidation[] { new I18NExtraNameOrNoneValidation(), new LengthValidation(BusinessEntitiesDefinitions.VM_EMULATED_MACHINE_SIZE) });
getCustomCpu().validateSelectedItem(new IValidation[] { new I18NExtraNameOrNoneValidation(), new LengthValidation(BusinessEntitiesDefinitions.VM_CPU_NAME_SIZE) });
setValidTab(TabName.CONSOLE_TAB, getUsbPolicy().getIsValid() && getNumOfMonitors().getIsValid() && getSpiceProxy().getIsValid());
setValidTab(TabName.HOST_TAB, getMigrationDowntime().getIsValid());
getRngBytes().validateEntity(new IValidation[] { new IntegerValidation(0, Integer.MAX_VALUE), new RngDevValidation() });
getRngPeriod().validateEntity(new IValidation[] { new IntegerValidation(0, Integer.MAX_VALUE) });
setValidTab(TabName.TAB_RNG, getRngBytes().getIsValid() && getRngPeriod().getIsValid());
// Minimum 'Physical Memory Guaranteed' is 1MB
validateMemorySize(getMemSize(), Integer.MAX_VALUE, 1);
if (getMemSize().getIsValid()) {
validateMemorySize(getMinAllocatedMemory(), getMemSize().getEntity(), 1);
}
validateMaxMemorySize();
validateMemoryAlignment(getMemSize());
setValidTab(TabName.RESOURCE_ALLOCATION_TAB, getMinAllocatedMemory().getIsValid());
setValidTab(TabName.SYSTEM_TAB, getMemSize().getIsValid() && getMaxMemorySize().getIsValid() && getTotalCPUCores().getIsValid() && getSerialNumberPolicy().getCustomSerialNumber().getIsValid() && getEmulatedMachine().getIsValid() && getCustomCpu().getIsValid());
/*
* This should be run at very end of the validation process otherwise general validation can override more
* strict checks in behaviors
*/
boolean behaviorValid = behavior.validate();
boolean isValid = behaviorValid && allTabsValid();
return isValid;
}
use of org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation 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();
}
use of org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation in project ovirt-engine by oVirt.
the class FenceAgentModel method validatePmModels.
/**
* Validate the Power Management related Entity Models.
*/
public void validatePmModels() {
EntityModel<String> ip = getManagementIp();
EntityModel<String> userName = getPmUserName();
EntityModel<String> password = getPmPassword();
ListModel<String> type = getPmType();
EntityModel<Integer> port = getPmPort();
ip.validateEntity(new IValidation[] { new NotEmptyValidation(), new HostAddressValidation() });
userName.validateEntity(new IValidation[] { new NotEmptyValidation() });
password.validateEntity(new IValidation[] { new NotEmptyValidation(), new LengthValidation(50) });
type.validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
port.validateEntity(new IValidation[] { new IntegerValidation(1, 65535) });
}
use of org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation in project ovirt-engine by oVirt.
the class NetworkAttachmentModel method validate.
public boolean validate() {
getIpv4Address().setIsValid(true);
getIpv4Subnet().setIsValid(true);
getIpv4Gateway().setIsValid(true);
if (getIsStaticIpv4Address()) {
getIpv4Address().validateEntity(new IValidation[] { new NotEmptyValidation(), new Ipv4AddressValidation() });
getIpv4Subnet().validateEntity(new IValidation[] { new NotEmptyValidation(), new SubnetMaskValidation(true) });
getIpv4Gateway().validateEntity(new IValidation[] { new Ipv4AddressValidation(true) });
}
getIpv6Address().setIsValid(true);
getIpv6Prefix().setIsValid(true);
getIpv6Gateway().setIsValid(true);
if (getIsStaticIpv6Address()) {
getIpv6Address().validateEntity(new IValidation[] { new NotEmptyValidation(), new Ipv6AddressValidation() });
getIpv6Prefix().validateEntity(new IValidation[] { new NotEmptyValidation(), new IntegerValidation(0, 128) });
getIpv6Gateway().validateEntity(new IValidation[] { new Ipv6AddressValidation(true) });
}
getQosModel().validate();
getDnsConfigurationModel().validate();
getCustomPropertiesModel().validate();
setValidTab(TabName.IPV4_TAB, getIpv4Address().getIsValid() && getIpv4Gateway().getIsValid() && getIpv4Subnet().getIsValid());
setValidTab(TabName.IPV6_TAB, getIpv6Address().getIsValid() && getIpv6Gateway().getIsValid() && getIpv6Prefix().getIsValid());
setValidTab(TabName.QOS_TAB, getQosModel().getIsValid());
setValidTab(TabName.CUSTOM_PROPERTIES_TAB, getCustomPropertiesModel().getIsValid());
setValidTab(TabName.DNS_CONFIGURATION_TAB, getDnsConfigurationModel().getIsValid());
return allTabsValid();
}
use of org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation in project ovirt-engine by oVirt.
the class SanStorageModelBase method validateDiscoverTargetFields.
private boolean validateDiscoverTargetFields() {
getContainer().getHost().validateSelectedItem(new NotEmptyValidation[] { new NotEmptyValidation() });
getAddress().validateEntity(new IValidation[] { new NotEmptyValidation() });
IntegerValidation tempVar = new IntegerValidation();
tempVar.setMinimum(0);
tempVar.setMaximum(65535);
getPort().validateEntity(new IValidation[] { new NotEmptyValidation(), tempVar });
if (getUseUserAuth().getEntity()) {
getUserName().validateEntity(new IValidation[] { new NotEmptyValidation() });
getPassword().validateEntity(new IValidation[] { new NotEmptyValidation() });
}
return getContainer().getHost().getIsValid() && getAddress().getIsValid() && getPort().getIsValid() && getUserName().getIsValid() && getPassword().getIsValid();
}
Aggregations