Search in sources :

Example 6 with OperationTypeEnum

use of com.emc.storageos.services.OperationTypeEnum in project coprhd-controller by CoprHD.

the class UcsComputeDevice method changePowerState.

private void changePowerState(URI csId, URI ceId, String state) throws DeviceControllerException {
    LOGGER.info("changePowerState");
    ComputeElement ce = _dbClient.queryObject(ComputeElement.class, ceId);
    ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, csId);
    OperationTypeEnum typeEnum = POWER_DOWN.equals(state) ? OperationTypeEnum.POWERDOWN_COMPUTE_ELEMENT : OperationTypeEnum.POWERUP_COMPUTE_ELEMENT;
    try {
        URL ucsmURL = getUcsmURL(cs);
        StringBuilder errorMessage = new StringBuilder();
        ucsmService.setLsServerPowerState(ucsmURL.toString(), cs.getUsername(), cs.getPassword(), ce.getDn(), state, errorMessage);
        pullAndPollManagedObject(ucsmURL.toString(), cs.getUsername(), cs.getPassword(), ce.getLabel(), ComputeBlade.class);
    } catch (ComputeSystemControllerTimeoutException cstoe) {
        LOGGER.error("Unable to change power state of compute element due to a device TimeOut", cstoe);
        throw cstoe;
    } catch (Exception e) {
        LOGGER.error("Unable to change power state of compute element due to a exception", e);
        throw ComputeSystemControllerException.exceptions.powerStateChangeFailed(state, ce != null ? ce.getId().toString() : null, e);
    }
    _auditMgr.recordAuditLog(null, null, EVENT_SERVICE_TYPE_CE, typeEnum, System.currentTimeMillis(), AuditLogManager.AUDITLOG_SUCCESS, AuditLogManager.AUDITOP_END, ce.getId().toString(), ce.getLabel(), ce.getNativeGuid(), ce.getUuid(), ce.getOriginalUuid());
}
Also used : ComputeSystemControllerTimeoutException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerTimeoutException) OperationTypeEnum(com.emc.storageos.services.OperationTypeEnum) ComputeElement(com.emc.storageos.db.client.model.ComputeElement) ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem) URL(java.net.URL) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ComputeSystemControllerTimeoutException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerTimeoutException) MalformedURLException(java.net.MalformedURLException) ClientGeneralException(com.emc.cloud.platform.clientlib.ClientGeneralException) ComputeSystemControllerException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)

Example 7 with OperationTypeEnum

use of com.emc.storageos.services.OperationTypeEnum in project coprhd-controller by CoprHD.

the class FileDeviceController method unexport.

@Override
public void unexport(URI storage, URI fileUri, List<FileShareExport> exports, String opId) throws ControllerException {
    ControllerUtils.setThreadLocalLogData(fileUri, opId);
    FileObject fsObj = null;
    FileShare fs = null;
    Snapshot snapshotObj = null;
    StorageSystem storageObj = null;
    try {
        storageObj = _dbClient.queryObject(StorageSystem.class, storage);
        FileDeviceInputOutput args = new FileDeviceInputOutput();
        boolean isFile = false;
        if (URIUtil.isType(fileUri, FileShare.class)) {
            isFile = true;
            fs = _dbClient.queryObject(FileShare.class, fileUri);
            setVirtualNASinArgs(fs.getVirtualNAS(), args);
            fsObj = fs;
            args.addFSFileObject(fs);
            StoragePool pool = _dbClient.queryObject(StoragePool.class, fs.getPool());
            args.addStoragePool(pool);
        } else {
            snapshotObj = _dbClient.queryObject(Snapshot.class, fileUri);
            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);
        _log.info("Export details...  ");
        List<FileExport> fileExports = new ArrayList<FileExport>();
        List<FileExportRule> exportRules = new ArrayList<FileExportRule>();
        if (exports != null) {
            for (FileShareExport fileShareExport : exports) {
                FileExport fileExport = fileShareExport.getFileExport();
                fileExports.add(fileExport);
                _log.info("FileExport:" + fileExport.getClients() + ":" + fileExport.getStoragePortName() + ":" + fileExport.getStoragePort() + ":" + fileExport.getRootUserMapping() + ":" + fileExport.getPermissions() + ":" + fileExport.getProtocol() + ":" + fileExport.getSecurityType() + ":" + fileExport.getMountPoint() + ":" + fileExport.getMountPath() + ":" + fileExport.getPath());
                _log.info("FileShareExport: " + fileExport.getFileExportKey());
                // Per New Model : Lets create the Export Rules, So these will not get missed.
                FileExportRule rule = getFileExportRule(fileUri, fileExport, args);
                exportRules.add(rule);
            }
        } else {
            _log.info("Exports are null");
        }
        WorkflowStepCompleter.stepExecuting(opId);
        BiosCommandResult result = getDevice(storageObj.getSystemType()).doUnexport(storageObj, args, fileExports);
        if (result.getCommandPending()) {
            return;
        }
        if (!result.isCommandSuccess() && !result.getCommandPending()) {
            WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
        }
        // Set status
        fsObj.getOpStatus().updateTaskStatus(opId, result.toOperation());
        String eventMsg = result.isCommandSuccess() ? "" : result.getMessage();
        OperationTypeEnum auditType = (isFile) ? OperationTypeEnum.UNEXPORT_FILE_SYSTEM : OperationTypeEnum.UNEXPORT_FILE_SNAPSHOT;
        if (result.isCommandSuccess()) {
            // Remove Export
            for (FileExport fileExport : fileExports) {
                fsObj.getFsExports().remove(fileExport.getFileExportKey());
                _log.info("FileShareExport removed : " + fileExport.getFileExportKey());
            }
            // Query Existing Export rule and if found set to delete.
            for (FileExportRule rule : exportRules) {
                URIQueryResultList dbresult = new URIQueryResultList();
                if (!args.getFileOperation() && rule.getSnapshotExportIndex() != null) {
                    _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getSnapshotExportRuleConstraint(rule.getSnapshotExportIndex()), dbresult);
                } else if (rule.getFsExportIndex() != null) {
                    _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getFileExportRuleConstraint(rule.getFsExportIndex()), dbresult);
                }
                Iterator<URI> it = dbresult.iterator();
                while (it.hasNext()) {
                    if (dbresult.iterator().hasNext()) {
                        rule = _dbClient.queryObject(FileExportRule.class, it.next());
                        if (rule != null && !rule.getInactive()) {
                            _log.info("Existing DB Model found {}", rule);
                            rule.setInactive(true);
                            _dbClient.updateObject(rule);
                            break;
                        }
                    }
                }
            }
            FSExportMap exportsMap = fsObj.getFsExports();
            List<FileExport> fsExports = new ArrayList<FileExport>(exportsMap.values());
            if (isFile) {
                recordFileDeviceOperation(_dbClient, auditType, result.isCommandSuccess(), eventMsg, getExportClientExtensions(fsExports), fs, storageObj);
            } else {
                recordFileDeviceOperation(_dbClient, auditType, result.isCommandSuccess(), eventMsg, getExportClientExtensions(fsExports), snapshotObj, fs, storageObj);
            }
        }
        _dbClient.updateObject(fsObj);
        if (result.isCommandSuccess()) {
            WorkflowStepCompleter.stepSucceded(opId);
        }
    } catch (Exception e) {
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        WorkflowStepCompleter.stepFailed(opId, serviceError);
        String[] params = { storage.toString(), fileUri.toString(), e.getMessage() };
        _log.error("Unable to unexport file system or snapshot: storage {}, FS/snapshot URI {}: {}", params);
        for (FileShareExport fsExport : exports) {
            _log.error("{}  ", fsExport);
        }
        updateTaskStatus(opId, fsObj, e);
        if (URIUtil.isType(fileUri, FileShare.class)) {
            if ((fs != null) && (storageObj != null)) {
                recordFileDeviceOperation(_dbClient, OperationTypeEnum.UNEXPORT_FILE_SYSTEM, false, e.getMessage(), "", fs, storageObj);
            }
        } else {
            if ((fs != null) && (storageObj != null) && (snapshotObj != null)) {
                recordFileDeviceOperation(_dbClient, OperationTypeEnum.UNEXPORT_FILE_SNAPSHOT, false, e.getMessage(), "", snapshotObj, fs, storageObj);
            }
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) StoragePool(com.emc.storageos.db.client.model.StoragePool) OperationTypeEnum(com.emc.storageos.services.OperationTypeEnum) ArrayList(java.util.ArrayList) FileDeviceInputOutput(com.emc.storageos.volumecontroller.FileDeviceInputOutput) FSExportMap(com.emc.storageos.db.client.model.FSExportMap) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) 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) FileShareExport(com.emc.storageos.volumecontroller.FileShareExport) Snapshot(com.emc.storageos.db.client.model.Snapshot) FileExportRule(com.emc.storageos.db.client.model.FileExportRule) FileExport(com.emc.storageos.db.client.model.FileExport) FileObject(com.emc.storageos.db.client.model.FileObject) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 8 with OperationTypeEnum

use of com.emc.storageos.services.OperationTypeEnum in project coprhd-controller by CoprHD.

the class FileDeviceController method updateShareACLs.

@Override
public void updateShareACLs(URI storage, URI fsURI, String shareName, CifsShareACLUpdateParams 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;
    _log.info("Controller recieved request to update ACL of share {}: cifsShareACLUpdateParams {}", shareName, param);
    try {
        StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
        args.setAllShareAcls(param);
        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 for existing ACLs
        args.setExistingShareAcls(queryExistingShareAcls(args));
        // Do the Operation on device.
        // Acquire lock for VNXFILE Storage System
        acquireStepLock(storageObj, opId);
        WorkflowStepCompleter.stepExecuting(opId);
        BiosCommandResult result = getDevice(storageObj.getSystemType()).updateShareACLs(storageObj, args);
        if (result.isCommandSuccess()) {
            // Update database
            updateShareACLsInDB(param, fs, args);
            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.UPDATE_FILE_SYSTEM_SHARE_ACL : OperationTypeEnum.UPDATE_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, getNewACLExtensions(param.retrieveAllACLs()), fs, storageObj);
        } else {
            recordFileDeviceOperation(_dbClient, auditType, result.isCommandSuccess(), eventMsg, getNewACLExtensions(param.retrieveAllACLs()), 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 update 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 9 with OperationTypeEnum

use of com.emc.storageos.services.OperationTypeEnum in project coprhd-controller by CoprHD.

the class FileDeviceController method export.

@Override
public void export(URI storage, URI uri, List<FileShareExport> exports, String opId) throws ControllerException {
    ControllerUtils.setThreadLocalLogData(uri, opId);
    FileObject fsObj = null;
    FileShare fs = null;
    Snapshot snapshotObj = null;
    StorageSystem storageObj = null;
    try {
        storageObj = _dbClient.queryObject(StorageSystem.class, storage);
        FileDeviceInputOutput args = new FileDeviceInputOutput();
        boolean isFile = false;
        if (URIUtil.isType(uri, FileShare.class)) {
            isFile = true;
            fs = _dbClient.queryObject(FileShare.class, uri);
            fsObj = fs;
            args.addFSFileObject(fs);
            StoragePool pool = _dbClient.queryObject(StoragePool.class, fs.getPool());
            args.addStoragePool(pool);
            setVirtualNASinArgs(fs.getVirtualNAS(), args);
        } else {
            snapshotObj = _dbClient.queryObject(Snapshot.class, uri);
            fsObj = snapshotObj;
            fs = _dbClient.queryObject(FileShare.class, snapshotObj.getParent());
            args.addFileShare(fs);
            args.addSnapshotFileObject(snapshotObj);
            StoragePool pool = _dbClient.queryObject(StoragePool.class, fs.getPool());
            args.addStoragePool(pool);
            setVirtualNASinArgs(fs.getVirtualNAS(), args);
        }
        args.setFileOperation(isFile);
        args.setOpId(opId);
        _log.info("Export details...  ");
        List<FileExport> fileExports = new ArrayList<FileExport>();
        if (exports != null) {
            for (FileShareExport fileShareExport : exports) {
                args.setBypassDnsCheck(fileShareExport.getBypassDnsCheck());
                FileExport fExport = fileShareExport.getFileExport();
                fExport.setMountPoint(fileShareExport.getMountPath());
                _log.info("FileExport:clients:" + fExport.getClients() + ":portName:" + fExport.getStoragePortName() + ":port:" + fExport.getStoragePort() + ":rootMapping:" + fExport.getRootUserMapping() + ":permissions:" + fExport.getPermissions() + ":protocol:" + fExport.getProtocol() + ":security:" + fExport.getSecurityType() + ":mountpoint:" + fExport.getMountPoint() + ":path:" + fExport.getPath() + ":comments:" + fExport.getComments() + ":subDirectory:" + fExport.getSubDirectory());
                fileExports.add(fExport);
            }
        } else {
            _log.info("Exports are null");
        }
        // Acquire lock for VNXFILE Storage System
        acquireStepLock(storageObj, opId);
        WorkflowStepCompleter.stepExecuting(opId);
        BiosCommandResult result = getDevice(storageObj.getSystemType()).doExport(storageObj, args, fileExports);
        if (result.getCommandPending()) {
            return;
        }
        if (!result.isCommandSuccess() && !result.getCommandPending()) {
            WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
        }
        // Set Mount path info for the exports
        FSExportMap fsExports = fsObj.getFsExports();
        // Per New model get the rules and see if any rules that are already saved and available.
        List<FileExportRule> existingRules = queryFileExports(args);
        if (null != fsExports) {
            Iterator it = fsExports.keySet().iterator();
            while (it.hasNext()) {
                String fsExpKey = (String) it.next();
                FileExport fileExport = fsObj.getFsExports().get(fsExpKey);
                if ((fileExport.getMountPath() != null) && (fileExport.getMountPath().length() > 0)) {
                    fileExport.setMountPoint(ExportUtils.getFileMountPoint(fileExport.getStoragePort(), fileExport.getMountPath()));
                } else {
                    fileExport.setMountPoint(ExportUtils.getFileMountPoint(fileExport.getStoragePort(), fileExport.getPath()));
                }
                _log.info("FileExport mountpath set to {} {}", fsExpKey, fileExport.getMountPoint());
                // Per New Model of Export Rules Lets create the rule and save it as FileExportRule.
                if (result.isCommandSuccess()) {
                    FileExportRule newRule = getFileExportRule(fsObj.getId(), fileExport, args);
                    _log.debug("ExportRule Constucted per expotkey {}, {}", fsExpKey, newRule);
                    if (existingRules != null && existingRules.isEmpty()) {
                        newRule.setId(URIUtil.createId(FileExportRule.class));
                        _log.info("No Existing rules available for this FS Export and so creating the rule now {}", newRule);
                        _dbClient.createObject(newRule);
                    } else {
                        _log.debug("Checking for existing rule(s) available for this export...");
                        boolean isRuleFound = false;
                        for (FileExportRule rule : existingRules) {
                            _log.debug("Available Export Rule {} - Matching with New Rule {}", rule, newRule);
                            if (newRule.getFsExportIndex() != null && rule.getFsExportIndex().equals(newRule.getFsExportIndex())) {
                                isRuleFound = true;
                                _log.info("Match Found : Skipping this rule as already available {}", newRule);
                                break;
                            }
                        }
                        if (!isRuleFound) {
                            _log.info("Creating new Export Rule {}", newRule);
                            newRule.setId(URIUtil.createId(FileExportRule.class));
                            _dbClient.createObject(newRule);
                            isRuleFound = false;
                        }
                    }
                }
            }
        }
        String eventMsg = result.isCommandSuccess() ? "" : result.getMessage();
        OperationTypeEnum auditType = null;
        auditType = (isFile) ? OperationTypeEnum.EXPORT_FILE_SYSTEM : OperationTypeEnum.EXPORT_FILE_SNAPSHOT;
        fsObj.getOpStatus().updateTaskStatus(opId, result.toOperation());
        if (isFile) {
            recordFileDeviceOperation(_dbClient, auditType, result.isCommandSuccess(), eventMsg, getExportClientExtensions(fileExports), fs, storageObj);
        } else {
            recordFileDeviceOperation(_dbClient, auditType, result.isCommandSuccess(), eventMsg, getExportClientExtensions(fileExports), snapshotObj, fs, storageObj);
        }
        _dbClient.updateObject(fsObj);
        if (result.isCommandSuccess()) {
            WorkflowStepCompleter.stepSucceded(opId);
        }
    } catch (Exception e) {
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        WorkflowStepCompleter.stepFailed(opId, serviceError);
        String[] params = { storage.toString(), uri.toString(), e.getMessage() };
        _log.error("Unable to export file system or snapshot: storage {}, FS/snapshot URI {}: {}", params);
        for (FileShareExport fsExport : exports) {
            _log.error("{}", fsExport);
        }
        updateTaskStatus(opId, fsObj, e);
        if (URIUtil.isType(uri, FileShare.class)) {
            if ((fs != null) && (storageObj != null)) {
                recordFileDeviceOperation(_dbClient, OperationTypeEnum.EXPORT_FILE_SYSTEM, false, e.getMessage(), "", fs, storageObj);
            }
        } else {
            if ((fs != null) && (storageObj != null) && (snapshotObj != null)) {
                recordFileDeviceOperation(_dbClient, OperationTypeEnum.EXPORT_FILE_SNAPSHOT, false, e.getMessage(), "", snapshotObj, fs, storageObj);
            }
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) StoragePool(com.emc.storageos.db.client.model.StoragePool) OperationTypeEnum(com.emc.storageos.services.OperationTypeEnum) ArrayList(java.util.ArrayList) FileDeviceInputOutput(com.emc.storageos.volumecontroller.FileDeviceInputOutput) FSExportMap(com.emc.storageos.db.client.model.FSExportMap) 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) FileShareExport(com.emc.storageos.volumecontroller.FileShareExport) Snapshot(com.emc.storageos.db.client.model.Snapshot) FileExportRule(com.emc.storageos.db.client.model.FileExportRule) FileExport(com.emc.storageos.db.client.model.FileExport) Iterator(java.util.Iterator) FileObject(com.emc.storageos.db.client.model.FileObject) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 10 with OperationTypeEnum

use of com.emc.storageos.services.OperationTypeEnum 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)

Aggregations

OperationTypeEnum (com.emc.storageos.services.OperationTypeEnum)12 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)10 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)10 FileShare (com.emc.storageos.db.client.model.FileShare)9 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)9 StoragePool (com.emc.storageos.db.client.model.StoragePool)9 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)9 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)9 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)9 ControllerException (com.emc.storageos.volumecontroller.ControllerException)9 FileDeviceInputOutput (com.emc.storageos.volumecontroller.FileDeviceInputOutput)9 WorkflowException (com.emc.storageos.workflow.WorkflowException)9 URISyntaxException (java.net.URISyntaxException)9 FileObject (com.emc.storageos.db.client.model.FileObject)7 Snapshot (com.emc.storageos.db.client.model.Snapshot)7 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)6 ArrayList (java.util.ArrayList)5 URI (java.net.URI)3 FSExportMap (com.emc.storageos.db.client.model.FSExportMap)2 FileExport (com.emc.storageos.db.client.model.FileExport)2