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;
}
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);
}
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);
}
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);
}
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;
}
Aggregations