use of org.ovirt.engine.ui.uicommonweb.validation.Ipv4AddressValidation in project ovirt-engine by oVirt.
the class ExternalSubnetModel method validate.
public boolean validate() {
getName().validateEntity(new IValidation[] { new NotEmptyValidation(), new AsciiNameValidation() });
boolean ipv4 = getIpVersion().getSelectedItem() == IpVersion.IPV4;
getCidr().validateEntity(new IValidation[] { ipv4 ? new CidrValidation() : new NotEmptyValidation() });
getIpVersion().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
getGateway().setIsValid(true);
if (StringHelper.isNotNullOrEmpty(getGateway().getEntity()) && ipv4) {
getGateway().validateEntity(new IValidation[] { new Ipv4AddressValidation() });
}
boolean dnsServersValid = true;
for (EntityModel<String> dnsServer : getDnsServers().getItems()) {
dnsServer.setIsValid(true);
if (StringHelper.isNotNullOrEmpty(dnsServer.getEntity()) && ipv4) {
dnsServer.validateEntity(new IValidation[] { new Ipv4AddressValidation() });
}
dnsServersValid &= dnsServer.getIsValid();
}
return getName().getIsValid() && getCidr().getIsValid() && getIpVersion().getIsValid() && getGateway().getIsValid() && dnsServersValid;
}
use of org.ovirt.engine.ui.uicommonweb.validation.Ipv4AddressValidation in project ovirt-engine by oVirt.
the class VmInitModel method validate.
public boolean validate() {
getHostname().setIsValid(true);
getWindowsHostname().setIsValid(true);
getSysprepAdminPassword().setIsValid(true);
getSysprepAdminPasswordVerification().setIsValid(true);
getCloudInitRootPassword().setIsValid(true);
getCloudInitRootPasswordVerification().setIsValid(true);
if (this.isWindowsOS) {
if (getSysprepPasswordEnabled()) {
getSysprepAdminPassword().validateEntity(new IValidation[] { new NotEmptyValidation(), new MatchFieldsValidator(getSysprepAdminPassword().getEntity(), getSysprepAdminPasswordVerification().getEntity()) });
}
} else {
if (getRootPasswordEnabled()) {
getCloudInitRootPassword().validateEntity(new IValidation[] { new NotEmptyValidation(), new MatchFieldsValidator(getCloudInitRootPassword().getEntity(), getCloudInitRootPasswordVerification().getEntity()) });
}
}
if (getHostnameEnabled()) {
if (this.isWindowsOS) {
getWindowsHostname().validateEntity(new IValidation[] { new HostnameValidation(), new LengthValidation(AsyncDataProvider.getInstance().getMaxVmNameLengthSysprep()) });
} else {
getHostname().validateEntity(new IValidation[] { new HostnameValidation(), new LengthValidation(AsyncDataProvider.getInstance().getMaxVmNameLength()) });
}
}
getSysprepDomain().setIsValid(true);
if (getDomainEnabled()) {
getSysprepDomain().setIsValid(new HostAddressValidation().validate(getSysprepDomain().getSelectedItem()).getSuccess());
}
getAuthorizedKeys().setIsValid(true);
getTimeZoneList().setIsValid(true);
if (getTimeZoneEnabled().getEntity()) {
getTimeZoneList().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
}
boolean networkIsValid = true;
getNetworkList().setIsValid(true);
getNetworkIpAddress().setIsValid(true);
getNetworkNetmask().setIsValid(true);
getNetworkGateway().setIsValid(true);
getNetworkIpv6Address().setIsValid(true);
getNetworkIpv6Prefix().setIsValid(true);
getNetworkIpv6Gateway().setIsValid(true);
boolean dnsIsValid = true;
getDnsServers().setIsValid(true);
getDnsSearchDomains().setIsValid(true);
if (getNetworkEnabled().getEntity()) {
saveNetworkFields();
for (Map.Entry<String, VmInitNetwork> entry : networkMap.entrySet()) {
String name = entry.getKey();
VmInitNetwork vmInitNetwork = entry.getValue();
if (vmInitNetwork.getBootProtocol() == Ipv4BootProtocol.STATIC_IP) {
if (!validateHidden(getNetworkList(), name, null, new IValidation[] { new VmInitNetworkNameValidation(), new NotEmptyValidation() }) || !validateHidden(getNetworkIpAddress(), vmInitNetwork.getIp(), null, new IValidation[] { new Ipv4AddressValidation() }) || !validateHidden(getNetworkNetmask(), vmInitNetwork.getNetmask(), null, new IValidation[] { new SubnetMaskValidation() }) || !validateHidden(getNetworkGateway(), vmInitNetwork.getGateway(), null, new IValidation[] { new Ipv4AddressValidation(true) })) {
getNetworkList().setSelectedItem(name);
networkIsValid = false;
break;
}
}
if (vmInitNetwork.getIpv6BootProtocol() == Ipv6BootProtocol.STATIC_IP) {
if (!validateHidden(getNetworkList(), name, null, new IValidation[] { new VmInitNetworkNameValidation(), new NotEmptyValidation() }) || !validateHidden(getNetworkIpv6Address(), vmInitNetwork.getIpv6Address(), null, new IValidation[] { new Ipv6AddressValidation() }) || !validateHidden(getNetworkIpv6Prefix(), vmInitNetwork.getIpv6Prefix(), null, new IValidation[] { new IntegerValidation(0, 128) }) || !validateHidden(getNetworkIpv6Gateway(), vmInitNetwork.getIpv6Gateway(), null, new IValidation[] { new Ipv6AddressValidation(true) })) {
getNetworkList().setSelectedItem(name);
networkIsValid = false;
break;
}
}
}
if (!networkMap.isEmpty()) {
if (getDnsServers().getEntity() != null) {
for (String server : tokenizeString(getDnsServers().getEntity())) {
if (!validateHidden(getDnsServers(), server, dnsServerListMessage, new IValidation[] { new IpAddressValidation() })) {
dnsIsValid = false;
break;
}
}
}
if (getDnsSearchDomains().getEntity() != null) {
for (String domain : tokenizeString(getDnsSearchDomains().getEntity())) {
if (!validateHidden(getDnsSearchDomains(), domain, null, new IValidation[] { new HostnameValidation() })) {
dnsIsValid = false;
break;
}
}
}
}
}
return getHostname().getIsValid() && getWindowsHostname().getIsValid() && getSysprepDomain().getIsValid() && getAuthorizedKeys().getIsValid() && getTimeZoneList().getIsValid() && getCloudInitRootPassword().getIsValid() && getSysprepAdminPassword().getIsValid() && networkIsValid && dnsIsValid;
}
use of org.ovirt.engine.ui.uicommonweb.validation.Ipv4AddressValidation 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();
}
Aggregations