use of org.ovirt.engine.core.common.businessentities.network.Nic in project ovirt-engine by oVirt.
the class UnmanagedNetworkValidatorTest method testValidateAttachementsForVlans.
@Test
public void testValidateAttachementsForVlans() {
String unmanagedBaseNicName = "eth0";
NetworkAttachment attachement1 = new NetworkAttachment();
attachement1.setNetworkName("network1");
attachement1.setNicName(unmanagedBaseNicName);
NetworkAttachment attachement2 = new NetworkAttachment();
attachement2.setNetworkName("any2");
attachement2.setNicName("eth1");
List<NetworkAttachment> attachementList = Arrays.asList(attachement1, attachement2);
Nic nic = createNic(unmanagedBaseNicName);
VdsNetworkInterface vlanNic = createVlanNic(nic, "eth0.100", 100, false);
List<VdsNetworkInterface> existingInterfaces = Collections.singletonList(vlanNic);
Set<String> nicsWithUnmanagedNetworks = validator.filterNicsWithUnmanagedNetworks(existingInterfaces, Collections.emptySet());
assertEquals(1, nicsWithUnmanagedNetworks.size());
String filteredNicName = nicsWithUnmanagedNetworks.iterator().next();
assertEquals(unmanagedBaseNicName, filteredNicName);
ValidationResult result = validator.validateAttachements(filteredNicName, attachementList);
assertThat(result, failsWith(EngineMessage.ACTION_TYPE_FAILED_HOST_NETWORK_ATTACHEMENT_ON_UNMANAGED_NETWORK, ReplacementUtils.createSetVariableString(NETWORK, "network1"), ReplacementUtils.createSetVariableString(NIC, "eth0")));
result = validator.validateAttachements("eth7", attachementList);
assertTrue(result.isValid());
}
use of org.ovirt.engine.core.common.businessentities.network.Nic in project ovirt-engine by oVirt.
the class UnmanagedNetworkValidatorTest method testValidateRemovedUnmanagedNetworks.
@Test
public void testValidateRemovedUnmanagedNetworks() {
String networkName = "networkName";
Nic nic = createNicWithNetworkImplementationDetails("eth0", false);
nic.setNetworkName(networkName);
Network network = new Network();
network.setName(networkName);
ValidationResult result = validator.validateRemovedUnmanagedNetworks(Collections.singletonList(networkName), Collections.singletonList(nic), new BusinessEntityMap<>(Collections.emptySet()));
assertTrue(result.isValid());
result = validator.validateRemovedUnmanagedNetworks(Collections.singletonList(networkName), Collections.singletonList(nic), new BusinessEntityMap<>(Collections.singletonList(network)));
assertThat(result, failsWith(EngineMessage.REMOVED_UNMANAGED_NETWORK_IS_A_CLUSTER_NETWORK, ReplacementUtils.createSetVariableString(NETWORK, networkName)));
String unmanagedNetworkNotPresentOnAnyNic = "unmanagedNetworkNotPresentOnAnyNic";
result = validator.validateRemovedUnmanagedNetworks(Arrays.asList(networkName, unmanagedNetworkNotPresentOnAnyNic), Collections.singletonList(nic), new BusinessEntityMap<>(Collections.emptySet()));
assertThat(result, failsWith(EngineMessage.REMOVED_UNMANAGED_NETWORK_DOES_NOT_EXISIT_ON_HOST, ReplacementUtils.createSetVariableString(NETWORK, unmanagedNetworkNotPresentOnAnyNic)));
}
use of org.ovirt.engine.core.common.businessentities.network.Nic in project ovirt-engine by oVirt.
the class UnmanagedNetworkValidatorTest method createNic.
private Nic createNic(String name) {
Nic nic = new Nic();
nic.setName(name);
return nic;
}
use of org.ovirt.engine.core.common.businessentities.network.Nic in project ovirt-engine by oVirt.
the class UnmanagedNetworkValidatorTest method testValidateLabelsForVlan.
@Test
public void testValidateLabelsForVlan() {
Nic nic = createNic("eth0");
NicLabel label = new NicLabel(null, "eth1", "label1");
NicLabel labelWithUnmanagedNetwork = new NicLabel(null, "eth0", "labelOnUnmanaged");
Collection<NicLabel> labels = Arrays.asList(label, labelWithUnmanagedNetwork);
VdsNetworkInterface vlanNic = createVlanNic(nic, "eth0.100", 100, false);
List<VdsNetworkInterface> existingInterfaces = Collections.singletonList(vlanNic);
Set<String> nicsWithUnmanagedNetworks = validator.filterNicsWithUnmanagedNetworks(existingInterfaces, Collections.emptySet());
assertEquals(1, nicsWithUnmanagedNetworks.size());
String vlanNicName = nicsWithUnmanagedNetworks.iterator().next();
ValidationResult result = validator.validateLabels(vlanNicName, labels);
assertThat(result, failsWith(EngineMessage.ACTION_TYPE_FAILED_HOST_NETWORK_LABEL_ON_UNMANAGED_NETWORK, ReplacementUtils.createSetVariableString(LABEL, "labelOnUnmanaged"), ReplacementUtils.createSetVariableString(NIC, "eth0")));
NicLabel labelWithoutUnmanaged = new NicLabel(null, "eth_other", "label1");
Collection<NicLabel> labelsNotOnUnmanagedNetwork = Collections.singletonList(labelWithoutUnmanaged);
result = validator.validateLabels(vlanNicName, labelsNotOnUnmanagedNetwork);
assertTrue(result.isValid());
}
use of org.ovirt.engine.core.common.businessentities.network.Nic in project ovirt-engine by oVirt.
the class UnmanagedNetworkValidatorTest method createNicWithNetworkImplementationDetails.
private Nic createNicWithNetworkImplementationDetails(String name, boolean isManaged) {
Nic nic = createNic(name);
NetworkImplementationDetails networkImplementationDetails1 = new NetworkImplementationDetails(true, isManaged);
nic.setNetworkImplementationDetails(networkImplementationDetails1);
return nic;
}
Aggregations