use of com.emc.storageos.isilon.restapi.IsilonPool in project coprhd-controller by CoprHD.
the class IsilonCommunicationInterface method discoverPools.
private Map<String, List<StoragePool>> discoverPools(StorageSystem storageSystem, List<StoragePool> poolsToMatchWithVpool) throws IsilonCollectionException {
// Discover storage pools
Map<String, List<StoragePool>> storagePools = new HashMap<String, List<StoragePool>>();
List<StoragePool> newPools = new ArrayList<StoragePool>();
List<StoragePool> existingPools = new ArrayList<StoragePool>();
URI storageSystemId = storageSystem.getId();
try {
_log.info("discoverPools for storage system {} - start", storageSystemId);
IsilonApi isilonApi = getIsilonDevice(storageSystem);
boolean isNfsV4Enabled = isilonApi.nfsv4Enabled(storageSystem.getFirmwareVersion());
boolean syncLicenseValid = isValidLicense(isilonApi.getReplicationLicenseInfo(), storageSystem);
boolean snapLicenseValid = isValidLicense(isilonApi.snapshotIQLicenseInfo(), storageSystem);
// Set file replication type for Isilon storage system!!!
if (syncLicenseValid) {
StringSet supportReplicationTypes = new StringSet();
supportReplicationTypes.add(SupportedFileReplicationTypes.REMOTE.name());
supportReplicationTypes.add(SupportedFileReplicationTypes.LOCAL.name());
storageSystem.setSupportedReplicationTypes(supportReplicationTypes);
}
_log.info("Isilon OneFS version: {}", storageSystem.getFirmwareVersion());
List<? extends IsilonPool> isilonPools = null;
if (VersionChecker.verifyVersionDetails(ONEFS_V7_2, storageSystem.getFirmwareVersion()) >= 0) {
_log.info("Querying for Isilon storage pools...");
isilonPools = isilonApi.getStoragePools();
} else {
_log.info("Querying for Isilon disk pools...");
isilonPools = isilonApi.getDiskPools();
}
for (IsilonPool isilonPool : isilonPools) {
// Check if this storage pool was already discovered
StoragePool storagePool = null;
String poolNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem, isilonPool.getNativeId(), NativeGUIDGenerator.POOL);
@SuppressWarnings("deprecation") List<URI> poolURIs = _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePoolByNativeGuidConstraint(poolNativeGuid));
for (URI poolUri : poolURIs) {
StoragePool pool = _dbClient.queryObject(StoragePool.class, poolUri);
if (!pool.getInactive() && pool.getStorageDevice().equals(storageSystemId)) {
storagePool = pool;
break;
}
}
if (storagePool == null) {
// New storage pool
storagePool = new StoragePool();
storagePool.setId(URIUtil.createId(StoragePool.class));
storagePool.setNativeGuid(poolNativeGuid);
storagePool.setLabel(poolNativeGuid);
storagePool.setPoolClassName(POOL_TYPE);
storagePool.setPoolServiceType(PoolServiceType.file.toString());
storagePool.setStorageDevice(storageSystemId);
StringSet protocols = new StringSet();
protocols.add("NFS");
protocols.add("CIFS");
storagePool.setProtocols(protocols);
storagePool.setPoolName(isilonPool.getNativeId());
storagePool.setNativeId(isilonPool.getNativeId());
storagePool.setLabel(poolNativeGuid);
storagePool.setSupportedResourceTypes(StoragePool.SupportedResourceTypes.THIN_AND_THICK.toString());
storagePool.setOperationalStatus(StoragePool.PoolOperationalStatus.READY.toString());
storagePool.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
_log.info("Creating new storage pool using NativeGuid : {}", poolNativeGuid);
newPools.add(storagePool);
} else {
existingPools.add(storagePool);
}
if (isNfsV4Enabled) {
storagePool.getProtocols().add(NFSv4);
} else {
storagePool.getProtocols().remove(NFSv4);
}
// Add the Copy type ASYNC, if the Isilon is enabled with SyncIQ service!!
StringSet copyTypesSupported = new StringSet();
if (syncLicenseValid) {
copyTypesSupported.add(CopyTypes.ASYNC.name());
storagePool.setSupportedCopyTypes(copyTypesSupported);
} else {
if (storagePool.getSupportedCopyTypes() != null && storagePool.getSupportedCopyTypes().contains(CopyTypes.ASYNC.name())) {
storagePool.getSupportedCopyTypes().remove(CopyTypes.ASYNC.name());
}
}
// Add the Copy type ScheduleSnapshot, if the Isilon is enabled with SnapshotIQ
if (snapLicenseValid) {
copyTypesSupported.add(CHECKPOINT_SCHEDULE);
storagePool.setSupportedCopyTypes(copyTypesSupported);
} else {
if (storagePool.getSupportedCopyTypes() != null && storagePool.getSupportedCopyTypes().contains(CHECKPOINT_SCHEDULE)) {
storagePool.getSupportedCopyTypes().remove(CHECKPOINT_SCHEDULE);
}
}
// scale capacity size
storagePool.setFreeCapacity(isilonPool.getAvailableBytes() / BYTESCONVERTER);
storagePool.setTotalCapacity(isilonPool.getTotalBytes() / BYTESCONVERTER);
storagePool.setSubscribedCapacity(isilonPool.getUsedBytes() / BYTESCONVERTER);
if (ImplicitPoolMatcher.checkPoolPropertiesChanged(storagePool.getCompatibilityStatus(), DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name()) || ImplicitPoolMatcher.checkPoolPropertiesChanged(storagePool.getDiscoveryStatus(), DiscoveryStatus.VISIBLE.name())) {
poolsToMatchWithVpool.add(storagePool);
}
storagePool.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
storagePool.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
}
_log.info("discoverPools for storage system {} - complete", storageSystemId);
storagePools.put(NEW, newPools);
storagePools.put(EXISTING, existingPools);
return storagePools;
} catch (IsilonException ie) {
_log.error("discoverPools failed. Storage system: {}", storageSystemId, ie);
IsilonCollectionException ice = new IsilonCollectionException("discoverPools failed. Storage system: " + storageSystemId);
ice.initCause(ie);
throw ice;
} catch (Exception e) {
_log.error("discoverPools failed. Storage system: {}", storageSystemId, e);
IsilonCollectionException ice = new IsilonCollectionException("discoverPools failed. Storage system: " + storageSystemId);
ice.initCause(e);
throw ice;
}
}
Aggregations