Search in sources :

Example 11 with NetAppCException

use of com.emc.storageos.netappc.NetAppCException in project coprhd-controller by CoprHD.

the class NetAppClusterModeCommIntf method discoverUnManagedCifsShares.

/**
 * discover the unmanaged cifs shares and add shares to ViPR db
 *
 * @param profile
 */
private void discoverUnManagedCifsShares(AccessProfile profile) {
    URI storageSystemId = profile.getSystemId();
    StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemId);
    if (null == storageSystem) {
        return;
    }
    storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.IN_PROGRESS.toString());
    String detailedStatusMessage = "Discovery of NetAppC Unmanaged Cifs started";
    NetAppClusterApi netAppCApi = new NetAppClusterApi.Builder(storageSystem.getIpAddress(), storageSystem.getPortNumber(), storageSystem.getUsername(), storageSystem.getPassword()).https(true).build();
    Collection<String> attrs = new ArrayList<String>();
    for (String property : ntpPropertiesList) {
        attrs.add(SupportedNtpFileSystemInformation.getFileSystemInformation(property));
    }
    try {
        // Used to Save the Acl to DB
        List<UnManagedCifsShareACL> unManagedCifsShareACLList = new ArrayList<UnManagedCifsShareACL>();
        List<UnManagedCifsShareACL> oldunManagedCifsShareACLList = new ArrayList<UnManagedCifsShareACL>();
        HashSet<UnManagedSMBFileShare> unManagedSMBFileShareHashSet = null;
        List<Map<String, String>> fileSystemInfo = netAppCApi.listVolumeInfo(null, attrs);
        List<StorageVirtualMachineInfo> svms = netAppCApi.listSVM();
        for (StorageVirtualMachineInfo svmInfo : svms) {
            netAppCApi = new NetAppClusterApi.Builder(storageSystem.getIpAddress(), storageSystem.getPortNumber(), storageSystem.getUsername(), storageSystem.getPassword()).https(true).svm(svmInfo.getName()).build();
            // Get All cifs shares and ACLs
            List<Map<String, String>> listShares = netAppCApi.listShares(null);
            if (listShares != null && !listShares.isEmpty()) {
                _logger.info("total no of shares in netappC system (s) {}", listShares.size());
            }
            // prepare the unmanagedSmbshare
            HashMap<String, HashSet<UnManagedSMBFileShare>> unMangedSMBFileShareMapSet = getAllCifsShares(listShares);
            for (String key : unMangedSMBFileShareMapSet.keySet()) {
                unManagedSMBFileShareHashSet = unMangedSMBFileShareMapSet.get(key);
                String fileSystem = key;
                String nativeId = fileSystem;
                // get a fileSystem name from the path
                int index = fileSystem.indexOf('/', 1);
                if (-1 != index) {
                    fileSystem = fileSystem.substring(0, index);
                    _logger.info("Unmanaged FileSystem Name {}", fileSystem);
                }
                // build native id
                String fsUnManagedFsNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileSystem(storageSystem.getSystemType(), storageSystem.getSerialNumber().toUpperCase(), fileSystem);
                UnManagedFileSystem unManagedFs = checkUnManagedFileSystemExistsInDB(fsUnManagedFsNativeGuid);
                boolean fsAlreadyExists = unManagedFs == null ? false : true;
                if (fsAlreadyExists) {
                    _logger.debug("retrieve info for file system: " + fileSystem);
                    String svm = getOwningSVM(fileSystem, fileSystemInfo);
                    String addr = getSVMAddress(svm, svms);
                    UnManagedSMBShareMap tempUnManagedSMBShareMap = new UnManagedSMBShareMap();
                    // get the SMB shares
                    createSMBShareMap(unManagedSMBFileShareHashSet, tempUnManagedSMBShareMap, addr, nativeId);
                    // add shares to fs object and set hasShare to true
                    if (tempUnManagedSMBShareMap.size() > 0 && !tempUnManagedSMBShareMap.isEmpty()) {
                        unManagedFs.setUnManagedSmbShareMap(tempUnManagedSMBShareMap);
                        unManagedFs.setHasShares(true);
                        unManagedFs.putFileSystemCharacterstics(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_FILESYSTEM_EXPORTED.toString(), TRUE);
                        _logger.debug("SMB Share map for NetAppC UMFS {} = {}", unManagedFs.getLabel(), unManagedFs.getUnManagedSmbShareMap());
                    }
                    // get the acls details for given fileshare of given fs
                    UnManagedCifsShareACL existingACL = null;
                    List<UnManagedCifsShareACL> tempUnManagedCifsShareAclList = getACLs(unManagedSMBFileShareHashSet, netAppCApi, storageSystem, unManagedFs.getId());
                    if (tempUnManagedCifsShareAclList != null && !tempUnManagedCifsShareAclList.isEmpty()) {
                        for (UnManagedCifsShareACL unManagedCifsShareACL : tempUnManagedCifsShareAclList) {
                            // Check whether the CIFS share ACL was present in ViPR DB.
                            existingACL = checkUnManagedFsCifsACLExistsInDB(_dbClient, unManagedCifsShareACL.getNativeGuid());
                            if (existingACL == null) {
                                // add new acl
                                unManagedCifsShareACLList.add(unManagedCifsShareACL);
                            } else {
                                // delete the existing acl by setting object to inactive to true
                                existingACL.setInactive(true);
                                oldunManagedCifsShareACLList.add(existingACL);
                                // then add new acl and save
                                unManagedCifsShareACLList.add(unManagedCifsShareACL);
                            }
                        }
                    }
                    // store or update the FS object into DB
                    if (unManagedSMBFileShareHashSet != null && !unManagedSMBFileShareHashSet.isEmpty()) {
                        _dbClient.persistObject(unManagedFs);
                        _logger.info("File System {} has Shares and their Count is {}", unManagedFs.getId(), tempUnManagedSMBShareMap.size());
                    }
                    // Adding this additional logic to avoid OOM
                    if (unManagedCifsShareACLList.size() >= MAX_UMFS_RECORD_SIZE) {
                        _logger.info("Saving Number of New UnManagedCifsShareACL(s) {}", unManagedCifsShareACLList.size());
                        _partitionManager.insertInBatches(unManagedCifsShareACLList, Constants.DEFAULT_PARTITION_SIZE, _dbClient, UNMANAGED_SHARE_ACL);
                        unManagedCifsShareACLList.clear();
                    }
                    if (!oldunManagedCifsShareACLList.isEmpty() && oldunManagedCifsShareACLList.size() >= MAX_UMFS_RECORD_SIZE) {
                        _logger.info("Update Number of Old UnManagedCifsShareACL(s) {}", oldunManagedCifsShareACLList.size());
                        _partitionManager.updateInBatches(oldunManagedCifsShareACLList, Constants.DEFAULT_PARTITION_SIZE, _dbClient, UNMANAGED_SHARE_ACL);
                        oldunManagedCifsShareACLList.clear();
                    }
                } else {
                    _logger.info("FileSystem " + unManagedFs + "is not present in ViPR DB. Hence ignoring " + fileSystem + " share");
                }
            }
        }
        if (unManagedCifsShareACLList != null && !unManagedCifsShareACLList.isEmpty()) {
            _logger.info("Saving Number of New UnManagedCifsShareACL(s) {}", unManagedCifsShareACLList.size());
            _partitionManager.insertInBatches(unManagedCifsShareACLList, Constants.DEFAULT_PARTITION_SIZE, _dbClient, UNMANAGED_SHARE_ACL);
            unManagedCifsShareACLList.clear();
        }
        if (oldunManagedCifsShareACLList != null && !oldunManagedCifsShareACLList.isEmpty()) {
            _logger.info("Saving Number of Old UnManagedCifsShareACL(s) {}", oldunManagedCifsShareACLList.size());
            _partitionManager.updateInBatches(oldunManagedCifsShareACLList, Constants.DEFAULT_PARTITION_SIZE, _dbClient, UNMANAGED_SHARE_ACL);
            oldunManagedCifsShareACLList.clear();
        }
        storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.COMPLETE.toString());
        // discovery succeeds
        detailedStatusMessage = String.format("Discovery completed successfully for NetAppC: %s", storageSystemId.toString());
    } catch (NetAppCException ve) {
        if (null != storageSystem) {
            cleanupDiscovery(storageSystem);
            storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.ERROR.toString());
        }
        _logger.error("discoverStorage failed.  Storage system: " + storageSystemId);
    } catch (Exception e) {
        if (null != storageSystem) {
            cleanupDiscovery(storageSystem);
            storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.ERROR.toString());
        }
        _logger.error("discoverStorage failed. Storage system: " + storageSystemId, e);
    } finally {
        if (storageSystem != null) {
            try {
                // set detailed message
                storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
                _dbClient.persistObject(storageSystem);
            } catch (Exception ex) {
                _logger.error("Error while persisting object to DB", ex);
            }
        }
    }
}
Also used : UnManagedCifsShareACL(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedCifsShareACL) UnManagedSMBShareMap(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBShareMap) ArrayList(java.util.ArrayList) URI(java.net.URI) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) NetAppException(com.emc.storageos.netapp.NetAppException) NetAppCException(com.emc.storageos.netappc.NetAppCException) IOException(java.io.IOException) UnManagedSMBFileShare(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBFileShare) NetAppClusterApi(com.emc.storageos.netappc.NetAppClusterApi) NetAppCException(com.emc.storageos.netappc.NetAppCException) StorageVirtualMachineInfo(com.iwave.ext.netappc.StorageVirtualMachineInfo) UnManagedFSExportMap(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFSExportMap) Map(java.util.Map) HashMap(java.util.HashMap) UnManagedSMBShareMap(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBShareMap) StringMap(com.emc.storageos.db.client.model.StringMap) UnManagedFileSystem(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) HashSet(java.util.HashSet)

Example 12 with NetAppCException

use of com.emc.storageos.netappc.NetAppCException 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)

Example 13 with NetAppCException

use of com.emc.storageos.netappc.NetAppCException 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 14 with NetAppCException

use of com.emc.storageos.netappc.NetAppCException 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 15 with NetAppCException

use of com.emc.storageos.netappc.NetAppCException in project coprhd-controller by CoprHD.

the class NetAppClusterModeCommIntf method discoverStoragePools.

/**
 * Discover the storage pools for NetApp Cluster mode array
 *
 * @param system
 *            Storage system information
 * @return Map of new and existing storage pools
 * @throws NetAppCException
 */
private Map<String, List<StoragePool>> discoverStoragePools(StorageSystem system, List<StoragePool> poolsToMatchWithVpool) throws NetAppCException {
    Map<String, List<StoragePool>> storagePools = new HashMap<String, List<StoragePool>>();
    List<StoragePool> newPools = new ArrayList<StoragePool>();
    List<StoragePool> existingPools = new ArrayList<StoragePool>();
    _logger.info("Start storage pool discovery for storage system {}", system.getId());
    try {
        NetAppClusterApi netAppCApi = new NetAppClusterApi.Builder(system.getIpAddress(), system.getPortNumber(), system.getUsername(), system.getPassword()).https(true).build();
        List<AggregateInfo> pools = netAppCApi.listClusterAggregates(null);
        for (AggregateInfo netAppPool : pools) {
            StoragePool pool = null;
            URIQueryResultList results = new URIQueryResultList();
            String poolNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, netAppPool.getName(), NativeGUIDGenerator.POOL);
            _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePoolByNativeGuidConstraint(poolNativeGuid), results);
            if (results.iterator().hasNext()) {
                StoragePool tmpPool = _dbClient.queryObject(StoragePool.class, results.iterator().next());
                if (tmpPool.getStorageDevice().equals(system.getId())) {
                    pool = tmpPool;
                }
            }
            if (pool == null) {
                pool = new StoragePool();
                pool.setId(URIUtil.createId(StoragePool.class));
                pool.setLabel(poolNativeGuid);
                pool.setNativeGuid(poolNativeGuid);
                pool.setPoolServiceType(PoolServiceType.file.toString());
                pool.setStorageDevice(system.getId());
                pool.setOperationalStatus(StoragePool.PoolOperationalStatus.READY.toString());
                StringSet protocols = new StringSet();
                protocols.add("NFS");
                protocols.add("CIFS");
                pool.setProtocols(protocols);
                pool.setPoolName(netAppPool.getName());
                pool.setNativeId(netAppPool.getName());
                pool.setSupportedResourceTypes(StoragePool.SupportedResourceTypes.THIN_AND_THICK.toString());
                Map<String, String> params = new HashMap<String, String>();
                params.put(StoragePool.ControllerParam.PoolType.name(), "File Pool");
                pool.addControllerParams(params);
                pool.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
                _logger.info("Creating new storage pool using NativeGuid : {}", poolNativeGuid);
                newPools.add(pool);
            } else {
                existingPools.add(pool);
            }
            // Update Pool details with new discovery run
            pool.setTotalCapacity(netAppPool.getSizeTotal() / BYTESCONVERTER);
            pool.setFreeCapacity(netAppPool.getSizeAvailable() / BYTESCONVERTER);
            pool.setSubscribedCapacity(netAppPool.getSizeUsed() / BYTESCONVERTER);
            if (ImplicitPoolMatcher.checkPoolPropertiesChanged(pool.getCompatibilityStatus(), DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name()) || ImplicitPoolMatcher.checkPoolPropertiesChanged(pool.getDiscoveryStatus(), DiscoveryStatus.VISIBLE.name())) {
                poolsToMatchWithVpool.add(pool);
            }
            pool.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
            pool.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
        }
    } catch (NumberFormatException e) {
        _logger.error("Data Format Exception:  Discovery of storage pools failed for storage system {} for {}", system.getId(), e);
        NetAppCException ntpe = new NetAppCException("Storage pool discovery data error for storage system " + system.getId());
        ntpe.initCause(e);
        throw ntpe;
    }
    _logger.info("Storage pool discovery for storage system {} complete", system.getId());
    storagePools.put(NEW, newPools);
    storagePools.put(EXISTING, existingPools);
    return storagePools;
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) NetAppClusterApi(com.emc.storageos.netappc.NetAppClusterApi) NetAppCException(com.emc.storageos.netappc.NetAppCException) StringSet(com.emc.storageos.db.client.model.StringSet) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) AggregateInfo(com.iwave.ext.netapp.AggregateInfo)

Aggregations

NetAppCException (com.emc.storageos.netappc.NetAppCException)23 NetAppClusterApi (com.emc.storageos.netappc.NetAppClusterApi)20 NetAppException (com.emc.storageos.netapp.NetAppException)18 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)16 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)16 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)14 ControllerException (com.emc.storageos.volumecontroller.ControllerException)12 ArrayList (java.util.ArrayList)8 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)6 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)6 IOException (java.io.IOException)6 URI (java.net.URI)6 HashMap (java.util.HashMap)6 StorageVirtualMachineInfo (com.iwave.ext.netappc.StorageVirtualMachineInfo)5 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)4 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)4 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)4 List (java.util.List)4 FileShare (com.emc.storageos.db.client.model.FileShare)3 StoragePool (com.emc.storageos.db.client.model.StoragePool)3