Search in sources :

Example 1 with MountPoint

use of com.iwave.ext.linux.model.MountPoint in project coprhd-controller by CoprHD.

the class ListMountPointsCommand method parseOutput.

@Override
public void parseOutput() {
    results = Maps.newHashMap();
    if (getOutput() != null && getOutput().getStdout() != null) {
        String[] lines = getOutput().getStdout().split("\n");
        for (String line : lines) {
            String s = StringUtils.substringBefore(line, "#");
            if (StringUtils.isNotBlank(s)) {
                String[] pieces = StringUtils.trim(s).split("\\s+");
                MountPoint mountPoint = new MountPoint();
                mountPoint.setDevice(pieces[0]);
                if (pieces.length > 1) {
                    mountPoint.setPath(pieces[1]);
                }
                if (pieces.length > 2) {
                    mountPoint.setFsType(pieces[2]);
                }
                if (pieces.length > 3) {
                    mountPoint.setOptions(pieces[3]);
                }
                results.put(mountPoint.getPath(), mountPoint);
            }
        }
    }
}
Also used : MountPoint(com.iwave.ext.linux.model.MountPoint)

Example 2 with MountPoint

use of com.iwave.ext.linux.model.MountPoint in project coprhd-controller by CoprHD.

the class ExpandBlockVolumeHelper method expandVolume.

public void expandVolume(BlockObjectRestRep volume, Double newSizeInGB) {
    logInfo("expand.block.volume.unmounting", linuxSupport.getHostName(), mountPoint.getPath());
    linuxSupport.unmountPath(mountPoint.getPath());
    ViPRService.artificialFailure(ArtificialFailures.ARTIFICIAL_FAILURE_LINUX_EXPAND_VOLUME_AFTER_UNMOUNT);
    linuxSupport.removeFromFSTab(mountPoint);
    linuxSupport.removeVolumeMountPointTag(volume);
    ViPRService.artificialFailure(ArtificialFailures.ARTIFICIAL_FAILURE_LINUX_EXPAND_VOLUME_AFTER_REMOVE_TAG);
    // Skip the expand if the current volume capacity is larger than the requested expand size
    if (BlockStorageUtils.isVolumeExpanded(volume, newSizeInGB)) {
        logWarn("linux.expand.skip", volume.getId(), BlockStorageUtils.getCapacity(volume));
    } else {
        logInfo("expand.block.volume.resize.volume", volume.getName(), newSizeInGB.toString());
        linuxSupport.resizeVolume(volume, newSizeInGB);
        ViPRService.artificialFailure(ArtificialFailures.ARTIFICIAL_FAILURE_LINUX_EXPAND_VOLUME_AFTER_VOLUME_RESIZE);
    }
    linuxSupport.refreshStorage(Collections.singletonList(volume), usePowerPath);
    logInfo("expand.block.volume.find.parent", mountPoint.getDevice());
    String parentDevice = linuxSupport.getParentDevice(mountPoint.getDevice(), usePowerPath);
    String initialBlockSize = linuxSupport.getFilesystemBlockSize(parentDevice);
    logInfo("expand.block.volume.partition.size", initialBlockSize);
    List<String> blockDevices = linuxSupport.getBlockDevices(parentDevice, volume, usePowerPath);
    if (blockDevices != null && !blockDevices.isEmpty()) {
        linuxSupport.rescanBlockDevices(blockDevices);
    }
    if (!usePowerPath) {
        logInfo("expand.block.volume.resize.multipath", linuxSupport.getHostName(), mountPoint.getDevice());
        linuxSupport.resizeMultipathPath(parentDevice);
    }
    // this is the dm-* name
    // TODO: get the multipath device name using this dm-* name
    boolean fileSystemExpanded = false;
    int resizeAttempts = 0;
    while (!fileSystemExpanded) {
        resizeAttempts++;
        logInfo("expand.block.volume.resize.partition", volume.getName());
        linuxSupport.resizePartition(parentDevice);
        ViPRService.artificialFailure(ArtificialFailures.ARTIFICIAL_FAILURE_LINUX_EXPAND_VOLUME_AFTER_RESIZE_PARTITION);
        String currentBlockSize = linuxSupport.getFilesystemBlockSize(parentDevice);
        logInfo("expand.block.volume.partition.size", currentBlockSize);
        if (initialBlockSize == null || currentBlockSize == null || !StringUtils.equalsIgnoreCase(initialBlockSize, currentBlockSize)) {
            fileSystemExpanded = true;
        } else if (resizeAttempts >= MAX_RESIZE_RETRIES) {
            fileSystemExpanded = true;
            logWarn("expand.block.volume.unable.to.determine.resize");
        } else {
            try {
                Thread.sleep(EXPAND_RETRY_DELAY);
            } catch (InterruptedException e) {
                logWarn("expand.block.volume.resize.sleep.failure");
            }
        }
    }
    logInfo("expand.block.volume.resize.file", linuxSupport.getHostName());
    linuxSupport.resizeFileSystem(mountPoint.getDevice());
    ViPRService.artificialFailure(ArtificialFailures.ARTIFICIAL_FAILURE_LINUX_EXPAND_VOLUME_AFTER_RESIZE_FILESYSTEM);
    logInfo("expand.block.volume.remounting", linuxSupport.getHostName(), mountPoint.getPath());
    linuxSupport.addToFSTab(mountPoint.getDevice(), mountPoint.getPath(), mountPoint.getFsType(), null);
    ExecutionUtils.clearRollback();
    linuxSupport.mountPath(mountPoint.getPath());
    ExecutionUtils.clearRollback();
    ViPRService.artificialFailure(ArtificialFailures.ARTIFICIAL_FAILURE_LINUX_EXPAND_VOLUME_AFTER_MOUNT);
    linuxSupport.setVolumeMountPointTag(volume, mountPoint.getPath());
    ExecutionUtils.clearRollback();
}
Also used : MountPoint(com.iwave.ext.linux.model.MountPoint)

Example 3 with MountPoint

use of com.iwave.ext.linux.model.MountPoint in project coprhd-controller by CoprHD.

the class FindMountPointsForVolumes method executeTask.

@Override
public Void executeTask() throws Exception {
    ListMountPointsCommand command = new ListMountPointsCommand();
    Map<String, MountPoint> results = executeCommand(command, SHORT_TIMEOUT);
    for (VolumeSpec volume : volumes) {
        volume.mountPoint = LinuxUtils.getMountPoint(hostId, results, volume.viprVolume);
    }
    return null;
}
Also used : ListMountPointsCommand(com.iwave.ext.linux.command.ListMountPointsCommand) MountPoint(com.iwave.ext.linux.model.MountPoint) VolumeSpec(com.emc.sa.service.linux.UnmountBlockVolumeHelper.VolumeSpec)

Example 4 with MountPoint

use of com.iwave.ext.linux.model.MountPoint in project coprhd-controller by CoprHD.

the class LinuxMountUtils method verifyMountPoints.

public boolean verifyMountPoints(String mountPoint, String mountPath) throws InternalException {
    ListMountPointsCommand command = new ListMountPointsCommand();
    _log.info("check existing command:" + command.getResolvedCommandLine());
    cli.executeCommand(command);
    Map<String, MountPoint> mountPoints = command.getResults();
    for (MountPoint mp : mountPoints.values()) {
        if (StringUtils.equals(mp.getDevice(), mountPoint) && StringUtils.equals(mp.getPath(), mountPath)) {
            return true;
        }
    }
    return false;
}
Also used : ListMountPointsCommand(com.iwave.ext.linux.command.ListMountPointsCommand) MountPoint(com.iwave.ext.linux.model.MountPoint)

Example 5 with MountPoint

use of com.iwave.ext.linux.model.MountPoint in project coprhd-controller by CoprHD.

the class LinuxMountUtils method checkExistingMountPoints.

protected void checkExistingMountPoints(String mountPoint) throws InternalException {
    ListMountPointsCommand command = new ListMountPointsCommand();
    _log.info("check existing command:" + command.getResolvedCommandLine());
    cli.executeCommand(command);
    Map<String, MountPoint> mountPoints = command.getResults();
    for (MountPoint mp : mountPoints.values()) {
        if (StringUtils.equals(mp.getPath(), mountPoint)) {
            throw new IllegalStateException("Mount point already exists: " + mountPoint);
        }
    }
}
Also used : ListMountPointsCommand(com.iwave.ext.linux.command.ListMountPointsCommand) MountPoint(com.iwave.ext.linux.model.MountPoint)

Aggregations

MountPoint (com.iwave.ext.linux.model.MountPoint)5 ListMountPointsCommand (com.iwave.ext.linux.command.ListMountPointsCommand)3 VolumeSpec (com.emc.sa.service.linux.UnmountBlockVolumeHelper.VolumeSpec)1