Search in sources :

Example 1 with GlusterVolumeOptionEntity

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

the class VolumeParameterListModel method resetParameter.

private void resetParameter() {
    if (getWindow() != null) {
        return;
    }
    if (getSelectedItem() == null) {
        return;
    }
    GlusterVolumeOptionEntity selectedOption = getSelectedItem();
    ConfirmationModel model = new ConfirmationModel();
    setWindow(model);
    model.setTitle(ConstantsManager.getInstance().getConstants().resetOptionVolumeTitle());
    model.setHelpTag(HelpTag.reset_option);
    // $NON-NLS-1$
    model.setHashName("reset_option");
    model.setMessage(ConstantsManager.getInstance().getConstants().resetOptionVolumeMsg());
    ArrayList<String> list = new ArrayList<>();
    list.add(selectedOption.getKey());
    model.setItems(list);
    // $NON-NLS-1$
    UICommand okCommand = UICommand.createDefaultOkUiCommand("OnResetParameter", this);
    model.getCommands().add(okCommand);
    // $NON-NLS-1$
    UICommand cancelCommand = UICommand.createCancelUiCommand("OnCancel", this);
    model.getCommands().add(cancelCommand);
}
Also used : ArrayList(java.util.ArrayList) GlusterVolumeOptionEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)

Example 2 with GlusterVolumeOptionEntity

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

the class VolumeParameterListModel method onSetParameter.

private void onSetParameter() {
    if (getEntity() == null) {
        return;
    }
    GlusterVolumeEntity volume = getEntity();
    VolumeParameterModel model = (VolumeParameterModel) getWindow();
    if (!model.validate()) {
        return;
    }
    GlusterVolumeOptionEntity option = new GlusterVolumeOptionEntity();
    option.setVolumeId(volume.getId());
    option.setKey(model.getKeyList().getSelectedItem());
    option.setValue(model.getValue().getEntity());
    model.startProgress();
    Frontend.getInstance().runAction(ActionType.SetGlusterVolumeOption, new GlusterVolumeOptionParameters(option), result -> {
        VolumeParameterListModel localModel = (VolumeParameterListModel) result.getState();
        localModel.postOnSetParameter(result.getReturnValue());
    }, this);
}
Also used : GlusterVolumeOptionParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeOptionParameters) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterVolumeOptionEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity)

Example 3 with GlusterVolumeOptionEntity

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

the class GlusterVolumeMapper method map.

@Mapping(from = GlusterVolumeEntity.class, to = GlusterVolume.class)
public static GlusterVolume map(GlusterVolumeEntity fromVolume, GlusterVolume toVolume) {
    GlusterVolume volume = toVolume != null ? toVolume : new GlusterVolume();
    if (fromVolume.getId() != null) {
        volume.setId(fromVolume.getId().toString());
    }
    if (fromVolume.getName() != null) {
        volume.setName(fromVolume.getName());
    }
    if (fromVolume.getVolumeType() != null) {
        volume.setVolumeType(map(fromVolume.getVolumeType(), null));
    }
    if (fromVolume.getTransportTypes() != null) {
        ArrayList<TransportType> transportTypeList = new ArrayList<>();
        for (org.ovirt.engine.core.common.businessentities.gluster.TransportType transportType : fromVolume.getTransportTypes()) {
            transportTypeList.add(map(transportType, null));
        }
        volume.setTransportTypes(new GlusterVolume.TransportTypesList());
        volume.getTransportTypes().getTransportTypes().addAll(transportTypeList);
    }
    volume.setReplicaCount(fromVolume.getReplicaCount());
    volume.setStripeCount(fromVolume.getStripeCount());
    volume.setDisperseCount(fromVolume.getDisperseCount());
    volume.setRedundancyCount(fromVolume.getRedundancyCount());
    if (fromVolume.getStatus() != null) {
        volume.setStatus(mapVolumeStatus(fromVolume.getStatus()));
    }
    if (fromVolume.getOptions() != null) {
        Options glusterOptions = new Options();
        List<Option> options = glusterOptions.getOptions();
        for (GlusterVolumeOptionEntity option : fromVolume.getOptions()) {
            options.add(mapOption(option));
        }
        volume.setOptions(glusterOptions);
    }
    return volume;
}
Also used : Options(org.ovirt.engine.api.model.Options) GlusterVolume(org.ovirt.engine.api.model.GlusterVolume) ArrayList(java.util.ArrayList) GlusterVolumeOptionEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity) Option(org.ovirt.engine.api.model.Option) TransportType(org.ovirt.engine.api.model.TransportType)

Example 4 with GlusterVolumeOptionEntity

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

the class SetGeoRepConfigCommand method executeCommand.

@Override
protected void executeCommand() {
    GlusterGeoRepSession session = getGeoRepSession();
    String configKey = getParameters().getConfigKey();
    String configValue = getParameters().getConfigValue();
    VDSReturnValue returnValue = runVdsCommand(VDSCommandType.SetGlusterVolumeGeoRepConfig, new GlusterVolumeGeoRepConfigVdsParameters(upServer.getId(), session.getMasterVolumeName(), session.getSlaveHostName(), session.getSlaveVolumeName(), configKey, configValue, session.getUserName()));
    boolean succeeded = returnValue.getSucceeded();
    if (succeeded && configKey.equals("use_meta_volume")) {
        // Not handling failures as there's no way to figure out if the error is that the option is already set.
        runVdsCommand(VDSCommandType.SetGlusterVolumeOption, new GlusterVolumeOptionVDSParameters(upServer.getId(), "all", new GlusterVolumeOptionEntity(getGeoRepSession().getMasterVolumeId(), "cluster.enable-shared-storage", "enable")));
    }
    setSucceeded(succeeded);
    if (getSucceeded()) {
        GlusterGeoRepSessionConfiguration geoRepSessionConfig = new GlusterGeoRepSessionConfiguration();
        geoRepSessionConfig.setValue(configValue);
        geoRepSessionConfig.setKey(configKey);
        geoRepSessionConfig.setId(session.getId());
        if (glusterGeoRepDao.getGeoRepSessionConfigByKey(session.getId(), configKey) == null) {
            glusterGeoRepDao.saveConfig(geoRepSessionConfig);
        } else {
            glusterGeoRepDao.updateConfig(geoRepSessionConfig);
        }
    } else {
        handleVdsError(AuditLogType.GLUSTER_GEOREP_CONFIG_SET_FAILED, returnValue.getVdsError().getMessage());
        return;
    }
}
Also used : GlusterGeoRepSessionConfiguration(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSessionConfiguration) GlusterVolumeOptionVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeOptionVDSParameters) GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession) GlusterVolumeOptionEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) GlusterVolumeGeoRepConfigVdsParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeGeoRepConfigVdsParameters)

Example 5 with GlusterVolumeOptionEntity

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

the class GlusterOptionDaoTest method testSaveAndGetById.

@Test
public void testSaveAndGetById() {
    GlusterVolumeOptionEntity newOption = new GlusterVolumeOptionEntity(EXISTING_VOL_ID, OPTION_AUTH_REJECT, OPTION_AUTH_REJECT_VALUE);
    dao.save(newOption);
    GlusterVolumeOptionEntity retrievedOption = dao.getById(newOption.getId());
    assertNotNull(retrievedOption);
    assertEquals(newOption, retrievedOption);
}
Also used : GlusterVolumeOptionEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity) Test(org.junit.Test)

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