Search in sources :

Example 1 with VNXStoragePool

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

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

the class VNXFileCommunicationInterface method getStoragePools.

private List<VNXStoragePool> getStoragePools(final StorageSystem system) throws VNXException {
    List<VNXStoragePool> storagePools = null;
    try {
        Map<String, Object> reqAttributeMap = getRequestParamsMap(system);
        _logger.info("{}", _discExecutor);
        _discExecutor.setKeyMap(reqAttributeMap);
        _logger.info("{}", _discNamespaces.getNsList().get("vnxfileStoragePool"));
        _discExecutor.execute((Namespace) _discNamespaces.getNsList().get("vnxfileStoragePool"));
        storagePools = (ArrayList<VNXStoragePool>) _discExecutor.getKeyMap().get(VNXFileConstants.STORAGEPOOLS);
    } catch (BaseCollectionException e) {
        throw new VNXException("Get control station op failed", e);
    }
    return storagePools;
}
Also used : VNXException(com.emc.storageos.vnx.xmlapi.VNXException) VNXStoragePool(com.emc.storageos.vnx.xmlapi.VNXStoragePool) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) UnManagedDiscoveredObject(com.emc.storageos.db.client.model.UnManagedDiscoveredObject) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 3 with VNXStoragePool

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

the class VNXStoragePoolProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    final PostMethod result = (PostMethod) resultObj;
    _logger.info("processing vnx storagepool response" + resultObj);
    try {
        ResponsePacket responsePacket = (ResponsePacket) _unmarshaller.unmarshal(result.getResponseBodyAsStream());
        if (null != responsePacket.getPacketFault()) {
            Status status = responsePacket.getPacketFault();
            processErrorStatus(status, keyMap);
        } else {
            List<Object> queryResponse = getQueryResponse(responsePacket);
            Iterator<Object> queryRespItr = queryResponse.iterator();
            List<VNXStoragePool> storagePools = new ArrayList<VNXStoragePool>();
            while (queryRespItr.hasNext()) {
                Object responseObj = queryRespItr.next();
                _logger.info("{}", responseObj);
                if (responseObj instanceof StoragePool) {
                    VNXStoragePool vnxPool = new VNXStoragePool();
                    StoragePool storagePool = (StoragePool) responseObj;
                    vnxPool.setName(storagePool.getName());
                    vnxPool.setPoolId(storagePool.getPool());
                    vnxPool.setSize(String.valueOf(storagePool.getSize()));
                    vnxPool.setAutoSize(String.valueOf(storagePool.getAutoSize()));
                    vnxPool.setVirtualProv(String.valueOf(storagePool.isVirtualProvisioning()));
                    vnxPool.setUsedSize(String.valueOf(storagePool.getUsedSize()));
                    SystemStoragePoolData data = storagePool.getSystemStoragePoolData();
                    if (null != data) {
                        String dynamic = String.valueOf(data.isDynamic());
                        vnxPool.setDynamic(dynamic);
                    }
                    _logger.info("VNX Pool Information {}", vnxPool.toString());
                    storagePools.add(vnxPool);
                }
            }
            _logger.info("Number of StorgePools found  : {}", storagePools.size());
            keyMap.put(VNXFileConstants.STORAGEPOOLS, storagePools);
            // 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("Recieved celerra session information from the Server.");
            }
        }
    } catch (final Exception ex) {
        _logger.error("Exception occurred while processing the vnx info response due to ", ex);
    } finally {
        result.releaseConnection();
    }
}
Also used : Status(com.emc.nas.vnxfile.xmlapi.Status) StoragePool(com.emc.nas.vnxfile.xmlapi.StoragePool) VNXStoragePool(com.emc.storageos.vnx.xmlapi.VNXStoragePool) PostMethod(org.apache.commons.httpclient.methods.PostMethod) VNXStoragePool(com.emc.storageos.vnx.xmlapi.VNXStoragePool) ArrayList(java.util.ArrayList) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) ResponsePacket(com.emc.nas.vnxfile.xmlapi.ResponsePacket) Header(org.apache.commons.httpclient.Header) SystemStoragePoolData(com.emc.nas.vnxfile.xmlapi.SystemStoragePoolData)

Aggregations

VNXStoragePool (com.emc.storageos.vnx.xmlapi.VNXStoragePool)3 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)2 ArrayList (java.util.ArrayList)2 ResponsePacket (com.emc.nas.vnxfile.xmlapi.ResponsePacket)1 Status (com.emc.nas.vnxfile.xmlapi.Status)1 StoragePool (com.emc.nas.vnxfile.xmlapi.StoragePool)1 SystemStoragePoolData (com.emc.nas.vnxfile.xmlapi.SystemStoragePoolData)1 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 DiscoveredDataObject (com.emc.storageos.db.client.model.DiscoveredDataObject)1 StoragePool (com.emc.storageos.db.client.model.StoragePool)1 UnManagedDiscoveredObject (com.emc.storageos.db.client.model.UnManagedDiscoveredObject)1 NamespaceList (com.emc.storageos.plugins.common.domainmodel.NamespaceList)1 VNXFileCollectionException (com.emc.storageos.plugins.metering.vnxfile.VNXFileCollectionException)1 VNXException (com.emc.storageos.vnx.xmlapi.VNXException)1 URI (java.net.URI)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Header (org.apache.commons.httpclient.Header)1