Search in sources :

Example 1 with TieringPolicyEnum

use of com.emc.storageos.vnxe.models.StorageResource.TieringPolicyEnum in project coprhd-controller by CoprHD.

the class VNXUnityBlockStorageDevice method doCreateVolumes.

@Override
public void doCreateVolumes(StorageSystem storage, StoragePool storagePool, String opId, List<Volume> volumes, VirtualPoolCapabilityValuesWrapper capabilities, TaskCompleter taskCompleter) throws DeviceControllerException {
    logger.info("creating volumes, array: {}, pool : {}", storage.getSerialNumber(), storagePool.getNativeId());
    VNXeApiClient apiClient = getVnxUnityClient(storage);
    List<String> jobs = new ArrayList<String>();
    boolean opFailed = false;
    try {
        InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_022);
        Map<String, List<Volume>> cgVolumes = new HashMap<String, List<Volume>>();
        Map<String, List<URI>> jobVolumesMap = new HashMap<String, List<URI>>();
        for (Volume volume : volumes) {
            String tenantName = "";
            try {
                TenantOrg tenant = dbClient.queryObject(TenantOrg.class, volume.getTenant().getURI());
                tenantName = tenant.getLabel();
            } catch (DatabaseException e) {
                logger.error("Error lookup TenantOrb object", e);
            }
            String label = nameGenerator.generate(tenantName, volume.getLabel(), volume.getId().toString(), '-', VNXeConstants.MAX_NAME_LENGTH);
            String cgName = volume.getReplicationGroupInstance();
            volume.setNativeGuid(label);
            dbClient.updateObject(volume);
            if (NullColumnValueGetter.isNullValue(cgName)) {
                String autoTierPolicyName = ControllerUtils.getAutoTieringPolicyName(volume.getId(), dbClient);
                if (autoTierPolicyName.equals(Constants.NONE)) {
                    autoTierPolicyName = null;
                }
                VNXeCommandJob job = apiClient.createLun(label, storagePool.getNativeId(), volume.getCapacity(), volume.getThinlyProvisioned(), autoTierPolicyName);
                jobs.add(job.getId());
                jobVolumesMap.put(job.getId(), Arrays.asList(volume.getId()));
            } else {
                logger.info(String.format("Creating the volume %s in CG %s", volume.getLabel(), cgName));
                List<Volume> vols = cgVolumes.get(cgName);
                if (vols == null) {
                    vols = new ArrayList<Volume>();
                }
                vols.add(volume);
                cgVolumes.put(cgName, vols);
            }
        }
        for (Map.Entry<String, List<Volume>> cgVol : cgVolumes.entrySet()) {
            // Creating volumes in a CG
            String cgName = cgVol.getKey();
            String cgId = apiClient.getConsistencyGroupIdByName(cgName);
            if (cgId == null) {
                String errorMsg = String.format("The CG %s could not be found in the array", cgName);
                logger.error(errorMsg);
                ServiceError error = DeviceControllerErrors.vnxe.jobFailed("CreateVolumes", errorMsg);
                taskCompleter.error(dbClient, error);
                dbClient.markForDeletion(cgVol.getValue());
                return;
            }
            List<Volume> vols = cgVol.getValue();
            VNXeUtils.getCGLock(workflowService, storage, cgName, opId);
            List<LunCreateParam> lunCreates = new ArrayList<LunCreateParam>();
            StorageResource cg = apiClient.getConsistencyGroup(cgId);
            List<URI> volURIs = new ArrayList<URI>();
            for (Volume volToCreate : vols) {
                volURIs.add(volToCreate.getId());
                boolean isPolicyOn = false;
                String tierPolicy = ControllerUtils.getAutoTieringPolicyName(volToCreate.getId(), dbClient);
                FastVPParam fastVP = new FastVPParam();
                if (!tierPolicy.equals(Constants.NONE)) {
                    TieringPolicyEnum tierValue = TieringPolicyEnum.valueOf(tierPolicy);
                    if (tierValue != null) {
                        fastVP.setTieringPolicy(tierValue.getValue());
                        isPolicyOn = true;
                    }
                }
                // Construct Unity API LunParam for each volume to be created.
                LunParam lunParam = new LunParam();
                lunParam.setIsThinEnabled(volToCreate.getThinlyProvisioned());
                lunParam.setSize(volToCreate.getCapacity());
                lunParam.setPool(new VNXeBase(storagePool.getNativeId()));
                List<BlockHostAccess> hostAccesses = cg.getBlockHostAccess();
                if (hostAccesses != null && !hostAccesses.isEmpty()) {
                    for (BlockHostAccess hostAccess : hostAccesses) {
                        hostAccess.setAccessMask(HostLUNAccessEnum.NOACCESS.getValue());
                    }
                    lunParam.setHostAccess(hostAccesses);
                }
                LunCreateParam createParam = new LunCreateParam();
                createParam.setName(volToCreate.getLabel());
                createParam.setLunParameters(lunParam);
                if (isPolicyOn) {
                    lunParam.setFastVPParameters(fastVP);
                }
                lunCreates.add(createParam);
            }
            VNXeCommandJob result = apiClient.createLunsInConsistencyGroup(lunCreates, cgId);
            jobs.add(result.getId());
            jobVolumesMap.put(result.getId(), volURIs);
        }
        VNXUnityCreateVolumesJob createVolumesJob = new VNXUnityCreateVolumesJob(jobVolumesMap, jobs, storage.getId(), taskCompleter, storagePool.getId());
        ControllerServiceImpl.enqueueJob(new QueueJob(createVolumesJob));
        InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_023);
    } catch (VNXeException e) {
        logger.error("Create volumes got the exception", e);
        opFailed = true;
        taskCompleter.error(dbClient, e);
    } catch (Exception ex) {
        logger.error("Create volumes got the exception", ex);
        opFailed = true;
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("CreateVolumes", ex.getMessage());
        taskCompleter.error(dbClient, error);
    }
    if (opFailed) {
        for (Volume vol : volumes) {
            vol.setInactive(true);
            dbClient.updateObject(vol);
        }
    }
}
Also used : StorageResource(com.emc.storageos.vnxe.models.StorageResource) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) URI(java.net.URI) VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) TieringPolicyEnum(com.emc.storageos.vnxe.models.StorageResource.TieringPolicyEnum) VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) List(java.util.List) ArrayList(java.util.ArrayList) VNXUnityCreateVolumesJob(com.emc.storageos.volumecontroller.impl.vnxunity.job.VNXUnityCreateVolumesJob) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) FastVPParam(com.emc.storageos.vnxe.models.FastVPParam) VNXeException(com.emc.storageos.vnxe.VNXeException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) BlockHostAccess(com.emc.storageos.vnxe.models.BlockHostAccess) LunParam(com.emc.storageos.vnxe.models.LunParam) Volume(com.emc.storageos.db.client.model.Volume) VNXeException(com.emc.storageos.vnxe.VNXeException) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) Map(java.util.Map) HashMap(java.util.HashMap) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StringMap(com.emc.storageos.db.client.model.StringMap) LunCreateParam(com.emc.storageos.vnxe.models.LunCreateParam) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob)

Example 2 with TieringPolicyEnum

use of com.emc.storageos.vnxe.models.StorageResource.TieringPolicyEnum in project coprhd-controller by CoprHD.

the class VNXeApiClient method createLunsInLunGroup.

/**
 * Create multiple volumes in a lun group
 *
 * @param names
 * @param poolId
 * @param size
 * @param isThin
 * @param tieringPolicy
 * @param lunGroupId
 * @return
 */
public VNXeCommandJob createLunsInLunGroup(List<String> names, String poolId, Long size, boolean isThin, String tieringPolicy, String lunGroupId) {
    _logger.info("creating luns in the lun group: {}", lunGroupId);
    LunGroupModifyParam param = new LunGroupModifyParam();
    List<LunCreateParam> lunCreates = new ArrayList<LunCreateParam>();
    boolean isPolicyOn = false;
    FastVPParam fastVP = new FastVPParam();
    if (tieringPolicy != null && !tieringPolicy.isEmpty()) {
        TieringPolicyEnum tierValue = TieringPolicyEnum.valueOf(tieringPolicy);
        if (tierValue != null) {
            fastVP.setTieringPolicy(tierValue.getValue());
            isPolicyOn = true;
        }
    }
    for (String lunName : names) {
        LunParam lunParam = new LunParam();
        lunParam.setIsThinEnabled(isThin);
        lunParam.setSize(size);
        lunParam.setPool(new VNXeBase(poolId));
        LunCreateParam createParam = new LunCreateParam();
        createParam.setName(lunName);
        createParam.setLunParameters(lunParam);
        if (isPolicyOn) {
            lunParam.setFastVPParameters(fastVP);
        }
        lunCreates.add(createParam);
    }
    param.setLunCreate(lunCreates);
    LunGroupRequests req = new LunGroupRequests(_khClient);
    return req.modifyLunGroupAsync(lunGroupId, param);
}
Also used : TieringPolicyEnum(com.emc.storageos.vnxe.models.StorageResource.TieringPolicyEnum) VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) FastVPParam(com.emc.storageos.vnxe.models.FastVPParam) LunParam(com.emc.storageos.vnxe.models.LunParam) LunGroupRequests(com.emc.storageos.vnxe.requests.LunGroupRequests) LunGroupModifyParam(com.emc.storageos.vnxe.models.LunGroupModifyParam) ArrayList(java.util.ArrayList) LunCreateParam(com.emc.storageos.vnxe.models.LunCreateParam)

Example 3 with TieringPolicyEnum

use of com.emc.storageos.vnxe.models.StorageResource.TieringPolicyEnum in project coprhd-controller by CoprHD.

the class VNXeApiClient method createLunsInConsistencyGroup.

/**
 * Create multiple volumes in a lun group
 *
 * @param names
 * @param poolId
 * @param size
 * @param isThin
 * @param tieringPolicy
 * @param cgId
 * @return
 */
public VNXeCommandJob createLunsInConsistencyGroup(List<String> names, String poolId, Long size, boolean isThin, String tieringPolicy, String cgId) {
    _logger.info("creating luns in the consistencyGroup group: {}", cgId);
    LunGroupModifyParam param = new LunGroupModifyParam();
    List<LunCreateParam> lunCreates = new ArrayList<LunCreateParam>();
    boolean isPolicyOn = false;
    FastVPParam fastVP = new FastVPParam();
    if (tieringPolicy != null && !tieringPolicy.isEmpty()) {
        TieringPolicyEnum tierValue = TieringPolicyEnum.valueOf(tieringPolicy);
        if (tierValue != null) {
            fastVP.setTieringPolicy(tierValue.getValue());
            isPolicyOn = true;
        }
    }
    StorageResourceRequest cgRequest = new StorageResourceRequest(_khClient);
    StorageResource cg = cgRequest.get(cgId);
    for (String lunName : names) {
        LunParam lunParam = new LunParam();
        lunParam.setIsThinEnabled(isThin);
        lunParam.setSize(size);
        lunParam.setPool(new VNXeBase(poolId));
        List<BlockHostAccess> hostAccesses = cg.getBlockHostAccess();
        if (hostAccesses != null && !hostAccesses.isEmpty()) {
            for (BlockHostAccess hostAccess : hostAccesses) {
                hostAccess.setAccessMask(HostLUNAccessEnum.NOACCESS.getValue());
            }
            lunParam.setHostAccess(hostAccesses);
        }
        LunCreateParam createParam = new LunCreateParam();
        createParam.setName(lunName);
        createParam.setLunParameters(lunParam);
        if (isPolicyOn) {
            lunParam.setFastVPParameters(fastVP);
        }
        lunCreates.add(createParam);
    }
    param.setLunCreate(lunCreates);
    ConsistencyGroupRequests req = new ConsistencyGroupRequests(_khClient);
    return req.modifyConsistencyGroupAsync(cgId, param);
}
Also used : StorageResource(com.emc.storageos.vnxe.models.StorageResource) FastVPParam(com.emc.storageos.vnxe.models.FastVPParam) LunGroupModifyParam(com.emc.storageos.vnxe.models.LunGroupModifyParam) ArrayList(java.util.ArrayList) ConsistencyGroupRequests(com.emc.storageos.vnxe.requests.ConsistencyGroupRequests) BlockHostAccess(com.emc.storageos.vnxe.models.BlockHostAccess) TieringPolicyEnum(com.emc.storageos.vnxe.models.StorageResource.TieringPolicyEnum) VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) LunParam(com.emc.storageos.vnxe.models.LunParam) StorageResourceRequest(com.emc.storageos.vnxe.requests.StorageResourceRequest) DeleteStorageResourceRequest(com.emc.storageos.vnxe.requests.DeleteStorageResourceRequest) LunCreateParam(com.emc.storageos.vnxe.models.LunCreateParam)

Example 4 with TieringPolicyEnum

use of com.emc.storageos.vnxe.models.StorageResource.TieringPolicyEnum in project coprhd-controller by CoprHD.

the class VNXeApiClient method createLun.

/**
 * Create standalone lun
 *
 * @param name
 * @param poolId
 * @param size
 * @param isThin
 * @param tieringPolicy
 * @param lunGroupId
 * @return
 */
public VNXeCommandJob createLun(String name, String poolId, Long size, boolean isThin, String tieringPolicy) {
    LunParam lunParam = new LunParam();
    lunParam.setIsThinEnabled(isThin);
    lunParam.setSize(size);
    lunParam.setPool(new VNXeBase(poolId));
    FastVPParam fastVP = new FastVPParam();
    if (tieringPolicy != null && !tieringPolicy.isEmpty()) {
        TieringPolicyEnum tierValue = TieringPolicyEnum.valueOf(tieringPolicy);
        if (tierValue != null) {
            fastVP.setTieringPolicy(tierValue.getValue());
            lunParam.setFastVPParameters(fastVP);
        }
    }
    LunCreateParam createParam = new LunCreateParam();
    createParam.setName(name);
    createParam.setLunParameters(lunParam);
    BlockLunRequests req = new BlockLunRequests(_khClient);
    return req.createLun(createParam);
}
Also used : TieringPolicyEnum(com.emc.storageos.vnxe.models.StorageResource.TieringPolicyEnum) VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) LunParam(com.emc.storageos.vnxe.models.LunParam) FastVPParam(com.emc.storageos.vnxe.models.FastVPParam) BlockLunRequests(com.emc.storageos.vnxe.requests.BlockLunRequests) LunCreateParam(com.emc.storageos.vnxe.models.LunCreateParam)

Aggregations

FastVPParam (com.emc.storageos.vnxe.models.FastVPParam)4 LunCreateParam (com.emc.storageos.vnxe.models.LunCreateParam)4 LunParam (com.emc.storageos.vnxe.models.LunParam)4 TieringPolicyEnum (com.emc.storageos.vnxe.models.StorageResource.TieringPolicyEnum)4 VNXeBase (com.emc.storageos.vnxe.models.VNXeBase)4 ArrayList (java.util.ArrayList)3 BlockHostAccess (com.emc.storageos.vnxe.models.BlockHostAccess)2 LunGroupModifyParam (com.emc.storageos.vnxe.models.LunGroupModifyParam)2 StorageResource (com.emc.storageos.vnxe.models.StorageResource)2 StringMap (com.emc.storageos.db.client.model.StringMap)1 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)1 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)1 Volume (com.emc.storageos.db.client.model.Volume)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)1 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)1 VNXeException (com.emc.storageos.vnxe.VNXeException)1 VNXeCommandJob (com.emc.storageos.vnxe.models.VNXeCommandJob)1 BlockLunRequests (com.emc.storageos.vnxe.requests.BlockLunRequests)1