use of org.ovirt.engine.core.common.businessentities.network.Network 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.Network in project ovirt-engine by oVirt.
the class VfSchedulerImplTest method mockVnic.
private VmNetworkInterface mockVnic(boolean passthrough, String networkName) {
VmNetworkInterface vnic = mock(VmNetworkInterface.class);
when(vnic.getId()).thenReturn(Guid.newGuid());
when(vnic.getName()).thenReturn(getRandomString());
when(vnic.isPassthrough()).thenReturn(passthrough);
Network network = createNetwork(networkName);
when(vnic.getNetworkName()).thenReturn(network.getName());
when(vnic.isPlugged()).thenReturn(true);
when(vnic.getVmId()).thenReturn(vmId);
return vnic;
}
use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method testValidateCustomPropertiesWhenCustomPropertyValidationFailed.
@Test
public void testValidateCustomPropertiesWhenCustomPropertyValidationFailed() 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 = spy(new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addNetworkAttachments(networkAttachment)).addNetworks(networkA).build());
// this was added just because of DI issues with 'Backend.getInstance().getErrorsTranslator()' is 'spyed' method
// noinspection unchecked
doReturn(Collections.emptyList()).when(validator).translateErrorMessages(any());
EngineMessage engineMessage = EngineMessage.ACTION_TYPE_FAILED_NETWORK_CUSTOM_PROPERTIES_BAD_INPUT;
assertThat(validator.validateCustomProperties(SimpleCustomPropertiesUtil.getInstance(), Collections.emptyMap(), Collections.emptyMap()), failsWith(engineMessage, ReplacementUtils.getVariableAssignmentStringWithMultipleValues(engineMessage, networkA.getName())));
}
use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method validateBondOptionsForNewAttachementWithOutOfSyncVmNetworOverridden.
@Test
public void validateBondOptionsForNewAttachementWithOutOfSyncVmNetworOverridden() {
NetworkAttachment modifiedAttachment = createNetworkAttachment(new Network());
HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addRemovedNetworkAttachments(modifiedAttachment)).build();
assertThat(validator.modifiedAttachmentNotRemoved(modifiedAttachment), failsWith(EngineMessage.NETWORK_ATTACHMENT_IN_BOTH_LISTS, ReplacementUtils.createSetVariableString("NETWORK_ATTACHMENT_IN_BOTH_LISTS_ENTITY", modifiedAttachment.getId().toString())));
}
use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method testNotRemovingLabeledNetworksLabelRemovedFromNicValid.
@Test
public void testNotRemovingLabeledNetworksLabelRemovedFromNicValid() {
VdsNetworkInterface nicWithLabel = createNic("nicWithLabel");
final String labelName = "lbl1";
nicWithLabel.setLabels(Collections.singleton(labelName));
Network network = createNetworkWithNameAndLabel("net", labelName);
NetworkAttachment removedAttachment = createNetworkAttachment(network, nicWithLabel);
assertTestNotRemovingLabeledNetworksValid(nicWithLabel, removedAttachment, new ParametersBuilder().addRemovedLabels(labelName).build(), network);
}
Aggregations