Search in sources :

Example 71 with UnManagedVolume

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

the class VplexBackendIngestionContext method getUnmanagedBackendOnlyClones.

/**
 * Returns a Map of parent backend volume to child backend volumes
 * for any clones (full copies) associated with the backend volumes
 * of this context's virtual volume.
 *
 * The term "backend-only clone" implies that the clone is only a copy
 * of the backend volume and there is no virtual volume in front of it.
 * This is as-opposed to a "full clone" that has a virtual volume in
 * front of it.
 *
 * @return a Map of UnManagedVolume parent objects to UnManagedVolume child objects
 */
public Map<UnManagedVolume, Set<UnManagedVolume>> getUnmanagedBackendOnlyClones() {
    if (null != unmanagedBackendOnlyClones) {
        return unmanagedBackendOnlyClones;
    }
    long start = System.currentTimeMillis();
    _logger.info("getting unmanaged backend-only clones");
    unmanagedBackendOnlyClones = new HashMap<UnManagedVolume, Set<UnManagedVolume>>();
    for (UnManagedVolume backendVolume : getUnmanagedBackendVolumes()) {
        List<UnManagedVolume> clonesForThisVolume = getUnManagedClones(backendVolume);
        if (clonesForThisVolume != null) {
            for (UnManagedVolume clone : clonesForThisVolume) {
                String parentVvol = extractValueFromStringSet(SupportedVolumeInformation.VPLEX_PARENT_VOLUME.name(), clone.getVolumeInformation());
                if (parentVvol == null || parentVvol.isEmpty()) {
                    if (!unmanagedBackendOnlyClones.containsKey(backendVolume)) {
                        Set<UnManagedVolume> cloneSet = new HashSet<UnManagedVolume>();
                        unmanagedBackendOnlyClones.put(backendVolume, cloneSet);
                    }
                    _logger.info("could not find a parent virtual volume for backend clone {}", clone.getLabel());
                    unmanagedBackendOnlyClones.get(backendVolume).add(clone);
                }
            }
        }
    }
    _logger.info("unmanaged backend-only clones found: " + unmanagedBackendOnlyClones);
    _tracker.fetchBackendOnlyClones = System.currentTimeMillis() - start;
    return unmanagedBackendOnlyClones;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) StringSet(com.emc.storageos.db.client.model.StringSet) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) HashSet(java.util.HashSet)

Example 72 with UnManagedVolume

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

the class VplexBackendIngestionContext method getUnManagedSnaphots.

/**
 * Copied from VolumeIngestionUtil, which is in apisvc and
 * can't be accessed from controllersvc.
 */
public List<UnManagedVolume> getUnManagedSnaphots(UnManagedVolume unManagedVolume) {
    List<UnManagedVolume> snapshots = new ArrayList<UnManagedVolume>();
    _logger.info("checking for snapshots related to unmanaged volume " + unManagedVolume.getLabel());
    if (checkUnManagedVolumeHasReplicas(unManagedVolume)) {
        StringSet snapshotNativeIds = extractValuesFromStringSet(SupportedVolumeInformation.SNAPSHOTS.toString(), unManagedVolume.getVolumeInformation());
        List<URI> snapshotUris = new ArrayList<URI>();
        if (null != snapshotNativeIds && !snapshotNativeIds.isEmpty()) {
            for (String nativeId : snapshotNativeIds) {
                _logger.info("   found snapshot native id " + nativeId);
                URIQueryResultList unManagedVolumeList = new URIQueryResultList();
                _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVolumeInfoNativeIdConstraint(nativeId), unManagedVolumeList);
                if (unManagedVolumeList.iterator().hasNext()) {
                    snapshotUris.add(unManagedVolumeList.iterator().next());
                }
            }
        }
        if (!snapshotUris.isEmpty()) {
            snapshots = _dbClient.queryObject(UnManagedVolume.class, snapshotUris, true);
            _logger.info("   returning snapshot objects: " + snapshots);
        }
    }
    return snapshots;
}
Also used : UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) ArrayList(java.util.ArrayList) StringSet(com.emc.storageos.db.client.model.StringSet) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 73 with UnManagedVolume

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

the class VplexBackendIngestionContext method getVplexDeviceToUnManagedVolumeMap.

/**
 * Returns a Map of backend supporting device name
 * to the UnManagedVolume that contains it. This is
 * necessary because there is no way to query the values
 * in a StringSetMap in the database. This is used for
 * Full clone (i.e. virtual volume clone) detection.
 *
 * @return a Map of backend supporting device name to its UnManagedVolume
 */
public Map<String, URI> getVplexDeviceToUnManagedVolumeMap() {
    URI vplexUri = getVplexUri();
    Iterator<UnManagedVolume> allUnmanagedVolumes = null;
    long dingleTimer = new Date().getTime();
    Map<String, URI> deviceToUnManagedVolumeMap = new HashMap<String, URI>();
    List<URI> storageSystem = new ArrayList<URI>();
    storageSystem.add(vplexUri);
    try {
        List<URI> ids = _dbClient.queryByType(UnManagedVolume.class, true);
        List<String> fields = new ArrayList<String>();
        fields.add("storageDevice");
        fields.add("volumeInformation");
        allUnmanagedVolumes = _dbClient.queryIterativeObjectFields(UnManagedVolume.class, fields, ids);
    } catch (Exception e) {
        // have to do this because the database sometimes returns UnManagedVolume
        // objects that no longer exist and are null
        _logger.warn("Exception caught:", e);
    }
    if (null != allUnmanagedVolumes) {
        while (allUnmanagedVolumes.hasNext()) {
            try {
                UnManagedVolume vol = allUnmanagedVolumes.next();
                if (vol.getStorageSystemUri().equals(vplexUri)) {
                    String supportingDeviceName = extractValueFromStringSet(SupportedVolumeInformation.VPLEX_SUPPORTING_DEVICE_NAME.toString(), vol.getVolumeInformation());
                    if (null != supportingDeviceName) {
                        deviceToUnManagedVolumeMap.put(supportingDeviceName, vol.getId());
                    }
                }
            } catch (NoSuchElementException ex) {
                // have to do this because the database sometimes returns UnManagedVolume
                // objects that no longer exist and are null
                _logger.warn("for some reason the database returned nonsense: " + ex.getLocalizedMessage());
            }
        }
    } else {
        throw VPlexApiException.exceptions.backendIngestionContextLoadFailure("could not load deviceToUnManagedVolumeMap");
    }
    _logger.info("creating deviceToUnManagedVolumeMap took {} ms", new Date().getTime() - dingleTimer);
    return deviceToUnManagedVolumeMap;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) URI(java.net.URI) Date(java.util.Date) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) NoSuchElementException(java.util.NoSuchElementException) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) NoSuchElementException(java.util.NoSuchElementException)

Example 74 with UnManagedVolume

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

the class VplexBackendIngestionContext method getUnmanagedSnapshots.

/**
 * Returns a List of any block snapshots associated
 * with the backend volumes of this context's virtual volume.
 *
 * @return a List of UnManagedVolume snaphot objects
 */
public List<UnManagedVolume> getUnmanagedSnapshots() {
    if (null != unmanagedSnapshots) {
        return unmanagedSnapshots;
    }
    long start = System.currentTimeMillis();
    _logger.info("getting unmanaged snapshots");
    unmanagedSnapshots = new ArrayList<UnManagedVolume>();
    for (UnManagedVolume sourceVolume : this.getUnmanagedBackendVolumes()) {
        unmanagedSnapshots.addAll(getUnManagedSnaphots(sourceVolume));
    }
    _logger.info("found these associated snapshots: " + unmanagedSnapshots);
    _tracker.fetchSnapshots = System.currentTimeMillis() - start;
    return unmanagedSnapshots;
}
Also used : UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)

Example 75 with UnManagedVolume

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

the class VplexBackendIngestionContext method updateUnmanagedBackendVolumesInParent.

/**
 * Sets the VPLEX_BACKEND_VOLUMES information on the virtual UnManagedVolume
 * as well as the VPLEX_PARENT_VOLUME and VPLEX_BACKEND_CLUSTER_ID
 * on each associated UnManagedVolume.
 */
private void updateUnmanagedBackendVolumesInParent() {
    if (!getUnmanagedBackendVolumes().isEmpty()) {
        StringSet bvols = new StringSet();
        for (UnManagedVolume backendVol : unmanagedBackendVolumes) {
            bvols.add(backendVol.getNativeGuid());
            // set the parent volume native guid on the backend volume
            StringSet parentVol = new StringSet();
            parentVol.add(_unmanagedVirtualVolume.getNativeGuid());
            backendVol.putVolumeInfo(SupportedVolumeInformation.VPLEX_PARENT_VOLUME.name(), parentVol);
            if (isDistributed()) {
                // determine cluster location of distributed component storage volume leg
                VPlexStorageVolumeInfo storageVolume = getBackendVolumeWwnToInfoMap().get(backendVol.getWwn());
                if (null != storageVolume) {
                    String clusterId = getClusterLocationForStorageVolume(storageVolume);
                    if (null != clusterId && !clusterId.isEmpty()) {
                        _logger.info("setting VPLEX_BACKEND_CLUSTER_ID: " + clusterId);
                        StringSet clusterIds = new StringSet();
                        clusterIds.add(clusterId);
                        backendVol.putVolumeInfo(SupportedVolumeInformation.VPLEX_BACKEND_CLUSTER_ID.name(), clusterIds);
                    }
                }
            }
            _dbClient.updateObject(backendVol);
        }
        if (bvols != null && !bvols.isEmpty()) {
            _logger.info("setting VPLEX_BACKEND_VOLUMES: " + unmanagedBackendVolumes);
            _unmanagedVirtualVolume.putVolumeInfo(SupportedVolumeInformation.VPLEX_BACKEND_VOLUMES.name(), bvols);
            _unmanagedVirtualVolume.setLabel(getFriendlyLabel());
        }
    }
}
Also used : UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) VPlexStorageVolumeInfo(com.emc.storageos.vplex.api.VPlexStorageVolumeInfo) StringSet(com.emc.storageos.db.client.model.StringSet)

Aggregations

UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)146 StringSet (com.emc.storageos.db.client.model.StringSet)66 URI (java.net.URI)53 Volume (com.emc.storageos.db.client.model.Volume)48 ArrayList (java.util.ArrayList)48 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)33 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)31 BlockObject (com.emc.storageos.db.client.model.BlockObject)30 HashMap (java.util.HashMap)29 HashSet (java.util.HashSet)24 NamedURI (com.emc.storageos.db.client.model.NamedURI)19 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)19 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)18 DataObject (com.emc.storageos.db.client.model.DataObject)13 UnManagedExportMask (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask)13 CIMObjectPath (javax.cim.CIMObjectPath)13 UnManagedProtectionSet (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet)12 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)11 Map (java.util.Map)11 StringMap (com.emc.storageos.db.client.model.StringMap)10