Search in sources :

Example 11 with VdsIdVDSCommandParametersBase

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

the class StorageDeviceSyncJob method getStorageDevicesFromServer.

private List<StorageDevice> getStorageDevicesFromServer(VDS server) {
    try {
        VDSReturnValue returnValue = runVdsCommand(VDSCommandType.GetStorageDeviceList, new VdsIdVDSCommandParametersBase(server.getId()));
        if (returnValue.getSucceeded()) {
            return (List<StorageDevice>) returnValue.getReturnValue();
        } else {
            log.error("VDS error retriving storage device {}", returnValue.getVdsError().getMessage());
            log.debug("VDS Error", returnValue.getVdsError());
            return null;
        }
    } catch (Exception e) {
        log.error("Exception retriving storage device from vds {}", e.getMessage());
        log.debug("Exception", e);
        return null;
    }
}
Also used : VdsIdVDSCommandParametersBase(org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase) ArrayList(java.util.ArrayList) List(java.util.List) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 12 with VdsIdVDSCommandParametersBase

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

the class SyncStorageDevicesCommand method executeCommand.

@Override
protected void executeCommand() {
    VDSReturnValue returnValue = runVdsCommand(VDSCommandType.GetStorageDeviceList, new VdsIdVDSCommandParametersBase(getVds().getId()));
    if (returnValue.getSucceeded()) {
        List<StorageDevice> storageDevices = (List<StorageDevice>) returnValue.getReturnValue();
        getStorageDeviceSyncJobInstance().updateStorageDevices(getVds(), storageDevices);
        setSucceeded(true);
    } else {
        handleVdsError(returnValue);
        setSucceeded(false);
    }
}
Also used : VdsIdVDSCommandParametersBase(org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase) StorageDevice(org.ovirt.engine.core.common.businessentities.gluster.StorageDevice) List(java.util.List) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 13 with VdsIdVDSCommandParametersBase

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

the class InitGlusterCommandHelper method initGlusterHost.

public boolean initGlusterHost(VDS vds) {
    VDSReturnValue returnValue = runVdsCommand(VDSCommandType.GetGlusterHostUUID, new VdsIdVDSCommandParametersBase(vds.getId()));
    if (returnValue.getSucceeded() && returnValue.getReturnValue() != null) {
        Guid addedServerUuid = Guid.createGuidFromString((String) returnValue.getReturnValue());
        if (hostUuidExists(vds, addedServerUuid)) {
            setNonOperational(vds, NonOperationalReason.GLUSTER_HOST_UUID_ALREADY_EXISTS, null);
            return false;
        }
        saveGlusterHostUuid(vds, addedServerUuid);
    } else {
        setNonOperational(vds, NonOperationalReason.GLUSTER_HOST_UUID_NOT_FOUND, null);
        return false;
    }
    refreshGlusterStorageDevices(vds);
    boolean ret = initGlusterPeerProcess(vds);
    glusterServerDao.updatePeerStatus(vds.getId(), ret ? PeerStatus.CONNECTED : PeerStatus.DISCONNECTED);
    // add webhook on cluster if eventing is supported
    if (ret) {
        addGlusterWebhook(vds);
        // ensure that webhooks from peers are synced.
        syncGlusterWebhook(vds);
    }
    return ret;
}
Also used : VdsIdVDSCommandParametersBase(org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase) Guid(org.ovirt.engine.core.compat.Guid) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 14 with VdsIdVDSCommandParametersBase

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

the class HostMaintenanceCallback method stopGlusterServices.

private void stopGlusterServices(Guid vdsId) {
    // Stop glusterd service first
    boolean succeeded = resourceManager.runVdsCommand(VDSCommandType.ManageGlusterService, new GlusterServiceVDSParameters(vdsId, Arrays.asList("glusterd"), "stop")).getSucceeded();
    if (succeeded) {
        // Stop other gluster related processes on the node
        succeeded = resourceManager.runVdsCommand(VDSCommandType.StopGlusterProcesses, new VdsIdVDSCommandParametersBase(vdsId)).getSucceeded();
        // Mark the bricks as DOWN on this node
        if (succeeded) {
            List<GlusterBrickEntity> bricks = glusterBrickDao.getGlusterVolumeBricksByServerId(vdsId);
            bricks.forEach(brick -> brick.setStatus(GlusterStatus.DOWN));
            glusterBrickDao.updateBrickStatuses(bricks);
        }
    }
    if (!succeeded) {
        log.error("Failed to stop gluster services while moving the host '{}' to maintenance", getHostName(vdsId));
    }
}
Also used : VdsIdVDSCommandParametersBase(org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase) GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterServiceVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterServiceVDSParameters)

Example 15 with VdsIdVDSCommandParametersBase

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

the class GlusterSyncJob method syncServers.

private void syncServers(Cluster cluster, List<VDS> existingServers, List<GlusterServerInfo> fetchedServers) {
    log.debug("Existing servers list returned '{}' comparing with fetched servers '{}'", existingServers, fetchedServers);
    boolean serverRemoved = false;
    Network glusterNetwork = findGlusterNetwork(cluster.getId());
    for (VDS server : existingServers) {
        GlusterServerInfo glusterServer = findGlusterServer(server, fetchedServers);
        if (isSyncableStatus(server.getStatus())) {
            if (glusterServer == null) {
                if (cluster.supportsVirtService()) {
                    // If the cluster supports virt service as well, we should not be removing any servers from it, even
                    // if they have been removed from the Gluster cluster using the Gluster cli, as they could
                    // potentially be
                    // used for running VMs. Will mark this server status as DISCONNECTED instead
                    log.debug("As cluster '{}' supports virt service as well, server '{}' detected as removed from glusterfs will not be removed from engine", cluster.getName(), server.getHostName());
                    setNonOperational(server);
                    continue;
                }
                log.info("Server '{}' has been removed directly using the gluster CLI. Removing it from engine as well.", server.getName());
                logUtil.logServerMessage(server, AuditLogType.GLUSTER_SERVER_REMOVED_FROM_CLI);
                try (EngineLock lock = glusterUtil.acquireGlusterLockWait(server.getId())) {
                    removeServerFromDb(server);
                    // if last but one server, reset alternate probed address for last server
                    checkAndResetKnownAddress(existingServers, server);
                    // remove the server from resource manager
                    runVdsCommand(VDSCommandType.RemoveVds, new RemoveVdsVDSCommandParameters(server.getId()));
                    serverRemoved = true;
                } catch (Exception e) {
                    log.error("Error while removing server '{}' from database: {}", server.getName(), e.getMessage());
                    log.debug("Exception", e);
                }
            } else if (server.getStatus() == VDSStatus.Up && glusterServer.getStatus() == PeerStatus.DISCONNECTED) {
                // check gluster is running, if down then move the host to Non-Operational
                VDSReturnValue returnValue = runVdsCommand(VDSCommandType.GlusterServersList, new VdsIdVDSCommandParametersBase(server.getId()));
                if (!returnValue.getSucceeded()) {
                    setNonOperational(server);
                }
            } else {
                // update correct status and check if all interfaces with gluster network have been peer probed.
                updateStatusAndpeerProbeOtherIface(glusterNetwork, server, glusterServer);
            }
        }
    }
    if (serverRemoved) {
        log.info("Servers detached using gluster CLI is removed from engine after inspecting the Gluster servers" + " list returned '{}' - comparing with db servers '{}'", fetchedServers, existingServers);
    }
}
Also used : RemoveVdsVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.RemoveVdsVDSCommandParameters) VdsIdVDSCommandParametersBase(org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase) VDS(org.ovirt.engine.core.common.businessentities.VDS) Network(org.ovirt.engine.core.common.businessentities.network.Network) GlusterServerInfo(org.ovirt.engine.core.common.businessentities.gluster.GlusterServerInfo) EngineLock(org.ovirt.engine.core.utils.lock.EngineLock) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Aggregations

VdsIdVDSCommandParametersBase (org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase)17 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)15 VDS (org.ovirt.engine.core.common.businessentities.VDS)6 List (java.util.List)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 Guid (org.ovirt.engine.core.compat.Guid)4 EngineException (org.ovirt.engine.core.common.errors.EngineException)3 Collections (java.util.Collections)2 Map (java.util.Map)2 Callable (java.util.concurrent.Callable)2 Collectors (java.util.stream.Collectors)2 Inject (javax.inject.Inject)2 AsyncTaskStatus (org.ovirt.engine.core.common.businessentities.AsyncTaskStatus)2 Pair (org.ovirt.engine.core.common.utils.Pair)2 AuditLogable (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable)2 EngineLock (org.ovirt.engine.core.utils.lock.EngineLock)2 MessageFormat (java.text.MessageFormat)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1