Search in sources :

Example 1 with AggregateInfo

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

the class NetAppCAggregate method listAllAggregates.

public List<AggregateInfo> listAllAggregates(boolean listAll) {
    ArrayList<AggregateInfo> aggrs = new ArrayList<AggregateInfo>();
    NaElement result = null;
    List aggrList = null;
    Iterator iter = null;
    String tag = null;
    /*
         * list disks, so we can add the disk-type to AggregateInfo
         */
    NaElement elem = new NaElement("storage-disk-get-iter");
    NaElement diskAttributes = null;
    List storageDiskList = null;
    Iterator storageDiskIter = null;
    Map<String, Set<String>> aggrDiskTypes = Maps.newHashMap();
    Map<String, Set<String>> aggrDiskSpeeds = Maps.newHashMap();
    try {
        do {
            NaElement results = server.invokeElem(elem);
            tag = results.getChildContent("next-tag");
            diskAttributes = results.getChildByName("attributes-list");
            if (diskAttributes != null) {
                storageDiskList = diskAttributes.getChildren();
                storageDiskIter = storageDiskList.iterator();
                while (storageDiskIter.hasNext()) {
                    NaElement storageDisk = (NaElement) storageDiskIter.next();
                    NaElement raidInfo = storageDisk.getChildByName("disk-raid-info");
                    NaElement inventoryInfo = storageDisk.getChildByName("disk-inventory-info");
                    String diskType = inventoryInfo.getChildContent("disk-type");
                    String serialNumber = inventoryInfo.getChildContent("serial-number");
                    int rpmNumber = inventoryInfo.getChildIntValue("rpm", 0);
                    // Prettify the RPM
                    String rpm = formatRPMs(rpmNumber);
                    String uid = storageDisk.getChildContent("disk-uid");
                    String name = storageDisk.getChildContent("disk-name");
                    String containerType = raidInfo.getChildContent("container-type");
                    NaElement diskAggrInfo = raidInfo.getChildByName("disk-aggregate-info");
                    if (diskAggrInfo != null) {
                        String aggregate = diskAggrInfo.getChildContent("aggregate-name");
                        System.out.println("Aggregate Name      : " + aggregate);
                        Set<String> diskTypes = aggrDiskTypes.get(aggregate);
                        if (diskTypes == null) {
                            diskTypes = Sets.newLinkedHashSet();
                            aggrDiskTypes.put(aggregate, diskTypes);
                        }
                        Set<String> diskSpeeds = aggrDiskSpeeds.get(aggregate);
                        if (diskSpeeds == null) {
                            diskSpeeds = Sets.newLinkedHashSet();
                            aggrDiskSpeeds.put(aggregate, diskSpeeds);
                        }
                        diskTypes.add(diskType);
                        diskSpeeds.add(rpm);
                    }
                }
            }
            if (tag != null && !tag.isEmpty()) {
                elem = new NaElement("storage-disk-get-iter");
                elem.addNewChild("tag", tag);
            }
        } while (tag != null && !tag.isEmpty());
    } catch (Exception e) {
        String msg = "Failed to get disk list info.";
        log.error(msg);
        throw new NetAppCException(msg, e);
    }
    elem = new NaElement("aggr-get-iter");
    if (!listAll) {
        elem.addNewChild("aggregate", name);
    }
    try {
        do {
            NaElement results = server.invokeElem(elem);
            if (results.getChildIntValue("num-records", 0) == 0) {
                return aggrs;
            }
            tag = results.getChildContent("next-tag");
            result = results.getChildByName("attributes-list");
            if (result != null) {
                aggrList = result.getChildren();
                iter = aggrList.iterator();
                while (iter.hasNext()) {
                    NaElement aggr = (NaElement) iter.next();
                    NaElement aggrSizeAttrs = aggr.getChildByName("aggr-space-attributes");
                    NaElement aggrRaidAttrs = aggr.getChildByName("aggr-raid-attributes");
                    NaElement aggrVolumeCountAttrs = aggr.getChildByName("aggr-volume-count-attributes");
                    AggregateInfo info = new AggregateInfo();
                    info.setName(aggr.getChildContent("aggregate-name"));
                    info.setSizeAvailable(aggrSizeAttrs.getChildLongValue("size-available", -1));
                    info.setSizeTotal(aggrSizeAttrs.getChildLongValue("size-total", -1));
                    info.setSizeUsed(aggrSizeAttrs.getChildLongValue("size-used", -1));
                    info.setDiskCount(aggrRaidAttrs.getChildIntValue("disk-count", -1));
                    info.setRaidStatus(aggrRaidAttrs.getChildContent("raid-status"));
                    info.setState(aggrRaidAttrs.getChildContent("state"));
                    info.setVolumeCount(aggrVolumeCountAttrs.getChildIntValue("flexvol-count", -1));
                    info.setDiskTypes(aggrDiskTypes.get(info.getName()));
                    info.setDiskSpeeds(aggrDiskSpeeds.get(info.getName()));
                    aggrs.add(info);
                }
            }
            if (tag != null && !tag.isEmpty()) {
                elem = new NaElement("aggr-get-iter");
                elem.addNewChild("tag", tag);
            }
        } while (tag != null && !tag.isEmpty());
    } catch (Exception e) {
        String msg = "Failed to get Aggregate list info.";
        log.error(msg);
        throw new NetAppCException(msg, e);
    }
    return aggrs;
}
Also used : Set(java.util.Set) ArrayList(java.util.ArrayList) NaElement(netapp.manage.NaElement) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) AggregateInfo(com.iwave.ext.netapp.AggregateInfo)

Example 2 with AggregateInfo

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

the class NetAppClusterModeCommIntf method discoverStoragePools.

/**
 * Discover the storage pools for NetApp Cluster mode array
 *
 * @param system
 *            Storage system information
 * @return Map of new and existing storage pools
 * @throws NetAppCException
 */
private Map<String, List<StoragePool>> discoverStoragePools(StorageSystem system, List<StoragePool> poolsToMatchWithVpool) throws NetAppCException {
    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 {
        NetAppClusterApi netAppCApi = new NetAppClusterApi.Builder(system.getIpAddress(), system.getPortNumber(), system.getUsername(), system.getPassword()).https(true).build();
        List<AggregateInfo> pools = netAppCApi.listClusterAggregates(null);
        for (AggregateInfo netAppPool : pools) {
            StoragePool pool = null;
            URIQueryResultList results = new URIQueryResultList();
            String poolNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, netAppPool.getName(), NativeGUIDGenerator.POOL);
            _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePoolByNativeGuidConstraint(poolNativeGuid), results);
            if (results.iterator().hasNext()) {
                StoragePool tmpPool = _dbClient.queryObject(StoragePool.class, results.iterator().next());
                if (tmpPool.getStorageDevice().equals(system.getId())) {
                    pool = tmpPool;
                }
            }
            if (pool == null) {
                pool = new StoragePool();
                pool.setId(URIUtil.createId(StoragePool.class));
                pool.setLabel(poolNativeGuid);
                pool.setNativeGuid(poolNativeGuid);
                pool.setPoolServiceType(PoolServiceType.file.toString());
                pool.setStorageDevice(system.getId());
                pool.setOperationalStatus(StoragePool.PoolOperationalStatus.READY.toString());
                StringSet protocols = new StringSet();
                protocols.add("NFS");
                protocols.add("CIFS");
                pool.setProtocols(protocols);
                pool.setPoolName(netAppPool.getName());
                pool.setNativeId(netAppPool.getName());
                pool.setSupportedResourceTypes(StoragePool.SupportedResourceTypes.THIN_AND_THICK.toString());
                Map<String, String> params = new HashMap<String, String>();
                params.put(StoragePool.ControllerParam.PoolType.name(), "File Pool");
                pool.addControllerParams(params);
                pool.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
                _logger.info("Creating new storage pool using NativeGuid : {}", poolNativeGuid);
                newPools.add(pool);
            } else {
                existingPools.add(pool);
            }
            // Update Pool details with new discovery run
            pool.setTotalCapacity(netAppPool.getSizeTotal() / BYTESCONVERTER);
            pool.setFreeCapacity(netAppPool.getSizeAvailable() / BYTESCONVERTER);
            pool.setSubscribedCapacity(netAppPool.getSizeUsed() / BYTESCONVERTER);
            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());
        }
    } catch (NumberFormatException e) {
        _logger.error("Data Format Exception:  Discovery of storage pools failed for storage system {} for {}", system.getId(), e);
        NetAppCException ntpe = new NetAppCException("Storage pool discovery data error for storage system " + system.getId());
        ntpe.initCause(e);
        throw ntpe;
    }
    _logger.info("Storage pool discovery for storage system {} complete", system.getId());
    storagePools.put(NEW, newPools);
    storagePools.put(EXISTING, existingPools);
    return storagePools;
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) NetAppClusterApi(com.emc.storageos.netappc.NetAppClusterApi) NetAppCException(com.emc.storageos.netappc.NetAppCException) StringSet(com.emc.storageos.db.client.model.StringSet) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) AggregateInfo(com.iwave.ext.netapp.AggregateInfo)

Example 3 with AggregateInfo

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

the class NetAppFileCommunicationInterface method discoverStoragePools.

private Map<String, List<StoragePool>> discoverStoragePools(StorageSystem system, List<StoragePool> poolsToMatchWithVpool) throws NetAppFileCollectionException, NetAppException {
    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 {
        NetAppApi netAppApi = new NetAppApi.Builder(system.getIpAddress(), system.getPortNumber(), system.getUsername(), system.getPassword()).https(true).build();
        List<AggregateInfo> pools = netAppApi.listAggregates(null);
        for (AggregateInfo netAppPool : pools) {
            StoragePool pool = null;
            URIQueryResultList results = new URIQueryResultList();
            String poolNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, netAppPool.getName(), NativeGUIDGenerator.POOL);
            _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePoolByNativeGuidConstraint(poolNativeGuid), results);
            if (results.iterator().hasNext()) {
                StoragePool tmpPool = _dbClient.queryObject(StoragePool.class, results.iterator().next());
                if (tmpPool.getStorageDevice().equals(system.getId())) {
                    pool = tmpPool;
                }
            }
            if (pool == null) {
                pool = new StoragePool();
                pool.setId(URIUtil.createId(StoragePool.class));
                pool.setLabel(poolNativeGuid);
                pool.setNativeGuid(poolNativeGuid);
                pool.setPoolServiceType(PoolServiceType.file.toString());
                pool.setStorageDevice(system.getId());
                pool.setOperationalStatus(StoragePool.PoolOperationalStatus.READY.toString());
                StringSet protocols = new StringSet();
                protocols.add("NFS");
                protocols.add("CIFS");
                pool.setProtocols(protocols);
                pool.setPoolName(netAppPool.getName());
                pool.setNativeId(netAppPool.getName());
                pool.setSupportedResourceTypes(StoragePool.SupportedResourceTypes.THIN_AND_THICK.toString());
                Map<String, String> params = new HashMap<String, String>();
                params.put(StoragePool.ControllerParam.PoolType.name(), "File Pool");
                pool.addControllerParams(params);
                pool.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
                _logger.info("Creating new storage pool using NativeGuid : {}", poolNativeGuid);
                newPools.add(pool);
            } else {
                existingPools.add(pool);
            }
            // Update Pool details with new discovery run
            pool.setTotalCapacity(netAppPool.getSizeTotal() / BYTESCONVERTER);
            pool.setFreeCapacity(netAppPool.getSizeAvailable() / BYTESCONVERTER);
            pool.setSubscribedCapacity(netAppPool.getSizeUsed() / BYTESCONVERTER);
            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());
        }
    } catch (NumberFormatException e) {
        _logger.error("Data Format Exception:  Discovery of storage pools failed for storage system {} for {}", system.getId(), e);
        NetAppFileCollectionException ntpe = new NetAppFileCollectionException("Storage pool discovery data error for storage system " + system.getId());
        ntpe.initCause(e);
        throw ntpe;
    }
    _logger.info("Storage pool discovery for storage system {} complete", system.getId());
    storagePools.put(NEW, newPools);
    storagePools.put(EXISTING, existingPools);
    return storagePools;
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StringSet(com.emc.storageos.db.client.model.StringSet) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) NetAppApi(com.emc.storageos.netapp.NetAppApi) NetAppFileCollectionException(com.emc.storageos.plugins.metering.netapp.NetAppFileCollectionException) AggregateInfo(com.iwave.ext.netapp.AggregateInfo)

Aggregations

AggregateInfo (com.iwave.ext.netapp.AggregateInfo)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)2 StoragePool (com.emc.storageos.db.client.model.StoragePool)2 StringSet (com.emc.storageos.db.client.model.StringSet)2 HashMap (java.util.HashMap)2 NetAppApi (com.emc.storageos.netapp.NetAppApi)1 NetAppCException (com.emc.storageos.netappc.NetAppCException)1 NetAppClusterApi (com.emc.storageos.netappc.NetAppClusterApi)1 NetAppFileCollectionException (com.emc.storageos.plugins.metering.netapp.NetAppFileCollectionException)1 Iterator (java.util.Iterator)1 Set (java.util.Set)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 NaElement (netapp.manage.NaElement)1