Search in sources :

Example 56 with VNXeBase

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

the class VNXeApiClient method createLunGroupSnap.

/**
 * Create lun snapshot
 *
 * @param lunID
 *            lun id
 * @param name
 *            snapshot name
 * @return VNXeCommandJob
 */
public VNXeCommandJob createLunGroupSnap(String lunGroupID, String name) {
    _logger.info("creating lun group snap:" + lunGroupID);
    LunSnapCreateParam parm = new LunSnapCreateParam();
    VNXeBase resource = new VNXeBase(lunGroupID);
    parm.setStorageResource(resource);
    parm.setName(name);
    LunGroupSnapRequests req = new LunGroupSnapRequests(_khClient);
    return req.createLunGroupSnap(parm);
}
Also used : LunGroupSnapRequests(com.emc.storageos.vnxe.requests.LunGroupSnapRequests) VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) LunSnapCreateParam(com.emc.storageos.vnxe.models.LunSnapCreateParam)

Example 57 with VNXeBase

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

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

the class VNXeApiClient method getHostLUNIds.

/**
 * Get host LUN Ids
 *
 * @param hostId
 * @return host LUN Ids
 */
public Set<String> getHostLUNIds(String hostId) {
    Set<String> lunIds = new HashSet<>();
    VNXeHost host = getHostById(hostId);
    if (host != null) {
        List<VNXeBase> hostLunIds = host.getHostLUNs();
        if (hostLunIds != null && !hostLunIds.isEmpty()) {
            for (VNXeBase hostLunId : hostLunIds) {
                HostLun hostLun = getHostLun(hostLunId.getId());
                VNXeBase vnxelunId = null;
                if (hostLun.getType() == HostLUNTypeEnum.LUN_SNAP.getValue()) {
                    vnxelunId = hostLun.getSnap();
                } else {
                    vnxelunId = hostLun.getLun();
                }
                lunIds.add(vnxelunId.getId());
            }
        }
    }
    return lunIds;
}
Also used : VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) HostLun(com.emc.storageos.vnxe.models.HostLun) VNXeHost(com.emc.storageos.vnxe.models.VNXeHost) HashSet(java.util.HashSet)

Example 59 with VNXeBase

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

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

the class VNXeApiClient method deleteLunsFromConsistencyGroup.

/**
 * Delete luns from consistency group
 *
 * @param cgId
 * @param luns
 * @return
 */
public VNXeCommandResult deleteLunsFromConsistencyGroup(String cgId, List<String> luns) {
    LunGroupModifyParam param = new LunGroupModifyParam();
    List<LunAddParam> lunDelete = new ArrayList<LunAddParam>();
    for (String lunId : luns) {
        VNXeBase lun = new VNXeBase(lunId);
        LunAddParam lunAdd = new LunAddParam();
        lunAdd.setLun(lun);
        lunDelete.add(lunAdd);
    }
    param.setLunDelete(lunDelete);
    ConsistencyGroupRequests req = new ConsistencyGroupRequests(_khClient);
    return req.modifyConsistencyGroupSync(cgId, param);
}
Also used : VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) LunAddParam(com.emc.storageos.vnxe.models.LunAddParam) LunGroupModifyParam(com.emc.storageos.vnxe.models.LunGroupModifyParam) ArrayList(java.util.ArrayList) ConsistencyGroupRequests(com.emc.storageos.vnxe.requests.ConsistencyGroupRequests)

Aggregations

VNXeBase (com.emc.storageos.vnxe.models.VNXeBase)71 ArrayList (java.util.ArrayList)39 URI (java.net.URI)17 HashMap (java.util.HashMap)14 LunGroupModifyParam (com.emc.storageos.vnxe.models.LunGroupModifyParam)13 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)12 VNXeHostInitiator (com.emc.storageos.vnxe.models.VNXeHostInitiator)11 HashSet (java.util.HashSet)11 List (java.util.List)11 StoragePort (com.emc.storageos.db.client.model.StoragePort)9 VNXeException (com.emc.storageos.vnxe.VNXeException)9 VNXeCommandJob (com.emc.storageos.vnxe.models.VNXeCommandJob)9 ConsistencyGroupRequests (com.emc.storageos.vnxe.requests.ConsistencyGroupRequests)9 LunGroupRequests (com.emc.storageos.vnxe.requests.LunGroupRequests)9 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)8 BlockHostAccess (com.emc.storageos.vnxe.models.BlockHostAccess)8 LunParam (com.emc.storageos.vnxe.models.LunParam)8 ModifyFileSystemParam (com.emc.storageos.vnxe.models.ModifyFileSystemParam)8 Initiator (com.emc.storageos.db.client.model.Initiator)7 VNXeHost (com.emc.storageos.vnxe.models.VNXeHost)7