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