Search in sources :

Example 56 with VDSReturnValue

use of org.ovirt.engine.core.common.vdscommands.VDSReturnValue in project ovirt-engine by oVirt.

the class RestoreGlusterVolumeSnapshotCommand method restoreVolumeToSnapshot.

private boolean restoreVolumeToSnapshot(Guid upServerId, GlusterVolumeEntity volume, String snapshotName) {
    if (volume != null) {
        VDSReturnValue retVal = runVdsCommand(VDSCommandType.RestoreGlusterVolumeSnapshot, new GlusterVolumeSnapshotActionVDSParameters(upServerId, volume.getName(), snapshotName));
        if (!retVal.getSucceeded()) {
            handleVdsError(AuditLogType.GLUSTER_VOLUME_SNAPSHOT_RESTORE_FAILED, retVal.getVdsError().getMessage());
            setSucceeded(false);
            return false;
        } else {
            glusterVolumeSnapshotDao.removeByName(volume.getId(), snapshotName);
            // Sync the new bricks of the volume immediately
            VDS upServer = glusterUtil.getRandomUpServer(volume.getClusterId());
            VDSReturnValue volDetailsRetVal = runVdsCommand(VDSCommandType.GetGlusterVolumeInfo, new GlusterVolumeInfoVDSParameters(upServer.getId(), volume.getClusterId(), volume.getName()));
            GlusterVolumeEntity fetchedVolume = ((Map<Guid, GlusterVolumeEntity>) volDetailsRetVal.getReturnValue()).get(volume.getId());
            List<GlusterBrickEntity> fetchedBricks = fetchedVolume.getBricks();
            if (fetchedBricks != null) {
                glusterBrickDao.removeAllInBatch(volume.getBricks());
                for (GlusterBrickEntity fetchdBrick : fetchedVolume.getBricks()) {
                    if (fetchdBrick.getServerId() != null) {
                        fetchdBrick.setStatus(GlusterStatus.UP);
                        glusterBrickDao.save(fetchdBrick);
                    } else {
                        log.warn("Invalid server details for brick " + fetchdBrick.getName() + ". Not adding now.");
                    }
                }
            }
        }
    }
    return true;
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterVolumeInfoVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeInfoVDSParameters) VDS(org.ovirt.engine.core.common.businessentities.VDS) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterVolumeSnapshotActionVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeSnapshotActionVDSParameters) Map(java.util.Map) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 57 with VDSReturnValue

use of org.ovirt.engine.core.common.vdscommands.VDSReturnValue in project ovirt-engine by oVirt.

the class ResumeGeoRepSessionCommand method executeCommand.

@Override
protected void executeCommand() {
    GlusterGeoRepSession session = getGeoRepSession();
    VDSReturnValue returnValue = runVdsCommand(VDSCommandType.ResumeGeoRepSession, new GlusterVolumeGeoRepSessionVDSParameters(upServer.getId(), session.getMasterVolumeName(), session.getSlaveHostName(), session.getSlaveVolumeName(), session.getUserName(), parameters.isForce()));
    setSucceeded(returnValue.getSucceeded());
    if (!getSucceeded()) {
        handleVdsError(AuditLogType.GLUSTER_VOLUME_GEO_REP_RESUME_FAILED, returnValue.getVdsError().getMessage());
        return;
    }
}
Also used : GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession) GlusterVolumeGeoRepSessionVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeGeoRepSessionVDSParameters) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 58 with VDSReturnValue

use of org.ovirt.engine.core.common.vdscommands.VDSReturnValue in project ovirt-engine by oVirt.

the class SetGeoRepConfigCommand method executeCommand.

@Override
protected void executeCommand() {
    GlusterGeoRepSession session = getGeoRepSession();
    String configKey = getParameters().getConfigKey();
    String configValue = getParameters().getConfigValue();
    VDSReturnValue returnValue = runVdsCommand(VDSCommandType.SetGlusterVolumeGeoRepConfig, new GlusterVolumeGeoRepConfigVdsParameters(upServer.getId(), session.getMasterVolumeName(), session.getSlaveHostName(), session.getSlaveVolumeName(), configKey, configValue, session.getUserName()));
    boolean succeeded = returnValue.getSucceeded();
    if (succeeded && configKey.equals("use_meta_volume")) {
        // Not handling failures as there's no way to figure out if the error is that the option is already set.
        runVdsCommand(VDSCommandType.SetGlusterVolumeOption, new GlusterVolumeOptionVDSParameters(upServer.getId(), "all", new GlusterVolumeOptionEntity(getGeoRepSession().getMasterVolumeId(), "cluster.enable-shared-storage", "enable")));
    }
    setSucceeded(succeeded);
    if (getSucceeded()) {
        GlusterGeoRepSessionConfiguration geoRepSessionConfig = new GlusterGeoRepSessionConfiguration();
        geoRepSessionConfig.setValue(configValue);
        geoRepSessionConfig.setKey(configKey);
        geoRepSessionConfig.setId(session.getId());
        if (glusterGeoRepDao.getGeoRepSessionConfigByKey(session.getId(), configKey) == null) {
            glusterGeoRepDao.saveConfig(geoRepSessionConfig);
        } else {
            glusterGeoRepDao.updateConfig(geoRepSessionConfig);
        }
    } else {
        handleVdsError(AuditLogType.GLUSTER_GEOREP_CONFIG_SET_FAILED, returnValue.getVdsError().getMessage());
        return;
    }
}
Also used : GlusterGeoRepSessionConfiguration(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSessionConfiguration) GlusterVolumeOptionVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeOptionVDSParameters) GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession) GlusterVolumeOptionEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) GlusterVolumeGeoRepConfigVdsParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeGeoRepConfigVdsParameters)

Example 59 with VDSReturnValue

use of org.ovirt.engine.core.common.vdscommands.VDSReturnValue in project ovirt-engine by oVirt.

the class UpdateGlusterHostPubKeyToSlaveInternalCommand method executeCommand.

@Override
protected void executeCommand() {
    final VDSReturnValue writePubKeysReturnValue = runVdsCommand(VDSCommandType.UpdateGlusterGeoRepKeys, new UpdateGlusterGeoRepKeysVDSParameters(getParameters().getId(), getParameters().getPubKeys(), getParameters().getRemoteUserName()));
    setSucceeded(writePubKeysReturnValue.getSucceeded());
    if (!writePubKeysReturnValue.getSucceeded()) {
        String errorMsg = writePubKeysReturnValue.getVdsError().getMessage();
        writePubKeysReturnValue.getVdsError().setMessage(errorMsg + " : " + vdsDao.get(getParameters().getId()).getName());
        propagateFailure(convertToActionReturnValue(writePubKeysReturnValue));
        return;
    }
}
Also used : UpdateGlusterGeoRepKeysVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.UpdateGlusterGeoRepKeysVDSParameters) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 60 with VDSReturnValue

use of org.ovirt.engine.core.common.vdscommands.VDSReturnValue 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)

Aggregations

VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)250 Guid (org.ovirt.engine.core.compat.Guid)65 ArrayList (java.util.ArrayList)43 VDS (org.ovirt.engine.core.common.businessentities.VDS)29 EngineException (org.ovirt.engine.core.common.errors.EngineException)29 Pair (org.ovirt.engine.core.common.utils.Pair)26 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)23 List (java.util.List)16 Test (org.junit.Test)15 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)15 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)15 VdsIdVDSCommandParametersBase (org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase)15 HashMap (java.util.HashMap)13 VDSError (org.ovirt.engine.core.common.errors.VDSError)13 Map (java.util.Map)11 Callable (java.util.concurrent.Callable)11 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)11 StoragePoolIsoMap (org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap)11 EngineLock (org.ovirt.engine.core.utils.lock.EngineLock)9 GlusterGeoRepSession (org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession)8