use of org.ovirt.engine.core.dao.ClusterDao in project ovirt-engine by oVirt.
the class VirtMonitoringStrategyTest method mockCluster.
private ClusterDao mockCluster() {
ClusterDao mock = mock(ClusterDao.class);
cluster = new Cluster();
cluster.setEmulatedMachine("pc-1.0");
cluster.setCompatibilityVersion(Version.getLast());
cluster.setClusterId(clusterId);
when(mock.get(clusterId)).thenReturn(cluster);
return mock;
}
use of org.ovirt.engine.core.dao.ClusterDao in project ovirt-engine by oVirt.
the class NetworkClusterDaoTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
datacenter = FixturesTool.DATA_CENTER;
dao = dbFacade.getNetworkClusterDao();
ClusterDao clusterDao = dbFacade.getClusterDao();
cluster = clusterDao.get(FixturesTool.CLUSTER);
freeCluster = clusterDao.get(new Guid("b399944a-81ab-4ec5-8266-e19ba7c3c9d3"));
NetworkDao networkDao = dbFacade.getNetworkDao();
network = networkDao.getByNameAndDataCenter("engine", datacenter);
networkNoCluster = networkDao.getByNameAndDataCenter("engine3", datacenter);
createNewNetworkCluster();
existingNetworkCluster = dao.getAll().get(0);
}
use of org.ovirt.engine.core.dao.ClusterDao in project ovirt-engine by oVirt.
the class MacPoolValidator method notRemovingUsedPool.
public ValidationResult notRemovingUsedPool() {
final ClusterDao clusterDao = getDbFacade().getClusterDao();
final List<Cluster> clusters = clusterDao.getAllClustersByMacPoolId(macPool.getId());
final Collection<String> replacements = ReplacementUtils.replaceWithNameable("CLUSTERS_USING_MAC_POOL", clusters);
replacements.add(EngineMessage.VAR__ENTITIES__CLUSTERS.name());
return ValidationResult.failWith(EngineMessage.ACTION_TYPE_FAILED_CANNOT_REMOVE_STILL_USED_MAC_POOL, replacements.toArray(new String[replacements.size()])).when(clusters.size() != 0);
}
use of org.ovirt.engine.core.dao.ClusterDao in project ovirt-engine by oVirt.
the class GlusterGeoRepUtil method getEligibilityPredicates.
public Map<GlusterGeoRepNonEligibilityReason, Predicate<GlusterVolumeEntity>> getEligibilityPredicates(final GlusterVolumeEntity masterVolume) {
Map<GlusterGeoRepNonEligibilityReason, Predicate<GlusterVolumeEntity>> eligibilityPredicates = new HashMap<>();
final List<Guid> existingSessionSlavesIds = getSessionSlaveVolumeIds();
eligibilityPredicates.put(GlusterGeoRepNonEligibilityReason.SLAVE_VOLUME_SHOULD_BE_UP, slaveVolume -> slaveVolume.getStatus() == GlusterStatus.UP);
eligibilityPredicates.put(GlusterGeoRepNonEligibilityReason.SLAVE_AND_MASTER_VOLUMES_SHOULD_NOT_BE_IN_SAME_CLUSTER, slaveVolume -> !masterVolume.getClusterId().equals(slaveVolume.getClusterId()));
final Predicate<GlusterVolumeEntity> nonNullSlaveSizePredicate = slaveVolume -> slaveVolume.getAdvancedDetails().getCapacityInfo() != null;
eligibilityPredicates.put(GlusterGeoRepNonEligibilityReason.SLAVE_VOLUME_SIZE_TO_BE_AVAILABLE, nonNullSlaveSizePredicate);
final Predicate<GlusterVolumeEntity> nonNullMasterSizePredicate = slaveVolume -> masterVolume.getAdvancedDetails().getCapacityInfo() != null;
eligibilityPredicates.put(GlusterGeoRepNonEligibilityReason.MASTER_VOLUME_SIZE_TO_BE_AVAILABLE, nonNullMasterSizePredicate);
Predicate<GlusterVolumeEntity> masterSlaveSizePredicate = slaveVolume -> {
boolean eligible = nonNullSlaveSizePredicate.test(slaveVolume) && nonNullMasterSizePredicate.test(masterVolume);
if (eligible) {
eligible = slaveVolume.getAdvancedDetails().getCapacityInfo().getTotalSize() >= masterVolume.getAdvancedDetails().getCapacityInfo().getTotalSize();
}
return eligible;
};
eligibilityPredicates.put(GlusterGeoRepNonEligibilityReason.SLAVE_VOLUME_SIZE_SHOULD_BE_GREATER_THAN_MASTER_VOLUME_SIZE, masterSlaveSizePredicate);
eligibilityPredicates.put(GlusterGeoRepNonEligibilityReason.SLAVE_VOLUME_SHOULD_NOT_BE_SLAVE_OF_ANOTHER_GEO_REP_SESSION, slaveVolume -> !existingSessionSlavesIds.contains(slaveVolume.getId()));
eligibilityPredicates.put(GlusterGeoRepNonEligibilityReason.SLAVE_CLUSTER_AND_MASTER_CLUSTER_COMPATIBILITY_VERSIONS_DO_NOT_MATCH, slaveVolume -> {
ClusterDao clusterDao = getClusterDao();
Version slaveCompatibilityVersion = clusterDao.get(slaveVolume.getClusterId()).getCompatibilityVersion();
Version masterCompatibilityVersion = clusterDao.get(masterVolume.getClusterId()).getCompatibilityVersion();
return masterCompatibilityVersion.equals(slaveCompatibilityVersion);
});
eligibilityPredicates.put(GlusterGeoRepNonEligibilityReason.NO_UP_SLAVE_SERVER, slaveVolume -> {
Guid slaveUpserverId = getUpServerId(slaveVolume.getClusterId());
return slaveUpserverId != null;
});
eligibilityPredicates.put(GlusterGeoRepNonEligibilityReason.SLAVE_VOLUME_TO_BE_EMPTY, slaveVolume -> {
Guid slaveUpserverId = getUpServerId(slaveVolume.getClusterId());
return slaveUpserverId != null && checkEmptyGlusterVolume(slaveUpserverId, slaveVolume.getName());
});
return eligibilityPredicates;
}
Aggregations