use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class HostSetupNetworksCommand method removeUnchangedBonds.
private void removeUnchangedBonds(List<VdsNetworkInterface> existingNics) {
Map<Guid, VdsNetworkInterface> nicsById = Entities.businessEntitiesById(existingNics);
List<CreateOrUpdateBond> createOrUpdateBonds = getParameters().getCreateOrUpdateBonds();
for (Iterator<CreateOrUpdateBond> iterator = createOrUpdateBonds.iterator(); iterator.hasNext(); ) {
CreateOrUpdateBond bondFromRequest = iterator.next();
Guid idOfBondFromRequest = bondFromRequest.getId();
boolean bondFromRequestIsNewBond = idOfBondFromRequest == null;
if (!bondFromRequestIsNewBond) {
if (bondFromRequest.equalToBond((Bond) nicsById.get(idOfBondFromRequest))) {
iterator.remove();
}
}
}
}
use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class HostSetupNetworksCommand method validate.
@Override
protected boolean validate() {
VDS host = getVds();
final ValidationResult hostValidatorResult = new HostValidator(host, isInternalExecution()).validate();
if (!hostValidatorResult.isValid()) {
return validate(hostValidatorResult);
}
completeMissingDataInParameters();
boolean requestValid = validateEntitiesFromRequest(getParameters().getNetworkAttachments()) && validateEntitiesFromRequest(getParameters().getCreateOrUpdateBonds());
if (!requestValid) {
return requestValid;
}
fillInUnsetBondingOptions();
IdQueryParameters idParameters = new IdQueryParameters(getVdsId());
QueryReturnValue existingBondsResponse = runInternalQuery(QueryType.GetHostBondsByHostId, idParameters);
if (!existingBondsResponse.getSucceeded()) {
return false;
}
List<VdsNetworkInterface> existingBonds = existingBondsResponse.getReturnValue();
removeUnchangedAttachments();
removeUnchangedBonds(existingBonds);
ValidationResult hostSetupNetworkValidatorResult = validateWithHostSetupNetworksValidator(host);
if (!hostSetupNetworkValidatorResult.isValid()) {
return validate(hostSetupNetworkValidatorResult);
}
return validate(checkForOutOfSyncNetworks());
}
use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class NicLabelValidatorTest method assertLabelBeingAttachedToNonVlanNonSlaveInterfaceFailed.
private void assertLabelBeingAttachedToNonVlanNonSlaveInterfaceFailed(HostSetupNetworksParameters params, VdsNetworkInterface attachLabelToNic) {
List<VdsNetworkInterface> nics = new ArrayList<>();
nics.add(attachLabelToNic);
if (attachLabelToNic.getBondName() != null) {
Bond bond = new Bond(attachLabelToNic.getBondName());
bond.setId(Guid.newGuid());
nics.add(bond);
}
NicLabel nicLabel = new NicLabel(attachLabelToNic.getId(), attachLabelToNic.getName(), "lbl1");
assertThat(createNicLabelValidator(params, nics).labelBeingAttachedToNonVlanNonSlaveInterface(nicLabel), failsWith(EngineMessage.LABEL_ATTACH_TO_IMPROPER_INTERFACE, ReplacementUtils.createSetVariableString("LABEL_ATTACH_TO_IMPROPER_INTERFACE_ENTITY", attachLabelToNic.getName())));
}
use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class NicLabelValidatorTest method labelBeingAttachedToNonVlanNonSlaveInterfaceValid.
@Test
public void labelBeingAttachedToNonVlanNonSlaveInterfaceValid() {
VdsNetworkInterface nic = createNic();
List<VdsNetworkInterface> nics = Collections.singletonList(nic);
NicLabel nicLabel = new NicLabel(nic.getId(), nic.getName(), "lbl1");
assertThat(createNicLabelValidator(nics).labelBeingAttachedToNonVlanNonSlaveInterface(nicLabel), isValid());
}
use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class NicLabelValidatorTest method labelBeingAttachedToNonVlanNonSlaveInterfaceAttachToExistingSlave.
@Test
public void labelBeingAttachedToNonVlanNonSlaveInterfaceAttachToExistingSlave() {
VdsNetworkInterface nic = createNic();
nic.setBondName("bond");
assertLabelBeingAttachedToNonVlanNonSlaveInterfaceFailed(createHostSetupNetworksParams(), nic);
}
Aggregations