Search in sources :

Example 76 with BiosCommandResult

use of com.emc.storageos.volumecontroller.impl.BiosCommandResult in project coprhd-controller by CoprHD.

the class NetAppClusterModeDevice method doCreateQuotaDirectory.

@Override
public BiosCommandResult doCreateQuotaDirectory(StorageSystem storage, FileDeviceInputOutput args, QuotaDirectory qtree) throws ControllerException {
    BiosCommandResult result = new BiosCommandResult();
    try {
        _log.info("NetAppClusterModeDevice doCreateQuotaDirectory - start");
        // Using NetApp terminology here
        String volName = args.getFsName();
        String qtreeName = args.getQuotaDirectoryName();
        Boolean oplocks = qtree.getOpLock();
        String securityStyle = qtree.getSecurityStyle();
        Long size = qtree.getSize();
        String method = new String("doCreateQuotaDirectory");
        result = validateQuotaDirectoryParams(volName, qtreeName, method);
        if (!result.isCommandSuccess()) {
            return result;
        }
        String portGroup = findSVMName(args.getFs());
        NetAppClusterApi ncApi = new NetAppClusterApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).svm(portGroup).build();
        ncApi.createQtree(qtreeName, volName, oplocks, securityStyle, size, portGroup);
        result = BiosCommandResult.createSuccessfulResult();
    } catch (NetAppCException e) {
        _log.error("NetAppClusterModeDevice::doCreateQuotaDirectory failed with a NetAppCException", e);
        _log.info("NetAppClusterModeDevice::doCreateQuotaDirectory e.getLocalizedMessage(): {}", e.getLocalizedMessage());
        ServiceError serviceError = DeviceControllerErrors.netappc.unableToCreateQtree();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    } catch (Exception e) {
        _log.error("NetAppClusterModeDevice::doCreateQuotaDirectory failed with an Exception", e);
        ServiceError serviceError = DeviceControllerErrors.netappc.unableToCreateQtree();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    }
    return result;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) NetAppClusterApi(com.emc.storageos.netappc.NetAppClusterApi) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) NetAppCException(com.emc.storageos.netappc.NetAppCException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) NetAppCException(com.emc.storageos.netappc.NetAppCException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) NetAppException(com.emc.storageos.netapp.NetAppException)

Example 77 with BiosCommandResult

use of com.emc.storageos.volumecontroller.impl.BiosCommandResult in project coprhd-controller by CoprHD.

the class NetAppClusterModeDevice method doUnexport.

@Override
public BiosCommandResult doUnexport(StorageSystem storage, FileDeviceInputOutput args, List<FileExport> exportList) throws ControllerException {
    BiosCommandResult result = new BiosCommandResult();
    try {
        _log.info("NetAppClusterModeDevice doUnexport: {} - start", args.getFileObjId());
        if (!args.getFileOperation()) {
            _log.error("NetAppClusterModeDevice::doUnexport {} : Snapshot unexport is not Supported", args.getSnapshotId());
            ServiceError serviceError = DeviceControllerErrors.netappc.unableToUnexportSnapshot();
            serviceError.setMessage(genDetailedMessage("doUnExport", args.getSnapshotId().toString(), "Snapshot unexport is not Supported"));
            result = BiosCommandResult.createErrorResult(serviceError);
            return result;
        }
        for (int expCount = 0; expCount < exportList.size(); expCount++) {
            FileExport export = exportList.get(expCount);
            String portGroup = findSVMName(args.getFs());
            NetAppClusterApi ncApi = new NetAppClusterApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).svm(portGroup).build();
            if (export.getPermissions() == null) {
                export.setPermissions(RO_PERM);
            }
            String mountPath = export.getMountPath();
            String exportPath = export.getPath();
            if (!ncApi.unexportFS(exportPath, mountPath)) {
                _log.error("NetAppClusterModeDevice::doUnexport {} failed", args.getFsId());
                ServiceError serviceError = DeviceControllerErrors.netappc.unableToUnexportFileSystem();
                serviceError.setMessage(genDetailedMessage("doUnexport", args.getFsId().toString()));
                result = BiosCommandResult.createErrorResult(serviceError);
                return result;
            } else {
                _log.info("NetAppClusterModeDevice doUnexport {} - completed", args.getFsId());
                result = BiosCommandResult.createSuccessfulResult();
            }
        }
    } catch (NetAppCException e) {
        _log.error("NetAppClusterModeDevice::doUnexport failed with a NetAppCException", e);
        ServiceError serviceError = DeviceControllerErrors.netappc.unableToUnexportFileSystem();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    } catch (Exception e) {
        _log.error("NetAppClusterModeDevice::doUnexport failed with an Exception", e);
        ServiceError serviceError = DeviceControllerErrors.netappc.unableToUnexportFileSystem();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    }
    _log.info("NetAppClusterModeDevice doUnexport {} - complete", args.getFileObjId());
    return result;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) NetAppClusterApi(com.emc.storageos.netappc.NetAppClusterApi) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) NetAppCException(com.emc.storageos.netappc.NetAppCException) FileExport(com.emc.storageos.db.client.model.FileExport) ControllerException(com.emc.storageos.volumecontroller.ControllerException) NetAppCException(com.emc.storageos.netappc.NetAppCException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) NetAppException(com.emc.storageos.netapp.NetAppException)

Example 78 with BiosCommandResult

use of com.emc.storageos.volumecontroller.impl.BiosCommandResult in project coprhd-controller by CoprHD.

the class NetAppClusterModeDevice method deleteExportRules.

@Override
public BiosCommandResult deleteExportRules(StorageSystem storage, FileDeviceInputOutput args) {
    BiosCommandResult result = new BiosCommandResult();
    String portGroup = findSVMName(args.getFs());
    NetAppClusterApi ncApi = new NetAppClusterApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).svm(portGroup).build();
    List<ExportRule> allExports = args.getExistingDBExportRules();
    String subDir = args.getSubDirectory();
    boolean allDirs = args.isAllDir();
    String exportPath;
    String qtreePath = "";
    if (!args.getFileOperation()) {
        _log.error("NetAppClusterModeDevice::doUnexport {} : Snapshot unexport is not Supported", args.getSnapshotId());
        ServiceError serviceError = DeviceControllerErrors.netappc.unableToUnexportSnapshot();
        serviceError.setMessage(genDetailedMessage("doUnExport", args.getSnapshotId().toString(), "Snapshot unexport is not Supported"));
        result = BiosCommandResult.createErrorResult(serviceError);
        return result;
    } else {
        exportPath = args.getFs().getPath();
        qtreePath = exportPath;
        if (subDir != null && subDir.length() > 0) {
            exportPath = args.getFs().getPath() + "/" + subDir;
            if (ncApi.isQtree(args.getFsName(), subDir)) {
                qtreePath = constructQtreePath(args.getFsName(), subDir);
            } else {
                _log.error("NetAppClusterModeDevice::doUnexport {} : Sub-directory unexport is not Supported", args.getFsId());
                ServiceError serviceError = DeviceControllerErrors.netappc.unableToExportFileSystem();
                serviceError.setMessage(genDetailedMessage("doUnExport", args.getFsId().toString(), "Sub-directory unexport is not Supported"));
                result = BiosCommandResult.createErrorResult(serviceError);
                return result;
            }
        }
    }
    _log.info("exportPath : {}", exportPath);
    args.setExportPath(exportPath);
    _log.info("Number of existing exports found {}", allExports.size());
    try {
        if (allDirs) {
            Set<String> allPaths = new HashSet<String>();
            // ALL EXPORTS
            _log.info("Deleting all exports specific to filesystem at device and rules from DB including sub dirs rules and exports");
            for (ExportRule rule : allExports) {
                allPaths.add(rule.getExportPath());
            }
            for (String path : allPaths) {
                boolean isSubDir = checkIfSubDirectory(args.getFsMountPath(), path);
                if (isSubDir) {
                    subDir = getSubDirectory(args.getFsMountPath(), path);
                    if (ncApi.isQtree(args.getFsName(), subDir)) {
                        path = constructQtreePath(args.getFsName(), subDir);
                    }
                }
                _log.info("deleting export path : {} ", path);
                ncApi.deleteNFSExport(path);
            }
        } else if (subDir != null && !subDir.isEmpty()) {
            // Filter for a specific Sub Directory export
            _log.info("Deleting all subdir exports rules at ViPR and  sub directory export at device {}", subDir);
            for (ExportRule rule : allExports) {
                if (rule.getExportPath().endsWith("/" + subDir)) {
                    ncApi.deleteNFSExport(qtreePath);
                    break;
                }
            }
        } else {
            // Filter for No SUBDIR - main export rules with no sub dirs
            _log.info("Deleting all export rules  from DB and export at device not included sub dirs");
            ncApi.deleteNFSExport(qtreePath);
        }
    } catch (NetAppCException e) {
        _log.info("Exception:" + e.getMessage());
        throw new DeviceControllerException("Exception while performing export for {0} ", new Object[] { args.getFsId() });
    }
    _log.info("NetAppClusterModeDevice unexportFS {} - complete", args.getFsId());
    result.setCommandSuccess(true);
    result.setCommandStatus(Operation.Status.ready.name());
    return result;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) NetAppClusterApi(com.emc.storageos.netappc.NetAppClusterApi) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) NetAppCException(com.emc.storageos.netappc.NetAppCException) ExportRule(com.emc.storageos.model.file.ExportRule) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) HashSet(java.util.HashSet)

Example 79 with BiosCommandResult

use of com.emc.storageos.volumecontroller.impl.BiosCommandResult in project coprhd-controller by CoprHD.

the class NetAppClusterModeDevice method updateShareACLs.

@Override
public BiosCommandResult updateShareACLs(StorageSystem storage, FileDeviceInputOutput args) {
    List<ShareACL> existingAcls = new ArrayList<ShareACL>();
    existingAcls = args.getExistingShareAcls();
    String portGroup = findSVMName(args.getFs());
    BiosCommandResult result = new BiosCommandResult();
    NetAppClusterApi ncApi = new NetAppClusterApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).svm(portGroup).build();
    try {
        processAclsForShare(ncApi, args);
        result = BiosCommandResult.createSuccessfulResult();
    } catch (Exception e) {
        _log.error("NetAppClusterModeDevice::updateShareACLs failed with an Exception", e);
        ServiceError serviceError = DeviceControllerErrors.netappc.unableToUpdateCIFSShareAcl();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
        // if delete or modify fails , revert to old acl
        rollbackShareACLs(storage, args, existingAcls);
    }
    return result;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) NetAppClusterApi(com.emc.storageos.netappc.NetAppClusterApi) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) ArrayList(java.util.ArrayList) ShareACL(com.emc.storageos.model.file.ShareACL) ControllerException(com.emc.storageos.volumecontroller.ControllerException) NetAppCException(com.emc.storageos.netappc.NetAppCException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) NetAppException(com.emc.storageos.netapp.NetAppException)

Example 80 with BiosCommandResult

use of com.emc.storageos.volumecontroller.impl.BiosCommandResult in project coprhd-controller by CoprHD.

the class NetAppClusterModeDevice method doSnapshotFS.

@Override
public BiosCommandResult doSnapshotFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    BiosCommandResult result = new BiosCommandResult();
    try {
        _log.info("NetAppClusterModeDevice doSnapshotFS - start");
        if (null == args.getFsName()) {
            _log.error("NetAppClusterModeDevice::doSnapshotFS failed:  Filesystem name is either missing or empty");
            ServiceError serviceError = DeviceControllerErrors.netappc.unableToCreateSnapshot();
            serviceError.setMessage(FileSystemConstants.FS_ERR_FS_NAME_MISSING_OR_EMPTY);
            result = BiosCommandResult.createErrorResult(serviceError);
            return result;
        }
        if (null == args.getSnapshotName()) {
            _log.error("NetAppClusterModeDevice::doSnapshotFS failed:  Snapshot name is either missing or empty");
            ServiceError serviceError = DeviceControllerErrors.netappc.unableToCreateSnapshot();
            serviceError.setMessage(FileSystemConstants.FS_ERR_SNAPSHOT_NAME_MISSING_OR_EMPTY);
            result = BiosCommandResult.createErrorResult(serviceError);
            return result;
        }
        boolean failedStatus = false;
        String portGroup = findSVMName(args.getFs());
        NetAppClusterApi ncApi = new NetAppClusterApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).svm(portGroup).build();
        if (!ncApi.createSnapshot(args.getFsName(), args.getSnapshotName())) {
            failedStatus = true;
        }
        if (failedStatus == true) {
            _log.error("NetAppClusterModeDevice doSnapshotFS {} - failed", args.getFsId());
            ServiceError serviceError = DeviceControllerErrors.netappc.unableToCreateSnapshot();
            serviceError.setMessage(genDetailedMessage("doSnapshotFS", args.getFsName()));
            result = BiosCommandResult.createErrorResult(serviceError);
        } else {
            _log.info("doSnapshotFS - Snapshot, {}  was successfully created for filesystem, {} ", args.getSnapshotName(), args.getFsName());
            // Set snapshot Path and MountPath information
            args.setSnapshotMountPath(getSnapshotMountPath(args.getFsMountPath(), args.getSnapshotName()));
            args.setSnapshotPath(getSnapshotPath(args.getFsPath(), args.getSnapshotName()));
            args.setSnapNativeId(args.getSnapshotName());
            result = BiosCommandResult.createSuccessfulResult();
        }
    } catch (NetAppCException e) {
        _log.error("NetAppClusterModeDevice::doSnapshotFS failed with a NetAppCException", e);
        ServiceError serviceError = DeviceControllerErrors.netappc.unableToCreateSnapshot();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    } catch (Exception e) {
        _log.error("NetAppClusterModeDevice::doSnapshotFS failed with an Exception", e);
        ServiceError serviceError = DeviceControllerErrors.netappc.unableToCreateSnapshot();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    }
    return result;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) NetAppClusterApi(com.emc.storageos.netappc.NetAppClusterApi) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) NetAppCException(com.emc.storageos.netappc.NetAppCException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) NetAppCException(com.emc.storageos.netappc.NetAppCException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) NetAppException(com.emc.storageos.netapp.NetAppException)

Aggregations

BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)135 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)76 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)69 ControllerException (com.emc.storageos.volumecontroller.ControllerException)64 NetAppException (com.emc.storageos.netapp.NetAppException)34 ArrayList (java.util.ArrayList)34 NetworkDeviceControllerException (com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException)28 NetAppCException (com.emc.storageos.netappc.NetAppCException)19 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)18 NetAppApi (com.emc.storageos.netapp.NetAppApi)18 NetAppClusterApi (com.emc.storageos.netappc.NetAppClusterApi)18 URI (java.net.URI)16 VNXException (com.emc.storageos.vnx.xmlapi.VNXException)15 XMLApiResult (com.emc.storageos.vnx.xmlapi.XMLApiResult)15 VNXFileCommApi (com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi)15 ApplicationContext (org.springframework.context.ApplicationContext)15 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)15 FileShare (com.emc.storageos.db.client.model.FileShare)14 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)14 NetworkSystem (com.emc.storageos.db.client.model.NetworkSystem)11