Search in sources :

Example 6 with GlusterVolumeOptionEntity

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());
}
Also used : GlusterVolumeOptionEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity) Test(org.junit.Test)

Example 7 with GlusterVolumeOptionEntity

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);
}
Also used : InOrder(org.mockito.InOrder) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) GlusterVolumeOptionEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity)

Example 8 with GlusterVolumeOptionEntity

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);
}
Also used : GlusterVolumeOptionParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeOptionParameters) Option(org.ovirt.engine.api.model.Option) GlusterVolumeOptionEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity)

Example 9 with GlusterVolumeOptionEntity

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;
    }
}
Also used : ResetGlusterVolumeOptionsVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.ResetGlusterVolumeOptionsVDSParameters) GlusterVolumeOptionEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 10 with GlusterVolumeOptionEntity

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);
    }
}
Also used : GlusterVolumeOptionEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity)

Aggregations

GlusterVolumeOptionEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity)18 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)5 GlusterVolumeOptionParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeOptionParameters)3 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)3 Test (org.junit.Test)2 Option (org.ovirt.engine.api.model.Option)2 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)2 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)2 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)2 Set (java.util.Set)1 InOrder (org.mockito.InOrder)1 GlusterVolume (org.ovirt.engine.api.model.GlusterVolume)1 Options (org.ovirt.engine.api.model.Options)1 TransportType (org.ovirt.engine.api.model.TransportType)1 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1 ResetGlusterVolumeOptionsParameters (org.ovirt.engine.core.common.action.gluster.ResetGlusterVolumeOptionsParameters)1 GlusterGeoRepSession (org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession)1 GlusterGeoRepSessionConfiguration (org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSessionConfiguration)1 GlusterVolumeOptionInfo (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionInfo)1