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;
}
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;
}
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()));
}
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;
}
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;
}
Aggregations