use of org.ovirt.engine.core.common.businessentities.network.NicLabel in project ovirt-engine by oVirt.
the class LabelNicCommand method createHostSetupNetworksParameters.
private HostSetupNetworksParameters createHostSetupNetworksParameters() {
HostSetupNetworksParameters params = new HostSetupNetworksParameters(getVdsId());
params.getLabels().add(new NicLabel(getNic().getId(), getNic().getName(), getLabel()));
return params;
}
use of org.ovirt.engine.core.common.businessentities.network.NicLabel in project ovirt-engine by oVirt.
the class NicLabelValidator method validNewOrModifiedLabels.
public ValidationResult validNewOrModifiedLabels() {
ValidationResult vr = ValidationResult.VALID;
Iterator<NicLabel> iterator = params.getLabels().iterator();
while (iterator.hasNext() && vr.isValid()) {
NicLabel nicLabel = iterator.next();
vr = skipValidation(vr) ? vr : validateCoherentNicIdentification(nicLabel);
vr = skipValidation(vr) ? vr : nicActuallyExistsOrReferencesNewBond(nicLabel);
vr = skipValidation(vr) ? vr : labelBeingAttachedToNonVlanNonSlaveInterface(nicLabel);
vr = skipValidation(vr) ? vr : labelBeingAttachedToValidBond(nicLabel);
}
return vr;
}
use of org.ovirt.engine.core.common.businessentities.network.NicLabel in project ovirt-engine by oVirt.
the class NicLabelValidator method labelAppearsOnlyOnceInParams.
public ValidationResult labelAppearsOnlyOnceInParams() {
Set<String> existingLabels = new HashSet<>();
Set<String> duplicateLabels = new HashSet<>();
for (NicLabel nicLabel : params.getLabels()) {
String label = nicLabel.getLabel();
addLabelToList(existingLabels, duplicateLabels, label);
}
for (String label : params.getRemovedLabels()) {
addLabelToList(existingLabels, duplicateLabels, label);
}
return ValidationResult.failWith(EngineMessage.PARAMS_CONTAIN_DUPLICATE_LABELS, ReplacementUtils.replaceWith("PARAMS_CONTAIN_DUPLICATE_LABELS_LIST", new ArrayList<>(duplicateLabels))).unless(duplicateLabels.isEmpty());
}
use of org.ovirt.engine.core.common.businessentities.network.NicLabel in project ovirt-engine by oVirt.
the class NicLabelsCompleter method completeNetworkAttachmentsByLabels.
private void completeNetworkAttachmentsByLabels() {
for (NicLabel nicLabel : params.getLabels()) {
List<Network> labelNetworks = labelToNetworks.get(nicLabel.getLabel());
if (labelNetworks == null) {
continue;
}
for (Network network : labelNetworks) {
NetworkAttachment newOrModifiedNetworkAttachment = attachmentsByNetworkId.get(network.getId());
NetworkAttachment existingNetworkAttachment = existingNetworkAttachmentsByNetworkId.get(network.getId());
boolean existingAttachmentRemoved = existingNetworkAttachment == null ? false : params.getRemovedNetworkAttachments().contains(existingNetworkAttachment.getId());
boolean noNewOrModifiedNetworkAttachment = newOrModifiedNetworkAttachment == null;
NetworkAttachment attachmentToConfigure = noNewOrModifiedNetworkAttachment && !existingAttachmentRemoved ? existingNetworkAttachment : newOrModifiedNetworkAttachment;
if (attachmentToConfigure == null) {
params.getNetworkAttachments().add(createNetworkAttachment(nicLabel.getNicId(), nicLabel.getNicName(), network.getId(), network.getName()));
} else if (!Objects.equals(attachmentToConfigure.getNicName(), nicLabel.getNicName()) && noNewOrModifiedNetworkAttachment) {
NetworkAttachment updatedNetworkAttachment = new NetworkAttachment(existingNetworkAttachment);
updatedNetworkAttachment.setNicId(nicLabel.getNicId());
updatedNetworkAttachment.setNicName(nicLabel.getNicName());
params.getNetworkAttachments().add(updatedNetworkAttachment);
}
}
}
}
use of org.ovirt.engine.core.common.businessentities.network.NicLabel in project ovirt-engine by oVirt.
the class HostSetupNetworksCommand method updateAddedModifiedLabelsOnNics.
private void updateAddedModifiedLabelsOnNics(Map<String, VdsNetworkInterface> nicsToConfigureByName) {
Map<String, VdsNetworkInterface> labelToExistingNic = getLabelToNic(nicsToConfigureByName.values());
for (NicLabel nicLabel : getParameters().getLabels()) {
VdsNetworkInterface currentLabelNic = labelToExistingNic.get(nicLabel.getLabel());
VdsNetworkInterface newLabelNic = nicsToConfigureByName.get(nicLabel.getNicName());
moveLabel(nicLabel.getLabel(), currentLabelNic, newLabelNic);
}
}
Aggregations