Search in sources :

Example 1 with VNXFileCollectionException

use of com.emc.storageos.plugins.metering.vnxfile.VNXFileCollectionException in project coprhd-controller by CoprHD.

the class VNXFileCommunicationInterface method discoverUmanagedFileSystems.

private void discoverUmanagedFileSystems(AccessProfile profile) throws BaseCollectionException {
    _logger.info("Access Profile Details :  IpAddress : PortNumber : {}, namespace : {}", profile.getIpAddress() + profile.getPortNumber(), profile.getnamespace());
    URI storageSystemId = profile.getSystemId();
    StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemId);
    if (null == storageSystem) {
        return;
    }
    List<UnManagedFileSystem> unManagedFileSystems = new ArrayList<UnManagedFileSystem>();
    List<UnManagedFileSystem> existingUnManagedFileSystems = new ArrayList<UnManagedFileSystem>();
    int newFileSystemsCount = 0;
    int existingFileSystemsCount = 0;
    Set<URI> allDiscoveredUnManagedFileSystems = new HashSet<URI>();
    String detailedStatusMessage = "Discovery of VNXFile Unmanaged FileSystem started";
    try {
        URIQueryResultList storagePoolURIs = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePoolConstraint(storageSystem.getId()), storagePoolURIs);
        HashMap<String, StoragePool> pools = new HashMap();
        Iterator<URI> poolsItr = storagePoolURIs.iterator();
        while (poolsItr.hasNext()) {
            URI storagePoolURI = poolsItr.next();
            StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolURI);
            if (storagePool != null && !storagePool.getInactive()) {
                pools.put(storagePool.getNativeId(), storagePool);
            }
        }
        StoragePort storagePort = this.getStoragePortPool(storageSystem);
        List<VNXFileSystem> discoveredFS = discoverAllFileSystems(storageSystem);
        StringSet umfsIds = new StringSet();
        if (discoveredFS != null) {
            for (VNXFileSystem fs : discoveredFS) {
                String fsNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem.getSystemType(), storageSystem.getSerialNumber(), fs.getFsId() + "");
                StoragePool pool = pools.get(fs.getStoragePool());
                if (!checkStorageFileSystemExistsInDB(fsNativeGuid)) {
                    // Create UnManaged FS
                    String fsUnManagedFsNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileSystem(storageSystem.getSystemType(), storageSystem.getSerialNumber().toUpperCase(), fs.getFsId() + "");
                    UnManagedFileSystem unManagedFs = checkUnManagedFileSystemExistsInDB(fsUnManagedFsNativeGuid);
                    boolean alreadyExist = unManagedFs == null ? false : true;
                    unManagedFs = createUnManagedFileSystem(unManagedFs, fsUnManagedFsNativeGuid, storageSystem, pool, storagePort, fs);
                    if (alreadyExist) {
                        existingUnManagedFileSystems.add(unManagedFs);
                        existingFileSystemsCount++;
                    } else {
                        unManagedFileSystems.add(unManagedFs);
                        newFileSystemsCount++;
                    }
                    allDiscoveredUnManagedFileSystems.add(unManagedFs.getId());
                    umfsIds.add(fs.getFsId() + "");
                    /**
                     * Persist 200 objects and clear them to avoid memory issue
                     */
                    validateListSizeLimitAndPersist(unManagedFileSystems, existingUnManagedFileSystems, Constants.DEFAULT_PARTITION_SIZE * 2);
                }
            }
        }
        // Process those active unmanaged fs objects available in database but not in newly discovered items, to mark them inactive.
        markUnManagedFSObjectsInActive(storageSystem, allDiscoveredUnManagedFileSystems);
        _logger.info("New unmanaged VNXFile file systems count: {}", newFileSystemsCount);
        _logger.info("Update unmanaged VNXFile file systems count: {}", existingFileSystemsCount);
        if (!unManagedFileSystems.isEmpty()) {
            // Add UnManagedFileSystem
            _dbClient.createObject(unManagedFileSystems);
        }
        if (!existingUnManagedFileSystems.isEmpty()) {
            // Update UnManagedFilesystem
            _dbClient.updateAndReindexObject(existingUnManagedFileSystems);
        }
        // discovery succeeds
        detailedStatusMessage = String.format("Discovery completed successfully for VNXFile: %s", storageSystemId.toString());
        if (null != umfsIds && !umfsIds.isEmpty()) {
            // Discovering unmanaged quota directories
            discoverUmanagedFileQuotaDirectory(profile, umfsIds);
        }
    } catch (Exception e) {
        if (storageSystem != null) {
            cleanupDiscovery(storageSystem);
        }
        detailedStatusMessage = String.format("Discovery failed for VNXFile %s because %s", storageSystemId.toString(), e.getLocalizedMessage());
        _logger.error(detailedStatusMessage, e);
        throw new VNXFileCollectionException(detailedStatusMessage);
    } 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 : VNXStoragePool(com.emc.storageos.vnx.xmlapi.VNXStoragePool) StoragePool(com.emc.storageos.db.client.model.StoragePool) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) StoragePort(com.emc.storageos.db.client.model.StoragePort) URI(java.net.URI) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) URISyntaxException(java.net.URISyntaxException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) VNXException(com.emc.storageos.vnx.xmlapi.VNXException) IOException(java.io.IOException) VNXFileCollectionException(com.emc.storageos.plugins.metering.vnxfile.VNXFileCollectionException) VNXFileCollectionException(com.emc.storageos.plugins.metering.vnxfile.VNXFileCollectionException) VNXFileSystem(com.emc.storageos.vnx.xmlapi.VNXFileSystem) StringSet(com.emc.storageos.db.client.model.StringSet) UnManagedFileSystem(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) HashSet(java.util.HashSet)

Example 2 with VNXFileCollectionException

use of com.emc.storageos.plugins.metering.vnxfile.VNXFileCollectionException in project coprhd-controller by CoprHD.

the class VNXFileCommunicationInterface method discoverStoragePools.

/**
 * Returns the list of storage pools for the specified VNX File storage system.
 *
 * @param system storage system information including credentials.
 * @return Map of New and Existing known storage pools.
 * @throws VNXFileCollectionException
 */
private Map<String, List<StoragePool>> discoverStoragePools(StorageSystem system, List<StoragePool> poolsToMatchWithVpool, StringSet fileSharingProtocols) throws VNXFileCollectionException, VNXException {
    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 {
        List<VNXStoragePool> pools = getStoragePools(system);
        for (VNXStoragePool vnxPool : pools) {
            StoragePool pool = null;
            URIQueryResultList results = new URIQueryResultList();
            String poolNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, vnxPool.getPoolId(), NativeGUIDGenerator.POOL);
            _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePoolByNativeGuidConstraint(poolNativeGuid), results);
            Iterator<URI> iter = results.iterator();
            while (iter.hasNext()) {
                StoragePool tmpPool = _dbClient.queryObject(StoragePool.class, iter.next());
                if (tmpPool != null && !tmpPool.getInactive() && tmpPool.getStorageDevice().equals(system.getId())) {
                    pool = tmpPool;
                    _logger.info("Found StoragePool {} at {}", pool.getPoolName(), poolNativeGuid);
                    break;
                }
            }
            if (pool == null) {
                pool = new StoragePool();
                pool.setId(URIUtil.createId(StoragePool.class));
                pool.setLabel(poolNativeGuid);
                pool.setNativeGuid(poolNativeGuid);
                pool.setOperationalStatus(StoragePool.PoolOperationalStatus.READY.toString());
                pool.setPoolServiceType(PoolServiceType.file.toString());
                pool.setStorageDevice(system.getId());
                pool.setProtocols(fileSharingProtocols);
                pool.setNativeId(vnxPool.getPoolId());
                pool.setPoolName(vnxPool.getName());
                // Supported resource type indicates what type of file systems are supported.
                if ("true".equalsIgnoreCase(vnxPool.getVirtualProv())) {
                    pool.setSupportedResourceTypes(StoragePool.SupportedResourceTypes.THICK_ONLY.toString());
                } else {
                    pool.setSupportedResourceTypes(StoragePool.SupportedResourceTypes.THIN_AND_THICK.toString());
                }
                pool.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
                _logger.info("Creating new storage pool using NativeGuid : {}", poolNativeGuid);
                newPools.add(pool);
            } else {
                // Set protocols if it has changed between discoveries or a upgrade scenario
                pool.setProtocols(fileSharingProtocols);
                existingPools.add(pool);
            }
            long size = 0;
            if (vnxPool.getDynamic().equals("true")) {
                _logger.info("Using auto size for capacity.");
                size = Long.parseLong(vnxPool.getAutoSize());
            } else {
                size = Long.parseLong(vnxPool.getSize());
            }
            pool.setTotalCapacity(size * BYTESCONV);
            long used = Long.parseLong(vnxPool.getUsedSize()) * BYTESCONV;
            long free = pool.getTotalCapacity() - used;
            if (0 > free) {
                free = 0;
            }
            pool.setFreeCapacity(free);
            pool.setSubscribedCapacity(used);
            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());
        }
        _logger.info("Number of pools found {} : ", storagePools.size());
    } catch (NumberFormatException e) {
        _logger.error("Data Format Exception:  Discovery of storage pools failed for storage system {} for {}", system.getId(), e.getMessage());
        VNXFileCollectionException vnxe = new VNXFileCollectionException("Storage pool discovery data error for storage system " + system.getId());
        vnxe.initCause(e);
        throw vnxe;
    }
    _logger.info("Storage pool discovery for storage system {} complete", system.getId());
    for (StoragePool newPool : newPools) {
        _logger.info("New Storage Pool : " + newPool);
        _logger.info("New Storage Pool : {} : {}", newPool.getNativeGuid(), newPool.getId());
    }
    for (StoragePool pool : existingPools) {
        _logger.info("Old Storage Pool : " + pool);
        _logger.info("Old Storage Pool : {} : {}", pool.getNativeGuid(), pool.getId());
    }
    // return storagePools;
    storagePools.put(this.NEW, newPools);
    storagePools.put(this.EXISTING, existingPools);
    return storagePools;
}
Also used : VNXStoragePool(com.emc.storageos.vnx.xmlapi.VNXStoragePool) StoragePool(com.emc.storageos.db.client.model.StoragePool) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) VNXStoragePool(com.emc.storageos.vnx.xmlapi.VNXStoragePool) ArrayList(java.util.ArrayList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) VNXFileCollectionException(com.emc.storageos.plugins.metering.vnxfile.VNXFileCollectionException) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) NamespaceList(com.emc.storageos.plugins.common.domainmodel.NamespaceList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 3 with VNXFileCollectionException

use of com.emc.storageos.plugins.metering.vnxfile.VNXFileCollectionException in project coprhd-controller by CoprHD.

the class VNXFileCommunicationInterface method discoverControlStation.

/**
 * Discover the Control Station for the specified VNX File storage array. Since the StorageSystem object
 * currently exists, this method updates information in the object.
 *
 * @param system
 * @throws VNXFileCollectionException
 */
private void discoverControlStation(StorageSystem system) throws VNXFileCollectionException {
    _logger.info("Start Control Station discovery for storage system {}", system.getId());
    VNXControlStation tmpSystem = null;
    try {
        tmpSystem = getControlStation(system);
    } catch (VNXException e) {
        throw new VNXFileCollectionException("Get control station op failed", e);
    }
    if (tmpSystem != null) {
        String sysNativeGuid = NativeGUIDGenerator.generateNativeGuid(DiscoveredDataObject.Type.vnxfile.toString(), tmpSystem.getSerialNumber());
        system.setNativeGuid(sysNativeGuid);
        system.setSerialNumber(tmpSystem.getSerialNumber());
        String firmwareVersion = tmpSystem.getSoftwareVersion();
        String minimumSupportedVersion = VersionChecker.getMinimumSupportedVersion(Type.valueOf(system.getSystemType()));
        // Example version String for VNX looks like 7.1.56-5.
        firmwareVersion = firmwareVersion.replaceAll("-", ".").trim();
        minimumSupportedVersion = minimumSupportedVersion.replaceAll("-", ".");
        system.setFirmwareVersion(firmwareVersion);
        _logger.info("Verifying version details : Minimum Supported Version {} - Discovered VNX Version {}", minimumSupportedVersion, firmwareVersion);
        if (VersionChecker.verifyVersionDetails(minimumSupportedVersion, firmwareVersion) < 0) {
            system.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.INCOMPATIBLE.name());
            system.setReachableStatus(false);
            DiscoveryUtils.setSystemResourcesIncompatible(_dbClient, _coordinator, system.getId());
            VNXFileCollectionException vnxe = new VNXFileCollectionException(String.format(" ** This version of VNX File is not supported ** Should be a minimum of %s", minimumSupportedVersion));
            throw vnxe;
        }
        system.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
        system.setReachableStatus(true);
    } else {
        _logger.error("Failed to retrieve control station info!");
        system.setReachableStatus(false);
    }
    _logger.info("Control Station discovery for storage system {} complete", system.getId());
}
Also used : VNXFileCollectionException(com.emc.storageos.plugins.metering.vnxfile.VNXFileCollectionException) VNXControlStation(com.emc.storageos.vnx.xmlapi.VNXControlStation) VNXException(com.emc.storageos.vnx.xmlapi.VNXException)

Example 4 with VNXFileCollectionException

use of com.emc.storageos.plugins.metering.vnxfile.VNXFileCollectionException in project coprhd-controller by CoprHD.

the class VNXFileCommunicationInterface method discoverAllFileSystems.

/**
 * Retrieve the FileSystem for the specified VNX File Storage Array
 *
 * @param system storage system information including credentials.
 * @return list of Storage FileSystems
 * @throws VNXFileCollectionException
 */
private List<VNXFileSystem> discoverAllFileSystems(StorageSystem system) throws VNXFileCollectionException, VNXException {
    List<VNXFileSystem> fileSystems = new ArrayList<VNXFileSystem>();
    _logger.info("Start FileSystem discovery for storage system {}", system.getId());
    try {
        // Retrieve the list of FileSystem for the VNX File device.
        List<VNXFileSystem> vnxFileSystems = getAllFileSystem(system);
        _logger.info("Number filesytems found: {}", vnxFileSystems.size());
        if (vnxFileSystems != null) {
            // Create the list of FileSystem.
            for (VNXFileSystem vnxfs : vnxFileSystems) {
                FileShare fs = null;
                // Check if FileSystem was already discovered
                URIQueryResultList results = new URIQueryResultList();
                String fsNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, vnxfs.getFsId() + "", NativeGUIDGenerator.FILESYSTEM);
                if (checkStorageFileSystemExistsInDB(fsNativeGuid)) {
                    continue;
                }
                vnxfs.setFsNativeGuid(fsNativeGuid);
                fileSystems.add(vnxfs);
            }
        }
        _logger.info("Number of FileSystem found {} and they are : ", fileSystems.size());
    } catch (IOException e) {
        _logger.error("I/O Exception: Discovery of FileSystem failed for storage system {} for {}", system.getId(), e.getMessage());
        VNXFileCollectionException vnxe = new VNXFileCollectionException("Storage FileSystem discovery error for storage system " + system.getId());
        vnxe.initCause(e);
        throw vnxe;
    }
    _logger.info("Storage FilesSystem discovery for storage system {} complete", system.getId());
    return fileSystems;
}
Also used : VNXFileCollectionException(com.emc.storageos.plugins.metering.vnxfile.VNXFileCollectionException) VNXFileSystem(com.emc.storageos.vnx.xmlapi.VNXFileSystem) ArrayList(java.util.ArrayList) IOException(java.io.IOException) FileShare(com.emc.storageos.db.client.model.FileShare) UnManagedSMBFileShare(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBFileShare) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 5 with VNXFileCollectionException

use of com.emc.storageos.plugins.metering.vnxfile.VNXFileCollectionException in project coprhd-controller by CoprHD.

the class VNXFileCommunicationInterface 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 control station information.
        discoverControlStation(storageSystem);
        // Model number
        VNXFileSshApi sshDmApi = new VNXFileSshApi();
        sshDmApi.setConnParams(storageSystem.getIpAddress(), storageSystem.getUsername(), storageSystem.getPassword());
        String model = sshDmApi.getModelInfo();
        storageSystem.setModel(model);
        boolean connectionStatus = getVnxFileSMISConnection(accessProfile, storageSystem);
        if (connectionStatus) {
            storageSystem.setSmisConnectionStatus(ConnectionStatus.CONNECTED.toString());
        } else {
            storageSystem.setSmisConnectionStatus(ConnectionStatus.NOTCONNECTED.toString());
        }
        _dbClient.persistObject(storageSystem);
        if (!storageSystem.getReachableStatus()) {
            throw new VNXFileCollectionException("Failed to connect to " + storageSystem.getIpAddress());
        }
        // Get All Existing DataMovers
        Map<String, StorageHADomain> allExistingDataMovers = getAllDataMovers(storageSystem);
        for (StorageHADomain activeDM : allExistingDataMovers.values()) {
            _logger.info("Existing DataMovers in database {}", activeDM.getName());
        }
        // Discover port groups (data movers)
        StringSet fileSharingProtocols = new StringSet();
        Map<String, List<StorageHADomain>> groups = discoverPortGroups(storageSystem, fileSharingProtocols);
        _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));
            for (StorageHADomain newDm : groups.get(NEW)) {
                _logger.info("New DM {} ", newDm.getAdapterName());
            }
        }
        if (!groups.get(EXISTING).isEmpty()) {
            _dbClient.persistObject(groups.get(EXISTING));
            for (StorageHADomain existingDm : groups.get(EXISTING)) {
                _logger.info("Existing DM {} ", existingDm.getAdapterName());
            }
        }
        // Discover storage pools.
        List<StoragePool> poolsToMatchWithVpool = new ArrayList<StoragePool>();
        List<StoragePool> allPools = new ArrayList<StoragePool>();
        Map<String, List<StoragePool>> pools = discoverStoragePools(storageSystem, poolsToMatchWithVpool, fileSharingProtocols);
        _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);
        }
        // Keep a set of active data movers. Data movers in 'standby' state are not added to the
        // database since they cannot be used in this state.
        Set<StorageHADomain> activeDataMovers = new HashSet<StorageHADomain>();
        activeDataMovers.addAll(groups.get(NEW));
        activeDataMovers.addAll(groups.get(EXISTING));
        int i = 0;
        for (StorageHADomain activeDM : activeDataMovers) {
            _logger.info("DataMover {} : {}", i++, activeDM.getName());
        }
        // Discover ports (data mover interfaces) with the data movers in the active set.
        Map<String, List<StoragePort>> ports = discoverPorts(storageSystem, activeDataMovers);
        _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()) {
            _dbClient.createObject(ports.get(NEW));
        }
        if (!ports.get(EXISTING).isEmpty()) {
            _dbClient.persistObject(ports.get(EXISTING));
        }
        // Discover VDM and Ports
        Map<String, StorageHADomain> allVdmsInDb = this.getAllVDMs(storageSystem);
        for (StorageHADomain activeVDM : allVdmsInDb.values()) {
            _logger.info("Existing DataMovers in the Database {}", activeVDM.getName());
        }
        Map<String, List<StorageHADomain>> vdms = discoverVdmPortGroups(storageSystem, activeDataMovers);
        _logger.info("No of newly Vdm discovered groups {}", vdms.get(NEW).size());
        _logger.info("No of existing vdm discovered groups {}", vdms.get(EXISTING).size());
        if (!vdms.get(NEW).isEmpty()) {
            _dbClient.createObject(vdms.get(NEW));
        }
        if (!vdms.get(EXISTING).isEmpty()) {
            _dbClient.persistObject(vdms.get(EXISTING));
            for (StorageHADomain existingVdm : vdms.get(EXISTING)) {
                _logger.info("Existing VDM {}", existingVdm.getAdapterName());
            }
        }
        // Keep a set of active data movers. Data movers in 'standby' state are not added to the
        // database since they cannot be used in this state.
        Set<StorageHADomain> activeVDMs = new HashSet<StorageHADomain>();
        List<StorageHADomain> newVdms = vdms.get(NEW);
        for (StorageHADomain vdm : newVdms) {
            _logger.debug("New VDM : {}", vdm.getName());
            activeVDMs.add(vdm);
        }
        List<StorageHADomain> existingVdms = vdms.get(EXISTING);
        for (StorageHADomain vdm : existingVdms) {
            _logger.debug("Existing VDM : {}", vdm.getName());
            activeVDMs.add(vdm);
        }
        // Discover VDM Interfaces
        // Discover ports (data mover interfaces) with the data movers in the active set.
        Map<String, List<StoragePort>> vdmPorts = discoverVdmPorts(storageSystem, activeVDMs);
        _logger.info("No of newly discovered port {}", vdmPorts.get(NEW).size());
        _logger.info("No of existing discovered port {}", vdmPorts.get(EXISTING).size());
        if (!vdmPorts.get(NEW).isEmpty()) {
            _dbClient.createObject(vdmPorts.get(NEW));
            for (StoragePort port : vdmPorts.get(NEW)) {
                _logger.debug("New VDM Port : {}", port.getPortName());
            }
        }
        if (!vdmPorts.get(EXISTING).isEmpty()) {
            _dbClient.persistObject(vdmPorts.get(EXISTING));
            for (StoragePort port : vdmPorts.get(EXISTING)) {
                _logger.info("EXISTING VDM Port : {}", port.getPortName());
            }
        }
        List<StoragePort> allExistingPorts = new ArrayList<StoragePort>(ports.get(EXISTING));
        allExistingPorts.addAll(vdmPorts.get(EXISTING));
        List<StoragePort> allNewPorts = new ArrayList<StoragePort>(ports.get(NEW));
        allNewPorts.addAll(vdmPorts.get(NEW));
        List<StoragePort> allPorts = new ArrayList<StoragePort>(allExistingPorts);
        allPorts.addAll(allNewPorts);
        List<StoragePort> notVisiblePorts = DiscoveryUtils.checkStoragePortsNotVisible(allPorts, _dbClient, storageSystemId);
        allExistingPorts.addAll(notVisiblePorts);
        StoragePortAssociationHelper.updatePortAssociations(allNewPorts, _dbClient);
        StoragePortAssociationHelper.updatePortAssociations(allExistingPorts, _dbClient);
        StringBuffer errorMessage = new StringBuffer();
        ImplicitPoolMatcher.matchModifiedStoragePoolsWithAllVpool(poolsToMatchWithVpool, _dbClient, _coordinator, storageSystemId, errorMessage);
        // Update the virtual nas association with virtual arrays!!!
        // For existing virtual nas ports!!
        StoragePortAssociationHelper.runUpdateVirtualNasAssociationsProcess(allExistingPorts, null, _dbClient);
        // discovery succeeds
        detailedStatusMessage = String.format("Discovery completed successfully for Storage System: %s", storageSystemId.toString());
    } catch (Exception e) {
        if (storageSystem != null) {
            cleanupDiscovery(storageSystem);
        }
        detailedStatusMessage = String.format("Discovery failed for Storage System: %s because %s", storageSystemId.toString(), e.getLocalizedMessage());
        _logger.error(detailedStatusMessage, e);
        throw new VNXFileCollectionException(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 : VNXStoragePool(com.emc.storageos.vnx.xmlapi.VNXStoragePool) StoragePool(com.emc.storageos.db.client.model.StoragePool) ArrayList(java.util.ArrayList) URI(java.net.URI) VNXFileCollectionException(com.emc.storageos.plugins.metering.vnxfile.VNXFileCollectionException) StringSet(com.emc.storageos.db.client.model.StringSet) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) NamespaceList(com.emc.storageos.plugins.common.domainmodel.NamespaceList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) HashSet(java.util.HashSet) StoragePort(com.emc.storageos.db.client.model.StoragePort) VNXFileSshApi(com.emc.storageos.vnx.xmlapi.VNXFileSshApi) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) URISyntaxException(java.net.URISyntaxException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) VNXException(com.emc.storageos.vnx.xmlapi.VNXException) IOException(java.io.IOException) VNXFileCollectionException(com.emc.storageos.plugins.metering.vnxfile.VNXFileCollectionException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Aggregations

VNXFileCollectionException (com.emc.storageos.plugins.metering.vnxfile.VNXFileCollectionException)5 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)4 ArrayList (java.util.ArrayList)4 StoragePool (com.emc.storageos.db.client.model.StoragePool)3 VNXException (com.emc.storageos.vnx.xmlapi.VNXException)3 VNXStoragePool (com.emc.storageos.vnx.xmlapi.VNXStoragePool)3 IOException (java.io.IOException)3 URI (java.net.URI)3 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)2 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)2 StoragePort (com.emc.storageos.db.client.model.StoragePort)2 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)2 StringSet (com.emc.storageos.db.client.model.StringSet)2 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)2 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)2 NamespaceList (com.emc.storageos.plugins.common.domainmodel.NamespaceList)2 VNXFileSystem (com.emc.storageos.vnx.xmlapi.VNXFileSystem)2 URISyntaxException (java.net.URISyntaxException)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2