Search in sources :

Example 1 with SizeUnit

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()));
    }
}
Also used : SizeUnit(org.ovirt.engine.core.common.utils.SizeConverter.SizeUnit) AnsibleReturnValue(org.ovirt.engine.core.common.utils.ansible.AnsibleReturnValue) StorageDevice(org.ovirt.engine.core.common.businessentities.gluster.StorageDevice) AnsibleCommandBuilder(org.ovirt.engine.core.common.utils.ansible.AnsibleCommandBuilder) ArrayList(java.util.ArrayList) EngineException(org.ovirt.engine.core.common.errors.EngineException) Pair(org.ovirt.engine.core.common.utils.Pair)

Example 2 with SizeUnit

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");
}
Also used : SizeUnit(org.ovirt.engine.core.common.utils.SizeConverter.SizeUnit) StorageDevice(org.ovirt.engine.core.common.businessentities.gluster.StorageDevice) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) StorageDeviceStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.StorageDeviceStatusColumn)

Example 3 with SizeUnit

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

Aggregations

StorageDevice (org.ovirt.engine.core.common.businessentities.gluster.StorageDevice)3 SizeUnit (org.ovirt.engine.core.common.utils.SizeConverter.SizeUnit)3 ArrayList (java.util.ArrayList)1 EngineException (org.ovirt.engine.core.common.errors.EngineException)1 Pair (org.ovirt.engine.core.common.utils.Pair)1 AnsibleCommandBuilder (org.ovirt.engine.core.common.utils.ansible.AnsibleCommandBuilder)1 AnsibleReturnValue (org.ovirt.engine.core.common.utils.ansible.AnsibleReturnValue)1 AbstractTextColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn)1 StorageDeviceStatusColumn (org.ovirt.engine.ui.webadmin.widget.table.column.StorageDeviceStatusColumn)1