Search in sources :

Example 6 with GlusterVolumeSnapshotConfig

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotConfig in project ovirt-engine by oVirt.

the class GlusterClusterSnapshotConfigModel method validate.

public boolean validate() {
    boolean isValid = true;
    setMessage(null);
    Iterable<EntityModel<GlusterVolumeSnapshotConfig>> items1 = getClusterConfigOptions().getItems();
    for (EntityModel<GlusterVolumeSnapshotConfig> model : items1) {
        GlusterVolumeSnapshotConfig option = model.getEntity();
        if (option.getParamValue().trim().length() == 0) {
            setMessage(ConstantsManager.getInstance().getMessages().clusterSnapshotOptionValueEmpty(option.getParamName()));
            isValid = false;
            break;
        }
    }
    return isValid;
}
Also used : GlusterVolumeSnapshotConfig(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotConfig) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel)

Example 7 with GlusterVolumeSnapshotConfig

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotConfig in project ovirt-engine by oVirt.

the class UpdateGlusterVolumeSnapshotConfigCommand method validate.

@Override
protected boolean validate() {
    if (!super.validate()) {
        return false;
    }
    if (getParameters().getClusterId() == null) {
        addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_CLUSTER_IS_NOT_VALID);
        return false;
    }
    if (getParameters().getConfigParams() == null) {
        addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_GLUSTER_VOLUME_SNAPSHOT_CONFIG_PARAMS_IS_EMPTY);
        return false;
    }
    for (GlusterVolumeSnapshotConfig param : getParameters().getConfigParams()) {
        if (StringUtils.isEmpty(param.getParamValue())) {
            addCustomValue("snapshotConfigParam", param.getParamName());
            addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_GLUSTER_VOLUME_SNAPSHOT_CONFIG_PARAM_VALUE_IS_EMPTY);
            return false;
        }
    }
    return true;
}
Also used : GlusterVolumeSnapshotConfig(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotConfig)

Example 8 with GlusterVolumeSnapshotConfig

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotConfig in project ovirt-engine by oVirt.

the class UpdateGlusterVolumeSnapshotConfigCommand method executeCommand.

@Override
protected void executeCommand() {
    Guid clusterId = getParameters().getClusterId();
    Guid volumeId = getParameters().getVolumeId();
    List<GlusterVolumeSnapshotConfig> fetchedConfigParams = glusterVolumeSnapshotConfigDao.getConfigByClusterId(clusterId);
    // segregate the fetched cluster and volume specific config params
    Map<String, GlusterVolumeSnapshotConfig> fetchedClusterConfigParams = new HashMap<>();
    Map<String, GlusterVolumeSnapshotConfig> fetchedVolumeConfigParams = new HashMap<>();
    for (GlusterVolumeSnapshotConfig param : fetchedConfigParams) {
        if (Guid.isNullOrEmpty(param.getVolumeId())) {
            fetchedClusterConfigParams.put(param.getParamName(), param);
        } else if (volumeId != null && param.getVolumeId().equals(volumeId)) {
            fetchedVolumeConfigParams.put(param.getParamName(), param);
        }
    }
    List<GlusterVolumeSnapshotConfig> configParams = getParameters().getConfigParams();
    // segregate the cluster and volume specific config params
    Map<String, GlusterVolumeSnapshotConfig> clusterConfigParams = new HashMap<>();
    Map<String, GlusterVolumeSnapshotConfig> volumeConfigParams = new HashMap<>();
    for (GlusterVolumeSnapshotConfig param : configParams) {
        if (Guid.isNullOrEmpty(param.getVolumeId())) {
            clusterConfigParams.put(param.getParamName(), param);
        } else {
            volumeConfigParams.put(param.getParamName(), param);
        }
    }
    // form the final list of updated config params
    List<GlusterVolumeSnapshotConfig> updatedClusterConfigParams = new ArrayList<>();
    for (GlusterVolumeSnapshotConfig cfgParam : clusterConfigParams.values()) {
        GlusterVolumeSnapshotConfig fetchedCfgParam = fetchedClusterConfigParams.get(cfgParam.getParamName());
        if (fetchedCfgParam != null && !fetchedCfgParam.getParamValue().equals(cfgParam.getParamValue())) {
            updatedClusterConfigParams.add(cfgParam);
        }
    }
    List<GlusterVolumeSnapshotConfig> updatedVolumeConfigParams = new ArrayList<>();
    for (GlusterVolumeSnapshotConfig cfgParam : volumeConfigParams.values()) {
        GlusterVolumeSnapshotConfig fetchedCfgParam = fetchedVolumeConfigParams.get(cfgParam.getParamName());
        if (fetchedCfgParam != null && !fetchedCfgParam.getParamValue().equals(cfgParam.getParamValue())) {
            updatedVolumeConfigParams.add(cfgParam);
        }
    }
    List<GlusterVolumeSnapshotConfig> updatedConfigs = new ArrayList<>();
    for (GlusterVolumeSnapshotConfig param : updatedClusterConfigParams) {
        updatedConfigs.add(param);
    }
    for (GlusterVolumeSnapshotConfig param : updatedVolumeConfigParams) {
        updatedConfigs.add(param);
    }
    for (GlusterVolumeSnapshotConfig config : updatedConfigs) {
        VDSReturnValue retVal = runVdsCommand(VDSCommandType.SetGlusterVolumeSnapshotConfig, new GlusterVolumeSnapshotSetConfigVDSParameters(upServer.getId(), config));
        if (!retVal.getSucceeded()) {
            failedCfgs.add(config.getParamName());
            updatesSuccessful = false;
        } else {
            if (config.getVolumeId() != null) {
                glusterVolumeSnapshotConfigDao.updateConfigByVolumeIdAndName(config.getClusterId(), config.getVolumeId(), config.getParamName(), config.getParamValue());
            } else {
                glusterVolumeSnapshotConfigDao.updateConfigByClusterIdAndName(config.getClusterId(), config.getParamName(), config.getParamValue());
            }
            updatesSuccessful = true;
        }
    }
    if (!updatesSuccessful) {
        addCustomValue("failedSnapshotConfigs", failedCfgs.toString());
    }
    setSucceeded(true);
}
Also used : GlusterVolumeSnapshotConfig(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotConfig) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) GlusterVolumeSnapshotSetConfigVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeSnapshotSetConfigVDSParameters) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 9 with GlusterVolumeSnapshotConfig

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotConfig in project ovirt-engine by oVirt.

the class GlusterDBUtils method isVolumeSnapshotHardLimitReached.

public boolean isVolumeSnapshotHardLimitReached(Guid volumeId) {
    GlusterVolumeEntity volume = glusterVolumeDao.getById(volumeId);
    if (volume != null) {
        GlusterVolumeSnapshotConfig config = glusterVolumeSnapshotConfigDao.getConfigByVolumeIdAndName(volume.getClusterId(), volumeId, "snap-max-hard-limit");
        if (config != null) {
            int snapMaxHardLimit = Integer.parseInt(config.getParamValue());
            int snapshotCount = volume.getSnapshotsCount();
            return snapshotCount >= snapMaxHardLimit;
        }
    }
    return false;
}
Also used : GlusterVolumeSnapshotConfig(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotConfig) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)

Example 10 with GlusterVolumeSnapshotConfig

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotConfig in project ovirt-engine by oVirt.

the class GlusterVolumeSnapshotConfigDaoTest method testGetGlusterVolumeSnapshotConfigByVolumeIdAndName.

@Test
public void testGetGlusterVolumeSnapshotConfigByVolumeIdAndName() {
    GlusterVolumeSnapshotConfig config = dao.getConfigByVolumeIdAndName(CLUSTER_ID, VOLUME_ID, PARAM_NAME_2);
    assertNotNull(config);
    assertEquals(config, existingConfig2);
}
Also used : GlusterVolumeSnapshotConfig(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotConfig) Test(org.junit.Test)

Aggregations

GlusterVolumeSnapshotConfig (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotConfig)23 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)5 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)5 HashMap (java.util.HashMap)4 Guid (org.ovirt.engine.core.compat.Guid)3 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)3 List (java.util.List)2 UpdateGlusterVolumeSnapshotConfigParameters (org.ovirt.engine.core.common.action.gluster.UpdateGlusterVolumeSnapshotConfigParameters)2 GlusterClusterSnapshotConfigModel (org.ovirt.engine.ui.uicommonweb.models.gluster.GlusterClusterSnapshotConfigModel)2 TextInputCell (com.google.gwt.cell.client.TextInputCell)1 Column (com.google.gwt.user.cellview.client.Column)1 NoSelectionModel (com.google.gwt.view.client.NoSelectionModel)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Inject (javax.inject.Inject)1 Named (javax.inject.Named)1 Singleton (javax.inject.Singleton)1 StringUtils (org.apache.commons.lang.StringUtils)1