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