use of com.emc.storageos.volumecontroller.impl.VolumeURIHLU in project coprhd-controller by CoprHD.
the class VmaxExportOperations method addVolumesToPhantomStorageGroup.
/**
* Adds the volumes to new or existing phantom storage group which is associated with given policy.
* This is used internally for operation - change volume's policy by moving them from one vPool to another.
*/
private void addVolumesToPhantomStorageGroup(StorageSystem storage, ExportMask exportMask, List<URI> volumesInSG, String newPolicyName, String childGroupName, TaskCompleter taskCompleter, boolean forceFlag) throws Exception {
// Check to see if there already is a phantom storage group with this policy on the array
StorageGroupPolicyLimitsParam phantomStorageGroupPolicyLimitsParam = new StorageGroupPolicyLimitsParam(newPolicyName);
List<String> phantomStorageGroupNames = _helper.findPhantomStorageGroupAssociatedWithFastPolicy(storage, phantomStorageGroupPolicyLimitsParam);
VolumeURIHLU[] volumeURIHlus = constructVolumeURIHLUFromURIList(volumesInSG, newPolicyName);
// If there's no existing phantom storage group, create one.
if (phantomStorageGroupNames == null || phantomStorageGroupNames.isEmpty()) {
String phantomStorageGroupName = generateNewNameForPhantomSG(storage, childGroupName, phantomStorageGroupPolicyLimitsParam);
// We need to create a new phantom storage group with our policy associated with it.
_log.info("phantom storage group {} doesn't exist, creating a new group", phantomStorageGroupName);
CIMObjectPath phantomStorageGroupCreated = createVolumeGroup(storage, phantomStorageGroupName, volumeURIHlus, taskCompleter, true);
_log.info("Adding Storage Group {} to Fast Policy {}", phantomStorageGroupName, newPolicyName);
addVolumeGroupToAutoTieringPolicy(storage, newPolicyName, phantomStorageGroupCreated, taskCompleter);
} else {
// take the first matching phantom SG from the list
String phantomStorageGroupName = phantomStorageGroupNames.get(0);
// We found a phantom storage group with our policy, use it.
_log.info("Found that we need to add volumes to the phantom storage group: {}", phantomStorageGroupName);
// Create a relatively empty completer associated with the export mask. We don't have the export group
// at this level, so there's nothing decent to attach the completer to anyway.
String task = UUID.randomUUID().toString();
ExportMaskVolumeToStorageGroupCompleter completer = new ExportMaskVolumeToStorageGroupCompleter(null, exportMask.getId(), task);
SmisMaskingViewAddVolumeJob job = new SmisMaskingViewAddVolumeJob(null, storage.getId(), exportMask.getId(), volumeURIHlus, null, completer);
job.setCIMObjectPathfactory(_cimPath);
_helper.addVolumesToStorageGroup(volumeURIHlus, storage, phantomStorageGroupName, job, forceFlag);
ExportOperationContext.insertContextOperation(taskCompleter, VmaxExportOperationContext.OPERATION_ADD_VOLUMES_TO_STORAGE_GROUP, phantomStorageGroupName, volumeURIHlus, forceFlag);
_log.info("Adding Volumes to Phantom Storage Group {}", phantomStorageGroupName);
}
}
use of com.emc.storageos.volumecontroller.impl.VolumeURIHLU in project coprhd-controller by CoprHD.
the class VNXeExportOperations method createExportMask.
@Override
public void createExportMask(StorageSystem storage, URI exportMask, VolumeURIHLU[] volumeURIHLUs, List<URI> targetURIList, List<Initiator> initiatorList, TaskCompleter taskCompleter) throws DeviceControllerException {
_logger.info("{} createExportMask START...", storage.getSerialNumber());
VNXeApiClient apiClient = getVnxeClient(storage);
List<URI> mappedVolumes = new ArrayList<URI>();
ExportMask mask = null;
try {
_logger.info("createExportMask: Export mask id: {}", exportMask);
_logger.info("createExportMask: volume-HLU pairs: {}", Joiner.on(',').join(volumeURIHLUs));
_logger.info("createExportMask: initiators: {}", Joiner.on(',').join(initiatorList));
_logger.info("createExportMask: assignments: {}", Joiner.on(',').join(targetURIList));
ExportOperationContext context = new VNXeExportOperationContext();
taskCompleter.updateWorkflowStepContext(context);
mask = _dbClient.queryObject(ExportMask.class, exportMask);
if (mask == null || mask.getInactive()) {
throw new DeviceControllerException("Invalid ExportMask URI: " + exportMask);
}
Set<String> processedCGs = new HashSet<String>();
Collection<VNXeHostInitiator> initiators = prepareInitiators(initiatorList).values();
VNXeBase host = apiClient.prepareHostsForExport(initiators);
validateInitiators(_dbClient, initiatorList, apiClient, host.getId());
String opId = taskCompleter.getOpId();
for (VolumeURIHLU volURIHLU : volumeURIHLUs) {
URI volUri = volURIHLU.getVolumeURI();
String hlu = volURIHLU.getHLU();
_logger.info(String.format("hlu %s", hlu));
BlockObject blockObject = BlockObject.fetch(_dbClient, volUri);
String nativeId = blockObject.getNativeId();
VNXeExportResult result = null;
Integer newhlu = -1;
if (hlu != null && !hlu.isEmpty() && !hlu.equals(ExportGroup.LUN_UNASSIGNED_STR)) {
newhlu = Integer.valueOf(hlu);
}
String cgName = VNXeUtils.getBlockObjectCGName(blockObject, _dbClient);
if (cgName != null && !processedCGs.contains(cgName)) {
processedCGs.add(cgName);
VNXeUtils.getCGLock(workflowService, storage, cgName, opId);
}
if (URIUtil.isType(volUri, Volume.class)) {
result = apiClient.exportLun(host, nativeId, newhlu);
mask.addVolume(volUri, result.getHlu());
if (result.isNewAccess()) {
mappedVolumes.add(volUri);
}
} else if (URIUtil.isType(volUri, BlockSnapshot.class)) {
if (BlockObject.checkForRP(_dbClient, volUri)) {
_logger.info(String.format("BlockObject %s is a RecoverPoint bookmark. Exporting associated lun %s instead of snap.", volUri, nativeId));
result = apiClient.exportLun(host, nativeId, newhlu);
} else {
result = apiClient.exportSnap(host, nativeId, newhlu);
setSnapWWN(apiClient, blockObject, nativeId);
}
mask.addVolume(volUri, result.getHlu());
if (result.isNewAccess()) {
mappedVolumes.add(volUri);
}
}
}
ExportOperationContext.insertContextOperation(taskCompleter, VNXeExportOperationContext.OPERATION_ADD_VOLUMES_TO_HOST_EXPORT, mappedVolumes);
mask.setNativeId(host.getId());
_dbClient.updateObject(mask);
taskCompleter.ready(_dbClient);
} catch (Exception e) {
_logger.error("Unexpected error: createExportMask failed.", e);
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("createExportMask", e.getMessage());
taskCompleter.error(_dbClient, error);
}
_logger.info("{} createExportMask END...", storage.getSerialNumber());
}
use of com.emc.storageos.volumecontroller.impl.VolumeURIHLU in project coprhd-controller by CoprHD.
the class SmisCreateMaskingViewJob method enableRecoverPointTag.
/**
* Method will set the EMCRecoverPointEnabled flag on the device masking group for VMAX.
*
* @param dbClient [in] - Client instance for reading/writing from/to DB
* @param client [in] - WBEMClient used for reading/writing from/to SMI-S
* @param deviceGroupPath [in] - CIMObjectPath referencing the volume
*/
private void enableRecoverPointTag(DbClient dbClient, WBEMClient client, CIMObjectPath deviceGroupPath) {
try {
boolean isRPTagNeeded = false;
// Check if the volumes being protected are RP volumes
for (VolumeURIHLU volUriHlu : _volumeURIHLUs) {
URI volumeURI = volUriHlu.getVolumeURI();
BlockObject bo = null;
if (URIUtil.isType(volumeURI, BlockSnapshot.class)) {
bo = dbClient.queryObject(BlockSnapshot.class, volumeURI);
} else if (URIUtil.isType(volumeURI, Volume.class)) {
bo = dbClient.queryObject(Volume.class, volumeURI);
}
if (bo != null && BlockObject.checkForRP(dbClient, bo.getId())) {
isRPTagNeeded = true;
break;
}
}
// Do nothing and return from if none of the volumes are RP protected
if (isRPTagNeeded) {
_log.info("Attempting to enable RecoverPoint tag on Device Group : " + deviceGroupPath.toString());
CIMPropertyFactory factoryRef = (CIMPropertyFactory) ControllerServiceImpl.getBean("CIMPropertyFactory");
CIMInstance toUpdate = new CIMInstance(deviceGroupPath, new CIMProperty[] { factoryRef.bool(SmisConstants.EMC_RECOVERPOINT_ENABLED, true) });
_log.debug("Params: " + toUpdate.toString());
client.modifyInstance(toUpdate, SmisConstants.CP_EMC_RECOVERPOINT_ENABLED);
_log.info(String.format("Device group has been successfully set with RecoverPoint tag "));
}
} catch (WBEMException e) {
_log.error("Encountered an error while trying to set the RecoverPoint tag", e);
} catch (DatabaseException e) {
_log.error("Encountered an error while trying to set the RecoverPoint tag", e);
}
}
use of com.emc.storageos.volumecontroller.impl.VolumeURIHLU in project coprhd-controller by CoprHD.
the class SmisCreateMaskingViewJob method enableRecoverPointTagOn803.
/**
* Method will set the EMCRecoverPointEnabled flag on all the volumes within 8.0.3 Provider.
* 8.0.3 Provider doesnt support setting RP tag on Storage Groups.
*
* @param dbClient [in] - Client instance for reading/writing from/to DB
* @param client [in] - WBEMClient used for reading/writing from/to SMI-S
* @param deviceGroupPath [in] - CIMObjectPath referencing the volume
*/
private void enableRecoverPointTagOn803(DbClient dbClient, WBEMClient client, StorageSystem storage, JobContext jobContext) {
try {
boolean isRPTagNeeded = false;
List<URI> blockObjectUris = new ArrayList<URI>();
for (VolumeURIHLU volUriHlu : _volumeURIHLUs) {
URI volumeURI = volUriHlu.getVolumeURI();
BlockObject bo = null;
if (URIUtil.isType(volumeURI, BlockSnapshot.class)) {
bo = dbClient.queryObject(BlockSnapshot.class, volumeURI);
} else if (URIUtil.isType(volumeURI, Volume.class)) {
bo = dbClient.queryObject(Volume.class, volumeURI);
}
if (bo != null) {
blockObjectUris.add(bo.getId());
if (BlockObject.checkForRP(dbClient, bo.getId())) {
isRPTagNeeded = true;
}
}
}
// Do nothing and return from if none of the volumes are RP protected
if (isRPTagNeeded) {
SmisCommandHelper helper = jobContext.getSmisCommandHelper();
helper.setRecoverPointTag(storage, helper.getVolumeMembers(storage, blockObjectUris), true);
}
} catch (WBEMException e) {
_log.error("Encountered an error while trying to set the RecoverPoint tag", e);
} catch (DatabaseException e) {
_log.error("Encountered an error while trying to set the RecoverPoint tag", e);
} catch (Exception e) {
_log.error("Encountered an error while trying to set the RecoverPoint tag", e);
}
}
use of com.emc.storageos.volumecontroller.impl.VolumeURIHLU in project coprhd-controller by CoprHD.
the class CinderExportOperations method createExportMask.
@Override
public void createExportMask(StorageSystem storage, URI exportMaskId, VolumeURIHLU[] volumeURIHLUs, List<URI> targetURIList, List<Initiator> initiatorList, TaskCompleter taskCompleter) throws DeviceControllerException {
log.info("{} createExportMask START...", storage.getSerialNumber());
try {
log.info("createExportMask: Export mask id: {}", exportMaskId);
log.info("createExportMask: volume-HLU pairs: {}", Joiner.on(',').join(volumeURIHLUs));
log.info("createExportMask: initiators: {}", Joiner.on(',').join(initiatorList));
log.info("createExportMask: assignments: {}", Joiner.on(',').join(targetURIList));
log.info("User assigned HLUs will be ignored as Cinder does not support it.");
ExportMask exportMask = dbClient.queryObject(ExportMask.class, exportMaskId);
List<Volume> volumes = new ArrayList<Volume>();
// map to store target LUN id generated for each volume
Map<URI, Integer> volumeToTargetLunMap = new HashMap<URI, Integer>();
// Map to store volume to initiatorTargetMap
Map<Volume, Map<String, List<String>>> volumeToFCInitiatorTargetMap = new HashMap<>();
for (VolumeURIHLU volumeURIHLU : volumeURIHLUs) {
URI volumeURI = volumeURIHLU.getVolumeURI();
Volume volume = dbClient.queryObject(Volume.class, volumeURI);
volumes.add(volume);
}
attachVolumesToInitiators(storage, volumes, initiatorList, volumeToTargetLunMap, volumeToFCInitiatorTargetMap, exportMask);
// Update targets in the export mask
if (!volumeToFCInitiatorTargetMap.isEmpty()) {
updateTargetsInExportMask(storage, volumes.get(0), volumeToFCInitiatorTargetMap, initiatorList, exportMask);
}
updateTargetLunIdInExportMask(volumeToTargetLunMap, exportMask);
dbClient.updateObject(exportMask);
taskCompleter.ready(dbClient);
} catch (final Exception ex) {
log.error("Problem in AttachVolumes: ", ex);
ServiceError serviceError = DeviceControllerErrors.cinder.operationFailed("doAttachVolumes", ex.getMessage());
taskCompleter.error(dbClient, serviceError);
}
log.info("{} createExportMask END...", storage.getSerialNumber());
}
Aggregations