Search in sources :

Example 1 with StorageDevice

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;
}
Also used : StorageDevice(org.ovirt.engine.core.common.businessentities.gluster.StorageDevice) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) HostValidator(org.ovirt.engine.core.bll.validator.HostValidator)

Example 2 with StorageDevice

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()));
    }
}
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 3 with StorageDevice

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);
}
Also used : Linq(org.ovirt.engine.ui.uicommonweb.Linq) CreateBrickParameters(org.ovirt.engine.core.common.action.gluster.CreateBrickParameters) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) RaidType(org.ovirt.engine.core.common.businessentities.RaidType) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) SyncGlusterStorageDevicesParameter(org.ovirt.engine.core.common.action.gluster.SyncGlusterStorageDevicesParameter) ApplicationMode(org.ovirt.engine.core.common.mode.ApplicationMode) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) ArrayList(java.util.ArrayList) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) List(java.util.List) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) GetConfigurationValueParameters(org.ovirt.engine.core.common.queries.GetConfigurationValueParameters) StorageDevice(org.ovirt.engine.core.common.businessentities.gluster.StorageDevice) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) Collections(java.util.Collections) VDS(org.ovirt.engine.core.common.businessentities.VDS) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) VDS(org.ovirt.engine.core.common.businessentities.VDS) StorageDevice(org.ovirt.engine.core.common.businessentities.gluster.StorageDevice) GetConfigurationValueParameters(org.ovirt.engine.core.common.queries.GetConfigurationValueParameters) ArrayList(java.util.ArrayList) List(java.util.List) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand)

Example 4 with StorageDevice

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");
}
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 5 with StorageDevice

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;
}
Also used : StorageDevice(org.ovirt.engine.core.common.businessentities.gluster.StorageDevice) ArrayList(java.util.ArrayList) List(java.util.List) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Aggregations

StorageDevice (org.ovirt.engine.core.common.businessentities.gluster.StorageDevice)23 Test (org.junit.Test)7 ArrayList (java.util.ArrayList)6 CreateBrickParameters (org.ovirt.engine.core.common.action.gluster.CreateBrickParameters)4 List (java.util.List)3 SizeUnit (org.ovirt.engine.core.common.utils.SizeConverter.SizeUnit)3 HashSet (java.util.HashSet)2 BaseCommandTest (org.ovirt.engine.core.bll.BaseCommandTest)2 VDS (org.ovirt.engine.core.common.businessentities.VDS)2 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)2 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 Pattern (java.util.regex.Pattern)1 HostValidator (org.ovirt.engine.core.bll.validator.HostValidator)1 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1 ActionType (org.ovirt.engine.core.common.action.ActionType)1 SyncGlusterStorageDevicesParameter (org.ovirt.engine.core.common.action.gluster.SyncGlusterStorageDevicesParameter)1 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)1 RaidType (org.ovirt.engine.core.common.businessentities.RaidType)1 VDSStatus (org.ovirt.engine.core.common.businessentities.VDSStatus)1