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