use of com.emc.storageos.hds.api.HDSApiVolumeManager in project coprhd-controller by CoprHD.
the class HDSVolumeDiscoverer method discoverUnManagedVolumes.
public void discoverUnManagedVolumes(AccessProfile accessProfile, DbClient dbClient, CoordinatorClient coordinator, PartitionManager partitionManager) throws Exception {
log.info("Started discovery of UnManagedVolumes for system {}", accessProfile.getSystemId());
HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(accessProfile), accessProfile.getUserName(), accessProfile.getPassword());
List<UnManagedVolume> newUnManagedVolumeList = new ArrayList<UnManagedVolume>();
List<UnManagedVolume> updateUnManagedVolumeList = new ArrayList<UnManagedVolume>();
Set<URI> allDiscoveredUnManagedVolumes = new HashSet<URI>();
HDSApiVolumeManager volumeManager = hdsApiClient.getHDSApiVolumeManager();
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
String systemObjectId = HDSUtils.getSystemObjectID(storageSystem);
List<LogicalUnit> luList = volumeManager.getAllLogicalUnits(systemObjectId);
if (null != luList && !luList.isEmpty()) {
log.info("Processing {} volumes received from HiCommand server.", luList.size());
URIQueryResultList storagePoolURIs = new URIQueryResultList();
dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePoolConstraint(storageSystem.getId()), storagePoolURIs);
HashMap<String, StoragePool> pools = new HashMap<String, StoragePool>();
Iterator<URI> poolsItr = storagePoolURIs.iterator();
while (poolsItr.hasNext()) {
URI storagePoolURI = poolsItr.next();
StoragePool storagePool = dbClient.queryObject(StoragePool.class, storagePoolURI);
pools.put(storagePool.getNativeGuid(), storagePool);
}
for (LogicalUnit logicalUnit : luList) {
log.info("Processing LogicalUnit: {}", logicalUnit.getObjectID());
UnManagedVolume unManagedVolume = null;
String managedVolumeNativeGuid = NativeGUIDGenerator.generateNativeGuidForVolumeOrBlockSnapShot(storageSystem.getNativeGuid(), String.valueOf(logicalUnit.getDevNum()));
if (null != DiscoveryUtils.checkStorageVolumeExistsInDB(dbClient, managedVolumeNativeGuid)) {
log.info("Skipping volume {} as it is already managed by ViPR", managedVolumeNativeGuid);
}
String unManagedVolumeNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingVolume(storageSystem.getNativeGuid(), String.valueOf(logicalUnit.getDevNum()));
unManagedVolume = DiscoveryUtils.checkUnManagedVolumeExistsInDB(dbClient, unManagedVolumeNativeGuid);
boolean unManagedVolumeExists = (null != unManagedVolume) ? true : false;
StoragePool storagePool = getStoragePoolOfUnManagedVolume(logicalUnit, storageSystem, pools, dbClient);
if (null != storagePool) {
if (!unManagedVolumeExists) {
unManagedVolume = createUnManagedVolume(unManagedVolumeNativeGuid, logicalUnit, storageSystem, storagePool, dbClient);
newUnManagedVolumeList.add(unManagedVolume);
} else {
updateUnManagedVolumeInfo(logicalUnit, storageSystem, storagePool, unManagedVolume, dbClient);
updateUnManagedVolumeList.add(unManagedVolume);
}
allDiscoveredUnManagedVolumes.add(unManagedVolume.getId());
} else {
log.error("Skipping unmanaged volume discovery as the volume {} storage pool doesn't exist in ViPR", logicalUnit.getObjectID());
}
performUnManagedVolumesBookKeepting(newUnManagedVolumeList, updateUnManagedVolumeList, partitionManager, dbClient, Constants.DEFAULT_PARTITION_SIZE);
}
performUnManagedVolumesBookKeepting(newUnManagedVolumeList, updateUnManagedVolumeList, partitionManager, dbClient, 0);
// Process those active unmanaged volume objects available in database but not in newly discovered items, to mark them inactive.
DiscoveryUtils.markInActiveUnManagedVolumes(storageSystem, allDiscoveredUnManagedVolumes, dbClient, partitionManager);
} else {
log.info("No volumes retured by HiCommand Server for system {}", storageSystem.getId());
}
}
Aggregations