Search in sources :

Example 1 with ClusterDao

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;
}
Also used : Cluster(org.ovirt.engine.core.common.businessentities.Cluster) ClusterDao(org.ovirt.engine.core.dao.ClusterDao)

Example 2 with ClusterDao

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);
}
Also used : ClusterDao(org.ovirt.engine.core.dao.ClusterDao) Guid(org.ovirt.engine.core.compat.Guid)

Example 3 with ClusterDao

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);
}
Also used : Cluster(org.ovirt.engine.core.common.businessentities.Cluster) MacPoolPerCluster(org.ovirt.engine.core.bll.network.macpool.MacPoolPerCluster) ClusterDao(org.ovirt.engine.core.dao.ClusterDao)

Example 4 with ClusterDao

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;
}
Also used : GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession) ClusterDao(org.ovirt.engine.core.dao.ClusterDao) Backend(org.ovirt.engine.core.bll.Backend) Predicate(java.util.function.Predicate) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) Guid(org.ovirt.engine.core.compat.Guid) HashMap(java.util.HashMap) GlusterVolumeVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeVDSParameters) GlusterGeoRepDao(org.ovirt.engine.core.dao.gluster.GlusterGeoRepDao) Singleton(javax.inject.Singleton) Collectors(java.util.stream.Collectors) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) Inject(javax.inject.Inject) GlusterStatus(org.ovirt.engine.core.common.businessentities.gluster.GlusterStatus) List(java.util.List) Map(java.util.Map) VDSCommandType(org.ovirt.engine.core.common.vdscommands.VDSCommandType) Version(org.ovirt.engine.core.compat.Version) VDS(org.ovirt.engine.core.common.businessentities.VDS) GlusterGeoRepNonEligibilityReason(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepNonEligibilityReason) HashMap(java.util.HashMap) Version(org.ovirt.engine.core.compat.Version) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterGeoRepNonEligibilityReason(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepNonEligibilityReason) Guid(org.ovirt.engine.core.compat.Guid) ClusterDao(org.ovirt.engine.core.dao.ClusterDao) Predicate(java.util.function.Predicate)

Aggregations

ClusterDao (org.ovirt.engine.core.dao.ClusterDao)4 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)2 Guid (org.ovirt.engine.core.compat.Guid)2 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Predicate (java.util.function.Predicate)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 Singleton (javax.inject.Singleton)1 Backend (org.ovirt.engine.core.bll.Backend)1 MacPoolPerCluster (org.ovirt.engine.core.bll.network.macpool.MacPoolPerCluster)1 VDS (org.ovirt.engine.core.common.businessentities.VDS)1 GlusterGeoRepNonEligibilityReason (org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepNonEligibilityReason)1 GlusterGeoRepSession (org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession)1 GlusterStatus (org.ovirt.engine.core.common.businessentities.gluster.GlusterStatus)1 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)1 VDSCommandType (org.ovirt.engine.core.common.vdscommands.VDSCommandType)1 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)1 GlusterVolumeVDSParameters (org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeVDSParameters)1