Search in sources :

Example 6 with UnManagedConsistencyGroup

use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedConsistencyGroup in project coprhd-controller by CoprHD.

the class DiscoveryUtils method performUnManagedConsistencyGroupsBookKeeping.

/**
 * Compares the set of unmanaged consistency groups for the current discovery operation
 * to the set of unmanaged consistency groups already in the database from a previous
 * discovery operation.  Removes existing database entries if the object was not present
 * in the current discovery operation.
 *
 * @param storageSystem - storage system containing the CGs
 * @param currentUnManagedCGs - current list of unmanaged CGs
 * @param dbClient - database client
 * @param partitionManager - partition manager
 */
public static void performUnManagedConsistencyGroupsBookKeeping(StorageSystem storageSystem, Set<URI> currentUnManagedCGs, DbClient dbClient, PartitionManager partitionManager) {
    _log.info(" -- Processing {} discovered UnManaged Consistency Group Objects from -- {}", currentUnManagedCGs.size(), storageSystem.getLabel());
    // no consistency groups discovered
    if (currentUnManagedCGs.isEmpty()) {
        return;
    }
    // Get all available existing unmanaged CG URIs for this array from DB
    URIQueryResultList allAvailableUnManagedCGsInDB = new URIQueryResultList();
    dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageSystemUnManagedCGConstraint(storageSystem.getId()), allAvailableUnManagedCGsInDB);
    Set<URI> unManagedCGsInDBSet = new HashSet<URI>();
    Iterator<URI> allAvailableUnManagedCGsItr = allAvailableUnManagedCGsInDB.iterator();
    while (allAvailableUnManagedCGsItr.hasNext()) {
        unManagedCGsInDBSet.add(allAvailableUnManagedCGsItr.next());
    }
    SetView<URI> onlyAvailableinDB = Sets.difference(unManagedCGsInDBSet, currentUnManagedCGs);
    _log.info("Diff :" + Joiner.on("\t").join(onlyAvailableinDB));
    if (!onlyAvailableinDB.isEmpty()) {
        List<UnManagedConsistencyGroup> unManagedCGTobeDeleted = new ArrayList<UnManagedConsistencyGroup>();
        Iterator<UnManagedConsistencyGroup> unManagedCGs = dbClient.queryIterativeObjects(UnManagedConsistencyGroup.class, new ArrayList<URI>(onlyAvailableinDB));
        while (unManagedCGs.hasNext()) {
            UnManagedConsistencyGroup cg = unManagedCGs.next();
            if (null == cg || cg.getInactive()) {
                continue;
            }
            _log.info("Setting UnManagedConsistencyGroup {} inactive", cg.getId());
            cg.setStorageSystemUri(NullColumnValueGetter.getNullURI());
            cg.setInactive(true);
            unManagedCGTobeDeleted.add(cg);
        }
        if (!unManagedCGTobeDeleted.isEmpty()) {
            partitionManager.updateAndReIndexInBatches(unManagedCGTobeDeleted, unManagedCGTobeDeleted.size(), dbClient, UNMANAGED_CONSISTENCY_GROUP);
        }
    }
}
Also used : UnManagedConsistencyGroup(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedConsistencyGroup) ArrayList(java.util.ArrayList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) HashSet(java.util.HashSet)

Example 7 with UnManagedConsistencyGroup

use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedConsistencyGroup in project coprhd-controller by CoprHD.

the class VNXUnityUnManagedObjectDiscoverer method createUnManagedCG.

/**
 * Creates a new UnManagedConsistencyGroup object in the database
 *
 * @param unManagedCGNativeGuid
 *            - nativeGuid of the unmanaged consistency group
 * @param res
 *            - unity consistency group returned from REST client
 * @param storageSystemURI
 *            - storage system of the consistency group
 * @param dbClient
 *            - database client
 * @return the new UnManagedConsistencyGroup object
 */
private UnManagedConsistencyGroup createUnManagedCG(String unManagedCGNativeGuid, StorageResource res, URI storageSystemURI, DbClient dbClient) {
    UnManagedConsistencyGroup unManagedCG = new UnManagedConsistencyGroup();
    unManagedCG.setId(URIUtil.createId(UnManagedConsistencyGroup.class));
    unManagedCG.setLabel(res.getName());
    unManagedCG.setName(res.getName());
    unManagedCG.setNativeGuid(unManagedCGNativeGuid);
    unManagedCG.setStorageSystemUri(storageSystemURI);
    unManagedCG.setNumberOfVols(Integer.toString(res.getLuns().size()));
    dbClient.createObject(unManagedCG);
    return unManagedCG;
}
Also used : UnManagedConsistencyGroup(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedConsistencyGroup)

Example 8 with UnManagedConsistencyGroup

use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedConsistencyGroup in project coprhd-controller by CoprHD.

the class VNXUnityUnManagedObjectDiscoverer 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());
    VNXeApiClient apiClient = getVnxUnityClient(accessProfile);
    unManagedVolumesInsert = new ArrayList<UnManagedVolume>();
    unManagedVolumesUpdate = new ArrayList<UnManagedVolume>();
    unManagedCGToUpdateMap = new HashMap<String, UnManagedConsistencyGroup>();
    StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
    List<VNXeLun> luns = apiClient.getAllLuns();
    if (luns != null && !luns.isEmpty()) {
        Map<String, StoragePool> pools = getStoragePoolMap(storageSystem, dbClient);
        Map<String, List<UnManagedVolume>> hostVolumesMap = new HashMap<String, List<UnManagedVolume>>();
        for (VNXeLun lun : luns) {
            UnManagedVolume unManagedVolume = null;
            String managedVolumeNativeGuid = NativeGUIDGenerator.generateNativeGuidForVolumeOrBlockSnapShot(storageSystem.getNativeGuid(), lun.getId());
            if (null != DiscoveryUtils.checkStorageVolumeExistsInDB(dbClient, managedVolumeNativeGuid)) {
                log.info("Skipping volume {} as it is already managed by ViPR", managedVolumeNativeGuid);
            }
            StoragePool storagePool = getStoragePoolOfUnManagedObject(lun.getPool().getId(), storageSystem, pools);
            if (null == storagePool) {
                log.error("Skipping unmanaged volume discovery as the volume {} storage pool doesn't exist in ViPR", lun.getId());
                continue;
            }
            String unManagedVolumeNatvieGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingVolume(storageSystem.getNativeGuid(), lun.getId());
            unManagedVolume = DiscoveryUtils.checkUnManagedVolumeExistsInDB(dbClient, unManagedVolumeNatvieGuid);
            unManagedVolume = createUnManagedVolume(unManagedVolume, unManagedVolumeNatvieGuid, lun, storageSystem, storagePool, dbClient, hostVolumesMap);
            unManagedVolumesReturnedFromProvider.add(unManagedVolume.getId());
            Boolean isVolumeInCG = lun.getType() == VNXeApiClient.GENERIC_STORAGE_LUN_TYPE ? true : false;
            String cgId = null;
            if (isVolumeInCG) {
                cgId = lun.getStorageResource().getId();
                addObjectToUnManagedConsistencyGroup(apiClient, unManagedVolume, cgId, storageSystem, dbClient);
            } else {
                // Make sure the unManagedVolume object does not contain CG information from previous discovery
                unManagedVolume.getVolumeCharacterstics().put(SupportedVolumeCharacterstics.IS_VOLUME_ADDED_TO_CONSISTENCYGROUP.toString(), Boolean.FALSE.toString());
                // set the uri of the unmanaged CG in the unmanaged volume object to empty
                unManagedVolume.getVolumeInformation().put(SupportedVolumeInformation.UNMANAGED_CONSISTENCY_GROUP_URI.toString(), "");
            }
            // Discover snaps
            Integer snapCount = lun.getSnapCount();
            boolean hasSnap = false;
            if (snapCount > 0) {
                List<Snap> snaps = apiClient.getSnapshotsForLun(lun.getId());
                if (snaps != null && !snaps.isEmpty()) {
                    StringSet parentMatchedVPools = unManagedVolume.getSupportedVpoolUris();
                    StringSet discoveredSnaps = discoverVolumeSnaps(storageSystem, snaps, unManagedVolumeNatvieGuid, parentMatchedVPools, apiClient, dbClient, hostVolumesMap, lun, isVolumeInCG, cgId);
                    if (discoveredSnaps != null && !discoveredSnaps.isEmpty()) {
                        hasSnap = true;
                        unManagedVolume.getVolumeCharacterstics().put(SupportedVolumeCharacterstics.HAS_REPLICAS.toString(), Boolean.TRUE.toString());
                        StringSetMap unManagedVolumeInformation = unManagedVolume.getVolumeInformation();
                        if (unManagedVolumeInformation.containsKey(SupportedVolumeInformation.SNAPSHOTS.toString())) {
                            // replace with new StringSet
                            unManagedVolumeInformation.get(SupportedVolumeInformation.SNAPSHOTS.toString()).replace(discoveredSnaps);
                            log.info("Replaced snaps :" + Joiner.on("\t").join(unManagedVolumeInformation.get(SupportedVolumeInformation.SNAPSHOTS.toString())));
                        } else {
                            unManagedVolumeInformation.put(SupportedVolumeInformation.SNAPSHOTS.toString(), discoveredSnaps);
                        }
                    }
                }
            }
            if (!hasSnap) {
                // no snap
                unManagedVolume.getVolumeCharacterstics().put(SupportedVolumeCharacterstics.HAS_REPLICAS.toString(), Boolean.FALSE.toString());
                StringSetMap unManagedVolumeInformation = unManagedVolume.getVolumeInformation();
                if (unManagedVolumeInformation != null && unManagedVolumeInformation.containsKey(SupportedVolumeInformation.SNAPSHOTS.toString())) {
                    // replace with empty string set doesn't work, hence added explicit code to remove all
                    unManagedVolumeInformation.get(SupportedVolumeInformation.SNAPSHOTS.toString()).clear();
                }
            }
        }
        if (!unManagedCGToUpdateMap.isEmpty()) {
            unManagedCGToUpdate = new ArrayList<UnManagedConsistencyGroup>(unManagedCGToUpdateMap.values());
            partitionManager.updateAndReIndexInBatches(unManagedCGToUpdate, unManagedCGToUpdate.size(), dbClient, UNMANAGED_CONSISTENCY_GROUP);
            unManagedCGToUpdate.clear();
        }
        if (!unManagedVolumesInsert.isEmpty()) {
            partitionManager.insertInBatches(unManagedVolumesInsert, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_VOLUME);
        }
        if (!unManagedVolumesUpdate.isEmpty()) {
            partitionManager.updateAndReIndexInBatches(unManagedVolumesUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_VOLUME);
        }
        // Process those active unmanaged volume objects available in database but not in newly discovered items, to
        // mark them inactive.
        DiscoveryUtils.markInActiveUnManagedVolumes(storageSystem, unManagedVolumesReturnedFromProvider, dbClient, partitionManager);
        // Process those active unmanaged consistency group objects available in database but not in newly
        // discovered items, to mark them
        // inactive.
        DiscoveryUtils.performUnManagedConsistencyGroupsBookKeeping(storageSystem, allCurrentUnManagedCgURIs, dbClient, partitionManager);
        // Next discover the unmanaged export masks
        discoverUnmanagedExportMasks(storageSystem.getId(), hostVolumesMap, apiClient, dbClient, partitionManager);
    } else {
        log.info("There are no luns found on the system: {}", storageSystem.getId());
    }
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StoragePool(com.emc.storageos.db.client.model.StoragePool) UnManagedConsistencyGroup(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedConsistencyGroup) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) HashMap(java.util.HashMap) Snap(com.emc.storageos.vnxe.models.Snap) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) StringSet(com.emc.storageos.db.client.model.StringSet) VNXeLun(com.emc.storageos.vnxe.models.VNXeLun) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 9 with UnManagedConsistencyGroup

use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedConsistencyGroup in project coprhd-controller by CoprHD.

the class XtremIOUnManagedVolumeDiscoverer method createUnManagedCG.

/**
 * Creates a new UnManagedConsistencyGroup object in the database
 *
 * @param unManagedCGNativeGuid - nativeGuid of the unmanaged consistency group
 * @param consistencyGroup - xtremio consistency group returned from REST client
 * @param storageSystemURI - storage system of the consistency group
 * @param dbClient - database client
 * @return the new UnManagedConsistencyGroup object
 */
private UnManagedConsistencyGroup createUnManagedCG(String unManagedCGNativeGuid, XtremIOConsistencyGroup consistencyGroup, URI storageSystemURI, DbClient dbClient) {
    UnManagedConsistencyGroup unManagedCG = new UnManagedConsistencyGroup();
    unManagedCG.setId(URIUtil.createId(UnManagedConsistencyGroup.class));
    unManagedCG.setLabel(consistencyGroup.getName());
    unManagedCG.setName(consistencyGroup.getName());
    unManagedCG.setNativeGuid(unManagedCGNativeGuid);
    unManagedCG.setStorageSystemUri(storageSystemURI);
    unManagedCG.setNumberOfVols(consistencyGroup.getNumOfVols());
    dbClient.createObject(unManagedCG);
    return unManagedCG;
}
Also used : UnManagedConsistencyGroup(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedConsistencyGroup)

Example 10 with UnManagedConsistencyGroup

use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedConsistencyGroup in project coprhd-controller by CoprHD.

the class XtremIOUnManagedVolumeDiscoverer method addObjectToUnManagedConsistencyGroup.

/**
 * Adds the passed in unmanaged volume or unmanaged snapshot
 * to an unmanaged consistency group object
 *
 * @param xtremIOClient - connection to xtremio REST interface
 * @param unManagedVolume - either and unmanaged volume or unmanaged snapshot
 *            associated with a consistency group
 * @param cgNameToProcess - consistency group being processed
 * @param storageSystem - storage system the objects are on
 * @param xioClusterName - name of the xtremio cluster being managed by the xtremio XMS
 * @param dbClient - dbclient
 * @throws Exception
 */
private void addObjectToUnManagedConsistencyGroup(XtremIOClient xtremIOClient, UnManagedVolume unManagedVolume, String cgNameToProcess, StorageSystem storageSystem, String xioClusterName, DbClient dbClient) throws Exception {
    // Check if the current CG is in the list of unsupported CGs
    if (!unSupportedCG.isEmpty() && unSupportedCG.contains(cgNameToProcess.toString())) {
        // leave the for loop and do nothing
        log.warn("Skipping CG {} as it contains volumes belonging to multiple CGs and this is not supported", cgNameToProcess.toString());
        return;
    }
    log.info("Unmanaged volume {} belongs to consistency group {} on the array", unManagedVolume.getLabel(), cgNameToProcess);
    // Update the unManagedVolume object with CG information
    unManagedVolume.getVolumeCharacterstics().put(SupportedVolumeCharacterstics.IS_VOLUME_ADDED_TO_CONSISTENCYGROUP.toString(), Boolean.TRUE.toString());
    // Get the unmanaged CG details from the array
    XtremIOConsistencyGroup xioCG = xtremIOClient.getConsistencyGroupDetails(cgNameToProcess.toString(), xioClusterName);
    // determine the native guid for the unmanaged CG (storage system id + xio cg guid)
    String unManagedCGNativeGuid = NativeGUIDGenerator.generateNativeGuidForCG(storageSystem.getNativeGuid(), xioCG.getGuid());
    // determine if the unmanaged CG already exists in the unManagedCGToUpdateMap or in the database
    // if the the unmanaged CG is not in either create a new one
    UnManagedConsistencyGroup unManagedCG = null;
    if (unManagedCGToUpdateMap.containsKey(unManagedCGNativeGuid)) {
        unManagedCG = unManagedCGToUpdateMap.get(unManagedCGNativeGuid);
        log.info("Unmanaged consistency group {} was previously added to the unManagedCGToUpdateMap", unManagedCG.getLabel());
    } else {
        unManagedCG = DiscoveryUtils.checkUnManagedCGExistsInDB(dbClient, unManagedCGNativeGuid);
        if (null == unManagedCG) {
            // unmanaged CG does not exist in the database, create it
            unManagedCG = createUnManagedCG(unManagedCGNativeGuid, xioCG, storageSystem.getId(), dbClient);
            log.info("Created unmanaged consistency group: {}", unManagedCG.getId().toString());
        } else {
            log.info("Unmanaged consistency group {} was previously added to the database", unManagedCG.getLabel());
            // clean out the list of unmanaged volumes if this unmanaged cg was already
            // in the database and its first time being used in this discovery operation
            // the list should be re-populated by the current discovery operation
            log.info("Cleaning out unmanaged volume map from unmanaged consistency group: {}", unManagedCG.getLabel());
            unManagedCG.getUnManagedVolumesMap().clear();
        }
    }
    log.info("Adding unmanaged volume {} to unmanaged consistency group {}", unManagedVolume.getLabel(), unManagedCG.getLabel());
    // set the uri of the unmanaged CG in the unmanaged volume object
    unManagedVolume.getVolumeInformation().put(SupportedVolumeInformation.UNMANAGED_CONSISTENCY_GROUP_URI.toString(), unManagedCG.getId().toString());
    // add the unmanaged volume object to the unmanaged CG
    unManagedCG.getUnManagedVolumesMap().put(unManagedVolume.getNativeGuid(), unManagedVolume.getId().toString());
    // add the unmanaged CG to the map of unmanaged CGs to be updated in the database once all volumes have been processed
    unManagedCGToUpdateMap.put(unManagedCGNativeGuid, unManagedCG);
    // add the unmanaged CG to the current set of CGs being discovered on the array. This is for book keeping later.
    allCurrentUnManagedCgURIs.add(unManagedCG.getId());
}
Also used : XtremIOConsistencyGroup(com.emc.storageos.xtremio.restapi.model.response.XtremIOConsistencyGroup) UnManagedConsistencyGroup(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedConsistencyGroup)

Aggregations

UnManagedConsistencyGroup (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedConsistencyGroup)17 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)5 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)4 URI (java.net.URI)4 ArrayList (java.util.ArrayList)4 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)3 BlockObject (com.emc.storageos.db.client.model.BlockObject)3 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 List (java.util.List)3 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)2 DataObject (com.emc.storageos.db.client.model.DataObject)2 StoragePool (com.emc.storageos.db.client.model.StoragePool)2 StringSet (com.emc.storageos.db.client.model.StringSet)2 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)2 Volume (com.emc.storageos.db.client.model.Volume)2 VolumeIngestionContext (com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.VolumeIngestionContext)1 DiscoveredDataObject (com.emc.storageos.db.client.model.DiscoveredDataObject)1 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)1