Search in sources :

Example 1 with BlockObject

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

the class RPDeviceController method getStorageToBlockObjects.

/**
 * Given a Map of snapshots (bookmarks) to HLUs, this method obtains all target copy volumes
 * corresponding to the snapshot and groups them by storage system.
 *
 * @param snapshots
 *            the base mapping of snapshots to HLU
 * @return a mapping of snapshot export BlockObjects by storage system
 */
private Map<URI, Map<URI, Integer>> getStorageToBlockObjects(Map<URI, Integer> snapshots) {
    Map<URI, Map<URI, Integer>> storageToBlockObjects = new HashMap<URI, Map<URI, Integer>>();
    for (Map.Entry<URI, Integer> entry : snapshots.entrySet()) {
        BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, entry.getKey());
        // Get the export objects corresponding to this snapshot
        List<BlockObject> blockObjects = getExportObjectsForBookmark(snapshot);
        for (BlockObject blockObject : blockObjects) {
            URI storage = blockObject.getStorageController();
            Map<URI, Integer> volumesForStorage = storageToBlockObjects.get(storage);
            if (volumesForStorage == null) {
                volumesForStorage = new HashMap<URI, Integer>();
                storageToBlockObjects.put(storage, volumesForStorage);
            }
            // Add the BlockObject entry and set the HLU to the HLU corresponding to the snapshot
            volumesForStorage.put(blockObject.getId(), entry.getValue());
        }
    }
    return storageToBlockObjects;
}
Also used : HashMap(java.util.HashMap) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) Map(java.util.Map) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) OpStatusMap(com.emc.storageos.db.client.model.OpStatusMap) HashMap(java.util.HashMap) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 2 with BlockObject

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

the class RPDeviceController method disableImageAccessStep.

/**
 * Workflow step method for disabling an image access of all snapshots in an export group
 *
 * @param rpSystem
 *            RP system
 * @param token
 *            the task
 * @return true if successful
 * @param exportGroupID
 *            export group ID
 * @throws ControllerException
 */
public boolean disableImageAccessStep(URI rpSystemId, URI exportGroupURI, String token) throws ControllerException {
    try {
        WorkflowStepCompleter.stepExecuting(token);
        List<URI> snapshots = new ArrayList<URI>();
        // In order to find all of the snapshots to deactivate, go through the devices, find the RP snapshots, and
        // deactivate any active
        // ones
        ExportGroup exportGroup = _dbClient.queryObject(ExportGroup.class, exportGroupURI);
        for (String exportVolumeIDStr : exportGroup.getVolumes().keySet()) {
            URI blockID;
            blockID = new URI(exportVolumeIDStr);
            BlockObject block = BlockObject.fetch(_dbClient, blockID);
            if (block.getProtectionController() != null) {
                if (block.getId().toString().contains("BlockSnapshot")) {
                    // Collect this snapshot; it needs to be disabled
                    snapshots.add(block.getId());
                }
            }
        }
        disableImageForSnapshots(rpSystemId, new ArrayList<URI>(snapshots), false, token);
        // Update the workflow state.
        WorkflowStepCompleter.stepSucceded(token);
    } catch (Exception e) {
        _log.error(String.format("disableImageAccessStep Failed - Protection System: %s, export group: %s", String.valueOf(rpSystemId), String.valueOf(exportGroupURI)));
        return stepFailed(token, e, "disableImageAccessStep");
    }
    return true;
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) BlockObject(com.emc.storageos.db.client.model.BlockObject) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) LockRetryException(com.emc.storageos.locking.LockRetryException) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) URISyntaxException(java.net.URISyntaxException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) RecoverPointException(com.emc.storageos.recoverpoint.exceptions.RecoverPointException)

Example 3 with BlockObject

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

the class RPDeviceController method addExportRemoveVolumeSteps.

/**
 * Add the export remove volume step to the workflow
 *
 * @param workflow
 *            workflow object
 * @param rpSystem
 *            protection system
 * @param exportGroupID
 *            export group
 * @param boIDs
 *            volume/snapshot IDs
 * @throws InternalException
 */
private void addExportRemoveVolumeSteps(Workflow workflow, ProtectionSystem rpSystem, URI exportGroupID, List<URI> boIDs) throws InternalException {
    ExportGroup exportGroup = _dbClient.queryObject(ExportGroup.class, exportGroupID);
    String exportStep = workflow.createStepId();
    initTaskStatus(exportGroup, exportStep, Operation.Status.pending, "export remove volumes (that contain RP snapshots)");
    Map<URI, List<URI>> deviceToBlockObjects = new HashMap<URI, List<URI>>();
    for (URI snapshotID : boIDs) {
        BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, snapshotID);
        // Get the export objects corresponding to this snapshot
        List<BlockObject> objectsToRemove = getExportObjectsForBookmark(snapshot);
        for (BlockObject blockObject : objectsToRemove) {
            List<URI> blockObjects = deviceToBlockObjects.get(blockObject.getStorageController());
            if (blockObjects == null) {
                blockObjects = new ArrayList<URI>();
                deviceToBlockObjects.put(blockObject.getStorageController(), blockObjects);
            }
            blockObjects.add(blockObject.getId());
        }
    }
    for (Map.Entry<URI, List<URI>> deviceEntry : deviceToBlockObjects.entrySet()) {
        _log.info(String.format("Adding workflow step to remove RP bookmarks and associated target volumes from export.  ExportGroup: %s, Storage System: %s, BlockObjects: %s", exportGroup.getId(), deviceEntry.getKey(), deviceEntry.getValue()));
        _exportWfUtils.generateExportGroupRemoveVolumes(workflow, STEP_EXPORT_REMOVE_SNAPSHOT, STEP_EXPORT_GROUP_DISABLE, deviceEntry.getKey(), exportGroupID, deviceEntry.getValue());
    }
    _log.info(String.format("Created export group remove snapshot steps in workflow: %s", exportGroup.getId()));
}
Also used : HashMap(java.util.HashMap) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) ExportGroup(com.emc.storageos.db.client.model.ExportGroup) ApplicationAddVolumeList(com.emc.storageos.volumecontroller.ApplicationAddVolumeList) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) List(java.util.List) Map(java.util.Map) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) OpStatusMap(com.emc.storageos.db.client.model.OpStatusMap) HashMap(java.util.HashMap) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 4 with BlockObject

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

the class ExportUtils method getVarraysForStorageSystemVolumes.

/**
 * Get the varrays used for the set of volumes for a storage system.
 * For the VPlex, it will include the HA virtual array if there are distributed volumes.
 *
 * @param exportGroup -- ExportGroup instance
 * @param storageURI -- the URI of the Storage System
 * @param dbClient
 */
public static List<URI> getVarraysForStorageSystemVolumes(ExportGroup exportGroup, URI storageURI, DbClient dbClient) {
    List<URI> varrayURIs = new ArrayList<URI>();
    varrayURIs.add(exportGroup.getVirtualArray());
    Map<URI, Map<URI, Integer>> systemToVolumeMap = getStorageToVolumeMap(exportGroup, false, dbClient);
    if (systemToVolumeMap.containsKey(storageURI)) {
        Set<URI> blockObjectURIs = systemToVolumeMap.get(storageURI).keySet();
        for (URI blockObjectURI : blockObjectURIs) {
            BlockObject blockObject = BlockObject.fetch(dbClient, blockObjectURI);
            Set<URI> blockObjectVarrays = getBlockObjectVarrays(blockObject, dbClient);
            varrayURIs.addAll(blockObjectVarrays);
        }
    }
    return varrayURIs;
}
Also used : ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) OpStatusMap(com.emc.storageos.db.client.model.OpStatusMap) HashMap(java.util.HashMap) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StringMap(com.emc.storageos.db.client.model.StringMap) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 5 with BlockObject

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

the class ExportUtils method getAllLUNsForHost.

/**
 * Get all LUNs on the array that mapped to a host identified by initiators in the mask
 *
 * @param dbClient
 * @param exportMask
 * @return LUNs mapped to the host
 */
public static Set<String> getAllLUNsForHost(DbClient dbClient, ExportMask exportMask) {
    Set<String> lunIds = new HashSet<>();
    URI storageUri = exportMask.getStorageDevice();
    if (NullColumnValueGetter.isNullURI(storageUri)) {
        return lunIds;
    }
    URI hostUri = null;
    for (String init : exportMask.getInitiators()) {
        Initiator initiator = dbClient.queryObject(Initiator.class, URI.create(init));
        if (initiator != null && !initiator.getInactive()) {
            hostUri = initiator.getHost();
            if (!NullColumnValueGetter.isNullURI(hostUri)) {
                break;
            }
        }
    }
    // get initiators from host
    Map<URI, ExportMask> exportMasks = new HashMap<>();
    if (!NullColumnValueGetter.isNullURI(hostUri)) {
        URIQueryResultList list = new URIQueryResultList();
        dbClient.queryByConstraint(ContainmentConstraint.Factory.getContainedObjectsConstraint(hostUri, Initiator.class, "host"), list);
        Iterator<URI> uriIter = list.iterator();
        while (uriIter.hasNext()) {
            URI initiatorId = uriIter.next();
            URIQueryResultList egUris = new URIQueryResultList();
            dbClient.queryByConstraint(AlternateIdConstraint.Factory.getExportGroupInitiatorConstraint(initiatorId.toString()), egUris);
            ExportGroup exportGroup = null;
            for (URI egUri : egUris) {
                exportGroup = dbClient.queryObject(ExportGroup.class, egUri);
                if (exportGroup == null || exportGroup.getInactive() || exportGroup.getExportMasks() == null) {
                    continue;
                }
                List<ExportMask> masks = ExportMaskUtils.getExportMasks(dbClient, exportGroup);
                for (ExportMask mask : masks) {
                    if (mask != null && !mask.getInactive() && mask.hasInitiator(initiatorId.toString()) && mask.getVolumes() != null && storageUri.equals(mask.getStorageDevice())) {
                        exportMasks.put(mask.getId(), mask);
                    }
                }
            }
        }
    }
    for (ExportMask mask : exportMasks.values()) {
        StringMap volumeMap = mask.getVolumes();
        if (volumeMap != null && !volumeMap.isEmpty()) {
            for (String strUri : mask.getVolumes().keySet()) {
                BlockObject bo = BlockObject.fetch(dbClient, URI.create(strUri));
                if (bo != null && !bo.getInactive()) {
                    lunIds.add(bo.getNativeId());
                }
            }
        }
    }
    return lunIds;
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ExportMask(com.emc.storageos.db.client.model.ExportMask) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) ExportGroup(com.emc.storageos.db.client.model.ExportGroup) Initiator(com.emc.storageos.db.client.model.Initiator) BlockObject(com.emc.storageos.db.client.model.BlockObject) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Aggregations

BlockObject (com.emc.storageos.db.client.model.BlockObject)341 URI (java.net.URI)222 ArrayList (java.util.ArrayList)152 Volume (com.emc.storageos.db.client.model.Volume)141 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)109 NamedURI (com.emc.storageos.db.client.model.NamedURI)82 HashMap (java.util.HashMap)82 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)69 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)65 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)60 ExportMask (com.emc.storageos.db.client.model.ExportMask)56 HashSet (java.util.HashSet)56 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)48 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)45 CIMObjectPath (javax.cim.CIMObjectPath)44 Initiator (com.emc.storageos.db.client.model.Initiator)43 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)43 List (java.util.List)40 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)38 StringSet (com.emc.storageos.db.client.model.StringSet)36