Search in sources :

Example 1 with LunGroupModifyParam

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

the class VNXeApiClient method exportLun.

/**
 * Export a lun for a given host
 *
 * @param host
 *            host
 * @param lunId
 *            lun id
 * @param newhlu
 *            HLU
 * @return
 * @throws VNXeException
 */
public VNXeExportResult exportLun(VNXeBase host, String lunId, Integer newhlu) throws VNXeException {
    _logger.info("Exporting lun: {}", lunId);
    VNXeLun lun = getLun(lunId);
    if (lun == null) {
        _logger.info("Could not find lun in the vxne: {}", lunId);
        throw VNXeException.exceptions.vnxeCommandFailed("Could not find lun : " + lunId);
    }
    List<BlockHostAccess> hostAccesses = lun.getHostAccess();
    boolean lunHostAccessExists = false;
    if (hostAccesses == null) {
        hostAccesses = new ArrayList<BlockHostAccess>();
    } else {
        // already defined for the given host with a different access mask.
        for (BlockHostAccess hostAccess : hostAccesses) {
            String hostId = hostAccess.getHost().getId();
            if (hostId.equals(host.getId())) {
                if (hostAccess.getAccessMask() == HostLUNAccessEnum.SNAPSHOT.getValue()) {
                    hostAccess.setAccessMask(HostLUNAccessEnum.BOTH.getValue());
                    lunHostAccessExists = true;
                    break;
                } else if (hostAccess.getAccessMask() == HostLUNAccessEnum.NOACCESS.getValue()) {
                    hostAccess.setAccessMask(HostLUNAccessEnum.PRODUCTION.getValue());
                    lunHostAccessExists = true;
                    break;
                }
            }
        }
    }
    if (!lunHostAccessExists) {
        BlockHostAccess access = new BlockHostAccess();
        access.setHost(host);
        access.setAccessMask(BlockHostAccess.HostLUNAccessEnum.PRODUCTION.getValue());
        hostAccesses.add(access);
    }
    LunParam lunParam = new LunParam();
    lunParam.setHostAccess(hostAccesses);
    LunModifyParam exportParam = new LunModifyParam();
    exportParam.setLunParameters(lunParam);
    int type = lun.getType();
    if (type == VNXeLun.LUNTypeEnum.Standalone.getValue()) {
        // if standalone lun
        BlockLunRequests lunReq = new BlockLunRequests(_khClient);
        lunReq.modifyLunSync(exportParam, lun.getStorageResource().getId());
    } else {
        // lun in a lun group
        exportParam.setLun(new VNXeBase(lunId));
        List<LunModifyParam> list = new ArrayList<LunModifyParam>();
        list.add(exportParam);
        LunGroupModifyParam groupParam = new LunGroupModifyParam();
        groupParam.setLunModify(list);
        if (!_khClient.isUnity()) {
            LunGroupRequests lunGroupReq = new LunGroupRequests(_khClient);
            lunGroupReq.modifyLunGroupSync(lun.getStorageResource().getId(), groupParam);
        } else {
            ConsistencyGroupRequests cgReq = new ConsistencyGroupRequests(_khClient);
            cgReq.modifyConsistencyGroupSync(lun.getStorageResource().getId(), groupParam);
        }
    }
    // get hlu
    HostLunRequests hostLunReq = new HostLunRequests(_khClient);
    HostLun hostLun = hostLunReq.getHostLun(lunId, host.getId(), HostLunRequests.ID_SEQUENCE_LUN);
    int hluResult = hostLun.getHlu();
    if (isUnityClient() && newhlu != null && newhlu.intValue() != -1) {
        _logger.info("Modify hlu");
        modifyHostLunHlu(host.getId(), hostLun.getId(), newhlu);
        hluResult = newhlu;
    }
    VNXeExportResult result = new VNXeExportResult();
    result.setHlu(hluResult);
    result.setLunId(lunId);
    result.setHostId(host.getId());
    result.setNewAccess(!lunHostAccessExists);
    _logger.info("Done exporting lun: {}", lunId);
    return result;
}
Also used : HostLunRequests(com.emc.storageos.vnxe.requests.HostLunRequests) ArrayList(java.util.ArrayList) LunGroupModifyParam(com.emc.storageos.vnxe.models.LunGroupModifyParam) HostLun(com.emc.storageos.vnxe.models.HostLun) ConsistencyGroupRequests(com.emc.storageos.vnxe.requests.ConsistencyGroupRequests) VNXeExportResult(com.emc.storageos.vnxe.models.VNXeExportResult) BlockHostAccess(com.emc.storageos.vnxe.models.BlockHostAccess) VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) LunParam(com.emc.storageos.vnxe.models.LunParam) BlockLunRequests(com.emc.storageos.vnxe.requests.BlockLunRequests) LunGroupRequests(com.emc.storageos.vnxe.requests.LunGroupRequests) VNXeLun(com.emc.storageos.vnxe.models.VNXeLun) HostLunModifyParam(com.emc.storageos.vnxe.models.HostLunModifyParam) LunModifyParam(com.emc.storageos.vnxe.models.LunModifyParam)

Example 2 with LunGroupModifyParam

use of com.emc.storageos.vnxe.models.LunGroupModifyParam 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 LunGroupModifyParam

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

the class VNXeApiClient method exportSnap.

/**
 * Export a snap for a given host
 *
 * @param host
 *            host
 * @param snapId
 *            snap id
 * @param newhlu
 *            HLU
 * @return
 * @throws VNXeException
 */
public VNXeExportResult exportSnap(VNXeBase host, String snapId, Integer newhlu) throws VNXeException {
    _logger.info("Exporting lun snap: {}", snapId);
    String parentLunId = null;
    VNXeLun parentLun = null;
    if (!_khClient.isUnity()) {
        VNXeLunSnap lunSnap = getLunSnapshot(snapId);
        if (lunSnap == null) {
            _logger.info("Could not find lun snap in the vxne: {}", snapId);
            throw VNXeException.exceptions.vnxeCommandFailed("Could not find lun snap: " + snapId);
        }
        if (!lunSnap.getIsAttached()) {
            _logger.info("Attaching the snap: {}", snapId);
            attachLunSnap(snapId);
        }
        parentLunId = lunSnap.getLun().getId();
    } else {
        Snap snap = getSnapshot(snapId);
        if (snap == null) {
            _logger.info("Could not find snap in the vxn unity: {}", snapId);
            throw VNXeException.exceptions.vnxeCommandFailed("Could not find lun snap: " + snapId);
        }
        VNXeBase snapGroup = snap.getSnapGroup();
        parentLunId = snap.getLun().getId();
        if (snapGroup == null && (!snap.isAttached())) {
            _logger.info("Attaching the snap: {}", snapId);
            attachSnap(snapId);
        } else if (snapGroup != null && (!snap.isAttached())) {
            String groupId = snapGroup.getId();
            attachSnap(groupId);
        }
    }
    // Get host access info of the parent lun
    parentLun = getLun(parentLunId);
    List<BlockHostAccess> hostAccesses = parentLun.getHostAccess();
    boolean snapHostAccessExists = false;
    if (hostAccesses == null) {
        hostAccesses = new ArrayList<BlockHostAccess>();
    } else {
        // already defined for the given host with a different access mask.
        for (BlockHostAccess hostAccess : hostAccesses) {
            String hostId = hostAccess.getHost().getId();
            if (hostId.equals(host.getId())) {
                if (hostAccess.getAccessMask() == HostLUNAccessEnum.PRODUCTION.getValue()) {
                    hostAccess.setAccessMask(HostLUNAccessEnum.BOTH.getValue());
                    snapHostAccessExists = true;
                    break;
                } else if (hostAccess.getAccessMask() == HostLUNAccessEnum.NOACCESS.getValue()) {
                    hostAccess.setAccessMask(HostLUNAccessEnum.SNAPSHOT.getValue());
                    snapHostAccessExists = true;
                    break;
                }
            }
        }
    }
    if (!snapHostAccessExists) {
        BlockHostAccess access = new BlockHostAccess();
        access.setHost(host);
        access.setAccessMask(BlockHostAccess.HostLUNAccessEnum.SNAPSHOT.getValue());
        hostAccesses.add(access);
    }
    LunParam lunParam = new LunParam();
    lunParam.setHostAccess(hostAccesses);
    LunModifyParam exportParam = new LunModifyParam();
    exportParam.setLunParameters(lunParam);
    int type = parentLun.getType();
    if (type == VNXeLun.LUNTypeEnum.Standalone.getValue()) {
        // if standalone lun
        BlockLunRequests lunReq = new BlockLunRequests(_khClient);
        lunReq.modifyLunSync(exportParam, parentLun.getStorageResource().getId());
    } else {
        // parent lun in a lun group
        exportParam.setLun(new VNXeBase(parentLun.getId()));
        List<LunModifyParam> list = new ArrayList<LunModifyParam>();
        list.add(exportParam);
        LunGroupModifyParam groupParam = new LunGroupModifyParam();
        groupParam.setLunModify(list);
        if (!_khClient.isUnity()) {
            LunGroupRequests lunGroupReq = new LunGroupRequests(_khClient);
            lunGroupReq.modifyLunGroupSync(parentLun.getStorageResource().getId(), groupParam);
        } else {
            ConsistencyGroupRequests cgReq = new ConsistencyGroupRequests(_khClient);
            cgReq.modifyConsistencyGroupSync(parentLun.getStorageResource().getId(), groupParam);
        }
    }
    // get hlu
    HostLunRequests hostLunReq = new HostLunRequests(_khClient);
    HostLun hostLun = hostLunReq.getHostLun(parentLun.getId(), host.getId(), HostLunRequests.ID_SEQUENCE_SNAP);
    int hluResult = hostLun.getHlu();
    if (isUnityClient() && newhlu != null && newhlu.intValue() != -1) {
        _logger.info("Modify hlu");
        modifyHostLunHlu(host.getId(), hostLun.getId(), newhlu);
        hluResult = newhlu;
    }
    VNXeExportResult result = new VNXeExportResult();
    result.setHlu(hluResult);
    result.setHostId(host.getId());
    result.setNewAccess(!snapHostAccessExists);
    _logger.info("Done exporting lun snap: {}", snapId);
    return result;
}
Also used : HostLunRequests(com.emc.storageos.vnxe.requests.HostLunRequests) ArrayList(java.util.ArrayList) LunGroupModifyParam(com.emc.storageos.vnxe.models.LunGroupModifyParam) HostLun(com.emc.storageos.vnxe.models.HostLun) ConsistencyGroupRequests(com.emc.storageos.vnxe.requests.ConsistencyGroupRequests) VNXeLunSnap(com.emc.storageos.vnxe.models.VNXeLunSnap) VNXeLunSnap(com.emc.storageos.vnxe.models.VNXeLunSnap) VNXeFileSystemSnap(com.emc.storageos.vnxe.models.VNXeFileSystemSnap) VNXeLunGroupSnap(com.emc.storageos.vnxe.models.VNXeLunGroupSnap) Snap(com.emc.storageos.vnxe.models.Snap) VNXeExportResult(com.emc.storageos.vnxe.models.VNXeExportResult) BlockHostAccess(com.emc.storageos.vnxe.models.BlockHostAccess) VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) LunParam(com.emc.storageos.vnxe.models.LunParam) BlockLunRequests(com.emc.storageos.vnxe.requests.BlockLunRequests) LunGroupRequests(com.emc.storageos.vnxe.requests.LunGroupRequests) VNXeLun(com.emc.storageos.vnxe.models.VNXeLun) HostLunModifyParam(com.emc.storageos.vnxe.models.HostLunModifyParam) LunModifyParam(com.emc.storageos.vnxe.models.LunModifyParam)

Example 4 with LunGroupModifyParam

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

the class VNXeApiClient method expandLun.

public VNXeCommandJob expandLun(String lunID, long newSize, String lunGroupID) {
    VNXeCommandJob job = null;
    _logger.info("expanding lun:" + lunID);
    VNXeLun vnxeLun = getLun(lunID);
    if (vnxeLun == null) {
        _logger.info("Could not find lun in the vxne");
        throw VNXeException.exceptions.vnxeCommandFailed("Could not find lun in the vnxe for: " + lunID);
    }
    LunModifyParam lunModifyParam = new LunModifyParam();
    // set lunParam
    LunParam lunParam = new LunParam();
    lunParam.setSize(newSize);
    lunModifyParam.setLunParameters(lunParam);
    if (vnxeLun.getType() == GENERIC_STORAGE_LUN_TYPE) {
        if (lunGroupID == null || lunGroupID.isEmpty()) {
            _logger.error("Lun Group Id not found for lun: " + lunID);
            throw VNXeException.exceptions.vnxeCommandFailed("Could not find lun group for lun: " + lunID);
        }
        LunGroupModifyParam param = new LunGroupModifyParam();
        List<LunModifyParam> lunModifyParamList = new ArrayList<LunModifyParam>();
        lunModifyParam.setLun(new VNXeBase(lunID));
        lunModifyParamList.add(lunModifyParam);
        param.setLunModify(lunModifyParamList);
        if (isUnityClient()) {
            ConsistencyGroupRequests cgRequest = new ConsistencyGroupRequests(_khClient);
            job = cgRequest.modifyConsistencyGroupAsync(lunGroupID, param);
        } else {
            LunGroupRequests lunGroupRequest = new LunGroupRequests(_khClient);
            job = lunGroupRequest.modifyLunGroupAsync(lunGroupID, param);
        }
    } else if (vnxeLun.getType() == STANDALONE_LUN_TYPE) {
        BlockLunRequests req = new BlockLunRequests(_khClient);
        job = req.modifyLunAsync(lunModifyParam, lunID);
    }
    return job;
}
Also used : VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) LunParam(com.emc.storageos.vnxe.models.LunParam) BlockLunRequests(com.emc.storageos.vnxe.requests.BlockLunRequests) LunGroupRequests(com.emc.storageos.vnxe.requests.LunGroupRequests) LunGroupModifyParam(com.emc.storageos.vnxe.models.LunGroupModifyParam) ArrayList(java.util.ArrayList) VNXeLun(com.emc.storageos.vnxe.models.VNXeLun) ConsistencyGroupRequests(com.emc.storageos.vnxe.requests.ConsistencyGroupRequests) HostLunModifyParam(com.emc.storageos.vnxe.models.HostLunModifyParam) LunModifyParam(com.emc.storageos.vnxe.models.LunModifyParam)

Example 5 with LunGroupModifyParam

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

the class VNXeApiClient method addLunsToLunGroup.

/**
 * Add luns to LunGroup
 */
public VNXeCommandResult addLunsToLunGroup(String lunGroupId, List<String> luns) {
    LunGroupModifyParam param = new LunGroupModifyParam();
    List<LunAddParam> lunAdds = new ArrayList<LunAddParam>();
    for (String lunId : luns) {
        VNXeBase lun = new VNXeBase(lunId);
        LunAddParam lunAdd = new LunAddParam();
        lunAdd.setLun(lun);
        lunAdds.add(lunAdd);
    }
    param.setLunAdd(lunAdds);
    LunGroupRequests req = new LunGroupRequests(_khClient);
    return req.modifyLunGroupSync(lunGroupId, param);
}
Also used : VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) LunAddParam(com.emc.storageos.vnxe.models.LunAddParam) LunGroupRequests(com.emc.storageos.vnxe.requests.LunGroupRequests) LunGroupModifyParam(com.emc.storageos.vnxe.models.LunGroupModifyParam) ArrayList(java.util.ArrayList)

Aggregations

LunGroupModifyParam (com.emc.storageos.vnxe.models.LunGroupModifyParam)13 VNXeBase (com.emc.storageos.vnxe.models.VNXeBase)13 ArrayList (java.util.ArrayList)13 ConsistencyGroupRequests (com.emc.storageos.vnxe.requests.ConsistencyGroupRequests)9 LunGroupRequests (com.emc.storageos.vnxe.requests.LunGroupRequests)9 LunParam (com.emc.storageos.vnxe.models.LunParam)7 LunAddParam (com.emc.storageos.vnxe.models.LunAddParam)6 BlockHostAccess (com.emc.storageos.vnxe.models.BlockHostAccess)5 HostLunModifyParam (com.emc.storageos.vnxe.models.HostLunModifyParam)5 LunModifyParam (com.emc.storageos.vnxe.models.LunModifyParam)5 VNXeLun (com.emc.storageos.vnxe.models.VNXeLun)5 BlockLunRequests (com.emc.storageos.vnxe.requests.BlockLunRequests)5 FastVPParam (com.emc.storageos.vnxe.models.FastVPParam)2 HostLun (com.emc.storageos.vnxe.models.HostLun)2 LunCreateParam (com.emc.storageos.vnxe.models.LunCreateParam)2 Snap (com.emc.storageos.vnxe.models.Snap)2 TieringPolicyEnum (com.emc.storageos.vnxe.models.StorageResource.TieringPolicyEnum)2 VNXeExportResult (com.emc.storageos.vnxe.models.VNXeExportResult)2 VNXeFileSystemSnap (com.emc.storageos.vnxe.models.VNXeFileSystemSnap)2 VNXeLunGroupSnap (com.emc.storageos.vnxe.models.VNXeLunGroupSnap)2