use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class LogicalNetworkModelParametersHelper method prepareSetupNetworksParamsToAttachTo.
public void prepareSetupNetworksParamsToAttachTo(NetworkInterfaceModel targetNic) {
NetworkAttachment networkAttachment = createAttachmentWhenAttachingTo(targetNic.getOriginalIface());
networkModel.getSetupModel().getHostSetupNetworksParametersData().addNetworkAttachmentToParameters(networkAttachment);
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method createNetworkAttachment.
private NetworkAttachment createNetworkAttachment(Network network, Guid id) {
NetworkAttachment networkAttachment = new NetworkAttachment();
networkAttachment.setId(id);
networkAttachment.setNetworkId(network.getId());
networkAttachment.setNetworkName(network.getName());
return networkAttachment;
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method testGetAttachmentsToConfigureWhenRemovingNetworkAttachments.
@Test
public void testGetAttachmentsToConfigureWhenRemovingNetworkAttachments() 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(networkAttachmentB).addRemovedNetworkAttachments(networkAttachmentA).build()).addExistingAttachments(Arrays.asList(networkAttachmentA, networkAttachmentB)).addNetworks((Collection<Network>) null).build();
Collection<NetworkAttachment> attachmentsToConfigure = validator.getAttachmentsToConfigure();
assertThat(attachmentsToConfigure.size(), is(1));
assertThat(attachmentsToConfigure.contains(networkAttachmentA), is(false));
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 attachmentAndNicLabelReferenceSameLabelCommonTest.
private void attachmentAndNicLabelReferenceSameLabelCommonTest(boolean referenceSameNic, boolean valid) {
VdsNetworkInterface nic = createNic("nic");
final String labelName = "lbl1";
Network network = createNetworkWithNameAndLabel("net", labelName);
NetworkAttachment attachment = createNetworkAttachment(network, nic);
NicLabel nicLabel = referenceSameNic ? new NicLabel(nic.getId(), nic.getName(), labelName) : new NicLabel(Guid.newGuid(), nic.getName() + "not", labelName);
HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addLabels(nicLabel)).addNetworks(network).addExistingInterfaces(nic).build();
if (valid) {
assertThat(validator.validateAttachmentAndNicReferenceSameLabelNotConflict(attachment), isValid());
} else {
EngineMessage engineMessage = EngineMessage.NETWORK_SHOULD_BE_ATTACHED_VIA_LABEL_TO_ANOTHER_NIC;
assertThat(validator.validateAttachmentAndNicReferenceSameLabelNotConflict(attachment), failsWith(engineMessage, ReplacementUtils.getVariableAssignmentString(engineMessage, network.getName()), ReplacementUtils.createSetVariableString("nicName", attachment.getNicName()), ReplacementUtils.createSetVariableString("labeledNicName", nicLabel.getNicName())));
}
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method testNotRemovingLabeledNetworksWhenLabelRelatedToRemovedBond.
@Test
public void testNotRemovingLabeledNetworksWhenLabelRelatedToRemovedBond() throws Exception {
String label = "label";
String nicName = "nicName";
Network labeledNetwork = new Network();
labeledNetwork.setId(Guid.newGuid());
labeledNetwork.setLabel(label);
NetworkAttachment networkAttachment = createNetworkAttachment(labeledNetwork);
networkAttachment.setNicName(nicName);
bond.setLabels(Collections.singleton(label));
bond.setName(nicName);
HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addRemovedBonds(bond.getId())).addExistingInterfaces(Collections.singletonList(bond)).addExistingAttachments((List<NetworkAttachment>) null).addNetworks(Collections.singletonList(labeledNetwork)).build();
assertThat(validator.notRemovingLabeledNetworks(networkAttachment), isValid());
}
Aggregations