Search in sources :

Example 1 with VNXFileSystem

use of com.emc.storageos.vnx.xmlapi.VNXFileSystem in project coprhd-controller by CoprHD.

the class VNXFileSystemsProcessor method processFilesystemList.

/**
 * Process the fileSystemList which are received from XMLAPI server.
 *
 * @param filesystemList : List of FileSystem objects.
 * @param keyMap : keyMap.
 */
private List<VNXFileSystem> processFilesystemList(List<Object> filesystemList, Map<String, Object> keyMap) throws VNXFilePluginException {
    Iterator<Object> iterator = filesystemList.iterator();
    List<VNXFileSystem> processedFileSystem = new ArrayList<VNXFileSystem>();
    if (iterator.hasNext()) {
        Status status = (Status) iterator.next();
        if ((status.getMaxSeverity() == Severity.OK) || (status.getMaxSeverity() == Severity.WARNING)) {
            Map<String, FileSystem> fileSystems = new HashMap<String, FileSystem>();
            Map<String, FileSystemCapacityInfo> fileSysCapacityInfos = new HashMap<String, FileSystemCapacityInfo>();
            while (iterator.hasNext()) {
                Object obj = iterator.next();
                if (obj instanceof FileSystem) {
                    FileSystem fs = (FileSystem) obj;
                    if (fs.isInternalUse() == false) {
                        fileSystems.put(fs.getFileSystem(), fs);
                    }
                } else if (obj instanceof FileSystemCapacityInfo) {
                    FileSystemCapacityInfo fsCapacityInfo = (FileSystemCapacityInfo) obj;
                    fileSysCapacityInfos.put(fsCapacityInfo.getFileSystem(), fsCapacityInfo);
                }
            }
            Iterator it = fileSystems.keySet().iterator();
            while (it.hasNext()) {
                String fsId = (String) it.next();
                FileSystem fileSystem = fileSystems.get(fsId);
                FileSystemCapacityInfo fsCapacity = fileSysCapacityInfos.get(fsId);
                List<String> pools = new ArrayList<String>();
                if (null != fileSystem.getStoragePools()) {
                    pools = fileSystem.getStoragePools();
                }
                String poolId = "";
                if (null != pools) {
                    poolId = pools.get(0);
                }
                StringBuffer debugInfo = new StringBuffer();
                debugInfo.append("VNXFileSystem : " + fileSystem.getName());
                debugInfo.append(" Pool : " + poolId);
                long totalCapacity = 0;
                VNXFileSystem vnxFS = new VNXFileSystem(fileSystem.getName(), Integer.valueOf(fileSystem.getFileSystem()));
                if (fileSystem.isVirtualProvisioning()) {
                    vnxFS.setType(UnManagedDiscoveredObject.SupportedProvisioningType.THIN.name());
                    FileSystemAutoExtInfo autoExtInfo = fileSystem.getFileSystemAutoExtInfo();
                    if (null != autoExtInfo) {
                        totalCapacity = autoExtInfo.getAutoExtensionMaxSize();
                        totalCapacity = totalCapacity * MBTOBYTECONVERTER;
                    } else {
                        totalCapacity = fsCapacity.getVolumeSize() * MBTOBYTECONVERTER;
                    }
                } else {
                    vnxFS.setType(UnManagedDiscoveredObject.SupportedProvisioningType.THICK.name());
                    totalCapacity = fsCapacity.getVolumeSize() * MBTOBYTECONVERTER;
                }
                vnxFS.setStoragePool(poolId);
                debugInfo.append(" fsCapacity.getVolumeSize() : " + fsCapacity.getVolumeSize());
                vnxFS.setTotalCapacity(totalCapacity + "");
                vnxFS.setUsedCapcity("0");
                if (null != fsCapacity.getResourceUsage()) {
                    // We can get Used capacity
                    // Size is in MB, convert to Bytes
                    debugInfo.append(" fsCapacity.getUsedCapacity:" + fsCapacity.getResourceUsage().getSpaceUsed());
                    long usedCapacity = fsCapacity.getResourceUsage().getSpaceUsed() * MBTOBYTECONVERTER;
                    vnxFS.setUsedCapcity(usedCapacity + "");
                }
                debugInfo.append(" Total Capacity :" + vnxFS.getTotalCapacity());
                debugInfo.append(" Used Capacity :" + vnxFS.getUsedCapacity());
                _logger.debug(debugInfo.toString());
                processedFileSystem.add(vnxFS);
            }
        } else {
            throw new com.emc.storageos.plugins.metering.vnxfile.VNXFilePluginException("Fault response received from XMLAPI Server.", VNXFilePluginException.ERRORCODE_INVALID_RESPONSE);
        }
    }
    return processedFileSystem;
}
Also used : Status(com.emc.nas.vnxfile.xmlapi.Status) HashMap(java.util.HashMap) FileSystemCapacityInfo(com.emc.nas.vnxfile.xmlapi.FileSystemCapacityInfo) VNXFilePluginException(com.emc.storageos.plugins.metering.vnxfile.VNXFilePluginException) ArrayList(java.util.ArrayList) VNXFileSystem(com.emc.storageos.vnx.xmlapi.VNXFileSystem) VNXFileSystem(com.emc.storageos.vnx.xmlapi.VNXFileSystem) FileSystem(com.emc.nas.vnxfile.xmlapi.FileSystem) Iterator(java.util.Iterator) FileSystemAutoExtInfo(com.emc.nas.vnxfile.xmlapi.FileSystemAutoExtInfo) UnManagedDiscoveredObject(com.emc.storageos.db.client.model.UnManagedDiscoveredObject)

Example 2 with VNXFileSystem

use of com.emc.storageos.vnx.xmlapi.VNXFileSystem in project coprhd-controller by CoprHD.

the class VNXFileSystemsProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    final PostMethod result = (PostMethod) resultObj;
    try {
        ResponsePacket responsePacket = (ResponsePacket) _unmarshaller.unmarshal(result.getResponseBodyAsStream());
        // Extract session information from the response header.
        Header[] headers = result.getResponseHeaders(VNXFileConstants.CELERRA_SESSION);
        if (null != headers && headers.length > 0) {
            keyMap.put(VNXFileConstants.CELERRA_SESSION, headers[0].getValue());
            _logger.info("Received celerra session info from the Server.");
        }
        Status status = null;
        if (null != responsePacket.getPacketFault()) {
            status = responsePacket.getPacketFault();
            processErrorStatus(status, keyMap);
        } else {
            List<Object> filesystemList = getQueryResponse(responsePacket);
            List<VNXFileSystem> processedFileSystems = processFilesystemList(filesystemList, keyMap);
            keyMap.put(VNXFileConstants.FILESYSTEMS, processedFileSystems);
            keyMap.put(VNXFileConstants.CMD_RESULT, VNXFileConstants.CMD_SUCCESS);
        }
    } catch (final Exception ex) {
        _logger.error("Exception occurred while processing the vnx fileShare response due to {}", ex.getMessage());
        keyMap.put(com.emc.storageos.plugins.metering.vnxfile.VNXFileConstants.FAULT_DESC, ex.getMessage());
        keyMap.put(com.emc.storageos.plugins.metering.vnxfile.VNXFileConstants.CMD_RESULT, com.emc.storageos.plugins.metering.vnxfile.VNXFileConstants.CMD_FAILURE);
    } finally {
        result.releaseConnection();
    }
}
Also used : Status(com.emc.nas.vnxfile.xmlapi.Status) ResponsePacket(com.emc.nas.vnxfile.xmlapi.ResponsePacket) Header(org.apache.commons.httpclient.Header) PostMethod(org.apache.commons.httpclient.methods.PostMethod) VNXFileSystem(com.emc.storageos.vnx.xmlapi.VNXFileSystem) UnManagedDiscoveredObject(com.emc.storageos.db.client.model.UnManagedDiscoveredObject) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) VNXFilePluginException(com.emc.storageos.plugins.metering.vnxfile.VNXFilePluginException)

Example 3 with VNXFileSystem

use of com.emc.storageos.vnx.xmlapi.VNXFileSystem 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 4 with VNXFileSystem

use of com.emc.storageos.vnx.xmlapi.VNXFileSystem in project coprhd-controller by CoprHD.

the class VNXFileCommunicationInterface method discoverNamedFileSystem.

private VNXFileSystem discoverNamedFileSystem(StorageSystem system, String fsName) {
    List<VNXFileSystem> fileSystems = null;
    VNXFileSystem fileSystem = null;
    try {
        // Retrieve list of File Systems from the VNX file device.
        Map<String, Object> reqAttributeMap = getRequestParamsMap(system);
        reqAttributeMap.put(VNXFileConstants.FILESYSTEM_NAME, fsName);
        _discExecutor.setKeyMap(reqAttributeMap);
        _discExecutor.execute((Namespace) _discNamespaces.getNsList().get(VNXFileConstants.VNX_FILE_SELECTED_FS));
        fileSystems = (List<VNXFileSystem>) _discExecutor.getKeyMap().get(VNXFileConstants.FILESYSTEMS);
        if ((fileSystems != null) && !(fileSystems.isEmpty())) {
            _logger.info("Number of file systems found: {}", fileSystems.size());
            fileSystem = fileSystems.get(0);
        } else {
            _logger.info("No File System was found on the VNX device");
        }
    } catch (BaseCollectionException ex) {
        _logger.error("VNX Exception: Discovery of File Systems failed for storage system {} due to {}", system.getId(), ex.getMessage());
    }
    return fileSystem;
}
Also used : VNXFileSystem(com.emc.storageos.vnx.xmlapi.VNXFileSystem) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) UnManagedDiscoveredObject(com.emc.storageos.db.client.model.UnManagedDiscoveredObject) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 5 with VNXFileSystem

use of com.emc.storageos.vnx.xmlapi.VNXFileSystem 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)

Aggregations

VNXFileSystem (com.emc.storageos.vnx.xmlapi.VNXFileSystem)8 UnManagedDiscoveredObject (com.emc.storageos.db.client.model.UnManagedDiscoveredObject)4 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)4 VNXException (com.emc.storageos.vnx.xmlapi.VNXException)4 ArrayList (java.util.ArrayList)3 Status (com.emc.nas.vnxfile.xmlapi.Status)2 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)2 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)2 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)2 DiscoveredDataObject (com.emc.storageos.db.client.model.DiscoveredDataObject)2 VNXFileCollectionException (com.emc.storageos.plugins.metering.vnxfile.VNXFileCollectionException)2 VNXFilePluginException (com.emc.storageos.plugins.metering.vnxfile.VNXFilePluginException)2 XMLApiResult (com.emc.storageos.vnx.xmlapi.XMLApiResult)2 IOException (java.io.IOException)2 URISyntaxException (java.net.URISyntaxException)2 HashMap (java.util.HashMap)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 Checkpoint (com.emc.nas.vnxfile.xmlapi.Checkpoint)1 FileSystem (com.emc.nas.vnxfile.xmlapi.FileSystem)1 FileSystemAutoExtInfo (com.emc.nas.vnxfile.xmlapi.FileSystemAutoExtInfo)1