use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.
the class UnmanagedNetworkValidator method validateRemovedUnmanagedNetworks.
protected ValidationResult validateRemovedUnmanagedNetworks(Collection<String> removedUnmanagedNetworks, Collection<VdsNetworkInterface> existingInterfaces, BusinessEntityMap<Network> networkBusinessEntityMap) {
for (String removedUnmanagedNetworkName : removedUnmanagedNetworks) {
Network network = networkBusinessEntityMap.get(removedUnmanagedNetworkName);
if (network != null) {
EngineMessage engineMessage = EngineMessage.REMOVED_UNMANAGED_NETWORK_IS_A_CLUSTER_NETWORK;
return new ValidationResult(engineMessage, ReplacementUtils.createSetVariableString(NETWORK, removedUnmanagedNetworkName));
}
ValidationResult result = validateNetworkIsAnUnmanagedNetworkOnHost(removedUnmanagedNetworkName, existingInterfaces);
if (!result.isValid()) {
return result;
}
}
return ValidationResult.VALID;
}
use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.
the class HostSetupNetworksValidator method validRemovedBonds.
ValidationResult validRemovedBonds(Collection<NetworkAttachment> attachmentsToConfigure) {
List<Guid> invalidBondIds = Entities.idsNotReferencingExistingRecords(params.getRemovedBonds(), existingInterfacesMap.unmodifiableEntitiesByIdMap());
if (!invalidBondIds.isEmpty()) {
EngineMessage engineMessage = EngineMessage.NETWORK_BOND_RECORDS_DOES_NOT_EXISTS;
return new ValidationResult(engineMessage, ReplacementUtils.getListVariableAssignmentString(engineMessage, invalidBondIds));
}
Map<String, List<Guid>> nicNameToAttachedNetworkAttachmentIds = getIdsOfNetworkAttachmentsRelatedToInterfaceNames(attachmentsToConfigure);
for (VdsNetworkInterface removedBond : removedBondVdsNetworkInterface) {
String bondName = removedBond.getName();
VdsNetworkInterface existingBond = existingInterfacesMap.get(bondName);
ValidationResult interfaceIsBondOrNull = createHostInterfaceValidator(existingBond).interfaceIsBondOrNull();
if (!interfaceIsBondOrNull.isValid()) {
return interfaceIsBondOrNull;
}
boolean cantRemoveRequiredInterface = nicNameToAttachedNetworkAttachmentIds.containsKey(bondName);
if (cantRemoveRequiredInterface) {
List<Guid> networkAttachmentsForNic = nicNameToAttachedNetworkAttachmentIds.get(bondName);
EngineMessage engineMessage = EngineMessage.BOND_USED_BY_NETWORK_ATTACHMENTS;
List<String> replacements = new ArrayList<>();
replacements.add(ReplacementUtils.getVariableAssignmentString(engineMessage, bondName));
replacements.addAll(ReplacementUtils.replaceWith(VAR_ATTACHMENT_IDS, networkAttachmentsForNic));
return new ValidationResult(engineMessage, replacements);
}
}
return ValidationResult.VALID;
}
use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.
the class HostSetupNetworksValidator method networksUniquelyConfiguredOnHost.
ValidationResult networksUniquelyConfiguredOnHost(Collection<NetworkAttachment> attachmentsToConfigure) {
Set<Guid> usedNetworkIds = new HashSet<>(attachmentsToConfigure.size());
for (NetworkAttachment attachment : attachmentsToConfigure) {
boolean alreadyUsedNetworkId = usedNetworkIds.contains(attachment.getNetworkId());
if (alreadyUsedNetworkId) {
Network network = existingNetworkRelatedToAttachment(attachment);
EngineMessage engineMessage = EngineMessage.NETWORKS_ALREADY_ATTACHED_TO_IFACES;
return new ValidationResult(engineMessage, ReplacementUtils.getVariableAssignmentStringWithMultipleValues(engineMessage, network.getName()));
} else {
usedNetworkIds.add(attachment.getNetworkId());
}
}
return ValidationResult.VALID;
}
use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.
the class HostSetupNetworksValidator method validateAttachmentAndNicReferenceSameLabelNotConflict.
ValidationResult validateAttachmentAndNicReferenceSameLabelNotConflict(NetworkAttachment attachment) {
Network network = existingNetworkRelatedToAttachment(attachment);
if (!NetworkUtils.isLabeled(network)) {
return ValidationResult.VALID;
}
String label = network.getLabel();
String nicThatShouldHaveTheLabel = nicLabelByLabel.containsKey(label) ? nicLabelByLabel.get(label).getNicName() : null;
EngineMessage engineMessage = EngineMessage.NETWORK_SHOULD_BE_ATTACHED_VIA_LABEL_TO_ANOTHER_NIC;
return ValidationResult.failWith(engineMessage, ReplacementUtils.getVariableAssignmentString(engineMessage, network.getName()), ReplacementUtils.createSetVariableString(VAR_NIC_NAME, attachment.getNicName()), ReplacementUtils.createSetVariableString(VAR_LABELED_NIC_NAME, nicThatShouldHaveTheLabel)).unless(nicThatShouldHaveTheLabel == null || nicThatShouldHaveTheLabel.equals(attachment.getNicName()));
}
use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.
the class HostSetupNetworksValidator method modifiedAttachmentExists.
private ValidationResult modifiedAttachmentExists(Guid networkAttachmentId) {
if (isNewAttachment(networkAttachmentId)) {
return ValidationResult.VALID;
}
for (NetworkAttachment existingAttachment : existingAttachments) {
if (existingAttachment.getId().equals(networkAttachmentId)) {
return ValidationResult.VALID;
}
}
EngineMessage engineMessage = EngineMessage.MODIFIED_NETWORK_ATTACHMENT_DOES_NOT_EXISTS;
String replacement = ReplacementUtils.getVariableAssignmentString(engineMessage, networkAttachmentId.toString());
return new ValidationResult(engineMessage, replacement);
}
Aggregations