Search in sources :

Example 1 with VFilerInfo

use of com.iwave.ext.netapp.VFilerInfo in project coprhd-controller by CoprHD.

the class NetAppFileCommunicationInterface method discoverPorts.

private Map<String, List<StoragePort>> discoverPorts(StorageSystem storageSystem, List<VFilerInfo> vFilers, List<StorageHADomain> haDomains) throws NetAppFileCollectionException {
    URI storageSystemId = storageSystem.getId();
    HashMap<String, List<StoragePort>> storagePorts = new HashMap<String, List<StoragePort>>();
    List<StoragePort> newStoragePorts = new ArrayList<StoragePort>();
    List<StoragePort> existingStoragePorts = new ArrayList<StoragePort>();
    // Discover storage ports
    try {
        _logger.info("discoverPorts for storage system {} - start", storageSystemId);
        StoragePort storagePort = null;
        if (vFilers != null && !vFilers.isEmpty()) {
            for (VFilerInfo filer : vFilers) {
                for (VFNetInfo intf : filer.getInterfaces()) {
                    if (intf.getNetInterface().equals(MANAGEMENT_INTERFACE)) {
                        continue;
                    }
                    URIQueryResultList results = new URIQueryResultList();
                    String portNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem, intf.getIpAddress(), NativeGUIDGenerator.PORT);
                    _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePortByNativeGuidConstraint(portNativeGuid), results);
                    storagePort = null;
                    if (results.iterator().hasNext()) {
                        StoragePort tmpPort = _dbClient.queryObject(StoragePort.class, results.iterator().next());
                        if (tmpPort.getStorageDevice().equals(storageSystem.getId()) && tmpPort.getPortGroup().equals(filer.getName())) {
                            storagePort = tmpPort;
                            _logger.debug("found duplicate intf {}", intf.getIpAddress());
                        }
                    }
                    if (storagePort == null) {
                        storagePort = new StoragePort();
                        storagePort.setId(URIUtil.createId(StoragePort.class));
                        storagePort.setTransportType("IP");
                        storagePort.setNativeGuid(portNativeGuid);
                        storagePort.setLabel(portNativeGuid);
                        storagePort.setStorageDevice(storageSystemId);
                        storagePort.setPortName(intf.getIpAddress());
                        storagePort.setPortNetworkId(intf.getIpAddress());
                        storagePort.setPortGroup(filer.getName());
                        storagePort.setStorageHADomain(findMatchingHADomain(filer.getName(), haDomains));
                        storagePort.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
                        _logger.info("Creating new storage port using NativeGuid : {}", portNativeGuid);
                        newStoragePorts.add(storagePort);
                    } else {
                        existingStoragePorts.add(storagePort);
                    }
                    storagePort.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
                    storagePort.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
                }
            }
        } else {
            // Check if storage port was already discovered
            URIQueryResultList results = new URIQueryResultList();
            String portNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem, storageSystem.getIpAddress(), NativeGUIDGenerator.PORT);
            _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePortByNativeGuidConstraint(portNativeGuid), results);
            if (results.iterator().hasNext()) {
                StoragePort tmpPort = _dbClient.queryObject(StoragePort.class, results.iterator().next());
                if (tmpPort.getStorageDevice().equals(storageSystem.getId()) && tmpPort.getPortGroup().equals(storageSystem.getSerialNumber())) {
                    storagePort = tmpPort;
                    _logger.debug("found duplicate dm intf {}", storageSystem.getSerialNumber());
                }
            }
            if (storagePort == null) {
                // Create NetApp storage port for IP address
                storagePort = new StoragePort();
                storagePort.setId(URIUtil.createId(StoragePort.class));
                storagePort.setTransportType("IP");
                storagePort.setNativeGuid(portNativeGuid);
                storagePort.setLabel(portNativeGuid);
                storagePort.setStorageDevice(storageSystemId);
                storagePort.setPortName(storageSystem.getIpAddress());
                storagePort.setPortNetworkId(storageSystem.getIpAddress());
                storagePort.setPortGroup(storageSystem.getSerialNumber());
                storagePort.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
                _logger.info("Creating new storage port using NativeGuid : {}", portNativeGuid);
                newStoragePorts.add(storagePort);
            } else {
                existingStoragePorts.add(storagePort);
            }
            storagePort.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
        }
        _logger.info("discoverPorts for storage system {} - complete", storageSystemId);
        storagePorts.put(NEW, newStoragePorts);
        storagePorts.put(EXISTING, existingStoragePorts);
        return storagePorts;
    } catch (Exception e) {
        _logger.error("discoverPorts failed. Storage system: " + storageSystemId, e);
        throw new NetAppFileCollectionException("discoverPorts failed. Storage system: " + storageSystemId, e);
    }
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) 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) VFNetInfo(com.iwave.ext.netapp.VFNetInfo) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) NetAppFileCollectionException(com.emc.storageos.plugins.metering.netapp.NetAppFileCollectionException)

Example 2 with VFilerInfo

use of com.iwave.ext.netapp.VFilerInfo in project coprhd-controller by CoprHD.

the class NetAppFileCommunicationInterface method discoverUnManagedExports.

private void discoverUnManagedExports(AccessProfile profile) {
    URI storageSystemId = profile.getSystemId();
    StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemId);
    Boolean invalidateFS = false;
    if (null == storageSystem) {
        return;
    }
    String detailedStatusMessage = "Discovery of NetApp Unmanaged Exports started";
    List<UnManagedFileSystem> existingUnManagedFileSystems = new ArrayList<UnManagedFileSystem>();
    NetAppApi netAppApi = new NetAppApi.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 {
        URIQueryResultList storagePoolURIs = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePoolConstraint(storageSystem.getId()), storagePoolURIs);
        // Get storageport
        HashMap<String, StoragePool> pools = new HashMap<String, StoragePool>();
        Iterator<URI> poolsItr = storagePoolURIs.iterator();
        while (poolsItr.hasNext()) {
            URI storagePoolURI = poolsItr.next();
            StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolURI);
            pools.put(storagePool.getNativeGuid(), storagePool);
        }
        // Retrieve all the file system and vFiler info.
        List<Map<String, String>> fileSystemInfo = netAppApi.listVolumeInfo(null, attrs);
        List<VFilerInfo> vFilers = netAppApi.listVFilers(null);
        // Get exports on the array and loop through each export.
        List<ExportsRuleInfo> exports = netAppApi.listNFSExportRules(null);
        for (ExportsRuleInfo export : exports) {
            String filesystem = export.getPathname();
            String nativeId = null;
            if (!filesystem.startsWith(VOL_ROOT_NO_SLASH)) {
                nativeId = VOL_ROOT_NO_SLASH + filesystem;
            } else {
                nativeId = filesystem;
            }
            // Ignore export for root volume and don't pull it into ViPR db.
            if (filesystem.contains(ROOT_VOL)) {
                _logger.info("Ignore exports for root volumes on NTP array");
                continue;
            }
            // Ignore exports that have multiple security rules and security flavors.
            String secflavors = export.getSecurityRuleInfos().get(0).getSecFlavor();
            String[] secFlavorsAry = secflavors.split(",");
            Integer secFlavorAryLength = secFlavorsAry.length;
            Integer secRulesSize = export.getSecurityRuleInfos().size();
            if ((secRulesSize > 1) || (secFlavorAryLength > 1)) {
                invalidateFS = true;
            } else {
                invalidateFS = false;
            }
            nativeId = getFSPathIfSubDirectoryExport(nativeId);
            String fsUnManagedFsNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileSystem(storageSystem.getSystemType(), storageSystem.getSerialNumber().toUpperCase(), nativeId);
            UnManagedFileSystem unManagedFs = checkUnManagedFileSystemExistsInDB(fsUnManagedFsNativeGuid);
            boolean fsAlreadyExists = unManagedFs == null ? false : true;
            if (fsAlreadyExists) {
                // TODO: Come up with list of UMFSes to be presented to API.
                if (invalidateFS) {
                    _logger.info("FileSystem " + nativeId + "has a complex export with multiple secruity flavors and security rules, hence ignoring the filesystem and NOT brining into ViPR DB");
                    unManagedFs.setInactive(true);
                } else {
                    _logger.debug("retrieve info for file system: " + filesystem);
                    String vFiler = getOwningVfiler(filesystem, fileSystemInfo);
                    String addr = null;
                    if (vFiler == null || vFiler.isEmpty()) {
                        // No vfilers, use system storage port
                        StoragePort port = getStoragePortPool(storageSystem);
                        addr = port.getPortName();
                    } else {
                        // Use IP address of vFiler.
                        addr = getVfilerAddress(vFiler, vFilers);
                    }
                    UnManagedFSExportMap tempUnManagedExpMap = new UnManagedFSExportMap();
                    createExportMap(export, tempUnManagedExpMap, addr);
                    if (tempUnManagedExpMap.size() > 0) {
                        unManagedFs.setFsUnManagedExportMap(tempUnManagedExpMap);
                    }
                }
                existingUnManagedFileSystems.add(unManagedFs);
                // Adding this additional logic to avoid OOM
                if (existingUnManagedFileSystems.size() == MAX_UMFS_RECORD_SIZE) {
                    _partitionManager.updateInBatches(existingUnManagedFileSystems, Constants.DEFAULT_PARTITION_SIZE, _dbClient, UNMANAGED_FILESYSTEM);
                    existingUnManagedFileSystems.clear();
                }
            } else {
                _logger.info("FileSystem " + unManagedFs + "is not present in ViPR DB. Hence ignoring " + export + " export");
            }
        }
        if (!existingUnManagedFileSystems.isEmpty()) {
            // Update UnManagedFilesystem
            _partitionManager.updateInBatches(existingUnManagedFileSystems, Constants.DEFAULT_PARTITION_SIZE, _dbClient, UNMANAGED_FILESYSTEM);
        }
        // discovery succeeds
        detailedStatusMessage = String.format("Discovery completed successfully for NetApp: %s", storageSystemId.toString());
    } catch (NetAppException ve) {
        if (null != storageSystem) {
            cleanupDiscovery(storageSystem);
        }
        throw ve;
    } catch (Exception e) {
        if (null != storageSystem) {
            cleanupDiscovery(storageSystem);
        }
        _logger.error("discoverStorage failed. Storage system: " + storageSystemId, e);
        throw NetAppException.exceptions.discoveryFailed(storageSystemId.toString(), 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 : StoragePool(com.emc.storageos.db.client.model.StoragePool) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) URI(java.net.URI) NetAppException(com.emc.storageos.netapp.NetAppException) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) NetAppApi(com.emc.storageos.netapp.NetAppApi) UnManagedFileSystem(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) UnManagedFSExportMap(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFSExportMap) StoragePort(com.emc.storageos.db.client.model.StoragePort) ExportsRuleInfo(com.iwave.ext.netapp.model.ExportsRuleInfo) 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) UnManagedFSExportMap(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFSExportMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) UnManagedSMBShareMap(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBShareMap) StringMap(com.emc.storageos.db.client.model.StringMap)

Example 3 with VFilerInfo

use of com.iwave.ext.netapp.VFilerInfo in project coprhd-controller by CoprHD.

the class NetAppFileCommunicationInterface method discoverUnManagedNewExports.

private void discoverUnManagedNewExports(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 NetApp Unmanaged Exports started";
    // Used to Save the rules to DB
    List<UnManagedFileExportRule> newUnManagedExportRules = new ArrayList<UnManagedFileExportRule>();
    NetAppApi netAppApi = new NetAppApi.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 {
        List<Map<String, String>> fileSystemInfo = netAppApi.listVolumeInfo(null, attrs);
        List<VFilerInfo> vFilers = netAppApi.listVFilers(null);
        // Get exports on the array and loop through each export.
        List<ExportsRuleInfo> exports = netAppApi.listNFSExportRules(null);
        // Verification Utility
        UnManagedExportVerificationUtility validationUtility = new UnManagedExportVerificationUtility(_dbClient);
        for (ExportsRuleInfo deviceExport : exports) {
            String filesystem = deviceExport.getPathname();
            _logger.info("Export Path {}", filesystem);
            String nativeId = null;
            if (!filesystem.startsWith(VOL_ROOT_NO_SLASH)) {
                nativeId = VOL_ROOT_NO_SLASH + filesystem;
            } else {
                nativeId = filesystem;
            }
            // Ignore export for root volume and don't pull it into ViPR db.
            if (filesystem.contains(ROOT_VOL)) {
                _logger.info("Ignore exports for root volume {} on NTP array", filesystem);
                continue;
            }
            // Ignore export for snapshots and don't pull it into ViPR db.
            if (filesystem.contains(SNAPSHOT)) {
                _logger.info("Ignore exports for snapshot {}", filesystem);
                continue;
            }
            nativeId = getFSPathIfSubDirectoryExport(nativeId);
            String fsUnManagedFsNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileSystem(storageSystem.getSystemType(), storageSystem.getSerialNumber().toUpperCase(), nativeId);
            UnManagedFileSystem unManagedFs = checkUnManagedFileSystemExistsInDB(fsUnManagedFsNativeGuid);
            boolean fsAlreadyExists = unManagedFs == null ? false : true;
            // Used as for rules validation
            List<UnManagedFileExportRule> unManagedExportRules = new ArrayList<UnManagedFileExportRule>();
            if (fsAlreadyExists) {
                _logger.debug("retrieve info for file system: " + filesystem);
                String vFiler = getOwningVfiler(filesystem, fileSystemInfo);
                if (vFiler != null && !vFiler.equalsIgnoreCase(DEFAULT_FILER)) {
                    _logger.info("Ignoring {} because it is owned by {}", filesystem, vFiler);
                    continue;
                }
                String addr = null;
                if (vFiler == null || vFiler.isEmpty()) {
                    // No vfilers, use system storage port
                    StoragePort port = getStoragePortPool(storageSystem);
                    addr = port.getPortName();
                } else {
                    // Use IP address of vFiler.
                    addr = getVfilerAddress(vFiler, vFilers);
                }
                UnManagedFSExportMap tempUnManagedExpMap = new UnManagedFSExportMap();
                // create the export map for FS
                createExportMap(deviceExport, tempUnManagedExpMap, addr);
                if (tempUnManagedExpMap.size() > 0) {
                    unManagedFs.setFsUnManagedExportMap(tempUnManagedExpMap);
                    _logger.debug("Export map for NetApp UMFS {} = {}", unManagedFs.getLabel(), unManagedFs.getFsUnManagedExportMap());
                }
                List<UnManagedFileExportRule> exportRules = applyAllSecurityRules(deviceExport, addr, unManagedFs.getId());
                _logger.info("Number of export rules discovered for file system {} is {}", unManagedFs.getId(), exportRules.size());
                for (UnManagedFileExportRule dbExportRule : exportRules) {
                    _logger.info("Un Managed File Export Rule : {}", dbExportRule);
                    String fsExportRulenativeId = dbExportRule.getFsExportIndex();
                    _logger.info("Native Id using to build Native Guid {}", fsExportRulenativeId);
                    String fsUnManagedFileExportRuleNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileExportRule(storageSystem, fsExportRulenativeId);
                    _logger.info("Native GUID {}", fsUnManagedFileExportRuleNativeGuid);
                    dbExportRule.setNativeGuid(fsUnManagedFileExportRuleNativeGuid);
                    // dbExportRule.setFileSystemId(unManagedFs.getId());
                    dbExportRule.setId(URIUtil.createId(UnManagedFileExportRule.class));
                    // Build all export rules list.
                    unManagedExportRules.add(dbExportRule);
                }
                // apply as per API SVC Validations.
                if (!unManagedExportRules.isEmpty()) {
                    boolean isAllRulesValid = validationUtility.validateUnManagedExportRules(unManagedExportRules, false);
                    if (isAllRulesValid) {
                        _logger.info("Validating rules success for export {}", filesystem);
                        for (UnManagedFileExportRule exportRule : unManagedExportRules) {
                            UnManagedFileExportRule existingRule = checkUnManagedFsExportRuleExistsInDB(_dbClient, exportRule.getNativeGuid());
                            if (existingRule == null) {
                                newUnManagedExportRules.add(exportRule);
                            } else {
                                // Remove the existing rule.
                                existingRule.setInactive(true);
                                _dbClient.persistObject(existingRule);
                                newUnManagedExportRules.add(exportRule);
                            }
                        }
                        unManagedFs.setHasExports(true);
                        unManagedFs.putFileSystemCharacterstics(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_FILESYSTEM_EXPORTED.toString(), TRUE);
                        _dbClient.persistObject(unManagedFs);
                        _logger.info("File System {} has Exports and their size is {}", unManagedFs.getId(), newUnManagedExportRules.size());
                    } else {
                        _logger.warn("Validating rules failed for export {}. Ignroing to import these rules into ViPR DB", filesystem);
                        unManagedFs.setInactive(true);
                        _dbClient.persistObject(unManagedFs);
                    }
                }
                // Adding this additional logic to avoid OOM
                if (newUnManagedExportRules.size() == MAX_UMFS_RECORD_SIZE) {
                    _logger.info("Saving Number of UnManagedFileExportRule(s) {}", newUnManagedExportRules.size());
                    _partitionManager.updateInBatches(newUnManagedExportRules, Constants.DEFAULT_PARTITION_SIZE, _dbClient, UNMANAGED_EXPORT_RULE);
                    newUnManagedExportRules.clear();
                }
            } else {
                _logger.info("FileSystem " + unManagedFs + "is not present in ViPR DB. Hence ignoring " + deviceExport + " export");
            }
        }
        if (!newUnManagedExportRules.isEmpty()) {
            _logger.info("Saving Number of UnManagedFileExportRule(s) {}", newUnManagedExportRules.size());
            _partitionManager.updateInBatches(newUnManagedExportRules, Constants.DEFAULT_PARTITION_SIZE, _dbClient, UNMANAGED_EXPORT_RULE);
        }
        storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.COMPLETE.toString());
        // discovery succeeds
        detailedStatusMessage = String.format("Discovery completed successfully for NetApp: %s", storageSystemId.toString());
    } catch (NetAppException 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 : UnManagedExportVerificationUtility(com.emc.storageos.volumecontroller.impl.utils.UnManagedExportVerificationUtility) UnManagedFileExportRule(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileExportRule) ArrayList(java.util.ArrayList) StoragePort(com.emc.storageos.db.client.model.StoragePort) URI(java.net.URI) NetAppException(com.emc.storageos.netapp.NetAppException) ExportsRuleInfo(com.iwave.ext.netapp.model.ExportsRuleInfo) 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) NetAppApi(com.emc.storageos.netapp.NetAppApi) UnManagedFSExportMap(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFSExportMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) 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) UnManagedFSExportMap(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFSExportMap)

Example 4 with VFilerInfo

use of com.iwave.ext.netapp.VFilerInfo 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 5 with VFilerInfo

use of com.iwave.ext.netapp.VFilerInfo in project coprhd-controller by CoprHD.

the class NetAppApi method listVFilers.

public List<VFilerInfo> listVFilers(String name) {
    List<VFilerInfo> vFilers = null;
    try {
        netAppFacade = new NetAppFacade(_ipAddress, _portNumber, _userName, _password, _https);
        vFilers = netAppFacade.listVFilers();
    } catch (Exception e) {
        _logger.info("No vFilers discovered.");
    }
    return vFilers;
}
Also used : NetAppFacade(com.iwave.ext.netapp.NetAppFacade) VFilerInfo(com.iwave.ext.netapp.VFilerInfo)

Aggregations

VFilerInfo (com.iwave.ext.netapp.VFilerInfo)9 ArrayList (java.util.ArrayList)8 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)7 NetAppException (com.emc.storageos.netapp.NetAppException)7 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)7 NetAppFileCollectionException (com.emc.storageos.plugins.metering.netapp.NetAppFileCollectionException)7 IOException (java.io.IOException)7 URI (java.net.URI)7 HashMap (java.util.HashMap)7 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)7 StoragePort (com.emc.storageos.db.client.model.StoragePort)6 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)6 NetAppApi (com.emc.storageos.netapp.NetAppApi)6 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)5 StringMap (com.emc.storageos.db.client.model.StringMap)4 UnManagedFSExportMap (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFSExportMap)4 UnManagedFileSystem (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem)4 UnManagedSMBShareMap (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBShareMap)4 Map (java.util.Map)4 StoragePool (com.emc.storageos.db.client.model.StoragePool)3