Search in sources :

Example 1 with FileShare

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

the class FileDeviceController method deleteNFSAcls.

@Override
public void deleteNFSAcls(URI storage, URI fsURI, String subDir, String opId) throws InternalException {
    ControllerUtils.setThreadLocalLogData(fsURI, opId);
    FileObject fsObj = null;
    FileDeviceInputOutput args = new FileDeviceInputOutput();
    FileShare fs = null;
    Snapshot snapshotObj = null;
    boolean isFile = false;
    try {
        StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
        args.setSubDirectory(subDir);
        _log.info("FileDeviceController::deleteNFSAcls Recieved Nfs ACL DELETE Operation ");
        // File
        if (URIUtil.isType(fsURI, FileShare.class)) {
            isFile = true;
            fs = _dbClient.queryObject(FileShare.class, fsURI);
            fsObj = fs;
            args.addFSFileObject(fs);
            args.setFileSystemPath(fs.getPath());
            StoragePool pool = _dbClient.queryObject(StoragePool.class, fs.getPool());
            args.addStoragePool(pool);
        } else {
            // Snapshot
            snapshotObj = _dbClient.queryObject(Snapshot.class, fsURI);
            fsObj = snapshotObj;
            fs = _dbClient.queryObject(FileShare.class, snapshotObj.getParent());
            args.addFileShare(fs);
            args.setFileSystemPath(fs.getPath());
            args.addSnapshotFileObject(snapshotObj);
            StoragePool pool = _dbClient.queryObject(StoragePool.class, fs.getPool());
            args.addStoragePool(pool);
        }
        args.setFileOperation(isFile);
        args.setOpId(opId);
        List<NfsACE> aceDeleteList = new ArrayList<NfsACE>();
        List<NFSShareACL> dbNfsAclTemp = queryAllNfsACLInDB(fs, subDir, args);
        makeNfsAceFromDB(aceDeleteList, dbNfsAclTemp);
        args.setNfsAclsToDelete(aceDeleteList);
        // Do the Operation on device.
        BiosCommandResult result = getDevice(storageObj.getSystemType()).deleteNfsACLs(storageObj, args);
        if (result.isCommandSuccess()) {
            // Update Database
            if (!dbNfsAclTemp.isEmpty()) {
                for (NFSShareACL nfsShareACL : dbNfsAclTemp) {
                    nfsShareACL.setInactive(true);
                }
                _dbClient.updateObject(dbNfsAclTemp);
            }
        }
        if (result.getCommandPending()) {
            return;
        }
        // Audit & Update the task status
        OperationTypeEnum auditType = null;
        auditType = (isFile) ? OperationTypeEnum.DELETE_FILE_SYSTEM_NFS_ACL : OperationTypeEnum.DELETE_FILE_SNAPSHOT_NFS_ACL;
        fsObj.getOpStatus().updateTaskStatus(opId, result.toOperation());
        // Monitoring - Event Processing
        String eventMsg = result.isCommandSuccess() ? "" : result.getMessage();
        if (isFile) {
            recordFileDeviceOperation(_dbClient, auditType, result.isCommandSuccess(), eventMsg, args.getFileSystemPath(), fs, storageObj);
        } else {
            recordFileDeviceOperation(_dbClient, auditType, result.isCommandSuccess(), eventMsg, args.getFileSystemPath(), snapshotObj, fs, storageObj);
        }
        _dbClient.updateObject(fsObj);
    } catch (Exception e) {
        String[] params = { storage.toString(), fsURI.toString() };
        _log.error("Unable to Delete  ACL on  file system or snapshot: storage {}, FS/snapshot URI {}", params, e);
        _log.error("{}, {} ", e.getMessage(), e);
        updateTaskStatus(opId, fsObj, e);
    }
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) NfsACE(com.emc.storageos.model.file.NfsACE) OperationTypeEnum(com.emc.storageos.services.OperationTypeEnum) ArrayList(java.util.ArrayList) FileDeviceInputOutput(com.emc.storageos.volumecontroller.FileDeviceInputOutput) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) URISyntaxException(java.net.URISyntaxException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) Snapshot(com.emc.storageos.db.client.model.Snapshot) FileObject(com.emc.storageos.db.client.model.FileObject) NFSShareACL(com.emc.storageos.db.client.model.NFSShareACL) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 2 with FileShare

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

the class FileDeviceController method listSanpshotByPolicy.

@Override
public void listSanpshotByPolicy(URI storage, URI fsURI, URI policy, String opId) throws InternalException {
    ControllerUtils.setThreadLocalLogData(fsURI, opId);
    FileDeviceInputOutput args = new FileDeviceInputOutput();
    FileShare fs = null;
    try {
        fs = _dbClient.queryObject(FileShare.class, fsURI);
        FilePolicy fp = _dbClient.queryObject(FilePolicy.class, policy);
        if (fs != null && fp != null) {
            StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
            _log.info("Controller Recieved File Policy  {}", policy);
            args.addFSFileObject(fs);
            args.setFileSystemPath(fs.getPath());
            StoragePool pool = _dbClient.queryObject(StoragePool.class, fs.getPool());
            args.addStoragePool(pool);
            args.setFileProtectionPolicy(fp);
            args.setFileOperation(true);
            args.setOpId(opId);
            // Do the Operation on device.
            BiosCommandResult result = getDevice(storageObj.getSystemType()).listSanpshotByPolicy(storageObj, args);
            fs.getOpStatus().updateTaskStatus(opId, result.toOperation());
        } else {
            throw DeviceControllerException.exceptions.invalidObjectNull();
        }
    } catch (Exception e) {
        String[] params = { storage.toString(), fsURI.toString(), e.getMessage() };
        _log.error("Unable to get schedule snapshots : storage {}, FS URI {},: Error {}", params);
        updateTaskStatus(opId, fs, e);
    }
}
Also used : FilePolicy(com.emc.storageos.db.client.model.FilePolicy) StoragePool(com.emc.storageos.db.client.model.StoragePool) FileDeviceInputOutput(com.emc.storageos.volumecontroller.FileDeviceInputOutput) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) URISyntaxException(java.net.URISyntaxException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 3 with FileShare

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

the class FileDeviceController method performFileReplicationOperation.

@Override
public void performFileReplicationOperation(URI storage, URI sourceFSURI, String opType, String opId) throws ControllerException {
    StorageSystem system = _dbClient.queryObject(StorageSystem.class, storage);
    FileShare fileShare = _dbClient.queryObject(FileShare.class, sourceFSURI);
    TaskCompleter completer = null;
    BiosCommandResult result = new BiosCommandResult();
    WorkflowStepCompleter.stepExecuting(opId);
    _log.info("file replication operation {} started for file systerm {}", opType, fileShare.getName());
    try {
        if ("pause".equalsIgnoreCase(opType)) {
            completer = new MirrorFilePauseTaskCompleter(FileShare.class, sourceFSURI, opId);
            result = getDevice(system.getSystemType()).doPauseLink(system, fileShare);
        } else if ("resume".equalsIgnoreCase(opType)) {
            completer = new MirrorFileResumeTaskCompleter(FileShare.class, sourceFSURI, opId);
            result = getDevice(system.getSystemType()).doResumeLink(system, fileShare, completer);
        } else if ("start".equalsIgnoreCase(opType)) {
            completer = new MirrorFileStartTaskCompleter(FileShare.class, sourceFSURI, opId);
            result = getDevice(system.getSystemType()).doStartMirrorLink(system, fileShare, completer);
        } else if ("refresh".equalsIgnoreCase(opType)) {
            completer = new MirrorFileRefreshTaskCompleter(FileShare.class, sourceFSURI, opId);
            result = getDevice(system.getSystemType()).doRefreshMirrorLink(system, fileShare);
        } else if ("resync".equalsIgnoreCase(opType)) {
            completer = new MirrorFileResyncTaskCompleter(FileShare.class, sourceFSURI, opId);
            result = getDevice(system.getSystemType()).doResyncLink(system, fileShare, completer);
        }
        if (result.getCommandSuccess()) {
            _log.info("file replication operation {} finished successfully for file systerm {}", opType, fileShare.getName());
            completer.ready(_dbClient);
        } else if (result.getCommandPending()) {
            completer.statusPending(_dbClient, result.getMessage());
        } else {
            completer.error(_dbClient, result.getServiceCoded());
        }
    } catch (Exception e) {
        _log.error("unable to perform mirror operation {} on file system {} ", opType, sourceFSURI, e);
        updateTaskStatus(opId, fileShare, e);
        ServiceError error = DeviceControllerException.errors.jobFailed(e);
        WorkflowStepCompleter.stepFailed(opId, error);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) MirrorFileResumeTaskCompleter(com.emc.storageos.volumecontroller.impl.file.MirrorFileResumeTaskCompleter) MirrorFileRefreshTaskCompleter(com.emc.storageos.volumecontroller.impl.file.MirrorFileRefreshTaskCompleter) MirrorFilePauseTaskCompleter(com.emc.storageos.volumecontroller.impl.file.MirrorFilePauseTaskCompleter) MirrorFileStartTaskCompleter(com.emc.storageos.volumecontroller.impl.file.MirrorFileStartTaskCompleter) MirrorFileResyncTaskCompleter(com.emc.storageos.volumecontroller.impl.file.MirrorFileResyncTaskCompleter) MirrorFileRefreshTaskCompleter(com.emc.storageos.volumecontroller.impl.file.MirrorFileRefreshTaskCompleter) MirrorFileResumeTaskCompleter(com.emc.storageos.volumecontroller.impl.file.MirrorFileResumeTaskCompleter) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) MirrorFileStartTaskCompleter(com.emc.storageos.volumecontroller.impl.file.MirrorFileStartTaskCompleter) MirrorFileResyncTaskCompleter(com.emc.storageos.volumecontroller.impl.file.MirrorFileResyncTaskCompleter) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) MirrorFilePauseTaskCompleter(com.emc.storageos.volumecontroller.impl.file.MirrorFilePauseTaskCompleter) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) URISyntaxException(java.net.URISyntaxException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 4 with FileShare

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

the class FileDeviceController method queryFileExports.

private List<FileExportRule> queryFileExports(FileDeviceInputOutput args) {
    List<FileExportRule> fileExportRules = null;
    try {
        ContainmentConstraint containmentConstraint;
        if (args.getFileOperation()) {
            FileShare fs = args.getFs();
            _log.info("Querying all ExportRules Using FsId {}", fs.getId());
            containmentConstraint = ContainmentConstraint.Factory.getFileExportRulesConstraint(fs.getId());
        } else {
            URI snapshotId = args.getSnapshotId();
            _log.info("Querying all ExportRules Using Snapshot Id {}", snapshotId);
            containmentConstraint = ContainmentConstraint.Factory.getSnapshotExportRulesConstraint(snapshotId);
        }
        fileExportRules = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, FileExportRule.class, containmentConstraint);
    } catch (Exception e) {
        _log.error("Error while querying {}", e);
    }
    return fileExportRules;
}
Also used : ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) FileExportRule(com.emc.storageos.db.client.model.FileExportRule) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) URI(java.net.URI) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) URISyntaxException(java.net.URISyntaxException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 5 with FileShare

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

the class FileDeviceController method createFS.

@Override
public void createFS(URI storage, URI pool, URI fs, String nativeId, String opId) throws ControllerException {
    FileObject fileObject = null;
    FileShare fsObj = null;
    StorageSystem storageObj = null;
    try {
        ControllerUtils.setThreadLocalLogData(fs, opId);
        storageObj = _dbClient.queryObject(StorageSystem.class, storage);
        String[] params = { storage.toString(), pool.toString(), fs.toString() };
        _log.info("Create FS: {}, {}, {}", params);
        StoragePool poolObj = _dbClient.queryObject(StoragePool.class, pool);
        fsObj = _dbClient.queryObject(FileShare.class, fs);
        VirtualPool vPool = _dbClient.queryObject(VirtualPool.class, fsObj.getVirtualPool());
        fileObject = fsObj;
        FileDeviceInputOutput args = new FileDeviceInputOutput();
        args.addFileShare(fsObj);
        args.addStoragePool(poolObj);
        args.setVPool(vPool);
        args.setNativeDeviceFsId(nativeId);
        args.setOpId(opId);
        Project proj = _dbClient.queryObject(Project.class, fsObj.getProject());
        TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, fsObj.getTenant());
        setVirtualNASinArgs(fsObj.getVirtualNAS(), args);
        args.setTenantOrg(tenant);
        args.setProject(proj);
        // work flow and we need to add TaskCompleter(TBD for vnxfile)
        WorkflowStepCompleter.stepExecuting(opId);
        acquireStepLock(storageObj, opId);
        BiosCommandResult result = getDevice(storageObj.getSystemType()).doCreateFS(storageObj, args);
        if (!result.getCommandPending()) {
            fsObj.getOpStatus().updateTaskStatus(opId, result.toOperation());
        } else {
            // we need to add task completer
            fsObj.getOpStatus().updateTaskStatus(opId, result.toOperation());
        }
        if (result.isCommandSuccess()) {
            fsObj.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(_dbClient, fsObj));
            fsObj.setInactive(false);
            WorkflowStepCompleter.stepSucceded(opId);
        } else if (!result.getCommandPending()) {
            fsObj.setInactive(true);
            WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
        }
        _dbClient.updateObject(fsObj);
        if (!result.getCommandPending()) {
            recordFileDeviceOperation(_dbClient, OperationTypeEnum.CREATE_FILE_SYSTEM, result.isCommandSuccess(), "", "", fsObj);
        }
    } catch (Exception e) {
        String[] params = { storage.toString(), pool.toString(), fs.toString(), e.getMessage() };
        _log.error("Unable to create file system: storage {}, pool {}, FS {}: {}", params);
        // work flow fail
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        WorkflowStepCompleter.stepFailed(opId, serviceError);
        if ((fsObj != null) && (storageObj != null)) {
            fsObj.setInactive(true);
            _dbClient.updateObject(fsObj);
            recordFileDeviceOperation(_dbClient, OperationTypeEnum.CREATE_FILE_SYSTEM, false, e.getMessage(), "", fsObj, storageObj);
        }
        updateTaskStatus(opId, fileObject, e);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) StoragePool(com.emc.storageos.db.client.model.StoragePool) FileDeviceInputOutput(com.emc.storageos.volumecontroller.FileDeviceInputOutput) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) URISyntaxException(java.net.URISyntaxException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) Project(com.emc.storageos.db.client.model.Project) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) FileObject(com.emc.storageos.db.client.model.FileObject) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

FileShare (com.emc.storageos.db.client.model.FileShare)289 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)155 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)107 URI (java.net.URI)93 ArrayList (java.util.ArrayList)79 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)73 ControllerException (com.emc.storageos.volumecontroller.ControllerException)65 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)61 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)57 Operation (com.emc.storageos.db.client.model.Operation)56 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)56 URISyntaxException (java.net.URISyntaxException)56 Path (javax.ws.rs.Path)56 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)52 Produces (javax.ws.rs.Produces)51 Snapshot (com.emc.storageos.db.client.model.Snapshot)50 MapFileShare (com.emc.storageos.api.mapper.functions.MapFileShare)49 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)45 WorkflowException (com.emc.storageos.workflow.WorkflowException)42 NamedURI (com.emc.storageos.db.client.model.NamedURI)36