use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity in project ovirt-engine by oVirt.
the class GlusterOptionDaoTest method testUpdateVolumeOption.
@Test
public void testUpdateVolumeOption() {
GlusterVolumeOptionEntity optionAuthAllow = dao.getById(EXISTING_OPTION_ID);
assertEquals(GlusterConstants.OPTION_AUTH_ALLOW, optionAuthAllow.getKey());
assertEquals(OPTION_AUTH_ALLOW_VALUE_ALL, optionAuthAllow.getValue());
dao.updateVolumeOption(optionAuthAllow.getId(), OPTION_AUTH_ALLOW_VALUE_NEW);
GlusterVolumeOptionEntity retrievedOption = dao.getById(EXISTING_OPTION_ID);
assertNotNull(retrievedOption);
assertEquals(OPTION_AUTH_ALLOW_VALUE_NEW, retrievedOption.getValue());
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity in project ovirt-engine by oVirt.
the class GlusterSyncJobTest method verifyMocksForLightWeight.
private void verifyMocksForLightWeight() {
InOrder inOrder = inOrder(clusterDao, vdsDao, glusterUtil, glusterManager, vdsStatisticsDao, vdsDynamicDao, vdsStaticDao, volumeDao, brickDao, optionDao);
// all clusters fetched from db
inOrder.verify(clusterDao, times(1)).getAll();
// get servers of the cluster from db
inOrder.verify(vdsDao, times(1)).getAllForCluster(CLUSTER_ID);
// get the UP server from cluster
inOrder.verify(glusterUtil, times(1)).getUpServer(CLUSTER_ID);
// acquire lock on the cluster
inOrder.verify(glusterManager, times(1)).acquireLock(CLUSTER_ID);
// servers are fetched from glusterfs
inOrder.verify(glusterManager, times(1)).fetchServers(existingServer1);
// detached server SERVER_ID_3 is deleted from DB
inOrder.verify(vdsStatisticsDao, times(1)).remove(SERVER_ID_3);
inOrder.verify(vdsDynamicDao, times(1)).remove(SERVER_ID_3);
inOrder.verify(vdsStaticDao, times(1)).remove(SERVER_ID_3);
// detached server SERVER_ID_3 is removed from resource manager
inOrder.verify(glusterManager, times(1)).runVdsCommand(eq(VDSCommandType.RemoveVds), any());
// release lock on the cluster
inOrder.verify(glusterManager, times(1)).releaseLock(CLUSTER_ID);
// acquire lock on the cluster for next operation (refresh volumes)
inOrder.verify(glusterManager, times(1)).acquireLock(CLUSTER_ID);
// volumes are fetched from glusterfs
inOrder.verify(glusterManager, times(1)).fetchVolumes(any());
// get volumes by cluster id to identify those that need to be removed
inOrder.verify(volumeDao, times(1)).getByClusterId(CLUSTER_ID);
// remove deleted volumes
inOrder.verify(volumeDao, times(1)).removeAll(argThat(areRemovedVolumes()));
// create new volume
inOrder.verify(volumeDao, times(1)).save(newVolume);
// remove detached bricks
inOrder.verify(brickDao, times(1)).removeAll(argThat(containsRemovedBricks()));
// add new bricks
inOrder.verify(brickDao, times(2)).save(argThat(isAddedBrick()));
// add new options
inOrder.verify(optionDao, times(1)).saveAll(argThat(areAddedOptions()));
// update modified options
Map<String, GlusterVolumeOptionEntity> existingOptions = new HashMap<>();
existingReplVol.getOption(OPTION_NFS_DISABLE).setValue(OPTION_VALUE_ON);
existingOptions.put(OPTION_NFS_DISABLE, existingReplVol.getOption(OPTION_NFS_DISABLE));
List<GlusterVolumeOptionEntity> list = new ArrayList<>(existingOptions.values());
Collections.sort(list);
inOrder.verify(optionDao, times(1)).updateAll("UpdateGlusterVolumeOption", list);
// delete removed options
inOrder.verify(optionDao, times(1)).removeAll(argThat(areRemovedOptions()));
// release lock on the cluster
inOrder.verify(glusterManager, times(1)).releaseLock(CLUSTER_ID);
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity in project ovirt-engine by oVirt.
the class BackendGlusterVolumeResource method setOption.
@Override
public Response setOption(Action action) {
Option option = action.getOption();
validateParameters(option, "name", "value");
return doAction(ActionType.SetGlusterVolumeOption, new GlusterVolumeOptionParameters(new GlusterVolumeOptionEntity(guid, option.getName(), option.getValue())), action);
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity in project ovirt-engine by oVirt.
the class ResetGlusterVolumeOptionsCommand method executeCommand.
@Override
protected void executeCommand() {
VDSReturnValue returnValue = runVdsCommand(VDSCommandType.ResetGlusterVolumeOptions, new ResetGlusterVolumeOptionsVDSParameters(upServer.getId(), getGlusterVolumeName(), getParameters().getVolumeOption(), getParameters().isForceAction()));
setSucceeded(returnValue.getSucceeded());
if (getSucceeded()) {
if (getParameters().getVolumeOption() != null && !getParameters().getVolumeOption().getKey().isEmpty()) {
GlusterVolumeOptionEntity entity = getGlusterVolume().getOption(getParameters().getVolumeOption().getKey());
isResetAllOptions = false;
if (entity != null) {
removeOptionInDb(entity);
String optionValue = entity.getValue();
getParameters().getVolumeOption().setValue(optionValue != null ? optionValue : "");
addCustomValue(GlusterConstants.OPTION_KEY, getParameters().getVolumeOption().getKey());
addCustomValue(GlusterConstants.OPTION_VALUE, getParameters().getVolumeOption().getValue());
}
} else {
for (GlusterVolumeOptionEntity option : getGlusterVolume().getOptions()) {
removeOptionInDb(option);
}
isResetAllOptions = true;
}
} else {
handleVdsError(AuditLogType.GLUSTER_VOLUME_OPTIONS_RESET_FAILED, returnValue.getVdsError().getMessage());
return;
}
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity in project ovirt-engine by oVirt.
the class SetGlusterVolumeOptionCommand method updateOptionInDb.
/**
* Updates the volume option in DB. If the option with given key already exists for the volume, <br>
* it will be updated, else inserted.
*/
private void updateOptionInDb(final GlusterVolumeOptionEntity option) {
// update the option value if it exists, else add it
GlusterVolumeOptionEntity existingOption = getGlusterVolume().getOption(option.getKey());
if (existingOption != null) {
if (option.getValue().equalsIgnoreCase(existingOption.getValue())) {
return;
}
optionValueExists = true;
addCustomValue(GlusterConstants.OPTION_OLD_VALUE, existingOption.getValue());
glusterOptionDao.updateVolumeOption(existingOption.getId(), option.getValue());
} else {
optionValueExists = false;
glusterOptionDao.save(option);
}
}
Aggregations