Search in sources :

Example 1 with FileMountInfo

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

the class ComputeSystemControllerImpl method removeMountDBEntry.

private void removeMountDBEntry(URI resId, URI hostId, String mountPath) {
    ContainmentConstraint containmentConstraint = ContainmentConstraint.Factory.getFileMountsConstraint(resId);
    List<FileMountInfo> fsDBMounts = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, FileMountInfo.class, containmentConstraint);
    if (fsDBMounts != null && !fsDBMounts.isEmpty()) {
        for (FileMountInfo dbMount : fsDBMounts) {
            if (dbMount.getHostId().toString().equalsIgnoreCase(hostId.toString()) && dbMount.getMountPath().equalsIgnoreCase(mountPath)) {
                _log.debug("Found DB entry with mountpath {} " + mountPath);
                // Deactivate the entry!!
                dbMount.setInactive(true);
                _dbClient.updateObject(dbMount);
            }
        }
    }
}
Also used : ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) FileMountInfo(com.emc.storageos.db.client.model.FileMountInfo)

Example 2 with FileMountInfo

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

the class ComputeSystemControllerImpl method removeFromFSTabRollBack.

public void removeFromFSTabRollBack(URI hostId, String mountPath, URI resId, String stepId) {
    try {
        HostMountAdapter adapter = getMountAdapters().get(_dbClient.queryObject(Host.class, hostId).getType());
        WorkflowStepCompleter.stepExecuting(stepId);
        FileMountInfo fsMount = getMountInfo(hostId, mountPath, resId);
        List<String> lockKeys = new ArrayList<String>();
        lockKeys.add(ControllerLockingUtil.getMountHostKey(_dbClient, hostId));
        _workflowService.acquireWorkflowStepLocks(stepId, lockKeys, LockTimeoutValue.get(LockType.FILE_MOUNT_OPERATIONS));
        adapter.addToFSTab(hostId, mountPath, resId, fsMount.getSubDirectory(), fsMount.getSecurityType(), "auto");
        WorkflowStepCompleter.stepSucceded(stepId);
    } catch (ControllerException e) {
        WorkflowStepCompleter.stepFailed(stepId, e);
        throw e;
    } catch (Exception ex) {
        WorkflowStepCompleter.stepFailed(stepId, APIException.badRequests.commandFailedToComplete(ex.getMessage()));
        throw ex;
    }
}
Also used : ControllerException(com.emc.storageos.volumecontroller.ControllerException) ComputeSystemControllerException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ClientControllerException(com.emc.storageos.exceptions.ClientControllerException) HostMountAdapter(com.emc.storageos.computesystemcontroller.hostmountadapters.HostMountAdapter) ArrayList(java.util.ArrayList) FileMountInfo(com.emc.storageos.db.client.model.FileMountInfo) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) ComputeSystemControllerException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) RemoteException(java.rmi.RemoteException) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) ClientControllerException(com.emc.storageos.exceptions.ClientControllerException)

Example 3 with FileMountInfo

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

the class FileOperationUtils method queryDBFSMounts.

public static List<MountInfo> queryDBFSMounts(URI fsId, DbClient dbClient) {
    _log.info("Querying File System mounts using FsId {}", fsId);
    List<MountInfo> fsMounts = new ArrayList<MountInfo>();
    try {
        ContainmentConstraint containmentConstraint = ContainmentConstraint.Factory.getFileMountsConstraint(fsId);
        List<FileMountInfo> fsDBMounts = CustomQueryUtility.queryActiveResourcesByConstraint(dbClient, FileMountInfo.class, containmentConstraint);
        if (fsDBMounts != null && !fsDBMounts.isEmpty()) {
            for (FileMountInfo dbMount : fsDBMounts) {
                MountInfo mountInfo = new MountInfo();
                getMountInfo(dbMount, mountInfo);
                fsMounts.add(mountInfo);
            }
        }
        return fsMounts;
    } catch (Exception e) {
        _log.error("Error while querying {}", e);
    }
    return fsMounts;
}
Also used : ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) ArrayList(java.util.ArrayList) FileMountInfo(com.emc.storageos.db.client.model.FileMountInfo) FileMountInfo(com.emc.storageos.db.client.model.FileMountInfo) MountInfo(com.emc.storageos.model.file.MountInfo)

Example 4 with FileMountInfo

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

the class FileOperationUtils method queryDBHostMounts.

/**
 * Method to get the list file system mounts which are mount on a host
 *
 * @param host
 *            host system URI
 * @return List<MountInfo> List of mount infos
 */
public static List<MountInfo> queryDBHostMounts(URI host, DbClient dbClient) {
    _log.info("Querying NFS mounts for host {}", host);
    List<MountInfo> hostMounts = new ArrayList<MountInfo>();
    try {
        ContainmentConstraint containmentConstraint = ContainmentConstraint.Factory.getHostFileMountsConstraint(host);
        List<FileMountInfo> fileMounts = CustomQueryUtility.queryActiveResourcesByConstraint(dbClient, FileMountInfo.class, containmentConstraint);
        if (fileMounts != null && !fileMounts.isEmpty()) {
            for (FileMountInfo dbMount : fileMounts) {
                MountInfo mountInfo = new MountInfo();
                getMountInfo(dbMount, mountInfo);
                hostMounts.add(mountInfo);
            }
        }
        return hostMounts;
    } catch (Exception e) {
        _log.error("Error while querying {}", e);
    }
    return hostMounts;
}
Also used : ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) ArrayList(java.util.ArrayList) FileMountInfo(com.emc.storageos.db.client.model.FileMountInfo) FileMountInfo(com.emc.storageos.db.client.model.FileMountInfo) MountInfo(com.emc.storageos.model.file.MountInfo)

Example 5 with FileMountInfo

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

the class ComputeSystemControllerImpl method getMountInfo.

public FileMountInfo getMountInfo(URI hostId, String mountPath, URI resId) {
    ContainmentConstraint containmentConstraint = ContainmentConstraint.Factory.getFileMountsConstraint(resId);
    List<FileMountInfo> fsDBMounts = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, FileMountInfo.class, containmentConstraint);
    if (fsDBMounts != null && !fsDBMounts.isEmpty()) {
        for (FileMountInfo dbMount : fsDBMounts) {
            if (dbMount.getHostId().toString().equalsIgnoreCase(hostId.toString()) && dbMount.getMountPath().equalsIgnoreCase(mountPath)) {
                _log.debug("Found DB entry with mountpath {} " + mountPath);
                return dbMount;
            }
        }
    }
    return null;
}
Also used : ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) FileMountInfo(com.emc.storageos.db.client.model.FileMountInfo)

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