use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method testValidateCustomProperties.
@Test
public void testValidateCustomProperties() throws Exception {
Network networkA = createNetworkWithName("networkA");
NetworkAttachment networkAttachment = createNetworkAttachment(networkA);
Map<String, String> customProperties = new HashMap<>();
customProperties.put("a", "b");
networkAttachment.setProperties(customProperties);
HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addNetworkAttachments(networkAttachment)).addNetworks(networkA).build();
// we do not test SimpleCustomPropertiesUtil here, we just state what happens if it does not find ValidationError
SimpleCustomPropertiesUtil simpleCustomPropertiesUtilMock = mock(SimpleCustomPropertiesUtil.class);
assertThat(validator.validateCustomProperties(simpleCustomPropertiesUtilMock, Collections.emptyMap(), Collections.emptyMap()), isValid());
}
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 networkA, VdsNetworkInterface nic, Guid guid) {
NetworkAttachment attachment = createNetworkAttachment(networkA, guid);
if (nic != null) {
attachment.setNicId(nic.getId());
attachment.setNicName(nic.getName());
}
return attachment;
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment 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.NetworkAttachment in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method modifiedAttachmentNotRemovedAttachmentModifiedButNotRemovedValid.
@Test
public void modifiedAttachmentNotRemovedAttachmentModifiedButNotRemovedValid() {
HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().build();
NetworkAttachment modifiedAttachment = createNetworkAttachment(new Network());
assertThat(validator.modifiedAttachmentNotRemoved(modifiedAttachment), isValid());
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class IpConfigurationCompleterTest method setUp.
@Before
public void setUp() {
underTest = new IpConfigurationCompleter();
ipConfiguration = new IpConfiguration();
networkAttachment = new NetworkAttachment();
networkAttachment.setIpConfiguration(ipConfiguration);
networkAttachments = Collections.singleton(networkAttachment);
}
Aggregations