use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method initValidator.
private HostSetupNetworksValidator initValidator() {
Network network = addNewNetworkToDaoMock();
VdsNetworkInterface vdsNetworkInterface = createNic(HostSetupNetworksValidator.VAR_INTERFACE_NAME);
NetworkAttachment networkAttachment = createNetworkAttachment(network, vdsNetworkInterface, null);
HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addNetworkAttachments(networkAttachment)).addNetworks(network).addExistingInterfaces(vdsNetworkInterface).build();
return validator;
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method testGetAttachmentsToConfigureWhenUpdatingNetworkAttachments.
@Test
public void testGetAttachmentsToConfigureWhenUpdatingNetworkAttachments() throws Exception {
Network networkA = createNetworkWithName("networkA");
Network networkB = createNetworkWithName("networkB");
NetworkAttachment networkAttachmentA = createNetworkAttachment(networkA);
NetworkAttachment networkAttachmentB = createNetworkAttachment(networkB);
HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addNetworkAttachments(networkAttachmentA, networkAttachmentB)).addExistingAttachments(networkAttachmentA, networkAttachmentB).build();
Collection<NetworkAttachment> attachmentsToConfigure = validator.getAttachmentsToConfigure();
assertThat(attachmentsToConfigure.size(), is(2));
assertThat(attachmentsToConfigure.contains(networkAttachmentA), is(true));
assertThat(attachmentsToConfigure.contains(networkAttachmentB), is(true));
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method testNetworksUniquelyConfiguredOnHostWhenUniquelyConfigured.
@Test
public void testNetworksUniquelyConfiguredOnHostWhenUniquelyConfigured() throws Exception {
Network networkA = new Network();
networkA.setId(Guid.newGuid());
Network networkB = new Network();
networkB.setId(Guid.newGuid());
NetworkAttachment networkAttachmentA = createNetworkAttachment(networkA);
NetworkAttachment networkAttachmentB = createNetworkAttachment(networkB);
HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().addNetworks(Arrays.asList(networkA, networkB)).build();
assertThat(validator.networksUniquelyConfiguredOnHost(Arrays.asList(networkAttachmentA, networkAttachmentB)), isValid());
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method testValidateQosNotPartiallyConfigured.
private void testValidateQosNotPartiallyConfigured(boolean networkAttachment1HasQos, boolean networkAttachment2HasQos, Matcher<ValidationResult> matcher) {
VdsNetworkInterface baseNic = createNic("baseNic");
VdsNetworkInterface vlanNic1 = createVlanNic(baseNic, "vlanNic1", 10);
VdsNetworkInterface vlanNic2 = createVlanNic(baseNic, "vlanNic2", 11);
Network network1 = createNetworkWithName("network1");
Network network2 = createNetworkWithName("network2");
NetworkAttachment networkAttachment1 = createNetworkAttachment(network1, baseNic);
NetworkAttachment networkAttachment2 = createNetworkAttachment(network2, baseNic);
AnonymousHostNetworkQos qos = createHostNetworkQos(10, 10, 10);
if (networkAttachment1HasQos) {
networkAttachment1.setHostNetworkQos(qos);
}
if (networkAttachment2HasQos) {
networkAttachment2.setHostNetworkQos(qos);
}
Collection<NetworkAttachment> networkAttachments = Arrays.asList(networkAttachment1, networkAttachment2);
HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().addNetworks(network1, network2).addExistingInterfaces(baseNic, vlanNic1, vlanNic2).build();
assertThat(validator.validateQosNotPartiallyConfigured(networkAttachments), matcher);
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method testNotRemovingLabeledNetworksWhenNicNameDoesNotReferenceExistingNicItsOkToRemove.
@Test
public void testNotRemovingLabeledNetworksWhenNicNameDoesNotReferenceExistingNicItsOkToRemove() throws Exception {
Network labeledNetwork = new Network();
labeledNetwork.setId(Guid.newGuid());
labeledNetwork.setLabel("label");
NetworkAttachment networkAttachment = createNetworkAttachment(labeledNetwork);
networkAttachment.setNicName("noLongerExistingNicName");
VdsNetworkInterface existingNic = new VdsNetworkInterface();
existingNic.setName("existingNicName");
HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().addNetworks(Collections.singletonList(labeledNetwork)).build();
assertThat(validator.notRemovingLabeledNetworks(networkAttachment), isValid());
}
Aggregations