Search in sources :

Example 6 with BlockObject

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

the class ExportUtils method useEMCForceFlag.

/**
 * Figure out whether or not we need to use the EMC Force flag for the SMIS
 * operation being performed on this volume.
 *
 * @param _dbClient
 *            DB Client
 * @param blockObjectURI
 *            BlockObject to check
 * @return Whether or not to use the EMC force flag
 */
public static boolean useEMCForceFlag(DbClient _dbClient, URI blockObjectURI) {
    boolean forceFlag = false;
    // If there are any volumes that are RP, then we need to use the force flag on this operation
    BlockObject bo = Volume.fetchExportMaskBlockObject(_dbClient, blockObjectURI);
    if (bo != null && BlockObject.checkForRP(_dbClient, bo.getId())) {
        // Set the force flag if the Block object is an RP Volume or BlockSnapshot.
        forceFlag = true;
    }
    return forceFlag;
}
Also used : BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 7 with BlockObject

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

the class ExportUtils method getExportGroupVolumeMap.

/**
 * Using the ExportGroup object, produces a mapping of the BlockObject URI to LUN value
 *
 * @param dbClient
 * @param storage
 * @param exportGroup
 * @return
 */
public static Map<URI, Integer> getExportGroupVolumeMap(DbClient dbClient, StorageSystem storage, ExportGroup exportGroup) {
    Map<URI, Integer> map = new HashMap<>();
    if (exportGroup != null && exportGroup.getVolumes() != null) {
        for (Map.Entry<String, String> entry : exportGroup.getVolumes().entrySet()) {
            URI uri = URI.create(entry.getKey());
            Integer lun = Integer.valueOf(entry.getValue());
            BlockObject blockObject = BlockObject.fetch(dbClient, uri);
            if (blockObject != null && blockObject.getStorageController().equals(storage.getId())) {
                map.put(uri, lun);
            }
        }
    }
    return map;
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) 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 8 with BlockObject

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

the class VPlexUtil method isBackendVolumesNotHavingBackendCG.

/**
 * Checks vplex back end volumes having backend cg
 *
 * @param blockObjectList
 * @param dbClient
 * @return
 */
public static boolean isBackendVolumesNotHavingBackendCG(List<? extends BlockObject> blockObjectList, DbClient dbClient) {
    boolean result = false;
    for (BlockObject blockObject : blockObjectList) {
        if (blockObject instanceof Volume) {
            Volume srcVolume = getVPLEXBackendVolume((Volume) blockObject, true, dbClient);
            if (srcVolume.isInCG() && !ControllerUtils.checkCGCreatedOnBackEndArray(srcVolume)) {
                _log.error("Vplex backend volume {} is not associated with backend cg", srcVolume.getId());
                result = true;
                break;
            }
        } else {
            // TODO what action we should here?
            _log.info("Block object {} is not a Volume", blockObject.getId());
        }
    }
    return result;
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 9 with BlockObject

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

the class ControllerUtils method getVolumeURIHLUArray.

public static VolumeURIHLU[] getVolumeURIHLUArray(String storageType, Map<URI, Integer> volumeMap, DbClient dbClient) {
    // Have a non-null default value
    VolumeURIHLU[] volURIsHlus = EMPTY_VOLUME_URI_HLU_ARRAY;
    if (volumeMap != null && !volumeMap.keySet().isEmpty()) {
        boolean convertFromHex = storageType.equals(DiscoveredDataObject.Type.vmax.name());
        int entryCount = volumeMap.keySet().size();
        volURIsHlus = new VolumeURIHLU[entryCount];
        int index = 0;
        Map<URI, String> blockURIToLabelMap = new HashMap<URI, String>();
        Map<String, URI> nativeIdToURIMap = new HashMap<String, URI>();
        for (URI uri : volumeMap.keySet()) {
            BlockObject blockObject = BlockObject.fetch(dbClient, uri);
            Integer nativeId;
            String nativeIdString = blockObject.getNativeId();
            if (convertFromHex) {
                nativeId = Integer.parseInt(blockObject.getNativeId(), 16);
                nativeIdString = String.format("%04d", nativeId);
            } else if (!storageType.equals(DiscoveredDataObject.Type.vnxe.name()) && !storageType.equals(DiscoveredDataObject.Type.unity.name()) && blockObject.getNativeId().matches("\\d+")) {
                nativeId = Integer.parseInt(blockObject.getNativeId());
                nativeIdString = String.format("%04d", nativeId);
            }
            nativeIdToURIMap.put(nativeIdString, blockObject.getId());
            blockURIToLabelMap.put(blockObject.getId(), blockObject.getLabel());
        }
        Set<String> orderedByNativeId = new TreeSet<String>(nativeIdToURIMap.keySet());
        for (String nativeId : orderedByNativeId) {
            URI uri = nativeIdToURIMap.get(nativeId);
            Integer entryHLU = volumeMap.get(uri);
            String hluString = null;
            if (storageType.equals(DiscoveredDataObject.Type.unity.name())) {
                // Don't change to hex string for Unity
                hluString = (entryHLU != null) ? Integer.toString(entryHLU) : ExportGroup.LUN_UNASSIGNED_STR;
            } else {
                hluString = (entryHLU != null) ? Integer.toHexString(entryHLU) : ExportGroup.LUN_UNASSIGNED_STR;
            }
            String volLabel = blockURIToLabelMap.get(uri);
            if (storageType.equals(DiscoveredDataObject.Type.hds.name()) || storageType.equals(DiscoveredDataObject.Type.xtremio.name())) {
                // @TODO setting the policy name as null for now. We should handle when we support tiering.
                volURIsHlus[index++] = new VolumeURIHLU(uri, String.valueOf(entryHLU), null, volLabel);
            } else {
                String policyName = getAutoTieringPolicyName(uri, dbClient);
                VolumeURIHLU volumeURLHLU = new VolumeURIHLU(uri, hluString, policyName, volLabel);
                if (storageType.equals(DiscoveredDataObject.Type.vmax.name())) {
                    BlockObject blockObject = BlockObject.fetch(dbClient, uri);
                    if (blockObject instanceof Volume) {
                        Volume volume = (Volume) blockObject;
                        VirtualPool virtualPool = dbClient.queryObject(VirtualPool.class, volume.getVirtualPool());
                        volumeURLHLU = new VolumeURIHLU(uri, hluString, policyName, volLabel, virtualPool.getHostIOLimitBandwidth(), virtualPool.getHostIOLimitIOPs());
                        // Set the compression attribute as well
                        volumeURLHLU.setCompression(virtualPool.getCompressionEnabled());
                    }
                }
                volURIsHlus[index++] = volumeURLHLU;
            }
        }
        s_logger.info(String.format("getVolumeURIHLUArray = %s", Joiner.on(',').join(volURIsHlus)));
    }
    return volURIsHlus;
}
Also used : HashMap(java.util.HashMap) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) BigInteger(java.math.BigInteger) Volume(com.emc.storageos.db.client.model.Volume) TreeSet(java.util.TreeSet) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 10 with BlockObject

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

the class ControllerUtils method getApplicationsForFullCopies.

/**
 * get the list of applications for a list of full copy volumes
 *
 * @param fcVolumeIds full copy volume ids
 * @param dbClient
 * @return
 */
public static List<URI> getApplicationsForFullCopies(List<URI> fcVolumeIds, DbClient dbClient) {
    Set<URI> volumeGroupIds = new HashSet<URI>();
    Iterator<Volume> fcVolumes = dbClient.queryIterativeObjects(Volume.class, fcVolumeIds);
    while (fcVolumes.hasNext()) {
        Volume fcVolume = fcVolumes.next();
        if (!NullColumnValueGetter.isNullURI(fcVolume.getAssociatedSourceVolume())) {
            BlockObject sourceObj = BlockObject.fetch(dbClient, fcVolume.getAssociatedSourceVolume());
            if (sourceObj instanceof Volume) {
                for (String appId : ((Volume) sourceObj).getVolumeGroupIds()) {
                    volumeGroupIds.add(URI.create(appId));
                }
            }
        }
    }
    Iterator<VolumeGroup> volumeGroups = dbClient.queryIterativeObjects(VolumeGroup.class, volumeGroupIds);
    List<URI> applicationIds = new ArrayList<URI>();
    while (volumeGroups.hasNext()) {
        VolumeGroup app = volumeGroups.next();
        if (app.getRoles().contains(VolumeGroup.VolumeGroupRole.COPY.toString())) {
            applicationIds.add(app.getId());
        }
    }
    return applicationIds;
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) VolumeGroup(com.emc.storageos.db.client.model.VolumeGroup) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) URI(java.net.URI) BlockObject(com.emc.storageos.db.client.model.BlockObject) HashSet(java.util.HashSet)

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