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;
}
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;
}
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;
}
Aggregations