Search in sources :

Example 21 with FileObject

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

the class FileDeviceController method checkFileSystemDependenciesInStorage.

@Override
public void checkFileSystemDependenciesInStorage(URI storageURI, URI fsURI, String opId) throws ControllerException {
    _log.info("checkFileSystemDependenciesInStorage storage: {}, URI: {} ", storageURI, fsURI);
    ControllerUtils.setThreadLocalLogData(fsURI, opId);
    StorageSystem storageObj = null;
    FileObject fileObject = null;
    FileShare fsObj = null;
    BiosCommandResult result = null;
    FileDeviceInputOutput args = new FileDeviceInputOutput();
    try {
        WorkflowStepCompleter.stepExecuting(opId);
        storageObj = _dbClient.queryObject(StorageSystem.class, storageURI);
        args.setOpId(opId);
        fsObj = _dbClient.queryObject(FileShare.class, fsURI);
        setVirtualNASinArgs(fsObj.getVirtualNAS(), args);
        fileObject = fsObj;
        args.addFileShare(fsObj);
        args.setExportPath(fsObj.getPath());
        // Acquire lock for VNXFILE Storage System
        acquireStepLock(storageObj, opId);
        result = getDevice(storageObj.getSystemType()).doCheckFSDependencies(storageObj, args);
        // In case of VNXe
        if (result.getCommandPending()) {
            return;
        }
        fsObj.getOpStatus().updateTaskStatus(opId, result.toOperation());
        _dbClient.updateObject(fsObj);
        if (result.isCommandSuccess()) {
            WorkflowStepCompleter.stepSucceded(opId);
        } else if (!result.getCommandPending()) {
            WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
        }
    } catch (Exception e) {
        _log.error("Failed to check dependencies of FS {} on storage: {}", fsURI, storageURI);
        updateTaskStatus(opId, fileObject, e);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        WorkflowStepCompleter.stepFailed(opId, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) FileDeviceInputOutput(com.emc.storageos.volumecontroller.FileDeviceInputOutput) FileObject(com.emc.storageos.db.client.model.FileObject) 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 22 with FileObject

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

the class FileDeviceController method deleteShareACLs.

@Override
public void deleteShareACLs(URI storage, URI fsURI, String shareName, String opId) throws InternalException {
    ControllerUtils.setThreadLocalLogData(fsURI, opId);
    FileObject fsObj = null;
    FileDeviceInputOutput args = new FileDeviceInputOutput();
    FileShare fs = null;
    Snapshot snapshotObj = null;
    boolean isFile = false;
    _log.info("Controller recieved request to delete share ACL for share {}", shareName);
    try {
        StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
        args.setShareName(shareName);
        // File
        if (URIUtil.isType(fsURI, FileShare.class)) {
            isFile = true;
            fs = _dbClient.queryObject(FileShare.class, fsURI);
            setVirtualNASinArgs(fs.getVirtualNAS(), args);
            fsObj = fs;
            args.addFSFileObject(fs);
            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());
            setVirtualNASinArgs(fs.getVirtualNAS(), args);
            args.addFileShare(fs);
            args.addSnapshotFileObject(snapshotObj);
            StoragePool pool = _dbClient.queryObject(StoragePool.class, fs.getPool());
            args.addStoragePool(pool);
        }
        args.setFileOperation(isFile);
        args.setOpId(opId);
        // query and setExistingShare ACL
        args.setExistingShareAcls(queryExistingShareAcls(args));
        // Acquire lock for VNXFILE Storage System
        WorkflowStepCompleter.stepExecuting(opId);
        acquireStepLock(storageObj, opId);
        // Do the Operation on device.
        BiosCommandResult result = getDevice(storageObj.getSystemType()).deleteShareACLs(storageObj, args);
        if (result.isCommandSuccess()) {
            WorkflowStepCompleter.stepSucceded(opId);
            // Update database
            deleteShareACLsFromDB(args);
        }
        if (!result.isCommandSuccess() && !result.getCommandPending()) {
            WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
        }
        if (result.getCommandPending()) {
            return;
        }
        // Audit & Update the task status
        OperationTypeEnum auditType = null;
        auditType = (isFile) ? OperationTypeEnum.DELETE_FILE_SYSTEM_SHARE_ACL : OperationTypeEnum.DELETE_FILE_SNAPSHOT_SHARE_ACL;
        fsObj.getOpStatus().updateTaskStatus(opId, result.toOperation());
        // Monitoring - Event Processing
        String eventMsg = result.isCommandSuccess() ? "" : result.getMessage();
        if (isFile) {
            recordFileDeviceOperation(_dbClient, auditType, result.isCommandSuccess(), eventMsg, shareName, fs, storageObj);
        } else {
            recordFileDeviceOperation(_dbClient, auditType, result.isCommandSuccess(), eventMsg, shareName, snapshotObj, fs, storageObj);
        }
        _dbClient.updateObject(fsObj);
    } catch (Exception e) {
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        WorkflowStepCompleter.stepFailed(opId, serviceError);
        String[] logParams = { storage.toString(), fsURI.toString() };
        _log.error("Unable to delete share ACL for file system or snapshot: storage {}, FS/snapshot URI {}", logParams, e);
        _log.error("{}, {} ", e.getMessage(), e);
        updateTaskStatus(opId, fsObj, e);
    }
}
Also used : Snapshot(com.emc.storageos.db.client.model.Snapshot) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) StoragePool(com.emc.storageos.db.client.model.StoragePool) OperationTypeEnum(com.emc.storageos.services.OperationTypeEnum) FileDeviceInputOutput(com.emc.storageos.volumecontroller.FileDeviceInputOutput) FileObject(com.emc.storageos.db.client.model.FileObject) 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 23 with FileObject

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

the class FileDeviceController method updateExportRules.

@Override
public void updateExportRules(URI storage, URI fsURI, FileExportUpdateParams param, String opId) throws ControllerException {
    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(param.getSubDir());
        args.setAllExportRules(param);
        if (null != param.getBypassDnsCheck()) {
            args.setBypassDnsCheck(param.getBypassDnsCheck());
        } else {
            args.setBypassDnsCheck(false);
        }
        _log.info("Controller Recieved FileExportUpdateParams {}", param);
        // File
        if (URIUtil.isType(fsURI, FileShare.class)) {
            isFile = true;
            fs = _dbClient.queryObject(FileShare.class, fsURI);
            setVirtualNASinArgs(fs.getVirtualNAS(), args);
            fsObj = fs;
            args.addFSFileObject(fs);
            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());
            setVirtualNASinArgs(fs.getVirtualNAS(), args);
            args.addFileShare(fs);
            args.addSnapshotFileObject(snapshotObj);
            StoragePool pool = _dbClient.queryObject(StoragePool.class, fs.getPool());
            args.addStoragePool(pool);
        }
        args.setFileOperation(isFile);
        args.setOpId(opId);
        // Query & Pass all Existing Exports
        args.setExistingDBExportRules(queryExports(args));
        // Acquire lock for VNXFILE Storage System
        acquireStepLock(storageObj, opId);
        WorkflowStepCompleter.stepExecuting(opId);
        BiosCommandResult result = getDevice(storageObj.getSystemType()).updateExportRules(storageObj, args);
        if (result.isCommandSuccess()) {
            // Update Database
            doCRUDExports(param, fs, args);
            // Delete the Export Map, if there are no exports.
            if ((args.getFileObjExports() != null) && (queryExports(args).isEmpty())) {
                args.getFileObjExports().clear();
                _dbClient.updateObject(args.getFileObj());
            }
            WorkflowStepCompleter.stepSucceded(opId);
        }
        if (result.getCommandPending()) {
            return;
        }
        if (!result.isCommandSuccess() && !result.getCommandPending()) {
            WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
        }
        // Audit & Update the task status
        OperationTypeEnum auditType = null;
        auditType = (isFile) ? OperationTypeEnum.EXPORT_FILE_SYSTEM : OperationTypeEnum.EXPORT_FILE_SNAPSHOT;
        fsObj.getOpStatus().updateTaskStatus(opId, result.toOperation());
        // Monitoring - Event Processing
        String eventMsg = result.isCommandSuccess() ? "" : result.getMessage();
        if (isFile) {
            recordFileDeviceOperation(_dbClient, auditType, result.isCommandSuccess(), eventMsg, getExportNewClientExtensions(param.retrieveAllExports()), fs, storageObj);
        } else {
            recordFileDeviceOperation(_dbClient, auditType, result.isCommandSuccess(), eventMsg, getExportNewClientExtensions(param.retrieveAllExports()), snapshotObj, fs, storageObj);
        }
        _dbClient.updateObject(fsObj);
    } catch (Exception e) {
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        WorkflowStepCompleter.stepFailed(opId, serviceError);
        String[] params = { storage.toString(), fsURI.toString() };
        _log.error("Unable to export file system or snapshot: storage {}, FS/snapshot URI {}", params, e);
        _log.error("{}, {} ", e.getMessage(), e);
        updateTaskStatus(opId, fsObj, e);
    }
}
Also used : Snapshot(com.emc.storageos.db.client.model.Snapshot) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) StoragePool(com.emc.storageos.db.client.model.StoragePool) OperationTypeEnum(com.emc.storageos.services.OperationTypeEnum) FileDeviceInputOutput(com.emc.storageos.volumecontroller.FileDeviceInputOutput) FileObject(com.emc.storageos.db.client.model.FileObject) 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)

Aggregations

FileObject (com.emc.storageos.db.client.model.FileObject)23 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)21 FileShare (com.emc.storageos.db.client.model.FileShare)20 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)19 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)19 ControllerException (com.emc.storageos.volumecontroller.ControllerException)19 WorkflowException (com.emc.storageos.workflow.WorkflowException)19 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)18 Snapshot (com.emc.storageos.db.client.model.Snapshot)17 FileDeviceInputOutput (com.emc.storageos.volumecontroller.FileDeviceInputOutput)14 URISyntaxException (java.net.URISyntaxException)14 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)13 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)13 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)13 StoragePool (com.emc.storageos.db.client.model.StoragePool)9 OperationTypeEnum (com.emc.storageos.services.OperationTypeEnum)7 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)6 FileSnapshotWorkflowCompleter (com.emc.storageos.volumecontroller.impl.file.FileSnapshotWorkflowCompleter)6 FileWorkflowCompleter (com.emc.storageos.volumecontroller.impl.file.FileWorkflowCompleter)6 MirrorFileFailbackTaskCompleter (com.emc.storageos.volumecontroller.impl.file.MirrorFileFailbackTaskCompleter)6