use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.
the class HostSetupNetworksValidator method validateCustomProperties.
ValidationResult validateCustomProperties(SimpleCustomPropertiesUtil util, Map<String, String> validPropertiesForVm, Map<String, String> validPropertiesForNonVm) {
for (NetworkAttachment attachment : params.getNetworkAttachments()) {
Network network = existingNetworkRelatedToAttachment(attachment);
if (attachment.hasProperties()) {
List<ValidationError> errors = util.validateProperties(network.isVmNetwork() ? validPropertiesForVm : validPropertiesForNonVm, attachment.getProperties());
if (!errors.isEmpty()) {
handleCustomPropertiesError(util, errors);
EngineMessage engineMessage = EngineMessage.ACTION_TYPE_FAILED_NETWORK_CUSTOM_PROPERTIES_BAD_INPUT;
return new ValidationResult(engineMessage, ReplacementUtils.getVariableAssignmentStringWithMultipleValues(engineMessage, network.getName()));
}
}
}
return ValidationResult.VALID;
}
use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.
the class HostSetupNetworksValidator method validNewOrModifiedBonds.
ValidationResult validNewOrModifiedBonds() {
for (CreateOrUpdateBond modifiedOrNewBond : params.getCreateOrUpdateBonds()) {
String bondName = modifiedOrNewBond.getName();
Guid bondId = modifiedOrNewBond.getId();
/*
* bondId is provided, but bondName not. This means that user attempted update, but bond of such ID does not
* exit, thus completors did not complete name.
*/
if (bondId != null && bondName == null) {
return new ValidationResult(EngineMessage.HOST_NETWORK_INTERFACE_HAVING_ID_DOES_NOT_EXIST, ReplacementUtils.createSetVariableString(VAR_NIC_ID, bondId));
}
/*
* user did not provide neither bondId nor bondName. That means he probably attempted new bond creation
* but forgot to provide bondName.
*/
if (bondId == null && bondName == null) {
return new ValidationResult(EngineMessage.BOND_DOES_NOT_HAVE_NEITHER_ID_NOR_NAME_SPECIFIED);
}
/*
* if (bondId == null && bondName != null) …
* User provided only bondName, and completors failed to find existing bonds id for that name.
* We cannot tell, what user wanted to do(create/update). We have to assume, it's new record creation, which
* is valid scenario.
*/
ValidationResult validateCoherentNicIdentification = validateCoherentNicIdentification(modifiedOrNewBond);
if (!validateCoherentNicIdentification.isValid()) {
return validateCoherentNicIdentification;
}
boolean validBondName = bondName.matches(BusinessEntitiesDefinitions.BOND_NAME_PATTERN);
if (!validBondName) {
EngineMessage engineMessage = EngineMessage.NETWORK_BOND_NAME_BAD_FORMAT;
return new ValidationResult(engineMessage, ReplacementUtils.getVariableAssignmentString(engineMessage, bondName));
}
// either it's newly create bond, thus non existing, or given name must reference existing bond.
ValidationResult interfaceIsBondOrNull = createHostInterfaceValidator(existingInterfacesMap.get(bondName)).interfaceIsBondOrNull();
if (!interfaceIsBondOrNull.isValid()) {
return interfaceIsBondOrNull;
}
// count of bond slaves must be at least two.
if (modifiedOrNewBond.getSlaves().size() < 2) {
return new ValidationResult(EngineMessage.NETWORK_BONDS_INVALID_SLAVE_COUNT, ReplacementUtils.getVariableAssignmentString(EngineMessage.NETWORK_BONDS_INVALID_SLAVE_COUNT, bondName));
}
ValidationResult validateModifiedBondSlaves = validateModifiedBondSlaves(modifiedOrNewBond);
if (!validateModifiedBondSlaves.isValid()) {
return validateModifiedBondSlaves;
}
}
return ValidationResult.VALID;
}
use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.
the class HostSetupNetworksValidator method validateAttachmentNotReferenceVlanDevice.
private ValidationResult validateAttachmentNotReferenceVlanDevice(NetworkAttachment attachment) {
VdsNetworkInterface nic = existingInterfacesMap.get(attachment.getNicName());
EngineMessage engineMessage = EngineMessage.ATTACHMENT_REFERENCE_VLAN_DEVICE;
return ValidationResult.failWith(engineMessage, ReplacementUtils.getVariableAssignmentString(engineMessage, attachment.getNetworkName()), ReplacementUtils.createSetVariableString(VAR_NIC_NAME, attachment.getNicName())).when(nic != null && NetworkCommonUtils.isVlan(nic));
}
use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.
the class HostSetupNetworksValidator method modifiedAttachmentNotRemoved.
ValidationResult modifiedAttachmentNotRemoved(NetworkAttachment networkAttachment) {
Guid networkAttachmentId = networkAttachment.getId();
if (isNewAttachment(networkAttachmentId)) {
return ValidationResult.VALID;
}
boolean attachmentInRemoveList = params.getRemovedNetworkAttachments().contains(networkAttachmentId);
EngineMessage engineMessage = EngineMessage.NETWORK_ATTACHMENT_IN_BOTH_LISTS;
return ValidationResult.failWith(engineMessage, ReplacementUtils.getVariableAssignmentString(engineMessage, networkAttachmentId.toString())).when(attachmentInRemoveList);
}
use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.
the class HostSetupNetworksValidator method validateCoherentNicIdentification.
private ValidationResult validateCoherentNicIdentification(CreateOrUpdateBond createOrUpdateBond) {
Guid nicId = createOrUpdateBond.getId();
String nicName = createOrUpdateBond.getName();
EngineMessage message = EngineMessage.BOND_REFERENCES_NICS_INCOHERENTLY;
return hostSetupNetworksValidatorHelper.validateCoherentIdentification(nicName, nicId, nicName, message, existingInterfacesMap);
}
Aggregations