Search in sources :

Example 26 with VolumeURIHLU

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);
    }
}
Also used : ExportMaskVolumeToStorageGroupCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskVolumeToStorageGroupCompleter) SmisMaskingViewAddVolumeJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisMaskingViewAddVolumeJob) CIMObjectPath(javax.cim.CIMObjectPath) StorageGroupPolicyLimitsParam(com.emc.storageos.volumecontroller.impl.StorageGroupPolicyLimitsParam) VolumeURIHLU(com.emc.storageos.volumecontroller.impl.VolumeURIHLU)

Example 27 with VolumeURIHLU

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());
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) VNXeHostInitiator(com.emc.storageos.vnxe.models.VNXeHostInitiator) URI(java.net.URI) VNXeExportResult(com.emc.storageos.vnxe.models.VNXeExportResult) VNXeException(com.emc.storageos.vnxe.VNXeException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) ExportOperationContext(com.emc.storageos.volumecontroller.impl.utils.ExportOperationContext) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) BlockObject(com.emc.storageos.db.client.model.BlockObject) HashSet(java.util.HashSet) VolumeURIHLU(com.emc.storageos.volumecontroller.impl.VolumeURIHLU)

Example 28 with VolumeURIHLU

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);
    }
}
Also used : CIMPropertyFactory(com.emc.storageos.volumecontroller.impl.smis.CIMPropertyFactory) Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) WBEMException(javax.wbem.WBEMException) URI(java.net.URI) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) BlockObject(com.emc.storageos.db.client.model.BlockObject) CIMInstance(javax.cim.CIMInstance) VolumeURIHLU(com.emc.storageos.volumecontroller.impl.VolumeURIHLU)

Example 29 with VolumeURIHLU

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);
    }
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) SmisCommandHelper(com.emc.storageos.volumecontroller.impl.smis.SmisCommandHelper) ArrayList(java.util.ArrayList) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) WBEMException(javax.wbem.WBEMException) URI(java.net.URI) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) BlockObject(com.emc.storageos.db.client.model.BlockObject) WBEMException(javax.wbem.WBEMException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) VolumeURIHLU(com.emc.storageos.volumecontroller.impl.VolumeURIHLU)

Example 30 with VolumeURIHLU

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());
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) HashMap(java.util.HashMap) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) Volume(com.emc.storageos.db.client.model.Volume) HashMap(java.util.HashMap) Map(java.util.Map) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StringMap(com.emc.storageos.db.client.model.StringMap) VolumeURIHLU(com.emc.storageos.volumecontroller.impl.VolumeURIHLU)

Aggregations

VolumeURIHLU (com.emc.storageos.volumecontroller.impl.VolumeURIHLU)35 URI (java.net.URI)26 ArrayList (java.util.ArrayList)22 BlockObject (com.emc.storageos.db.client.model.BlockObject)19 ExportMask (com.emc.storageos.db.client.model.ExportMask)18 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)17 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)14 HashMap (java.util.HashMap)14 HashSet (java.util.HashSet)13 CIMObjectPath (javax.cim.CIMObjectPath)13 Initiator (com.emc.storageos.db.client.model.Initiator)9 WBEMException (javax.wbem.WBEMException)9 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)8 StorageGroupPolicyLimitsParam (com.emc.storageos.volumecontroller.impl.StorageGroupPolicyLimitsParam)7 CIMInstance (javax.cim.CIMInstance)7 Volume (com.emc.storageos.db.client.model.Volume)6 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)5 StringSet (com.emc.storageos.db.client.model.StringSet)5 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)5 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)4