Search in sources :

Example 1 with FileSystemAutoExtInfo

use of com.emc.nas.vnxfile.xmlapi.FileSystemAutoExtInfo 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)

Aggregations

FileSystem (com.emc.nas.vnxfile.xmlapi.FileSystem)1 FileSystemAutoExtInfo (com.emc.nas.vnxfile.xmlapi.FileSystemAutoExtInfo)1 FileSystemCapacityInfo (com.emc.nas.vnxfile.xmlapi.FileSystemCapacityInfo)1 Status (com.emc.nas.vnxfile.xmlapi.Status)1 UnManagedDiscoveredObject (com.emc.storageos.db.client.model.UnManagedDiscoveredObject)1 VNXFilePluginException (com.emc.storageos.plugins.metering.vnxfile.VNXFilePluginException)1 VNXFileSystem (com.emc.storageos.vnx.xmlapi.VNXFileSystem)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1