use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method createBondSlave.
private VdsNetworkInterface createBondSlave(Bond bond, String slaveName) {
VdsNetworkInterface slave = new VdsNetworkInterface();
slave.setId(Guid.newGuid());
slave.setName(slaveName);
slave.setBondName(bond.getName());
slave.setBonded(false);
return slave;
}
use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method validateSlaveHasNoLabelsHasNoOldNorNewLabelsValid.
@Test
public void validateSlaveHasNoLabelsHasNoOldNorNewLabelsValid() {
VdsNetworkInterface slave = createNic("slave");
HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().addExistingInterfaces(slave).build();
assertThat(validator.validateSlaveHasNoLabels(slave.getName()), isValid());
}
use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method validateSlaveHasNoLabelsOldLabelWasMovedToAnotherNicValid.
@Test
public void validateSlaveHasNoLabelsOldLabelWasMovedToAnotherNicValid() {
VdsNetworkInterface slave = createNic("slave");
slave.setLabels(Collections.singleton("lbl1"));
NicLabel nicLabel = new NicLabel(Guid.newGuid(), slave.getName() + "not", "lbl1");
HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addLabels(nicLabel)).addExistingInterfaces(slave).build();
assertThat(validator.validateSlaveHasNoLabels(slave.getName()), isValid());
}
use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method notMovingLabeledNetworkToDifferentNicCommonTest.
private void notMovingLabeledNetworkToDifferentNicCommonTest(boolean nicContainslabel, boolean labelShouldBeRemovedFromNic, boolean labelShouldBeAddedToNic, boolean valid) {
VdsNetworkInterface nic = createNic("nicWithLabel");
if (nicContainslabel) {
nic.setLabels(Collections.singleton("lbl1"));
}
Network movedNetwork = createNetworkWithNameAndLabel("net", "lbl1");
NetworkAttachment existingAttachment = createNetworkAttachment(movedNetwork, nic);
NetworkAttachment updatedAttachment = new NetworkAttachment(existingAttachment);
updatedAttachment.setNicId(Guid.newGuid());
updatedAttachment.setNicName(nic.getName() + "not");
HostSetupNetworksParameters params = new HostSetupNetworksParameters(host.getId());
if (labelShouldBeRemovedFromNic) {
params.getRemovedLabels().add("lbl1");
}
if (labelShouldBeAddedToNic) {
NicLabel nicLabel = new NicLabel(nic.getId(), nic.getName(), "lbl1");
params.getLabels().add(nicLabel);
}
HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(params).addExistingInterfaces(nic).addExistingAttachments(existingAttachment).addNetworks(movedNetwork).build();
if (valid) {
assertThat(validator.notMovingLabeledNetworkToDifferentNic(updatedAttachment), isValid());
} else {
EngineMessage engineMessage = EngineMessage.ACTION_TYPE_FAILED_CANNOT_MOVE_LABELED_NETWORK_TO_ANOTHER_NIC;
assertThat(validator.notMovingLabeledNetworkToDifferentNic(updatedAttachment), failsWith(engineMessage, ReplacementUtils.createSetVariableString(HostSetupNetworksValidator.VAR_NETWORK_NAME, movedNetwork.getName()), ReplacementUtils.getVariableAssignmentString(engineMessage, movedNetwork.getLabel())));
}
}
use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class NetworkDeviceHelperImplTest method mockNicForNetDevice.
private VdsNetworkInterface mockNicForNetDevice(HostDevice netDeviceParam) {
VdsNetworkInterface nic = new VdsNetworkInterface();
nic.setVdsId(netDeviceParam.getHostId());
nic.setName(netDeviceParam.getNetworkInterfaceName());
return nic;
}
Aggregations