Search in sources :

Example 6 with BlockLunRequests

use of com.emc.storageos.vnxe.requests.BlockLunRequests in project coprhd-controller by CoprHD.

the class VNXeApiClient method unexportLun.

/**
 * remove the hosts from the hostAccess list from the lun
 *
 * @param host
 * @param lunId
 */
public void unexportLun(String hostId, String lunId) {
    _logger.info("Unexporting lun: {}", lunId);
    if (!checkLunExists(lunId)) {
        _logger.info("The lun {} does not exist, do nothing", lunId);
        return;
    }
    VNXeLun lun = getLun(lunId);
    if (lun == null) {
        _logger.info("Could not find lun in the vxne: {}", lunId);
        return;
    }
    List<BlockHostAccess> hostAccesses = lun.getHostAccess();
    if (hostAccesses == null || hostAccesses.isEmpty()) {
        _logger.info("No block host access found for the lun: {}", lunId);
        return;
    }
    List<BlockHostAccess> changedHostAccessList = new ArrayList<BlockHostAccess>();
    for (BlockHostAccess hostAccess : hostAccesses) {
        if (hostId.equals(hostAccess.getHost().getId())) {
            if (hostAccess.getAccessMask() == HostLUNAccessEnum.BOTH.getValue()) {
                hostAccess.setAccessMask(HostLUNAccessEnum.SNAPSHOT.getValue());
            } else if (hostAccess.getAccessMask() == HostLUNAccessEnum.PRODUCTION.getValue()) {
                hostAccess.setAccessMask(HostLUNAccessEnum.NOACCESS.getValue());
            }
        }
        changedHostAccessList.add(hostAccess);
    }
    if (changedHostAccessList.isEmpty()) {
        // the removing hosts are not exported
        _logger.info("The unexport hosts were not exported.");
        return;
    }
    LunParam lunParam = new LunParam();
    lunParam.setHostAccess(changedHostAccessList);
    LunModifyParam modifyParam = new LunModifyParam();
    modifyParam.setLunParameters(lunParam);
    int type = lun.getType();
    if (type == VNXeLun.LUNTypeEnum.Standalone.getValue()) {
        // if standalone lun
        BlockLunRequests lunReq = new BlockLunRequests(_khClient);
        lunReq.modifyLunSync(modifyParam, lun.getStorageResource().getId());
    } else {
        // lun in a lun group
        modifyParam.setLun(new VNXeBase(lunId));
        List<LunModifyParam> list = new ArrayList<LunModifyParam>();
        list.add(modifyParam);
        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);
        }
    }
    _logger.info("Done unexporting lun: {}", lunId);
}
Also used : ArrayList(java.util.ArrayList) LunGroupModifyParam(com.emc.storageos.vnxe.models.LunGroupModifyParam) ConsistencyGroupRequests(com.emc.storageos.vnxe.requests.ConsistencyGroupRequests) 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 7 with BlockLunRequests

use of com.emc.storageos.vnxe.requests.BlockLunRequests in project coprhd-controller by CoprHD.

the class VNXeApiClient method getLunByStorageResourceId.

/**
 * get lun based on storage resource Id
 */
public List<VNXeLun> getLunByStorageResourceId(String storageResourceId) {
    _logger.info("getting lun by the storage resource id: " + storageResourceId);
    BlockLunRequests req = new BlockLunRequests(_khClient);
    return req.getByStorageResourceId(storageResourceId);
}
Also used : BlockLunRequests(com.emc.storageos.vnxe.requests.BlockLunRequests)

Example 8 with BlockLunRequests

use of com.emc.storageos.vnxe.requests.BlockLunRequests 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)

Example 9 with BlockLunRequests

use of com.emc.storageos.vnxe.requests.BlockLunRequests in project coprhd-controller by CoprHD.

the class VNXeApiClient method deleteConsistencyGroup.

/**
 * Delete Consistency group.
 * if isForceVolumeDeletion is true, it would delete all the volumes in the Consistency group
 * and the Consistency group.
 * if isForceVolumeDeletion is false, it would remove all the volumes from the Consistency group,
 * then delete the Consistency group.
 *
 * @param cgId
 * @param isForceSnapDeletion
 *            if to delete snaps
 * @param isForceVolumeDeletion
 *            if to delete all volumes in the CG
 * @return
 */
public VNXeCommandResult deleteConsistencyGroup(String cgId, boolean isForceSnapDeletion, boolean isForceVolumeDeletion) {
    if (isForceVolumeDeletion) {
        DeleteStorageResourceRequest deleteReq = new DeleteStorageResourceRequest(_khClient);
        return deleteReq.deleteLunGroup(cgId, isForceSnapDeletion);
    } else {
        BlockLunRequests lunReq = new BlockLunRequests(_khClient);
        List<VNXeLun> luns = lunReq.getLunsInLunGroup(cgId);
        if (luns != null && !luns.isEmpty()) {
            List<String> lunIds = new ArrayList<String>();
            for (VNXeLun lun : luns) {
                lunIds.add(lun.getId());
            }
            removeLunsFromConsistencyGroup(cgId, lunIds);
        }
        DeleteStorageResourceRequest deleteReq = new DeleteStorageResourceRequest(_khClient);
        return deleteReq.deleteLunGroup(cgId, isForceSnapDeletion);
    }
}
Also used : DeleteStorageResourceRequest(com.emc.storageos.vnxe.requests.DeleteStorageResourceRequest) BlockLunRequests(com.emc.storageos.vnxe.requests.BlockLunRequests) ArrayList(java.util.ArrayList) VNXeLun(com.emc.storageos.vnxe.models.VNXeLun)

Aggregations

BlockLunRequests (com.emc.storageos.vnxe.requests.BlockLunRequests)9 VNXeLun (com.emc.storageos.vnxe.models.VNXeLun)7 ArrayList (java.util.ArrayList)7 LunParam (com.emc.storageos.vnxe.models.LunParam)6 VNXeBase (com.emc.storageos.vnxe.models.VNXeBase)6 HostLunModifyParam (com.emc.storageos.vnxe.models.HostLunModifyParam)5 LunGroupModifyParam (com.emc.storageos.vnxe.models.LunGroupModifyParam)5 LunModifyParam (com.emc.storageos.vnxe.models.LunModifyParam)5 ConsistencyGroupRequests (com.emc.storageos.vnxe.requests.ConsistencyGroupRequests)5 LunGroupRequests (com.emc.storageos.vnxe.requests.LunGroupRequests)5 BlockHostAccess (com.emc.storageos.vnxe.models.BlockHostAccess)4 HostLun (com.emc.storageos.vnxe.models.HostLun)2 Snap (com.emc.storageos.vnxe.models.Snap)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 VNXeLunSnap (com.emc.storageos.vnxe.models.VNXeLunSnap)2 DeleteStorageResourceRequest (com.emc.storageos.vnxe.requests.DeleteStorageResourceRequest)2 HostLunRequests (com.emc.storageos.vnxe.requests.HostLunRequests)2 FastVPParam (com.emc.storageos.vnxe.models.FastVPParam)1