use of org.ovirt.engine.core.common.utils.SizeConverter.SizeUnit 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.utils.SizeConverter.SizeUnit 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.utils.SizeConverter.SizeUnit in project ovirt-engine by oVirt.
the class CreateBrickModel method updateBrickSize.
private void updateBrickSize() {
long totalSize = 0;
// capacity.
if (getStorageDevices().getSelectedItems() != null) {
for (StorageDevice storageDevice : getStorageDevices().getSelectedItems()) {
totalSize += storageDevice.getSize();
}
}
Pair<SizeUnit, Double> convertedSize = SizeConverter.autoConvert(totalSize, SizeUnit.MiB);
setBrickSize(convertedSize);
}
Aggregations