use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class HostInterfaceValidatorTest method testInterfaceIsValidSlaveWhenInterfaceIsBond.
@Test
public void testInterfaceIsValidSlaveWhenInterfaceIsBond() throws Exception {
VdsNetworkInterface vdsNetworkInterface = createVdsNetworkInterfaceWithName();
vdsNetworkInterface.setBonded(true);
Matcher<ValidationResult> matcher = failsWith(EngineMessage.NETWORK_INTERFACE_BOND_OR_VLAN_CANNOT_BE_SLAVE, ReplacementUtils.createSetVariableString(HostInterfaceValidator.VAR_NIC_NAME, vdsNetworkInterface.getName()));
assertThat(new HostInterfaceValidator(vdsNetworkInterface).interfaceIsValidSlave(), matcher);
}
use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class HostInterfaceValidatorTest method testLabeledNetworkAttachedToThisInterface.
@Test
public void testLabeledNetworkAttachedToThisInterface() throws Exception {
String networkName = "networkA";
Network network = new Network();
network.setName(networkName);
VdsNetworkInterface nicToWhichLabeledNetworkShouldBeAttached = createVdsNetworkInterfaceWithName("nicA");
nicToWhichLabeledNetworkShouldBeAttached.setNetworkName(networkName);
List<VdsNetworkInterface> hostInterfaces = Arrays.asList(nicToWhichLabeledNetworkShouldBeAttached, createVdsNetworkInterfaceWithName("nicB"));
HostInterfaceValidator validator = new HostInterfaceValidator(nicToWhichLabeledNetworkShouldBeAttached);
List<Network> clusterNetworksWithLabel = Collections.singletonList(network);
assertThat(validator.networksAreAttachedToThisInterface(hostInterfaces, clusterNetworksWithLabel), isValid());
}
use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class HostInterfaceValidatorTest method testInterfaceInHostWhenInSameHost.
@Test
public void testInterfaceInHostWhenInSameHost() throws Exception {
VdsNetworkInterface vdsNetworkInterface = createVdsNetworkInterfaceWithName();
Guid vdsId = Guid.newGuid();
vdsNetworkInterface.setVdsId(vdsId);
assertThat(new HostInterfaceValidator(vdsNetworkInterface).interfaceInHost(vdsId), isValid());
}
use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class HostInterfaceValidatorTest method testAnotherInterfaceAlreadyLabeledWithThisLabelDoNotCompareWithSelf.
@Test
public void testAnotherInterfaceAlreadyLabeledWithThisLabelDoNotCompareWithSelf() throws Exception {
// identity of nics is compared based on names.
String sameName = "sameName";
VdsNetworkInterface vdsNetworkInterface = createVdsNetworkInterfaceWithName(sameName);
VdsNetworkInterface preexistingVdsNetworkInterface = createVdsNetworkInterfaceWithName(sameName);
// set same label
String label = "label";
vdsNetworkInterface.setLabels(Collections.singleton(label));
preexistingVdsNetworkInterface.setLabels(Collections.singleton(label));
HostInterfaceValidator validator = new HostInterfaceValidator(vdsNetworkInterface);
List<VdsNetworkInterface> preexistingInterfaces = Collections.singletonList(preexistingVdsNetworkInterface);
assertThat(validator.anotherInterfaceAlreadyLabeledWithThisLabel(label, preexistingInterfaces), isValid());
}
use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class HostInterfaceValidatorTest method testAnotherInterfaceAlreadyLabeledWithThisLabel.
@Test
public void testAnotherInterfaceAlreadyLabeledWithThisLabel() throws Exception {
// identity of nics is compared based on names.
VdsNetworkInterface vdsNetworkInterface = createVdsNetworkInterfaceWithName("name");
VdsNetworkInterface preexistingVdsNetworkInterface = createVdsNetworkInterfaceWithName("differentName");
// set same label
String label = "label";
vdsNetworkInterface.setLabels(Collections.singleton(label));
preexistingVdsNetworkInterface.setLabels(Collections.singleton(label));
HostInterfaceValidator validator = new HostInterfaceValidator(vdsNetworkInterface);
List<VdsNetworkInterface> preexistingInterfaces = Collections.singletonList(preexistingVdsNetworkInterface);
assertThat("different nics cannot have same label set.", validator.anotherInterfaceAlreadyLabeledWithThisLabel(label, preexistingInterfaces), failsWith(EngineMessage.OTHER_INTERFACE_ALREADY_LABELED, ReplacementUtils.createSetVariableString(HostInterfaceValidator.VAR_LABELED_NIC, preexistingVdsNetworkInterface.getName()), ReplacementUtils.createSetVariableString(HostInterfaceValidator.VAR_NIC_LABEL, label)));
}
Aggregations