Search in sources :

Example 1 with UnManagedVolume

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

the class HostService method getUnmanagedVolumes.

/**
 * Gets the UnManagedVolumes exposed to a Host.
 *
 * @param id
 *            the URI of a ViPR Host
 * @brief List unmanaged volumes exposed to a host
 * @return a list of UnManagedVolumes exposed to this host
 * @throws DatabaseException
 *             when a database error occurs
 */
@GET
@Path("/{id}/unmanaged-volumes")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public UnManagedVolumeList getUnmanagedVolumes(@PathParam("id") URI id) throws DatabaseException {
    Host host = queryObject(Host.class, id, false);
    // check the user permissions
    verifyAuthorizedInTenantOrg(host.getTenant(), getUserFromContext());
    // get the unmanaged volumes
    List<UnManagedVolume> unmanagedVolumes = VolumeIngestionUtil.findUnManagedVolumesForHost(id, _dbClient, _coordinator);
    UnManagedVolumeList list = new UnManagedVolumeList();
    for (UnManagedVolume volume : unmanagedVolumes) {
        list.getUnManagedVolumes().add(toRelatedResource(ResourceTypeEnum.UNMANAGED_VOLUMES, volume.getId()));
    }
    return list;
}
Also used : UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) UnManagedVolumeList(com.emc.storageos.model.block.UnManagedVolumeList) Host(com.emc.storageos.db.client.model.Host) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with UnManagedVolume

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

the class ClusterService method getUnmanagedVolumes.

/**
 * Gets the UnManagedVolumes exposed to a Cluster.
 *
 * @param id the URI of a ViPR Cluster
 * @brief List unmanaged volumes exposed to a cluster
 * @return a list of UnManagedVolumes exposed to this host
 * @throws DatabaseException when a database error occurs
 */
@GET
@Path("/{id}/unmanaged-volumes")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public UnManagedVolumeList getUnmanagedVolumes(@PathParam("id") URI id) throws DatabaseException {
    Cluster cluster = queryObject(Cluster.class, id, false);
    // check the user permissions
    verifyAuthorizedInTenantOrg(cluster.getTenant(), getUserFromContext());
    // get the unmanaged volumes
    List<UnManagedVolume> unmanagedVolumes = VolumeIngestionUtil.findUnManagedVolumesForCluster(id, _dbClient);
    UnManagedVolumeList list = new UnManagedVolumeList();
    for (UnManagedVolume volume : unmanagedVolumes) {
        list.getUnManagedVolumes().add(toRelatedResource(ResourceTypeEnum.UNMANAGED_VOLUMES, volume.getId()));
    }
    return list;
}
Also used : UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) UnManagedVolumeList(com.emc.storageos.model.block.UnManagedVolumeList) MapCluster(com.emc.storageos.api.mapper.functions.MapCluster) Cluster(com.emc.storageos.db.client.model.Cluster) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 3 with UnManagedVolume

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

the class BlockIngestOrchestrator method markUnManagedVolumeInactive.

/**
 * Algorithm:
 *
 * 1. Get the parent of the Current UMV
 * 2. If parent is null AND current UMV doesn't have any replicas, its actually a UMV with no replicas.
 * 3. Else run while loop to find out the ROOT of the current's Parent.
 * 4. At the end of this while loop, we get the ROOT UMV, ROOT Block Object.
 * 5. Invoke RunReplicasIngestedCheck
 * a. Get the replicas of the ROOT UMV
 * b. Find if all replicas Ingested
 * c. If Yes, then update parent Replica Map [Parent --> Child]
 * 1. For each Replica unmanaged volume, RUN STEP 5.
 * d. Else Clear Parent Replica and come out.
 * 6. If parent Replica map is not empty (parent-child ingested successfully)
 * a. Set Parent Child relations
 * b. Hold the data in Memory and don't persist to DB.
 *
 * @param unmanagedVolume current Processed UnManaged Volume
 * @param blockObject current Processed Block Object
 * @param unManagedVolumes
 * @param createdObjects Already processed Block Objects in Memory
 * @param taskStatusMap
 * @param vplexIngestionMethod the VPLEX backend ingestion method
 * @return
 */
@SuppressWarnings("deprecation")
protected boolean markUnManagedVolumeInactive(IngestionRequestContext requestContext, BlockObject currentBlockObject) {
    UnManagedVolume currentUnmanagedVolume = requestContext.getCurrentUnmanagedVolume();
    _logger.info("Running unmanagedvolume {} replica ingestion status", currentUnmanagedVolume.getNativeGuid());
    boolean markUnManagedVolumeInactive = false;
    // if the vplex ingestion method is vvol-only, we don't need to check replicas
    if (VolumeIngestionUtil.isVplexVolume(currentUnmanagedVolume) && VplexBackendIngestionContext.INGESTION_METHOD_VVOL_ONLY.equals(requestContext.getVplexIngestionMethod())) {
        _logger.info("This is a VPLEX virtual volume and the ingestion method is " + "virtual volume only. Skipping replica ingestion algorithm.");
        return true;
    }
    StringSetMap unManagedVolumeInformation = currentUnmanagedVolume.getVolumeInformation();
    List<String> parentVolumeNativeGUIDs = getParentVolumeNativeGUIDByRepType(unManagedVolumeInformation);
    // TODO - may be move this to a single utility method
    if (parentVolumeNativeGUIDs.isEmpty() && !VolumeIngestionUtil.checkUnManagedVolumeHasReplicas(currentUnmanagedVolume)) {
        _logger.info("Simple unmanagedvolume without any replicas. Skipping replica ingestion algorithm.");
        return true;
    }
    _logger.info("Running algorithm to find the root source volume for {}", currentUnmanagedVolume.getNativeGuid());
    // Get the topmost parent object
    if (!parentVolumeNativeGUIDs.isEmpty()) {
        markUnManagedVolumeInactive = true;
        for (String parentVolumeNativeGUID : parentVolumeNativeGUIDs) {
            boolean allGood = false;
            Map<BlockObject, List<BlockObject>> parentReplicaMap = new HashMap<BlockObject, List<BlockObject>>();
            StringSet processedUnManagedGUIDS = new StringSet();
            UnManagedVolume rootUnManagedVolume = currentUnmanagedVolume;
            BlockObject rootBlockObject = currentBlockObject;
            while (parentVolumeNativeGUID != null) {
                _logger.info("Finding unmanagedvolume {} in vipr db", parentVolumeNativeGUID);
                List<URI> parentUnmanagedUris = _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVolumeInfoNativeIdConstraint(parentVolumeNativeGUID));
                if (!parentUnmanagedUris.isEmpty()) {
                    _logger.info("Found unmanagedvolume {} in vipr db", parentVolumeNativeGUID);
                    rootUnManagedVolume = _dbClient.queryObject(UnManagedVolume.class, parentUnmanagedUris.get(0));
                    unManagedVolumeInformation = rootUnManagedVolume.getVolumeInformation();
                    String blockObjectNativeGUID = rootUnManagedVolume.getNativeGuid().replace(VolumeIngestionUtil.UNMANAGEDVOLUME, VolumeIngestionUtil.VOLUME);
                    rootBlockObject = requestContext.getRootIngestionRequestContext().findCreatedBlockObject(blockObjectNativeGUID);
                    // If the root object is not found in locally createdObjects, check in DB.
                    if (rootBlockObject == null) {
                        rootBlockObject = VolumeIngestionUtil.getBlockObject(blockObjectNativeGUID, _dbClient);
                    }
                    // Get the parent unmanagedvolume for the current unmanagedvolume.
                    List<String> parents = getParentVolumeNativeGUIDByRepType(unManagedVolumeInformation);
                    if (parents.isEmpty()) {
                        parentVolumeNativeGUID = null;
                        _logger.info("No parent for current unmanagedvolume {}", rootUnManagedVolume.getNativeGuid());
                    } else {
                        parentVolumeNativeGUID = parents.get(0);
                        _logger.info("Found the parent {} for current unmanagedvolume {}", parentVolumeNativeGUID, rootUnManagedVolume.getNativeGuid());
                    }
                    // UnManaged Volumes, but the VPLEX device has not.
                    if ((null == parentVolumeNativeGUID) && VolumeIngestionUtil.isVplexBackendVolume(rootUnManagedVolume)) {
                        throw IngestionException.exceptions.vplexBackendVolumeHasNoParent(rootUnManagedVolume.getLabel());
                    }
                } else {
                    _logger.info("unmanagedvolume not found looking for ingested volume {} in vipr db", parentVolumeNativeGUID);
                    // parent might be already ingested
                    // Native guid might correspond to ViPR object, find if there is still a unmanaged volume corresponding to the
                    // parent
                    parentUnmanagedUris = _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVolumeInfoNativeIdConstraint(parentVolumeNativeGUID.replace(VolumeIngestionUtil.VOLUME, VolumeIngestionUtil.UNMANAGEDVOLUME)));
                    if (!parentUnmanagedUris.isEmpty()) {
                        _logger.info("Found ingested volume {} in vipr db", parentVolumeNativeGUID);
                        rootUnManagedVolume = _dbClient.queryObject(UnManagedVolume.class, parentUnmanagedUris.get(0));
                        unManagedVolumeInformation = rootUnManagedVolume.getVolumeInformation();
                        rootBlockObject = VolumeIngestionUtil.getBlockObject(parentVolumeNativeGUID, _dbClient);
                        List<String> parents = getParentVolumeNativeGUIDByRepType(unManagedVolumeInformation);
                        if (parents.isEmpty()) {
                            parentVolumeNativeGUID = null;
                        } else {
                            parentVolumeNativeGUID = parents.get(0);
                        }
                        _logger.info("Found the parent {} for current unmanagedvolume {}", parentVolumeNativeGUID, rootUnManagedVolume.getNativeGuid());
                        // UnManaged Volumes, but the VPLEX device has not.
                        if ((null == parentVolumeNativeGUID) && VolumeIngestionUtil.isVplexBackendVolume(rootUnManagedVolume)) {
                            throw IngestionException.exceptions.vplexBackendVolumeHasNoParent(rootUnManagedVolume.getLabel());
                        }
                    } else {
                        _logger.info("Found a replica {} whose parent is already ingested with PUBLIC_ACCESS=true", parentVolumeNativeGUID);
                        // Find the ViPR object and put the block object and the parent in the map and break
                        List<BlockObject> replicas = new ArrayList<BlockObject>();
                        replicas.add(rootBlockObject);
                        parentReplicaMap.put(VolumeIngestionUtil.getBlockObject(parentVolumeNativeGUID.replace(VolumeIngestionUtil.UNMANAGEDVOLUME, VolumeIngestionUtil.VOLUME), _dbClient), replicas);
                        break;
                    }
                }
            }
            if (null != rootBlockObject) {
                _logger.info("Found root source volume {}", rootBlockObject.getNativeGuid());
            }
            if (null != rootUnManagedVolume) {
                _logger.info("Found root unmanagedvolume {}", rootUnManagedVolume.getNativeGuid());
            }
            _logger.info("Running algorithm to check all replicas ingested for parent");
            runReplicasIngestedCheck(rootUnManagedVolume, rootBlockObject, currentUnmanagedVolume, currentBlockObject, processedUnManagedGUIDS, parentReplicaMap, requestContext);
            _logger.info("Ended algorithm to check all replicas ingested for parent");
            List<UnManagedVolume> processedUnManagedVolumes = _dbClient.queryObject(UnManagedVolume.class, VolumeIngestionUtil.getUnManagedVolumeUris(processedUnManagedGUIDS, _dbClient));
            if (!parentReplicaMap.isEmpty()) {
                setupParentReplicaRelationships(currentUnmanagedVolume, parentReplicaMap, requestContext, processedUnManagedVolumes);
                allGood = true;
            }
            if (!allGood) {
                markUnManagedVolumeInactive = false;
            }
        }
    } else {
        Map<BlockObject, List<BlockObject>> parentReplicaMap = new HashMap<BlockObject, List<BlockObject>>();
        StringSet processedUnManagedGUIDS = new StringSet();
        UnManagedVolume rootUnManagedVolume = currentUnmanagedVolume;
        BlockObject rootBlockObject = currentBlockObject;
        if (null != rootBlockObject) {
            _logger.info("Found root source volume {}", rootBlockObject.getNativeGuid());
        }
        if (null != rootUnManagedVolume) {
            _logger.info("Found root unmanagedvolume {}", rootUnManagedVolume.getNativeGuid());
        }
        _logger.info("Running algorithm to check all replicas ingested for parent");
        runReplicasIngestedCheck(rootUnManagedVolume, rootBlockObject, currentUnmanagedVolume, currentBlockObject, processedUnManagedGUIDS, parentReplicaMap, requestContext);
        _logger.info("Ended algorithm to check all replicas ingested for parent");
        List<UnManagedVolume> processedUnManagedVolumes = _dbClient.queryObject(UnManagedVolume.class, VolumeIngestionUtil.getUnManagedVolumeUris(processedUnManagedGUIDS, _dbClient));
        if (!parentReplicaMap.isEmpty()) {
            setupParentReplicaRelationships(currentUnmanagedVolume, parentReplicaMap, requestContext, processedUnManagedVolumes);
            return true;
        }
    }
    return markUnManagedVolumeInactive;
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) StringSet(com.emc.storageos.db.client.model.StringSet) ArrayList(java.util.ArrayList) List(java.util.List) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 4 with UnManagedVolume

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

the class BlockIngestOrchestrator method createVolume.

/**
 * Create ViPR managed volume in DB
 *
 * @param system
 * @param volumeNativeGuid
 * @param pool
 * @param virtualArray
 * @param vPool
 * @param unManagedVolume
 * @param project
 * @param tenant
 * @return
 * @throws Exception
 */
protected Volume createVolume(IngestionRequestContext requestContext, String volumeNativeGuid, StoragePool pool, UnManagedVolume unManagedVolume, String autoTierPolicyId) throws IngestionException {
    _logger.info("creating new Volume for native volume id " + volumeNativeGuid);
    Volume volume = new Volume();
    volume.setId(URIUtil.createId(Volume.class));
    updateVolume(volume, requestContext.getStorageSystem(), volumeNativeGuid, pool, requestContext.getVarray(unManagedVolume), requestContext.getVpool(unManagedVolume), unManagedVolume, requestContext.getProject());
    updateMetaVolumeProperties(volume, unManagedVolume);
    volume.setThinlyProvisioned(Boolean.parseBoolean(unManagedVolume.getVolumeCharacterstics().get(SupportedVolumeCharacterstics.IS_THINLY_PROVISIONED.toString())));
    String accessState = PropertySetterUtil.extractValueFromStringSet(SupportedVolumeInformation.ACCESS.toString(), unManagedVolume.getVolumeInformation());
    accessState = Volume.VolumeAccessState.getVolumeAccessStateDisplayName(accessState);
    volume.setAccessState(accessState);
    BlockConsistencyGroup cg = getConsistencyGroup(unManagedVolume, volume, requestContext, _dbClient);
    if (null != cg) {
        requestContext.getVolumeContext().getCGObjectsToCreateMap().put(cg.getLabel(), cg);
        decorateCGInfoInVolumes(cg, volume, requestContext, unManagedVolume);
    }
    if (null != autoTierPolicyId) {
        updateTierPolicyProperties(autoTierPolicyId, volume);
    }
    return volume;
}
Also used : UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 5 with UnManagedVolume

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

the class BlockIngestOrchestrator method isSRDFTargetVolume.

/**
 * Verifies whether volume is SRDF target volume or not.
 *
 * @param replica
 * @param processedUnManagedVolumes
 * @return
 */
private boolean isSRDFTargetVolume(BlockObject replica, List<UnManagedVolume> processedUnManagedVolumes) {
    boolean srdfTargetVolFound = false;
    String unmanagedVolumeNativeGuid = replica.getNativeGuid().replace(VolumeIngestionUtil.VOLUME, VolumeIngestionUtil.UNMANAGEDVOLUME);
    if (null != processedUnManagedVolumes && !processedUnManagedVolumes.isEmpty()) {
        for (UnManagedVolume umv : processedUnManagedVolumes) {
            String type = PropertySetterUtil.extractValueFromStringSet(SupportedVolumeInformation.REMOTE_VOLUME_TYPE.toString(), umv.getVolumeInformation());
            if (unmanagedVolumeNativeGuid.equalsIgnoreCase(umv.getNativeGuid()) && RemoteMirrorObject.Types.TARGET.toString().equalsIgnoreCase(type)) {
                srdfTargetVolFound = true;
                break;
            }
        }
    }
    return srdfTargetVolFound;
}
Also used : UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)

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