use of org.ovirt.engine.core.common.businessentities.gluster.StorageDevice in project ovirt-engine by oVirt.
the class CreateBrickCommand method validate.
@Override
protected boolean validate() {
Cluster cluster = getCluster();
if (!cluster.supportsGlusterService()) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_STORAGE_PROVISIONING_NOT_SUPPORTED_BY_CLUSTER);
}
HostValidator validator = HostValidator.createInstance(getVds());
if (!validate(validator.isUp())) {
return false;
}
String deviceType;
if (getParameters().getDisks() == null || getParameters().getDisks().isEmpty()) {
addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_STORAGE_DEVICE_REQUIRED);
return false;
} else {
deviceType = getParameters().getDisks().get(0).getDevType();
}
for (StorageDevice device : getParameters().getDisks()) {
// for performance reasons.
if (!Objects.equals(deviceType, device.getDevType())) {
addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_DIFFERENT_STORAGE_DEVICE_TYPES_SELECTED);
return false;
}
// Ensure that device is not already used by some other brick or LVM.
if (!device.getCanCreateBrick()) {
addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_DEVICE_IS_ALREADY_IN_USE);
addValidationMessageVariable("storageDevice", device.getName());
return false;
}
}
return true;
}
use of org.ovirt.engine.core.common.businessentities.gluster.StorageDevice in project ovirt-engine by oVirt.
the class CreateBrickCommand method runAnsibleCreateBrickPlaybook.
private void runAnsibleCreateBrickPlaybook() throws IOException, InterruptedException {
List<String> disks = new ArrayList<>();
Double totalSize = 0.0;
for (StorageDevice device : getParameters().getDisks()) {
disks.add(device.getDevPath());
// size is returned in MiB
totalSize += device.getSize();
}
if (totalSize < MIN_VG_SIZE) {
totalSize = totalSize - MIN_METADATA_PERCENT * totalSize;
} else {
totalSize = totalSize - DEFAULT_METADATA_SIZE_MB;
}
Pair<SizeUnit, Double> convertedSize = SizeConverter.autoConvert(totalSize.longValue(), SizeUnit.MiB);
String deviceSize = convertedSize.getSecond() + convertedSize.getFirst().toString();
String ssdDevice = "";
if (getParameters().getCacheDevice() != null) {
ssdDevice = getParameters().getCacheDevice().getDevPath();
}
int diskCount = getParameters().getNoOfPhysicalDisksInRaidVolume() == null ? 1 : getParameters().getNoOfPhysicalDisksInRaidVolume();
AnsibleCommandBuilder command = new AnsibleCommandBuilder().hostnames(getVds().getHostName()).variables(new Pair<>("ssd", ssdDevice), new Pair<>("disks", JsonHelper.objectToJson(disks, false)), new Pair<>("vgname", "RHGS_vg_" + getParameters().getLvName()), new Pair<>("size", deviceSize), new Pair<>("diskcount", diskCount), new Pair<>("stripesize", getParameters().getStripeSize()), new Pair<>("wipefs", "yes"), new Pair<>("disktype", getParameters().getRaidType().toString()), new Pair<>("lvname", getParameters().getLvName() + "_lv"), new Pair<>("cache_lvname", getParameters().getLvName() + "_cache_lv"), new Pair<>("cache_lvsize", getParameters().getCacheSize() + "GiB"), new Pair<>("cachemode", getParameters().getCacheMode()), new Pair<>("fstype", GlusterConstants.FS_TYPE_XFS), new Pair<>("mntpath", getParameters().getMountPoint())).logFileDirectory(CreateBrickCommand.CREATE_BRICK_LOG_DIRECTORY).logFilePrefix("ovirt-gluster-brick-ansible").logFileName(getVds().getHostName()).logFileSuffix(getCorrelationId()).playbook(AnsibleConstants.CREATE_BRICK_PLAYBOOK);
AnsibleReturnValue ansibleReturnValue = ansibleExecutor.runCommand(command);
if (ansibleReturnValue.getAnsibleReturnCode() != AnsibleReturnCode.OK) {
log.error("Failed to execute Ansible create brick role. Please check logs for more details: {}", command.logFile());
throw new EngineException(EngineError.GeneralException, String.format("Failed to execute Ansible create brick role. Please check logs for more details: %1$s", command.logFile()));
}
}
use of org.ovirt.engine.core.common.businessentities.gluster.StorageDevice in project ovirt-engine by oVirt.
the class HostGlusterStorageDevicesListModel method createBrick.
private void createBrick() {
if (getWindow() != null) {
return;
}
VDS host = getEntity();
if (host == null) {
return;
}
final CreateBrickModel lvModel = new CreateBrickModel();
lvModel.setTitle(ConstantsManager.getInstance().getConstants().createBrick());
lvModel.setHelpTag(HelpTag.create_brick);
// $NON-NLS-1$
lvModel.setHashName("create_brick");
lvModel.startProgress(ConstantsManager.getInstance().getConstants().fetchingDataMessage());
setWindow(lvModel);
lvModel.getRaidTypeList().setSelectedItem(RaidType.RAID6);
List<StorageDevice> selectedDevices = getSelectedItems();
lvModel.getStorageDevices().setItems(selectedDevices);
lvModel.setSelectedDevices(selectedDevices);
AsyncQuery<String> asyncQueryForDefaultMountPoint = lvModel.asyncQuery(defaultMountPoint -> {
lvModel.stopProgress();
lvModel.getDefaultMountFolder().setEntity(defaultMountPoint);
});
AsyncDataProvider.getInstance().getConfigFromCache(new GetConfigurationValueParameters(ConfigValues.GlusterDefaultBrickMountPoint, AsyncDataProvider.getInstance().getDefaultConfigurationVersion()), asyncQueryForDefaultMountPoint);
AsyncDataProvider.getInstance().getStorageDevices(new AsyncQuery<>(returnValue -> {
if (returnValue != null) {
List<StorageDevice> storageDeviceList = new ArrayList<>();
// $NON-NLS-1$
storageDeviceList.add(null);
for (StorageDevice storagedevice : returnValue) {
if (storagedevice.getCanCreateBrick() && !selectedDevices.contains(storagedevice)) {
storageDeviceList.add(storagedevice);
}
}
lvModel.getCacheDevicePathTypeList().setItems(storageDeviceList);
}
}), host.getId());
// $NON-NLS-1$
UICommand okCommand = UICommand.createDefaultOkUiCommand("onCreateBrick", this);
lvModel.getCommands().add(okCommand);
// $NON-NLS-1$
UICommand cancelCommand = UICommand.createCancelUiCommand("closeWindow", this);
lvModel.getCommands().add(cancelCommand);
}
use of org.ovirt.engine.core.common.businessentities.gluster.StorageDevice in project ovirt-engine by oVirt.
the class SubTabHostGlusterStorageDevicesView method initTable.
void initTable() {
getTable().enableColumnResizing();
StorageDeviceStatusColumn storageDeviceStatusColumn = new StorageDeviceStatusColumn();
storageDeviceStatusColumn.makeSortable();
// $NON-NLS-1$
getTable().addColumn(storageDeviceStatusColumn, constants.empty(), "30px");
AbstractTextColumn<StorageDevice> deviceNameColumn = new AbstractTextColumn<StorageDevice>() {
@Override
public String getValue(StorageDevice object) {
return object.getName();
}
};
deviceNameColumn.makeSortable();
// $NON-NLS-1$
getTable().addColumn(deviceNameColumn, constants.deviceName(), "250px");
AbstractTextColumn<StorageDevice> descriptionColumn = new AbstractTextColumn<StorageDevice>() {
@Override
public String getValue(StorageDevice object) {
return object.getDescription();
}
};
descriptionColumn.makeSortable();
// $NON-NLS-1$
getTable().addColumn(descriptionColumn, constants.description(), "300px");
AbstractTextColumn<StorageDevice> sizeColumn = new AbstractTextColumn<StorageDevice>() {
@Override
public String getValue(StorageDevice object) {
Pair<SizeUnit, Double> convertedSize = SizeConverter.autoConvert(object.getSize(), SizeUnit.MiB);
// $NON-NLS-1$
return formatSize(convertedSize.getSecond()) + " " + convertedSize.getFirst().toString();
}
};
sizeColumn.makeSortable();
// $NON-NLS-1$
getTable().addColumn(sizeColumn, constants.size(), "100px");
AbstractTextColumn<StorageDevice> mountPointColumn = new AbstractTextColumn<StorageDevice>() {
@Override
public String getValue(StorageDevice object) {
return object.getMountPoint();
}
};
mountPointColumn.makeSortable();
// $NON-NLS-1$
getTable().addColumn(mountPointColumn, constants.mountPoint(), "170px");
AbstractTextColumn<StorageDevice> fsTypeColumn = new AbstractTextColumn<StorageDevice>() {
@Override
public String getValue(StorageDevice object) {
return object.getFsType();
}
};
fsTypeColumn.makeSortable();
// $NON-NLS-1$
getTable().addColumn(fsTypeColumn, constants.fileSystemType(), "170px");
}
use of org.ovirt.engine.core.common.businessentities.gluster.StorageDevice in project ovirt-engine by oVirt.
the class StorageDeviceSyncJobTest method getStorageDevicesVDSReturnVal.
private Object getStorageDevicesVDSReturnVal(Guid hostId) {
VDSReturnValue vdsRetValue = new VDSReturnValue();
vdsRetValue.setSucceeded(true);
if (HOST_ID_WITH_NEW_DEVICES.equals(hostId)) {
vdsRetValue.setReturnValue(Arrays.asList(getStorageDevice("sda", null), getStorageDevice("sdb", null), getStorageDevice("sdc", null)));
} else if (HOST_ID_WITH_DEVICES_CHANGED.equals(hostId)) {
List<StorageDevice> devices = new ArrayList<>();
devices.add(getStorageDevice("device-without-anychange", DEVICE_WITHOUT_ANYCHANGE));
devices.add(getStorageDevice("new-device-with-name-change", DEVICE_WITH_NAME_CHANGE));
StorageDevice device = getStorageDevice("device-with-change", DEVICE_WITH_CHANGE);
device.setMountPoint("/temp-mount");
device.setFsType("XFS");
device.setSize(12345678L);
devices.add(device);
device = getStorageDevice("device-with-devuuid-but-name-changed-1", DEVICE_WITH_DEVUUID_BUT_NAME_CHANGED);
device.setDevUuid("123456");
devices.add(device);
devices.add(getStorageDevice("device-with-devuuid-but-name-changed", null));
vdsRetValue.setReturnValue(devices);
} else {
vdsRetValue.setReturnValue(Collections.emptyList());
}
return vdsRetValue;
}
Aggregations