use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class NetworkAttachmentsValidator method createNicNameToNetworkTypesMap.
private Map<String, List<NetworkType>> createNicNameToNetworkTypesMap() {
Map<String, List<NetworkType>> nicNameToNetworkTypes = new HashMap<>();
for (NetworkAttachment attachment : attachmentsToConfigure) {
String nicName = attachment.getNicName();
// have to check since if null, multiple results would be merged producing invalid results.
if (nicName == null) {
throw new IllegalArgumentException("nic name cannot be null");
}
Network networkToConfigure = networkBusinessEntityMap.get(attachment.getNetworkId());
NetworkType networkTypeToAdd = determineNetworkType(networkToConfigure);
nicNameToNetworkTypes.computeIfAbsent(nicName, k -> new ArrayList<>()).add(networkTypeToAdd);
}
return nicNameToNetworkTypes;
}
use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class IscsiBondValidator method getNetworksMissingInDataCenter.
private List<Guid> getNetworksMissingInDataCenter(Collection<Guid> networks, Guid dataCenterId) {
Set<Guid> existingNetworkIds = new HashSet<>();
List<Guid> res = new LinkedList<>();
List<Network> dcLogicalNetworks = getDBFacade().getNetworkDao().getAllForDataCenter(dataCenterId);
for (Network network : dcLogicalNetworks) {
existingNetworkIds.add(network.getId());
}
for (Guid id : networks) {
if (!existingNetworkIds.contains(id)) {
res.add(id);
}
}
return res;
}
use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class RemoveProviderValidatorTest method networksUsedTest.
private void networksUsedTest(boolean vmsNotUsingNetwork, boolean templatesNotUsingNetwork, Matcher<ValidationResult> matcher) {
NetworkValidator networkValidator = mock(NetworkValidator.class);
for (Network network : networks) {
when(validator.getValidator(network)).thenReturn(networkValidator);
}
when(networkValidator.networkNotUsedByVms()).thenReturn(createValidationResult(vmsNotUsingNetwork));
when(networkValidator.networkNotUsedByTemplates()).thenReturn(createValidationResult(templatesNotUsingNetwork));
assertThat(validator.providerNetworksNotUsed(), matcher);
}
use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class RemoveProviderValidatorTest method networksUsedByAVmMultipleNetworks.
@Test
public void networksUsedByAVmMultipleNetworks() throws Exception {
Network net = mockNetwork();
Network net2 = mockNetwork();
networksUsedTest(false, true, both(failsWith(EngineMessage.ACTION_TYPE_FAILED_PROVIDER_NETWORKS_USED_MULTIPLE_TIMES)).and(replacements(hasItem(containsString(net.getName())))).and(replacements(hasItem(containsString(net2.getName())))));
}
use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class GetAllExternalNetworksOnProviderQueryTest method testExecuteQueryCommand.
@Test
@SuppressWarnings("unchecked")
public void testExecuteQueryCommand() {
when(params.getId()).thenReturn(mock(Guid.class));
when((Provider<AdditionalProperties>) providerDao.get(any())).thenReturn(networkProvider);
when(providerProxyFactory.create(networkProvider)).thenReturn(client);
Network network = mock(Network.class);
ProviderNetwork providerNetwork = mock(ProviderNetwork.class);
when(client.getAll()).thenReturn(Collections.singletonList(network));
when(network.getProvidedBy()).thenReturn(providerNetwork);
when(providerNetwork.getExternalId()).thenReturn("");
Guid id = mock(Guid.class);
when(dcDao.getDcIdByExternalNetworkId(any())).thenReturn(Collections.singletonList(id));
Map<Network, Set<Guid>> expected = new HashMap<>();
expected.put(network, Collections.singleton(id));
query = getQuery();
query.executeQueryCommand();
assertEquals("Wrong result returned", expected, getQuery().getQueryReturnValue().getReturnValue());
}
Aggregations