Search in sources :

Example 1 with HDSApiVolumeManager

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());
    }
}
Also used : HDSApiVolumeManager(com.emc.storageos.hds.api.HDSApiVolumeManager) HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) StoragePool(com.emc.storageos.db.client.model.StoragePool) HashMap(java.util.HashMap) LogicalUnit(com.emc.storageos.hds.model.LogicalUnit) ArrayList(java.util.ArrayList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) HashSet(java.util.HashSet) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 StoragePool (com.emc.storageos.db.client.model.StoragePool)1 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)1 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)1 HDSApiClient (com.emc.storageos.hds.api.HDSApiClient)1 HDSApiVolumeManager (com.emc.storageos.hds.api.HDSApiVolumeManager)1 LogicalUnit (com.emc.storageos.hds.model.LogicalUnit)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1