Search in sources :

Example 21 with StringSetMap

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

the class BlockSnapIngestOrchestrator method createSnapshot.

private BlockSnapshot createSnapshot(IngestionRequestContext requestContext, String nativeGuid) throws IngestionException {
    UnManagedVolume unManagedVolume = requestContext.getCurrentUnmanagedVolume();
    BlockSnapshot snapShot = new BlockSnapshot();
    snapShot.setId(URIUtil.createId(BlockSnapshot.class));
    snapShot.setNativeGuid(nativeGuid);
    updateBlockObjectNativeIds(snapShot, unManagedVolume);
    StringSetMap unManagedVolumeInformation = unManagedVolume.getVolumeInformation();
    String deviceLabel = PropertySetterUtil.extractValueFromStringSet(SupportedVolumeInformation.DEVICE_LABEL.toString(), unManagedVolumeInformation);
    if (null == deviceLabel || deviceLabel.trim().isEmpty()) {
        deviceLabel = nativeGuid;
    }
    // In case of XIO snaps, the snapshots belong to a snapset which represents the snapshot CG. This will be
    // populated in SNAPSHOT_CONSISTENCY_GROUP_NAME
    // The same is applicable to external device snapshots
    String snapsetName = PropertySetterUtil.extractValueFromStringSet(SupportedVolumeInformation.SNAPSHOT_CONSISTENCY_GROUP_NAME.toString(), unManagedVolumeInformation);
    if (null == snapsetName || snapsetName.trim().isEmpty()) {
        snapsetName = deviceLabel;
    }
    snapShot.setSnapsetLabel(snapsetName);
    snapShot.setStorageController(requestContext.getStorageSystem().getId());
    String systemType = requestContext.getStorageSystem().checkIfVmax3() ? DiscoveredDataObject.Type.vmax3.name() : requestContext.getStorageSystem().getSystemType();
    snapShot.setSystemType(systemType);
    snapShot.setVirtualArray(requestContext.getVarray(unManagedVolume).getId());
    snapShot.setProject(new NamedURI(requestContext.getProject().getId(), snapShot.getLabel()));
    snapShot.setWWN(unManagedVolume.getWwn());
    String allocatedCapacity = PropertySetterUtil.extractValueFromStringSet(SupportedVolumeInformation.ALLOCATED_CAPACITY.toString(), unManagedVolume.getVolumeInformation());
    String provisionedCapacity = PropertySetterUtil.extractValueFromStringSet(SupportedVolumeInformation.PROVISIONED_CAPACITY.toString(), unManagedVolume.getVolumeInformation());
    snapShot.setAllocatedCapacity(Long.parseLong(allocatedCapacity));
    snapShot.setProvisionedCapacity(Long.parseLong(provisionedCapacity));
    String syncActive = PropertySetterUtil.extractValueFromStringSet(SupportedVolumeInformation.IS_SYNC_ACTIVE.toString(), unManagedVolume.getVolumeInformation());
    Boolean isSyncActive = (null != syncActive) ? Boolean.parseBoolean(syncActive) : false;
    snapShot.setIsSyncActive(isSyncActive);
    String readOnly = PropertySetterUtil.extractValueFromStringSet(SupportedVolumeInformation.IS_READ_ONLY.toString(), unManagedVolume.getVolumeInformation());
    Boolean isReadOnly = (null != readOnly) ? Boolean.parseBoolean(readOnly) : false;
    snapShot.setIsReadOnly(isReadOnly);
    String settingsInstance = PropertySetterUtil.extractValueFromStringSet(SupportedVolumeInformation.SETTINGS_INSTANCE.toString(), unManagedVolume.getVolumeInformation());
    snapShot.setSettingsInstance(settingsInstance);
    String needsCopyToTarget = PropertySetterUtil.extractValueFromStringSet(SupportedVolumeInformation.NEEDS_COPY_TO_TARGET.toString(), unManagedVolumeInformation);
    Boolean isNeedsCopyToTarget = (null != needsCopyToTarget) ? Boolean.parseBoolean(needsCopyToTarget) : false;
    snapShot.setNeedsCopyToTarget(isNeedsCopyToTarget);
    String techType = PropertySetterUtil.extractValueFromStringSet(SupportedVolumeInformation.TECHNOLOGY_TYPE.toString(), unManagedVolumeInformation);
    snapShot.setTechnologyType(techType);
    BlockConsistencyGroup cg = getConsistencyGroup(unManagedVolume, snapShot, requestContext, _dbClient);
    if (null != cg) {
        requestContext.getVolumeContext().getCGObjectsToCreateMap().put(cg.getLabel(), cg);
        decorateCGInfoInVolumes(cg, snapShot, requestContext, unManagedVolume);
    }
    return snapShot;
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) NamedURI(com.emc.storageos.db.client.model.NamedURI) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 22 with StringSetMap

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

the class BlockVplexCGIngestDecorator method decorateCG.

@Override
public void decorateCG(BlockConsistencyGroup cg, Collection<BlockObject> associatedObjects, IngestionRequestContext requestContext, UnManagedVolume unManagedVolume) throws Exception {
    if (null == associatedObjects || associatedObjects.isEmpty()) {
        logger.info("No associated BlockObject's found for cg {}", cg.getLabel());
        return;
    }
    for (BlockObject blockObj : associatedObjects) {
        StringSetMap systemCGs = cg.getSystemConsistencyGroups();
        // No entries yet in the system consistency groups list. That's OK, we'll create it.
        if (null == systemCGs || systemCGs.isEmpty()) {
            cg.setSystemConsistencyGroups(new StringSetMap());
        }
        // This volume is not in a CG of this type
        if (NullColumnValueGetter.isNullValue(blockObj.getReplicationGroupInstance())) {
            logger.info("BlockObject {} doesn't have replicationGroup name {}. No need to set system cg information.", blockObj.getNativeGuid());
            continue;
        }
        boolean found = false;
        // Look through the existing entries in the CG and see if we find a match.
        for (Entry<String, AbstractChangeTrackingSet<String>> systemCGEntry : systemCGs.entrySet()) {
            if (systemCGEntry.getKey().equalsIgnoreCase(blockObj.getStorageController().toString())) {
                if (checkIfCGNameAlreadyExists(systemCGEntry.getValue(), blockObj.getReplicationGroupInstance())) {
                    logger.info(String.format("Found BlockObject %s,%s system details in cg %s", blockObj.getNativeGuid(), blockObj.getReplicationGroupInstance(), cg.getLabel()));
                    found = true;
                    break;
                }
            }
        }
        // If we didn't find this storage:cg combo, let's add it.
        if (!found) {
            logger.info(String.format("Adding BlockObject %s/%s in CG %s", blockObj.getNativeGuid(), blockObj.getReplicationGroupInstance(), cg.getLabel()));
            if (blockObj instanceof Volume) {
                Volume volume = (Volume) blockObj;
                if (volume.getAssociatedVolumes() != null && volume.getAssociatedVolumes().size() > 1) {
                    // Since this is a distributed volume, ensure there is a CG entry for each cluster
                    String cgName = BlockConsistencyGroupUtils.fetchCgName(volume.getReplicationGroupInstance());
                    cg.addSystemConsistencyGroup(volume.getStorageController().toString(), BlockConsistencyGroupUtils.buildClusterCgName(BlockConsistencyGroupUtils.CLUSTER_1, cgName));
                    cg.addSystemConsistencyGroup(volume.getStorageController().toString(), BlockConsistencyGroupUtils.buildClusterCgName(BlockConsistencyGroupUtils.CLUSTER_2, cgName));
                    logger.info(String.format("Found BlockObject [%s] is a Distributed VPLEX volume. " + "Adding cg entry [%s] for both cluster1 and cluster2.", blockObj.getNativeGuid(), cgName));
                } else {
                    cg.addSystemConsistencyGroup(volume.getStorageController().toString(), volume.getReplicationGroupInstance());
                }
            }
        }
        // the virtual volume's replicationGroupInstance reference.  This does not impact the backing volumes.
        if (blockObj instanceof Volume) {
            Volume volume = (Volume) blockObj;
            logger.info(String.format("Moving replication group instance name %s on virtual volume %s to backingReplicationGroupInstance", volume.getReplicationGroupInstance(), volume.getLabel()));
            volume.setBackingReplicationGroupInstance(volume.getReplicationGroupInstance());
            volume.setReplicationGroupInstance(NullColumnValueGetter.getNullStr());
            requestContext.addDataObjectToUpdate(volume, unManagedVolume);
            if (volume.getAssociatedVolumes() != null) {
                // setting BlockConsistencyGroup on the backend volumes
                for (String volumeUriStr : volume.getAssociatedVolumes()) {
                    BlockObject backendVolume = requestContext.findDataObjectByType(Volume.class, URI.create(volumeUriStr), true);
                    if (backendVolume != null) {
                        logger.info("Setting BlockConsistencyGroup {} on VPLEX backend Volume {}", cg.forDisplay(), backendVolume.forDisplay());
                        backendVolume.setConsistencyGroup(cg.getId());
                    // this volume is already set for creation by its parent volume context
                    // so there's no need to add it into an updated objects collection at this point
                    }
                }
            }
        }
        if (!cg.getTypes().contains(Types.VPLEX.toString())) {
            cg.getTypes().add(Types.VPLEX.toString());
        }
    }
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) BlockObject(com.emc.storageos.db.client.model.BlockObject) AbstractChangeTrackingSet(com.emc.storageos.db.client.model.AbstractChangeTrackingSet)

Example 23 with StringSetMap

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

the class FileSystemIngestionUtil method getTotalUnManagedFileSystemCapacity.

public static long getTotalUnManagedFileSystemCapacity(DbClient dbClient, List<URI> unManagedFileSystemUris) {
    BigInteger totalUnManagedFileSystemCapacity = new BigInteger("0");
    try {
        Iterator<UnManagedFileSystem> unManagedFileSystems = dbClient.queryIterativeObjects(UnManagedFileSystem.class, unManagedFileSystemUris);
        while (unManagedFileSystems.hasNext()) {
            UnManagedFileSystem unManagedFileSystem = unManagedFileSystems.next();
            StringSetMap unManagedFileSystemInfo = unManagedFileSystem.getFileSystemInformation();
            if (null == unManagedFileSystemInfo) {
                continue;
            }
            String unManagedFileSystemCapacity = PropertySetterUtil.extractValueFromStringSet(SupportedFileSystemInformation.ALLOCATED_CAPACITY.toString(), unManagedFileSystemInfo);
            if (null != unManagedFileSystemCapacity && !unManagedFileSystemCapacity.isEmpty()) {
                totalUnManagedFileSystemCapacity = totalUnManagedFileSystemCapacity.add(new BigInteger(unManagedFileSystemCapacity));
            }
        }
    } catch (Exception e) {
        throw APIException.internalServerErrors.capacityComputationFailed();
    }
    return totalUnManagedFileSystemCapacity.longValue();
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) BigInteger(java.math.BigInteger) UnManagedFileSystem(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Example 24 with StringSetMap

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

the class RemoteReplicationIngestor method runRemoteReplicationStepsOnTarget.

/**
 * If unmanaged volume is a Target Volume, then 1. Find if source is ingested 2. If yes, then
 * find whether expected targets of this source had been ingested already excluding the current
 * target. 3. If yes, establish links between source and targets. 4. If not,then make sure
 * unmanaged volume hasn't been deleted.
 *
 * @param unManagedVolume
 * @param volume
 * @param unManagedVolumes
 * @param type
 * @return
 */
@SuppressWarnings("deprecation")
private static boolean runRemoteReplicationStepsOnTarget(UnManagedVolume unManagedVolume, Volume volume, List<UnManagedVolume> unManagedVolumes, String type, DbClient dbClient) {
    boolean removeUnManagedVolume = false;
    StringSetMap unManagedVolumeInformation = unManagedVolume.getVolumeInformation();
    String sourceUnManagedVolumeId = PropertySetterUtil.extractValueFromStringSet(SupportedVolumeInformation.REMOTE_MIRROR_SOURCE_VOLUME.toString(), unManagedVolumeInformation);
    _logger.info("Type {} Source Native Guid {}", type, sourceUnManagedVolumeId);
    String sourceVolumeId = sourceUnManagedVolumeId.replace(VolumeIngestionUtil.UNMANAGEDVOLUME, VolumeIngestionUtil.VOLUME);
    List<URI> sourceUris = dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVolumeNativeGuidConstraint(sourceVolumeId));
    String copyMode = PropertySetterUtil.extractValueFromStringSet(SupportedVolumeInformation.REMOTE_COPY_MODE.toString(), unManagedVolumeInformation);
    String raGroup = PropertySetterUtil.extractValueFromStringSet(SupportedVolumeInformation.REMOTE_MIRROR_RDF_GROUP.toString(), unManagedVolumeInformation);
    volume.setSrdfCopyMode(copyMode);
    volume.setSrdfGroup(URI.create(raGroup));
    if (sourceUris.isEmpty()) {
        _logger.info("Source {} Not found for target {}", sourceVolumeId, volume.getId());
    } else {
        // check whether all targets of the source are ingested
        List<URI> sourceUnmanagedUris = dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVolumeInfoNativeIdConstraint(sourceUnManagedVolumeId));
        if (!sourceUnmanagedUris.isEmpty()) {
            UnManagedVolume sourceUnManagedVolume = dbClient.queryObject(UnManagedVolume.class, sourceUnmanagedUris.get(0));
            if (null != sourceUnManagedVolume) {
                StringSet targetUnManagedVolumeGuids = sourceUnManagedVolume.getVolumeInformation().get(SupportedVolumeInformation.REMOTE_MIRRORS.toString());
                if (null != targetUnManagedVolumeGuids && !targetUnManagedVolumeGuids.isEmpty()) {
                    StringSet targetVolumeNativeGuids = VolumeIngestionUtil.getListofVolumeIds(targetUnManagedVolumeGuids);
                    List<URI> targetUris = VolumeIngestionUtil.getVolumeUris(targetVolumeNativeGuids, dbClient);
                    targetUris.add(volume.getId());
                    _logger.info("Expected targets Size {} , found {} ", targetUnManagedVolumeGuids.size(), targetUris.size());
                    _logger.debug("Expected Targets {} : Found {}", Joiner.on("\t").join(targetVolumeNativeGuids), Joiner.on("\t").join(targetUris));
                    List<Volume> modifiedVolumes = new ArrayList<Volume>();
                    if (targetUris.size() == targetUnManagedVolumeGuids.size()) {
                        // if all other targets are ingested, then
                        Volume sourceVolume = dbClient.queryObject(Volume.class, sourceUris.get(0));
                        // check whether the source Volume's VPool is actually having this target Volume's varray
                        // specified as remote
                        VirtualPool sourceVPool = dbClient.queryObject(VirtualPool.class, sourceVolume.getVirtualPool());
                        Map<URI, VpoolRemoteCopyProtectionSettings> settings = sourceVPool.getRemoteProtectionSettings(sourceVPool, dbClient);
                        if (null == settings || settings.size() == 0 || !settings.containsKey(volume.getVirtualArray())) {
                            _logger.info("Target Volume's VArray {} is not matching already ingested source volume virtual pool's remote VArray ", volume.getVirtualArray());
                            return false;
                        }
                        sourceVolume.setSrdfTargets(VolumeIngestionUtil.convertUrisToStrings(targetUris));
                        _logger.info("Clearing internal flag for source volume {} found", sourceVolume.getNativeGuid());
                        sourceVolume.clearInternalFlags(INTERNAL_VOLUME_FLAGS);
                        _logger.debug("Set srdf target for source volume {} found", sourceVolume.getId());
                        modifiedVolumes.add(sourceVolume);
                        // source unmanagedVolume
                        sourceUnManagedVolume.setInactive(true);
                        unManagedVolumes.add(sourceUnManagedVolume);
                        // this target unmanaged volume
                        volume.setSrdfParent(new NamedURI(sourceVolume.getId(), sourceVolume.getLabel()));
                        _logger.debug("target volume  set parent", volume.getId());
                        removeUnManagedVolume = true;
                        // handle other target volumes
                        List<Volume> targetVolumes = dbClient.queryObject(Volume.class, targetUris);
                        for (Volume targetVolume : targetVolumes) {
                            _logger.debug("Set parent for remaining target volume {}", targetVolume.getId());
                            targetVolume.setSrdfParent(new NamedURI(sourceVolume.getId(), sourceVolume.getLabel()));
                            targetVolume.clearInternalFlags(INTERNAL_VOLUME_FLAGS);
                        }
                        modifiedVolumes.addAll(targetVolumes);
                        // target unmanaged volumes
                        List<UnManagedVolume> targetUnManagedVolumes = dbClient.queryObject(UnManagedVolume.class, VolumeIngestionUtil.getUnManagedVolumeUris(targetUnManagedVolumeGuids, dbClient));
                        for (UnManagedVolume targetUnManagedVol : targetUnManagedVolumes) {
                            _logger.debug("Set Target unmanaged volume inactive {}", targetUnManagedVol.getId());
                            targetUnManagedVol.setInactive(true);
                            unManagedVolumes.add(targetUnManagedVol);
                        }
                        dbClient.persistObject(modifiedVolumes);
                        _logger.info("Target Volume successfully ingested with remote replication links", volume.getNativeGuid());
                    } else {
                        // set volume flag to false
                        _logger.info("Expected Targets not found for source Volume {}", sourceUnManagedVolumeId);
                    }
                } else {
                    _logger.info("Targets information not found on source volume {}." + "This could happen when parallel ingests are tried or the actual volume got deleted on array.", sourceUnManagedVolumeId);
                }
            }
        }
    }
    return removeUnManagedVolume;
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) VpoolRemoteCopyProtectionSettings(com.emc.storageos.db.client.model.VpoolRemoteCopyProtectionSettings) NamedURI(com.emc.storageos.db.client.model.NamedURI) ArrayList(java.util.ArrayList) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) StringSet(com.emc.storageos.db.client.model.StringSet)

Example 25 with StringSetMap

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

the class RemoteReplicationIngestor method runRemoteReplicationStepsOnPartiallyIngestedVolume.

public static boolean runRemoteReplicationStepsOnPartiallyIngestedVolume(UnManagedVolume unManagedVolume, BlockObject bo, List<UnManagedVolume> unManagedVolumes, DbClient dbClient) {
    Volume volume = (Volume) bo;
    StringSetMap unManagedVolumeInformation = unManagedVolume.getVolumeInformation();
    boolean remoteLinksEstablished = false;
    String type = PropertySetterUtil.extractValueFromStringSet(SupportedVolumeInformation.REMOTE_VOLUME_TYPE.toString(), unManagedVolumeInformation);
    if (null == type) {
        return true;
    }
    if (RemoteMirrorObject.Types.SOURCE.toString().equalsIgnoreCase(type)) {
        volume.setPersonality(PersonalityTypes.SOURCE.toString());
        remoteLinksEstablished = runRemoteReplicationStepsOnSource(unManagedVolume, volume, unManagedVolumes, type, dbClient);
    } else if (RemoteMirrorObject.Types.TARGET.toString().equalsIgnoreCase(type)) {
        volume.setPersonality(PersonalityTypes.TARGET.toString());
        remoteLinksEstablished = runRemoteReplicationStepsOnTarget(unManagedVolume, volume, unManagedVolumes, type, dbClient);
    }
    return remoteLinksEstablished;
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume)

Aggregations

StringSetMap (com.emc.storageos.db.client.model.StringSetMap)158 StringSet (com.emc.storageos.db.client.model.StringSet)95 URI (java.net.URI)72 ArrayList (java.util.ArrayList)68 List (java.util.List)49 HashMap (java.util.HashMap)43 StoragePort (com.emc.storageos.db.client.model.StoragePort)37 Map (java.util.Map)32 Initiator (com.emc.storageos.db.client.model.Initiator)31 NamedURI (com.emc.storageos.db.client.model.NamedURI)31 StringMap (com.emc.storageos.db.client.model.StringMap)31 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)26 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)26 ExportMask (com.emc.storageos.db.client.model.ExportMask)25 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)25 HashSet (java.util.HashSet)22 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)21 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)18 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)17 Test (org.junit.Test)16