Search in sources :

Example 56 with BlockObject

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

the class ExportUtils method getItlsForMaskInitiator.

/**
 * For a volume/snapshot-initiator pair find the target ports for the initiator in the list of
 * ports and find the zone name if zoning was performed. Return a list of ITLs for
 * each volume-initiator-target found.
 *
 * @param dbClient db client
 * @param exportMask the export mask the initiator is in
 * @param initiator the initiator
 * @param hlu the lun Id used by the initiator for the volume
 * @param blockObject the volume or snapshot
 * @param initiatorPorts ports to which the initiator is zoned in the export mask
 * @param zoneRefs a map of port-to-zone-reference
 * @param exportGroup the export groups in this export mask
 * @return all ITLs for a volume/snapshot-initiator pair.
 */
private static List<ITLRestRep> getItlsForMaskInitiator(DbClient dbClient, List<ExportGroup> exportGroups, ExportMask exportMask, Initiator initiator, String hlu, BlockObject blockObject, List<StoragePort> initiatorPorts, Map<StoragePort, List<FCZoneReference>> zoneRefs) {
    List<ITLRestRep> list = new ArrayList<ITLRestRep>();
    Map<StoragePort, FCZoneReference> initiatorZoneRefs = null;
    // Find the block object that would appear in the Export Mask
    BlockObject bo = Volume.fetchExportMaskBlockObject(dbClient, blockObject.getId());
    if (bo != null) {
        _log.debug("Finding target ports for initiator {} and block object {}", initiator.getInitiatorPort(), bo.getNativeGuid());
        initiatorZoneRefs = getZoneReferences(bo.getId(), initiator, initiatorPorts, zoneRefs);
        _log.debug("{} target ports and {} SAN zones were found for initiator {} and block object {}", new Object[] { initiatorPorts.size(), initiatorZoneRefs.size(), initiator.getInitiatorPort(), bo.getNativeGuid() });
        // TODO - Should we add special handling of iscsi initiators?
        for (ExportGroup exportGroup : exportGroups) {
            if (exportGroup.getVolumes() != null && exportGroup.getVolumes().containsKey(blockObject.getId().toString()) && exportGroup.getInitiators() != null && exportGroup.getInitiators().contains(initiator.getId().toString())) {
                // We want to check if there are any ports in this export group for this initiator
                List<StoragePort> portsInExportGroupVarray = filterPortsInVarray(exportGroup, exportMask.getStorageDevice(), initiatorPorts);
                if (!portsInExportGroupVarray.isEmpty()) {
                    for (StoragePort port : portsInExportGroupVarray) {
                        list.add(createInitiatorTargetRefRep(exportGroup, blockObject, hlu, initiator, port, initiatorZoneRefs.get(port)));
                    }
                } else {
                    list.add(createInitiatorTargetRefRep(exportGroup, blockObject, hlu, initiator, null, null));
                }
            }
        }
    }
    return list;
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) ArrayList(java.util.ArrayList) StoragePort(com.emc.storageos.db.client.model.StoragePort) ITLRestRep(com.emc.storageos.model.block.export.ITLRestRep) BlockObject(com.emc.storageos.db.client.model.BlockObject) FCZoneReference(com.emc.storageos.db.client.model.FCZoneReference)

Example 57 with BlockObject

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

the class ExportUtils method getBlockObjectExportMasks.

/**
 * Fetches all the export masks in which a block object is member
 *
 * @param blockObject the block object
 * @param dbClient an instance of {@link DbClient}
 * @return a map of export masks in which a block object is member
 */
private static Map<ExportMask, List<ExportGroup>> getBlockObjectExportMasks(BlockObject blockObject, DbClient dbClient) {
    Map<ExportMask, List<ExportGroup>> exportMasks = new HashMap<ExportMask, List<ExportGroup>>();
    ContainmentConstraint constraint = ContainmentConstraint.Factory.getBlockObjectExportGroupConstraint(blockObject.getId());
    // permission are checked by the API service - no need to check again
    List<ExportGroup> exportGroups = getExportGroupsByConstraint(constraint, dbClient, null, null);
    List<ExportMask> masks = getMasksForExportGroups(exportGroups, dbClient);
    // Get the actual export block object associated with the snapshot (if applicable)
    BlockObject bo = Volume.fetchExportMaskBlockObject(dbClient, blockObject.getId());
    if (bo != null) {
        for (ExportMask exportMask : masks) {
            if (exportMask != null && !exportMask.getInactive() && exportMask.hasVolume(bo.getId()) && (exportMask.getInitiators() != null || exportMask.getExistingInitiators() != null)) {
                List<ExportGroup> maskGroups = new ArrayList<ExportGroup>();
                exportMasks.put(exportMask, maskGroups);
                for (ExportGroup group : exportGroups) {
                    if (group.getExportMasks() != null && group.getExportMasks().contains(exportMask.getId().toString())) {
                        maskGroups.add(group);
                    }
                }
            }
        }
        _log.debug("Found {} export masks for block object {}", exportMasks.size(), bo.getLabel());
    }
    return exportMasks;
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) HashMap(java.util.HashMap) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) ITLRestRepList(com.emc.storageos.model.block.export.ITLRestRepList) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 58 with BlockObject

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

the class BlockFullCopyManager method activateFullCopy.

/**
 * Manages the activation of the full copy with the passed URI for the
 * source with the passed URI. For supported platforms, if the source is a
 * volume and the volume is part of a consistency group, this method will
 * also activate the corresponding full copies for all other volumes in the
 * consistency group.
 *
 * @param sourceURI The URI of the source.
 * @param fullCopyURI The URI of the full copy volume.
 *
 * @return TaskList
 *
 * @throws InternalException
 */
public TaskList activateFullCopy(URI sourceURI, URI fullCopyURI) throws InternalException {
    s_logger.info("START activate full copy {}", fullCopyURI);
    // Verify passed URIs for the full copy request.
    Map<URI, BlockObject> resourceMap = BlockFullCopyUtils.verifySourceAndFullCopy(sourceURI, fullCopyURI, _uriInfo, _dbClient);
    // Get the source and full copy volume.
    BlockObject fcSourceObj = resourceMap.get(sourceURI);
    Volume fullCopyVolume = (Volume) resourceMap.get(fullCopyURI);
    // If the full copy is detached, it cannot be activated.
    if (BlockFullCopyUtils.isFullCopyDetached(fullCopyVolume, _dbClient)) {
        throw APIException.badRequests.detachedFullCopyCannotBeActivated(fullCopyURI.toString());
    }
    // Otherwise, check if the full copy is in the inactive state.
    // If it is in any other state, it was already activated.
    // In this case, the code simply returns a successful task.
    boolean alreadyActive = !BlockFullCopyUtils.isFullCopyInactive(fullCopyVolume, _dbClient);
    // Now activate.
    BlockFullCopyApi fullCopyApiImpl = getPlatformSpecificFullCopyImpl(fullCopyVolume);
    TaskList taskList = fullCopyApiImpl.activate(fcSourceObj, fullCopyVolume);
    // Log an audit message if we actually need to active the full copy.
    if (!alreadyActive) {
        auditOp(OperationTypeEnum.ACTIVATE_VOLUME_FULL_COPY, true, AuditLogManager.AUDITOP_BEGIN, fullCopyURI);
    }
    s_logger.info("FINISH activate full copy {}", fullCopyURI);
    return taskList;
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) TaskList(com.emc.storageos.model.TaskList) URI(java.net.URI) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 59 with BlockObject

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

the class BlockFullCopyManager method checkFullCopyProgress.

/**
 * Checks the progress of the data copy from the source with the
 * passed URI to the full copy with the passed URI.
 *
 * TBD Maybe vice versa for restore?
 *
 * @param sourceURI The URI of the source.
 * @param fullCopyURI The URI of the full copy volume.
 *
 * @return VolumeRestRep
 *
 * @throws InternalException
 */
public VolumeRestRep checkFullCopyProgress(URI sourceURI, URI fullCopyURI) throws InternalException {
    s_logger.info("START full copy progress check for {}", fullCopyURI);
    // Verify passed URIs for the full copy request.
    Map<URI, BlockObject> resourceMap = BlockFullCopyUtils.verifySourceAndFullCopy(sourceURI, fullCopyURI, _uriInfo, _dbClient);
    // Get the full copy volume.
    Volume fullCopyVolume = (Volume) resourceMap.get(fullCopyURI);
    // Check if the full copy is detached.
    if (BlockFullCopyUtils.isFullCopyDetached(fullCopyVolume, _dbClient)) {
        throw APIException.badRequests.cannotCheckProgressFullCopyDetached(fullCopyURI.toString());
    }
    // Get the platform specific full copy implementation.
    BlockFullCopyApi fullCopyApiImpl = getPlatformSpecificFullCopyImpl(fullCopyVolume);
    // Now check the progress.
    s_logger.info("FINISH full copy progress check for {}", fullCopyURI);
    VolumeRestRep volumeRestRep = fullCopyApiImpl.checkProgress(sourceURI, fullCopyVolume);
    return volumeRestRep;
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) URI(java.net.URI) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 60 with BlockObject

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

the class BlockFullCopyManager method restoreFullCopy.

/**
 * Restores the source with the passed URI from the full copy with the
 * passed URI. For supported platforms, if the source is a volume and the
 * volume is part of a consistency group, this method will also restore all
 * other volumes in the consistency group with their corresponding full
 * copies.
 *
 * @param sourceURI The URI of the source.
 * @param fullCopyURI The URI of the full copy volume.
 *
 * @return TaskList
 *
 * @throws InternalException
 */
public TaskList restoreFullCopy(URI sourceURI, URI fullCopyURI) throws InternalException {
    s_logger.info("START restore source {} from full copy {}", sourceURI, fullCopyURI);
    // Verify passed URIs for the full copy request.
    Map<URI, BlockObject> resourceMap = BlockFullCopyUtils.verifySourceAndFullCopy(sourceURI, fullCopyURI, _uriInfo, _dbClient);
    // is a snapshot.
    if (URIUtil.isType(sourceURI, BlockSnapshot.class)) {
        throw APIException.badRequests.fullCopyRestoreNotSupportedForSnapshot();
    }
    // Get the source object and full copy volume
    Volume sourceVolume = (Volume) resourceMap.get(sourceURI);
    Volume fullCopyVolume = (Volume) resourceMap.get(fullCopyURI);
    // Check if the full copy is detached.
    if (BlockFullCopyUtils.isFullCopyDetached(fullCopyVolume, _dbClient)) {
        throw APIException.badRequests.detachedFullCopyCannotBeRestored(fullCopyURI.toString());
    }
    // Check if the full copy was not activated.
    if (BlockFullCopyUtils.isFullCopyInactive(fullCopyVolume, _dbClient)) {
        throw APIException.badRequests.inactiveFullCopyCannotBeRestored(fullCopyURI.toString());
    }
    // Verify that the full copy is restorable otherwise.
    if (!BlockFullCopyUtils.isFullCopyRestorable(fullCopyVolume, _dbClient)) {
        throw APIException.badRequests.fullCopyCannotBeRestored(fullCopyURI.toString(), fullCopyVolume.getReplicaState());
    }
    // Get the platform specific full copy implementation.
    BlockFullCopyApi fullCopyApiImpl = getPlatformSpecificFullCopyImpl(fullCopyVolume);
    // Now restore the source.
    TaskList taskList = fullCopyApiImpl.restoreSource(sourceVolume, fullCopyVolume);
    // Log an audit message
    auditOp(OperationTypeEnum.RESTORE_VOLUME_FULL_COPY, true, AuditLogManager.AUDITOP_BEGIN, fullCopyURI);
    s_logger.info("FINISH restore source {} from full copy {}", sourceURI, fullCopyURI);
    return taskList;
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) TaskList(com.emc.storageos.model.TaskList) URI(java.net.URI) BlockObject(com.emc.storageos.db.client.model.BlockObject)

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