use of org.ovirt.engine.core.common.businessentities.network.NetworkCluster in project ovirt-engine by oVirt.
the class NetworkUtilsTest method isRoleNetworkNoRoles.
@Test
public void isRoleNetworkNoRoles() {
NetworkCluster networkCluster = createNetworkCluster(false, false, false);
assertFalse(NetworkUtils.isRoleNetwork(networkCluster));
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkCluster in project ovirt-engine by oVirt.
the class NetworkUtilsTest method isRoleNetworkAllRoles.
@Test
public void isRoleNetworkAllRoles() {
NetworkCluster networkCluster = createNetworkCluster(true, true, true);
assertTrue(NetworkUtils.isRoleNetwork(networkCluster));
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkCluster in project ovirt-engine by oVirt.
the class NetworkUtilsTest method createNetworkCluster.
private NetworkCluster createNetworkCluster(boolean display, boolean migration, boolean gluster) {
NetworkCluster networkCluster = new NetworkCluster();
networkCluster.setDisplay(display);
networkCluster.setMigration(migration);
networkCluster.setGluster(gluster);
return networkCluster;
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkCluster in project ovirt-engine by oVirt.
the class NetworkClustersToSetupNetworksParametersTransformerImpl method getUpdatedNetworksByHost.
/**
* @param updates NetworkCluster instances related to updated networks
* @return Mapping HostId to list of updated networks, which relates to NetworkCluster from parameter.
*/
private Map<Guid, List<Network>> getUpdatedNetworksByHost(Collection<NetworkCluster> updates) {
Map<Guid, List<Network>> result = new HashMap<>();
Map<Guid, List<NetworkCluster>> updatesByClusterId = updates.stream().collect(Collectors.groupingBy(NetworkCluster::getClusterId));
Set<Guid> idsOfUpdatedNetworks = updates.stream().map(NetworkCluster::getNetworkId).collect(Collectors.toSet());
for (Guid clusterId : updatesByClusterId.keySet()) {
Map<String, Network> clusterNetworksByName = networkDao.getAllForCluster(clusterId).stream().filter(network -> idsOfUpdatedNetworks.contains(network.getId())).collect(Collectors.toMap(Network::getName, Function.identity()));
List<VdsNetworkInterface> interfacesOfCluster = interfaceDao.getAllInterfacesByClusterId(clusterId);
for (VdsNetworkInterface iface : interfacesOfCluster) {
if (!clusterNetworksByName.containsKey(iface.getNetworkName())) {
continue;
}
Network network = clusterNetworksByName.get(iface.getNetworkName());
Guid vdsId = iface.getVdsId();
VdsNetworkInterface.NetworkImplementationDetails networkImplementationDetails = networkImplementationDetailsUtils.calculateNetworkImplementationDetails(iface, network);
boolean networkShouldBeSynced = networkImplementationDetails != null && !networkImplementationDetails.isInSync();
if (networkShouldBeSynced) {
if (!result.containsKey(vdsId)) {
result.put(vdsId, new ArrayList<>());
}
result.get(vdsId).add(network);
}
}
}
return result;
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkCluster in project ovirt-engine by oVirt.
the class ManageNetworkClustersCommand method checkDetachmentsPermissions.
private boolean checkDetachmentsPermissions() {
for (NetworkCluster detachment : getParameters().getDetachments()) {
final List<PermissionSubject> permissionCheckSubjects = detachPermissionFinder.findPermissionCheckSubjects(detachment.getNetworkId(), DetachNetworkToCluster);
for (PermissionSubject permissionSubject : permissionCheckSubjects) {
final ArrayList<String> messages = new ArrayList<>();
final boolean isUserAllowed = checkSinglePermission(permissionSubject, messages);
if (!isUserAllowed) {
getReturnValue().getValidationMessages().addAll(messages);
return false;
}
}
}
return true;
}
Aggregations