Search in sources :

Example 26 with VNXeBase

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

the class VNXeApiClient method removeNfsShare.

/**
 * Delete nfsShare
 *
 * @param nfsShareId
 *            nfsShare Id
 * @param fsId
 *            file system Id
 * @return VNXeCommandJob
 */
public VNXeCommandJob removeNfsShare(String nfsShareId, String fsId) {
    VNXeCommandJob job = null;
    _logger.info("unexporting file system:" + fsId);
    FileSystemRequest fsRequest = new FileSystemRequest(_khClient, fsId);
    VNXeFileSystem fs = fsRequest.get();
    if (fs == null) {
        _logger.error("Could not find file system in the vxne");
        throw VNXeException.exceptions.vnxeCommandFailed("Could not find file system in the vnxe for: " + fsId);
    }
    if (nfsShareId == null || nfsShareId.isEmpty()) {
        _logger.error("NfsShareId is empty.");
        throw VNXeException.exceptions.vnxeCommandFailed("NfsShareId is empty. ");
    }
    String resourceId = fs.getStorageResource().getId();
    ModifyFileSystemParam modifyFSParm = new ModifyFileSystemParam();
    // set NfsShare delete parm
    NfsShareDeleteParam deleteParam = new NfsShareDeleteParam();
    VNXeBase share = new VNXeBase();
    share.setId(nfsShareId);
    deleteParam.setNfsShare(share);
    List<NfsShareDeleteParam> deleteList = new ArrayList<NfsShareDeleteParam>();
    deleteList.add(deleteParam);
    modifyFSParm.setNfsShareDelete(deleteList);
    FileSystemActionRequest req = new FileSystemActionRequest(_khClient);
    job = req.modifyFileSystemAsync(modifyFSParm, resourceId);
    return job;
}
Also used : VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) FileSystemRequest(com.emc.storageos.vnxe.requests.FileSystemRequest) NfsShareDeleteParam(com.emc.storageos.vnxe.models.NfsShareDeleteParam) VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) VNXeFileSystem(com.emc.storageos.vnxe.models.VNXeFileSystem) ArrayList(java.util.ArrayList) ModifyFileSystemParam(com.emc.storageos.vnxe.models.ModifyFileSystemParam) FileSystemActionRequest(com.emc.storageos.vnxe.requests.FileSystemActionRequest)

Example 27 with VNXeBase

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

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

the class VNXeApiClient method getHostLUNWWNs.

/**
 * Get host LUN WWN and HLU
 *
 * @param hostId
 * @return host LUN WWN to HLU map
 */
public Map<String, Integer> getHostLUNWWNs(String hostId) {
    Map<String, Integer> lunWWNToHLUs = new HashMap<>();
    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());
                String wwn = null;
                if (hostLun.getType() == HostLUNTypeEnum.LUN_SNAP.getValue()) {
                    VNXeBase snapId = hostLun.getSnap();
                    wwn = getSnapWWN(snapId.getId());
                } else {
                    VNXeBase lunId = hostLun.getLun();
                    VNXeLun vnxeLun = getLun(lunId.getId());
                    wwn = vnxeLun.getWwn();
                }
                lunWWNToHLUs.put(wwn, hostLun.getHlu());
            }
        }
    }
    return lunWWNToHLUs;
}
Also used : VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) HashMap(java.util.HashMap) HostLun(com.emc.storageos.vnxe.models.HostLun) VNXeLun(com.emc.storageos.vnxe.models.VNXeLun) VNXeHost(com.emc.storageos.vnxe.models.VNXeHost)

Example 29 with VNXeBase

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

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

the class ApiClientTest method getIscsiPorts.

// @Test
public void getIscsiPorts() {
    List<VNXeIscsiNode> allnodes = apiClient.getAllIscsiPorts();
    for (VNXeIscsiNode node : allnodes) {
        System.out.println("iqn: " + node.getName());
        VNXeBase sp = node.getEthernetPort().getStorageProcessorId();
        System.out.println("sp: " + sp.getId());
        if (node.getIscsiPortal() != null) {
            System.out.println("ip: " + node.getIscsiPortal().getIpAddress());
        }
    }
}
Also used : VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) VNXeIscsiNode(com.emc.storageos.vnxe.models.VNXeIscsiNode)

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