Search in sources :

Example 11 with NetAppException

use of com.emc.storageos.netapp.NetAppException in project coprhd-controller by CoprHD.

the class NetAppFileCommunicationInterface method discoverAll.

public void discoverAll(AccessProfile accessProfile) throws BaseCollectionException {
    URI storageSystemId = null;
    StorageSystem storageSystem = null;
    String detailedStatusMessage = "Unknown Status";
    try {
        _logger.info("Access Profile Details :  IpAddress : {}, PortNumber : {}", accessProfile.getIpAddress(), accessProfile.getPortNumber());
        storageSystemId = accessProfile.getSystemId();
        storageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemId);
        // Retrieve NetApp Filer information.
        discoverFilerInfo(storageSystem);
        String minimumSupportedVersion = VersionChecker.getMinimumSupportedVersion(Type.valueOf(storageSystem.getSystemType()));
        String firmwareVersion = storageSystem.getFirmwareVersion();
        // Example version String for Netapp looks like 8.1.2
        _logger.info("Verifying version details : Minimum Supported Version {} - Discovered NetApp Version {}", minimumSupportedVersion, firmwareVersion);
        if (VersionChecker.verifyVersionDetails(minimumSupportedVersion, firmwareVersion) < 0) {
            storageSystem.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.INCOMPATIBLE.name());
            storageSystem.setReachableStatus(false);
            DiscoveryUtils.setSystemResourcesIncompatible(_dbClient, _coordinator, storageSystem.getId());
            NetAppFileCollectionException netAppEx = new NetAppFileCollectionException(String.format(" ** This version of NetApp is not supported ** Should be a minimum of %s", minimumSupportedVersion));
            throw netAppEx;
        }
        storageSystem.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
        storageSystem.setReachableStatus(true);
        _dbClient.persistObject(storageSystem);
        if (!storageSystem.getReachableStatus()) {
            throw new NetAppException("Failed to connect to " + storageSystem.getIpAddress());
        }
        _completer.statusPending(_dbClient, "Identified physical storage");
        List<VFilerInfo> vFilers = new ArrayList<VFilerInfo>();
        Map<String, List<StorageHADomain>> groups = discoverPortGroups(storageSystem, vFilers);
        _logger.info("No of newly discovered groups {}", groups.get(NEW).size());
        _logger.info("No of existing discovered groups {}", groups.get(EXISTING).size());
        if (!groups.get(NEW).isEmpty()) {
            _dbClient.createObject(groups.get(NEW));
        }
        if (!groups.get(EXISTING).isEmpty()) {
            _dbClient.persistObject(groups.get(EXISTING));
        }
        List<StoragePool> poolsToMatchWithVpool = new ArrayList<StoragePool>();
        List<StoragePool> allPools = new ArrayList<StoragePool>();
        Map<String, List<StoragePool>> pools = discoverStoragePools(storageSystem, poolsToMatchWithVpool);
        _logger.info("No of newly discovered pools {}", pools.get(NEW).size());
        _logger.info("No of existing discovered pools {}", pools.get(EXISTING).size());
        if (!pools.get(NEW).isEmpty()) {
            allPools.addAll(pools.get(NEW));
            _dbClient.createObject(pools.get(NEW));
        }
        if (!pools.get(EXISTING).isEmpty()) {
            allPools.addAll(pools.get(EXISTING));
            _dbClient.persistObject(pools.get(EXISTING));
        }
        List<StoragePool> notVisiblePools = DiscoveryUtils.checkStoragePoolsNotVisible(allPools, _dbClient, storageSystemId);
        if (notVisiblePools != null && !notVisiblePools.isEmpty()) {
            poolsToMatchWithVpool.addAll(notVisiblePools);
        }
        _completer.statusPending(_dbClient, "Completed pool discovery");
        // discover ports
        List<StoragePort> allPorts = new ArrayList<StoragePort>();
        Map<String, List<StoragePort>> ports = discoverPorts(storageSystem, vFilers, groups.get(NEW));
        _logger.info("No of newly discovered port {}", ports.get(NEW).size());
        _logger.info("No of existing discovered port {}", ports.get(EXISTING).size());
        if (!ports.get(NEW).isEmpty()) {
            allPorts.addAll(ports.get(NEW));
            _dbClient.createObject(ports.get(NEW));
        }
        if (!ports.get(EXISTING).isEmpty()) {
            allPorts.addAll(ports.get(EXISTING));
            _dbClient.persistObject(ports.get(EXISTING));
        }
        List<StoragePort> notVisiblePorts = DiscoveryUtils.checkStoragePortsNotVisible(allPorts, _dbClient, storageSystemId);
        _completer.statusPending(_dbClient, "Completed port discovery");
        List<StoragePort> allExistingPorts = new ArrayList<StoragePort>(ports.get(EXISTING));
        if (notVisiblePorts != null && !notVisiblePorts.isEmpty()) {
            allExistingPorts.addAll(notVisiblePorts);
        }
        StoragePortAssociationHelper.runUpdatePortAssociationsProcess(ports.get(NEW), allExistingPorts, _dbClient, _coordinator, poolsToMatchWithVpool);
        // discovery succeeds
        detailedStatusMessage = String.format("Discovery completed successfully for Storage System: %s", storageSystemId.toString());
    } catch (Exception e) {
        if (null != storageSystem) {
            cleanupDiscovery(storageSystem);
        }
        detailedStatusMessage = String.format("Discovery failed for Storage System: %s because %s", storageSystemId.toString(), e.getLocalizedMessage());
        _logger.error(detailedStatusMessage, e);
        throw new NetAppFileCollectionException(detailedStatusMessage);
    } finally {
        if (storageSystem != null) {
            try {
                // set detailed message
                storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
                _dbClient.persistObject(storageSystem);
            } catch (DatabaseException ex) {
                _logger.error("Error while persisting object to DB", ex);
            }
        }
    }
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) ArrayList(java.util.ArrayList) StoragePort(com.emc.storageos.db.client.model.StoragePort) URI(java.net.URI) NetAppException(com.emc.storageos.netapp.NetAppException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) NetAppException(com.emc.storageos.netapp.NetAppException) NetAppFileCollectionException(com.emc.storageos.plugins.metering.netapp.NetAppFileCollectionException) IOException(java.io.IOException) VFilerInfo(com.iwave.ext.netapp.VFilerInfo) NetAppFileCollectionException(com.emc.storageos.plugins.metering.netapp.NetAppFileCollectionException) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 12 with NetAppException

use of com.emc.storageos.netapp.NetAppException in project coprhd-controller by CoprHD.

the class NetAppFileStorageDevice method doCreateFS.

@Override
public BiosCommandResult doCreateFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    BiosCommandResult result = new BiosCommandResult();
    try {
        _log.info("NetAppFileStorageDevice doCreateFS - start");
        if (null == args.getFsName()) {
            _log.error("NetAppFileStorageDevice::doCreateFS failed:  Filesystem name is either missing or empty");
            ServiceError serviceError = DeviceControllerErrors.netapp.unableToCreateFileSystem();
            serviceError.setMessage(FileSystemConstants.FS_ERR_FS_NAME_MISSING_OR_EMPTY);
            result = BiosCommandResult.createErrorResult(serviceError);
            return result;
        }
        if (null == args.getPoolNativeId()) {
            _log.error("NetAppFileStorageDevice::doCreateFS failed:  PoolNativeId either missing or empty");
            ServiceError serviceError = DeviceControllerErrors.netapp.unableToCreateFileSystem();
            serviceError.setMessage(FileSystemConstants.FS_ERR_POOL_NATIVE_ID_MISSING_OR_EMPTY);
            result = BiosCommandResult.createErrorResult(serviceError);
            return result;
        }
        if (null == args.getFsCapacity()) {
            _log.error("NetAppFileStorageDevice::doCreateFS failed:  Filesystem capacity is either missing or empty");
            ServiceError serviceError = DeviceControllerErrors.netapp.unableToCreateFileSystem();
            serviceError.setMessage(FileSystemConstants.FS_ERR_FS_CAPACITY_MISSING_OR_EMPTY);
            result = BiosCommandResult.createErrorResult(serviceError);
            return result;
        }
        String nativeId;
        if (args.getFsName().startsWith(VOL_ROOT)) {
            nativeId = args.getFsName();
        } else {
            nativeId = VOL_ROOT + args.getFsName();
        }
        args.setFsNativeId(nativeId);
        String fsNativeGuid = NativeGUIDGenerator.generateNativeGuid(storage.getSystemType(), storage.getSerialNumber(), nativeId);
        args.setFsNativeGuid(fsNativeGuid);
        String portGroup = findVfilerName(args.getFs());
        NetAppApi nApi = new NetAppApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).vFiler(portGroup).build();
        Long fsSize = args.getFsCapacity() / BYTESPERMB;
        String strFsSize = fsSize.toString() + "m";
        if (!nApi.createFS(args.getFsName(), args.getPoolNativeId(), strFsSize, args.getThinProvision())) {
            _log.error("NetAppFileStorageDevice doCreateFS {} - failed", args.getFsName());
            BiosCommandResult rollbackResult = doDeleteFS(storage, args);
            if (rollbackResult.isCommandSuccess()) {
                _log.info("NetAppFileStorageDevice doCreateFS rollback completed failed for fs, {}", args.getFsName());
            } else {
                _log.error("NetAppFileStorageDevice doCreateFS rollback failed for fs, {} with {}.", args.getFsName(), rollbackResult.getMessage());
            }
            ServiceError serviceError = DeviceControllerErrors.netapp.unableToCreateFileSystem();
            result = BiosCommandResult.createErrorResult(serviceError);
        } else {
            _log.info("NetAppFileStorageDevice doCreateFS {} - complete", args.getFsName());
            // Set FS path and Mount Path information
            args.setFsPath(nativeId);
            args.setFsMountPath(nativeId);
            result = BiosCommandResult.createSuccessfulResult();
        }
    } catch (NetAppException e) {
        _log.error("NetAppFileStorageDevice::doCreateFS failed with a NetAppException", e);
        ServiceError serviceError = DeviceControllerErrors.netapp.unableToCreateFileSystem();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    } catch (Exception e) {
        _log.error("NetAppFileStorageDevice::doCreateFS failed with an Exception", e);
        ServiceError serviceError = DeviceControllerErrors.netapp.unableToCreateFileSystem();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    }
    return result;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) NetAppApi(com.emc.storageos.netapp.NetAppApi) NetAppException(com.emc.storageos.netapp.NetAppException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) NetAppException(com.emc.storageos.netapp.NetAppException)

Example 13 with NetAppException

use of com.emc.storageos.netapp.NetAppException in project coprhd-controller by CoprHD.

the class NetAppFileStorageDevice method doUnexport.

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

Example 14 with NetAppException

use of com.emc.storageos.netapp.NetAppException in project coprhd-controller by CoprHD.

the class NetAppFileStorageDevice method doDeleteQuotaDirectory.

@Override
public BiosCommandResult doDeleteQuotaDirectory(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    BiosCommandResult result = new BiosCommandResult();
    try {
        _log.info("NetAppFileStorageDevice doDeleteQuotaDirectory - start");
        // Using NetApp terminology here
        String volName = args.getFsName();
        String qtreeName = args.getQuotaDirectoryName();
        if (null == volName) {
            _log.error("NetAppFileStorageDevice::doDeleteQuotaDirectory failed:  Filesystem name is either missing or empty");
            ServiceError serviceError = DeviceControllerErrors.netapp.unableToDeleteQtree();
            serviceError.setMessage(FileSystemConstants.FS_ERR_FS_NAME_MISSING_OR_EMPTY);
            result = BiosCommandResult.createErrorResult(serviceError);
            return result;
        }
        if (null == qtreeName) {
            _log.error("NetAppFileStorageDevice::doCreateQuotaDirectory failed:  Qtree name is either missing or empty");
            ServiceError serviceError = DeviceControllerErrors.netapp.unableToDeleteQtree();
            serviceError.setMessage(FileSystemConstants.FS_ERR_QUOTADIR_NAME_MISSING_OR_EMPTY);
            result = BiosCommandResult.createErrorResult(serviceError);
            return result;
        }
        String portGroup = findVfilerName(args.getFs());
        NetAppApi nApi = new NetAppApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).vFiler(portGroup).build();
        nApi.deleteQtree(qtreeName, volName, portGroup);
        result = BiosCommandResult.createSuccessfulResult();
    } catch (NetAppException e) {
        _log.error("NetAppFileStorageDevice::doDeleteQuotaDirectory failed with a NetAppException", e);
        ServiceError serviceError = DeviceControllerErrors.netapp.unableToDeleteQtree();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    } catch (Exception e) {
        _log.error("NetAppFileStorageDevice::doDeleteQuotaDirectory failed with an Exception", e);
        ServiceError serviceError = DeviceControllerErrors.netapp.unableToDeleteQtree();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    }
    return result;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) NetAppApi(com.emc.storageos.netapp.NetAppApi) NetAppException(com.emc.storageos.netapp.NetAppException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) NetAppException(com.emc.storageos.netapp.NetAppException)

Example 15 with NetAppException

use of com.emc.storageos.netapp.NetAppException in project coprhd-controller by CoprHD.

the class NetAppFileStorageDevice method doCreateQuotaDirectory.

// New Qtree methods
@Override
public BiosCommandResult doCreateQuotaDirectory(StorageSystem storage, FileDeviceInputOutput args, QuotaDirectory qtree) throws ControllerException {
    BiosCommandResult result = new BiosCommandResult();
    try {
        _log.info("NetAppFileStorageDevice 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();
        if (null == volName) {
            _log.error("NetAppFileStorageDevice::doCreateQuotaDirectory failed:  Filesystem name is either missing or empty");
            ServiceError serviceError = DeviceControllerErrors.netapp.unableToCreateQtree();
            serviceError.setMessage(FileSystemConstants.FS_ERR_FS_NAME_MISSING_OR_EMPTY);
            result = BiosCommandResult.createErrorResult(serviceError);
            return result;
        }
        if (null == qtreeName) {
            _log.error("NetAppFileStorageDevice::doCreateQuotaDirectory failed:  Qtree name is either missing or empty");
            ServiceError serviceError = DeviceControllerErrors.netapp.unableToCreateQtree();
            serviceError.setMessage(FileSystemConstants.FS_ERR_QUOTADIR_NAME_MISSING_OR_EMPTY);
            result = BiosCommandResult.createErrorResult(serviceError);
            return result;
        }
        if (!validQuotaDirectoryPath(volName, qtreeName)) {
            _log.error("NetAppFileStorageDevice::doCreateQuotaDirectory failed:  Qtree name or path is too long");
            ServiceError serviceError = DeviceControllerErrors.netapp.unableToCreateQtree();
            serviceError.setMessage(FileSystemConstants.FS_ERR_QUOTADIR_NAME_PATH_TOO_LONG);
            result = BiosCommandResult.createErrorResult(serviceError);
            return result;
        }
        String portGroup = findVfilerName(args.getFs());
        _log.info("NetAppFileStorageDevice::NetAppFileStorageDevice - For FS: {}, vFiler: {}", volName, portGroup);
        NetAppApi nApi = new NetAppApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).vFiler(portGroup).build();
        nApi.createQtree(qtreeName, volName, oplocks, securityStyle, size, portGroup);
        result = BiosCommandResult.createSuccessfulResult();
    } catch (NetAppException e) {
        _log.error("NetAppFileStorageDevice::doCreateQuotaDirectory failed with a NetAppException", e);
        _log.info("NetAppFileStorageDevice::doCreateQuotaDirectory e.getLocalizedMessage(): {}", e.getLocalizedMessage());
        ServiceError serviceError = DeviceControllerErrors.netapp.unableToCreateQtree();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    } catch (Exception e) {
        _log.error("NetAppFileStorageDevice::doCreateQuotaDirectory failed with an Exception", e);
        ServiceError serviceError = DeviceControllerErrors.netapp.unableToCreateQtree();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    }
    return result;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) NetAppApi(com.emc.storageos.netapp.NetAppApi) NetAppException(com.emc.storageos.netapp.NetAppException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) NetAppException(com.emc.storageos.netapp.NetAppException)

Aggregations

NetAppException (com.emc.storageos.netapp.NetAppException)27 NetAppApi (com.emc.storageos.netapp.NetAppApi)23 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)16 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)16 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)12 ControllerException (com.emc.storageos.volumecontroller.ControllerException)12 URI (java.net.URI)11 ArrayList (java.util.ArrayList)10 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)9 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)9 IOException (java.io.IOException)9 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)8 NetAppFileCollectionException (com.emc.storageos.plugins.metering.netapp.NetAppFileCollectionException)8 HashMap (java.util.HashMap)8 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)7 FileShare (com.emc.storageos.db.client.model.FileShare)6 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)6 VFilerInfo (com.iwave.ext.netapp.VFilerInfo)6 StoragePort (com.emc.storageos.db.client.model.StoragePort)5 StringMap (com.emc.storageos.db.client.model.StringMap)5