Search in sources :

Example 16 with GlusterHookEntity

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

the class BackendGlusterHookResourceTest method getEntity.

@Override
protected GlusterHookEntity getEntity(int index) {
    GlusterHookEntity hookEntity = new GlusterHookEntity();
    hookEntity.setId(hookId);
    hookEntity.setClusterId(clusterId);
    hookEntity.setChecksum(CHECKSUM);
    return hookEntity;
}
Also used : GlusterHookEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterHookEntity)

Example 17 with GlusterHookEntity

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

the class BackendGlusterHooksResourceTest method setUpHooksQueryExpectations.

private void setUpHooksQueryExpectations(Object failure) {
    QueryReturnValue queryResult = new QueryReturnValue();
    queryResult.setSucceeded(failure == null);
    List<GlusterHookEntity> entities = new ArrayList<>();
    if (failure == null) {
        for (int i = 0; i < NAMES.length; i++) {
            entities.add(getEntity(i));
        }
        queryResult.setReturnValue(entities);
    } else {
        if (failure instanceof String) {
            queryResult.setExceptionString((String) failure);
            setUpL10nExpectations((String) failure);
        } else if (failure instanceof Exception) {
            when(backend.runQuery(eq(QueryType.GetGlusterHooks), any())).thenThrow((Exception) failure);
            return;
        }
    }
    when(backend.runQuery(eq(QueryType.GetGlusterHooks), any())).thenReturn(queryResult);
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) GlusterHookEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterHookEntity) ArrayList(java.util.ArrayList) WebApplicationException(javax.ws.rs.WebApplicationException)

Example 18 with GlusterHookEntity

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

the class GetGlusterHookByIdQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    GlusterHookEntity hookEntity = glusterHooksDao.getById(getParameters().getHookId());
    if (hookEntity != null && getParameters().isIncludeServerHooks()) {
        hookEntity.setServerHooks(glusterHooksDao.getGlusterServerHooks(getParameters().getHookId()));
    }
    getQueryReturnValue().setReturnValue(hookEntity);
}
Also used : GlusterHookEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterHookEntity)

Example 19 with GlusterHookEntity

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

the class GetGlusterHookContentQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    GlusterHookEntity hook = glusterHooksDao.getById(getParameters().getGlusterHookId());
    String content = "";
    if (getParameters().getGlusterServerId() == null) {
        if (hook.getContentType().equals(GlusterHookContentType.TEXT)) {
            content = glusterHooksDao.getGlusterHookContent(getParameters().getGlusterHookId());
        }
    } else {
        GlusterServerHook serverHook = glusterHooksDao.getGlusterServerHook(hook.getId(), getParameters().getGlusterServerId());
        if (serverHook != null && serverHook.getContentType() == GlusterHookContentType.TEXT) {
            VDSReturnValue returnValue = runVdsCommand(VDSCommandType.GetGlusterHookContent, new GlusterHookVDSParameters(getParameters().getGlusterServerId(), hook.getGlusterCommand(), hook.getStage(), hook.getName()));
            if (returnValue.getSucceeded()) {
                content = (String) returnValue.getReturnValue();
            }
        }
    }
    content = StringUtils.newStringUtf8(Base64.decodeBase64(content));
    getQueryReturnValue().setReturnValue(content);
}
Also used : GlusterHookEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterHookEntity) GlusterServerHook(org.ovirt.engine.core.common.businessentities.gluster.GlusterServerHook) GlusterHookVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterHookVDSParameters) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 20 with GlusterHookEntity

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

the class GlusterHookSyncJobTest method getHook.

private GlusterHookEntity getHook(int index, boolean setId) {
    GlusterHookEntity hook = new GlusterHookEntity();
    hook.setChecksum("234230--090934");
    hook.setContentType(GlusterHookContentType.TEXT);
    hook.setStatus(GlusterHookStatus.ENABLED);
    hook.setGlusterCommand("create");
    hook.setStage("PRE");
    hook.setName("hook-" + index);
    if (setId) {
        hook.setId(EXISTING_HOOK_IDS[index]);
        hook.setClusterId(CLUSTER_GUIDS[0]);
    }
    return hook;
}
Also used : GlusterHookEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterHookEntity)

Aggregations

GlusterHookEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterHookEntity)34 Test (org.junit.Test)13 ArrayList (java.util.ArrayList)11 GlusterServerHook (org.ovirt.engine.core.common.businessentities.gluster.GlusterServerHook)8 Guid (org.ovirt.engine.core.compat.Guid)6 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)5 GlusterHookParameters (org.ovirt.engine.core.common.action.gluster.GlusterHookParameters)5 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)5 List (java.util.List)4 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)4 ActionType (org.ovirt.engine.core.common.action.ActionType)3 GlusterClusterParameters (org.ovirt.engine.core.common.action.gluster.GlusterClusterParameters)3 GlusterHookManageParameters (org.ovirt.engine.core.common.action.gluster.GlusterHookManageParameters)3 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)3 GlusterHookContentType (org.ovirt.engine.core.common.businessentities.gluster.GlusterHookContentType)3 GlusterHookStatus (org.ovirt.engine.core.common.businessentities.gluster.GlusterHookStatus)3 ApplicationMode (org.ovirt.engine.core.common.mode.ApplicationMode)3 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)3 Frontend (org.ovirt.engine.ui.frontend.Frontend)3 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)3