Search in sources :

Example 6 with FileMountInfo

use of com.emc.storageos.db.client.model.FileMountInfo in project coprhd-controller by CoprHD.

the class ComputeSystemControllerImpl method addStepsForUnmountDevice.

public String addStepsForUnmountDevice(Workflow workflow, HostDeviceInputOutput args) {
    // the wait for key returned by previous call
    String waitFor = null;
    FileMountInfo fsMount = getMountInfo(args.getHostId(), args.getMountPath(), args.getResId());
    args.setFsType(fsMount.getFsType());
    args.setSecurity(fsMount.getSecurityType());
    args.setSubDirectory(fsMount.getSubDirectory());
    _log.info("Generating steps for mounting device");
    // create a step
    String hostname = _dbClient.queryObject(Host.class, args.getHostId()).getHostName();
    String hostType = getHostType(args.getHostId());
    waitFor = workflow.createStep(null, String.format("Unmounting device: %s for host: %s", args.getMountPath(), hostname), null, args.getHostId(), hostType, this.getClass(), unmountDeviceMethod(args), unmountRollBackMethod(args), null);
    waitFor = workflow.createStep(null, String.format("removing from etc/fstab:%n%s for host: %s", args.getMountPath(), hostname), waitFor, args.getHostId(), hostType, this.getClass(), removeFromFSTabMethod(args), removeFromFSTabRollBackMethod(args), null);
    waitFor = workflow.createStep(null, String.format("Delete Directory:%n%s for host: %s", args.getMountPath(), hostname), waitFor, args.getHostId(), hostType, this.getClass(), deleteDirectoryMethod(args), createDirectoryMethod(args), null);
    return waitFor;
}
Also used : FileMountInfo(com.emc.storageos.db.client.model.FileMountInfo) Host(com.emc.storageos.db.client.model.Host)

Example 7 with FileMountInfo

use of com.emc.storageos.db.client.model.FileMountInfo in project coprhd-controller by CoprHD.

the class ComputeSystemControllerImpl method createMountDBEntry.

private void createMountDBEntry(URI resId, URI hostId, String mountPath, String subDir, String security, String fsType) {
    FileMountInfo fsMount = new FileMountInfo();
    fsMount.setId(URIUtil.createId(FileMountInfo.class));
    fsMount.setFsId(resId);
    fsMount.setFsType(fsType);
    fsMount.setHostId(hostId);
    fsMount.setMountPath(mountPath);
    fsMount.setSecurityType(security);
    fsMount.setSubDirectory(subDir);
    _log.debug("Storing New DB Mount Info {}" + fsMount);
    _dbClient.createObject(fsMount);
}
Also used : FileMountInfo(com.emc.storageos.db.client.model.FileMountInfo)

Example 8 with FileMountInfo

use of com.emc.storageos.db.client.model.FileMountInfo in project coprhd-controller by CoprHD.

the class FileDeviceController method checkIfMountExistsOnHost.

public void checkIfMountExistsOnHost(URI fsId, String opId) {
    try {
        WorkflowStepCompleter.stepExecuting(opId);
        ContainmentConstraint containmentConstraint = ContainmentConstraint.Factory.getFileMountsConstraint(fsId);
        List<FileMountInfo> fsDBMounts = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, FileMountInfo.class, containmentConstraint);
        FileShare fs = _dbClient.queryObject(FileShare.class, fsId);
        for (FileMountInfo fsMount : fsDBMounts) {
            LinuxMountUtils mountUtils = new LinuxMountUtils(_dbClient.queryObject(Host.class, fsMount.getHostId()));
            ExportRule export = FileOperationUtils.findExport(fs, fsMount.getSubDirectory(), fsMount.getSecurityType(), _dbClient);
            if (mountUtils.verifyMountPoints(export.getMountPoint(), fsMount.getMountPath())) {
                String errMsg = new String("delete file system from ViPR database failed because mounts exist for file system " + fs.getLabel() + " and once deleted the mounts cannot be ingested into ViPR");
                final ServiceCoded serviceCoded = DeviceControllerException.errors.jobFailedOpMsg(OperationTypeEnum.DELETE_FILE_SYSTEM.toString(), errMsg);
                WorkflowStepCompleter.stepFailed(opId, serviceCoded);
            }
        }
        for (FileMountInfo fsMount : fsDBMounts) {
            fsMount.setInactive(true);
        }
        _dbClient.updateObject(fsDBMounts);
        WorkflowStepCompleter.stepSucceded(opId);
    } catch (ControllerException ex) {
        WorkflowStepCompleter.stepFailed(opId, ex);
        _log.error("Couldn't verify dependencies: ", fsId);
        throw ex;
    }
}
Also used : LinuxMountUtils(com.emc.storageos.computesystemcontroller.hostmountadapters.LinuxMountUtils) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) FileExportRule(com.emc.storageos.db.client.model.FileExportRule) ExportRule(com.emc.storageos.model.file.ExportRule) FileMountInfo(com.emc.storageos.db.client.model.FileMountInfo) Host(com.emc.storageos.db.client.model.Host) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare)

Aggregations

FileMountInfo (com.emc.storageos.db.client.model.FileMountInfo)8 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)5 ArrayList (java.util.ArrayList)3 Host (com.emc.storageos.db.client.model.Host)2 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)2 MountInfo (com.emc.storageos.model.file.MountInfo)2 ControllerException (com.emc.storageos.volumecontroller.ControllerException)2 ComputeSystemControllerException (com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)1 HostMountAdapter (com.emc.storageos.computesystemcontroller.hostmountadapters.HostMountAdapter)1 LinuxMountUtils (com.emc.storageos.computesystemcontroller.hostmountadapters.LinuxMountUtils)1 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)1 FileExportRule (com.emc.storageos.db.client.model.FileExportRule)1 FileShare (com.emc.storageos.db.client.model.FileShare)1 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)1 ClientControllerException (com.emc.storageos.exceptions.ClientControllerException)1 ExportRule (com.emc.storageos.model.file.ExportRule)1 ServiceCoded (com.emc.storageos.svcs.errorhandling.model.ServiceCoded)1 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)1 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)1 WorkflowException (com.emc.storageos.workflow.WorkflowException)1