use of org.ovirt.engine.core.common.businessentities.BusinessEntityMap in project ovirt-engine by oVirt.
the class NetworkAttachmentsValidatorTest method testVerifyUserAttachmentsDoesNotReferenceSameNetworkDuplicatelyWhenNoDuplicates.
@Test
public void testVerifyUserAttachmentsDoesNotReferenceSameNetworkDuplicatelyWhenNoDuplicates() {
Network networkA = createNetworkWithIdAndName("networkA");
NetworkAttachment networkAttachmentA = createNetworkAttachment(networkA);
Network networkB = createNetworkWithIdAndName("networkB");
NetworkAttachment networkAttachmentB = createNetworkAttachment(networkB);
List<NetworkAttachment> attachments = Arrays.asList(networkAttachmentA, networkAttachmentB);
BusinessEntityMap<Network> networksMap = new BusinessEntityMap<>(Arrays.asList(networkA, networkB));
NetworkAttachmentsValidator validator = new NetworkAttachmentsValidator(attachments, networksMap, networkExclusivenessValidator);
assertThat(validator.verifyUserAttachmentsDoesNotReferenceSameNetworkDuplicately(), isValid());
}
use of org.ovirt.engine.core.common.businessentities.BusinessEntityMap in project ovirt-engine by oVirt.
the class GetNetworkAttachmentsByHostIdQuery method executeQueryCommand.
@Override
protected void executeQueryCommand() {
Guid hostId = getParameters().getId();
List<NetworkAttachment> networkAttachments = networkAttachmentDao.getAllForHost(hostId);
List<VdsNetworkInterface> allInterfacesForHost = interfaceDao.getAllInterfacesForVds(hostId);
VDS vds = hostDao.get(hostId);
Guid clusterId = vds.getClusterId();
BusinessEntityMap<Network> networkMap = new BusinessEntityMap<>(networkDao.getAllForCluster(clusterId));
reportedConfigurationsFiller.fillReportedConfigurations(allInterfacesForHost, networkMap, networkAttachments, vds.getDynamicData().getReportedDnsResolverConfiguration(), clusterId);
completeNicNames(networkAttachments, allInterfacesForHost);
completeNetworkNames(networkAttachments, networkMap);
getQueryReturnValue().setReturnValue(networkAttachments);
}
use of org.ovirt.engine.core.common.businessentities.BusinessEntityMap 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.BusinessEntityMap in project ovirt-engine by oVirt.
the class UnmanagedNetworksHelper method getUnmanagedNetworks.
public List<UnmanagedNetwork> getUnmanagedNetworks(Guid hostId) {
List<UnmanagedNetwork> unmanagedNetworks = new ArrayList<>();
VDS host = vdsDao.get(hostId);
if (host != null) {
List<VdsNetworkInterface> hostNetworkInterfaces = interfaceDao.getAllInterfacesForVds(hostId);
BusinessEntityMap<Network> clusterNetworkMap = new BusinessEntityMap<>(getClusterNetworks(host));
for (VdsNetworkInterface vdsNetworkInterface : hostNetworkInterfaces) {
String networkName = vdsNetworkInterface.getNetworkName();
if (networkName != null && !clusterNetworkMap.containsKey(networkName)) {
unmanagedNetworks.add(createUnmanagedNetworkEntity(vdsNetworkInterface, networkName));
}
}
}
return unmanagedNetworks;
}
use of org.ovirt.engine.core.common.businessentities.BusinessEntityMap in project ovirt-engine by oVirt.
the class NetworkMtuValidatorTest method testGetNetworksOnNics.
@Test
public void testGetNetworksOnNics() throws Exception {
Network networkA = createNetwork(1, true, "netA");
Network networkB = createNetwork(2, true, "netB");
Network networkC = createNetwork(2, true, "netC");
List<Network> networks = Arrays.asList(networkA, networkB, networkC);
NetworkMtuValidator networkMtuValidatorSpy = spy(new NetworkMtuValidator(new BusinessEntityMap<>(networks)));
String nicAName = "NicA";
String nicCName = "NicC";
NetworkAttachment networkAttachmentA = createNetworkAttachment(networkA, nicAName);
NetworkAttachment networkAttachmentB = createNetworkAttachment(networkB, nicAName);
NetworkAttachment networkAttachmentC = createNetworkAttachment(networkC, nicCName);
List<NetworkAttachment> networkAttachments = Arrays.asList(networkAttachmentA, networkAttachmentB, networkAttachmentC);
Map<String, List<Network>> networksOnNics = networkMtuValidatorSpy.getNetworksOnNics(networkAttachments);
assertThat(networksOnNics.keySet().size(), is(2));
assertThat(networksOnNics.containsKey(nicAName), is(true));
assertThat(networksOnNics.containsKey(nicCName), is(true));
assertThat(networksOnNics.get(nicAName).size(), is(2));
assertThat(networksOnNics.get(nicAName), CoreMatchers.hasItems(networkA, networkB));
assertThat(networksOnNics.get(nicCName).size(), is(1));
assertThat(networksOnNics.get(nicCName), CoreMatchers.hasItems(networkC));
}
Aggregations