Search in sources :

Example 6 with VNXeFileSystemSnap

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

the class VNXeApiClient method createNfsShareForSnap.

/**
 * Create Nfs share for snapshot
 *
 * @param snapId
 *            snapshot id
 * @param endpoints
 *            hosts
 * @param access
 *            READ, WRITE, ROOT
 * @param path
 * @param exportKey
 * @return VNXeCommandJob
 * @throws VNXeException
 */
public VNXeCommandJob createNfsShareForSnap(String snapId, List<String> roEndpoints, List<String> rwEndpoints, List<String> rootEndpoints, AccessEnum access, String path, String shareName, String comments) throws VNXeException {
    _logger.info("creating nfs share for the snap: " + snapId);
    NfsShareRequests request = new NfsShareRequests(_khClient);
    String softwareVersion = getBasicSystemInfo().getSoftwareVersion();
    FileSystemSnapRequests req = new FileSystemSnapRequests(_khClient, softwareVersion);
    VNXeFileSystemSnap snapshot = req.getFileSystemSnap(snapId, softwareVersion);
    if (snapshot == null) {
        _logger.info("Could not find snapshot in the vxne");
        throw VNXeException.exceptions.vnxeCommandFailed("Could not find snapshot in the vnxe for: " + snapId);
    }
    NfsShareCreateForSnapParam nfsCreateParam = new NfsShareCreateForSnapParam();
    VNXeBase snap = new VNXeBase(snapId);
    if (!VNXeUtils.isHigherVersion(softwareVersion, VNXeConstants.VNXE_BASE_SOFT_VER)) {
        nfsCreateParam.setFilesystemSnap(snap);
    } else {
        nfsCreateParam.setSnap(snap);
    }
    List<VNXeBase> roHosts = getHosts(roEndpoints);
    List<VNXeBase> rwHosts = getHosts(rwEndpoints);
    List<VNXeBase> rootHosts = getHosts(rootEndpoints);
    VNXeCommandJob job = null;
    VNXeNfsShare nfsShareFound = request.findSnapNfsShare(snapId, shareName, softwareVersion);
    if (nfsShareFound == null) {
        // new export
        nfsCreateParam.setReadOnlyHosts(roHosts);
        nfsCreateParam.setReadWriteHosts(rwHosts);
        nfsCreateParam.setRootAccessHosts(rootHosts);
        nfsCreateParam.setName(shareName);
        nfsCreateParam.setPath(path);
        if (comments != null) {
            nfsCreateParam.setDescription(comments);
        }
        request.unsetQueryParameters();
        job = request.createShareForSnapshot(nfsCreateParam);
    } else {
        String nfsShareId = nfsShareFound.getId();
        NFSShareDefaultAccessEnum nfsShareDefaultAccess = nfsShareFound.getDefaultAccess();
        NfsShareModifyForShareParam nfsModifyParam = new NfsShareModifyForShareParam();
        List<VNXeBase> hosts = new ArrayList<VNXeBase>();
        nfsModifyParam.setReadOnlyHosts(roHosts);
        nfsModifyParam.setReadWriteHosts(rwHosts);
        nfsModifyParam.setRootAccessHosts(rootHosts);
        if (comments != null) {
            nfsModifyParam.setDescription(comments);
        }
        if (access == null) {
            if (nfsShareFound != null) {
                hosts.addAll(nfsShareFound.getNoAccessHosts());
                hosts.addAll(nfsShareFound.getRootAccessHosts());
                hosts.addAll(nfsShareFound.getReadWriteHosts());
                hosts.addAll(nfsShareFound.getReadOnlyHosts());
            }
            if (nfsShareDefaultAccess.equals(NFSShareDefaultAccessEnum.ROOT)) {
                if (!hosts.isEmpty()) {
                    nfsModifyParam.setRootAccessHosts(hosts);
                } else {
                    nfsModifyParam.setRootAccessHosts(null);
                }
                nfsModifyParam.setNoAccessHosts(null);
                nfsModifyParam.setReadWriteHosts(null);
                nfsModifyParam.setReadOnlyHosts(null);
            } else if (nfsShareDefaultAccess.equals(NFSShareDefaultAccessEnum.READONLY)) {
                if (!hosts.isEmpty()) {
                    nfsModifyParam.setReadOnlyHosts(hosts);
                } else {
                    nfsModifyParam.setReadOnlyHosts(null);
                }
                nfsModifyParam.setNoAccessHosts(null);
                nfsModifyParam.setReadWriteHosts(null);
                nfsModifyParam.setRootAccessHosts(null);
            } else if (nfsShareDefaultAccess.equals(NFSShareDefaultAccessEnum.READWRITE)) {
                if (!hosts.isEmpty()) {
                    nfsModifyParam.setReadWriteHosts(hosts);
                } else {
                    nfsModifyParam.setReadWriteHosts(null);
                }
                nfsModifyParam.setNoAccessHosts(null);
                nfsModifyParam.setReadOnlyHosts(null);
                nfsModifyParam.setRootAccessHosts(null);
            } else if (nfsShareDefaultAccess.equals(NFSShareDefaultAccessEnum.NONE)) {
                if (!hosts.isEmpty()) {
                    nfsModifyParam.setNoAccessHosts(hosts);
                } else {
                    nfsModifyParam.setNoAccessHosts(null);
                }
                nfsModifyParam.setReadWriteHosts(null);
                nfsModifyParam.setReadOnlyHosts(null);
                nfsModifyParam.setRootAccessHosts(null);
            }
        }
        request.unsetQueryParameters();
        job = request.modifyShareForSnapshot(nfsShareId, nfsModifyParam);
    }
    return job;
}
Also used : VNXeFileSystemSnap(com.emc.storageos.vnxe.models.VNXeFileSystemSnap) VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) FileSystemSnapRequests(com.emc.storageos.vnxe.requests.FileSystemSnapRequests) VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) NfsShareRequests(com.emc.storageos.vnxe.requests.NfsShareRequests) NFSShareDefaultAccessEnum(com.emc.storageos.vnxe.models.NfsShareParam.NFSShareDefaultAccessEnum) NfsShareModifyForShareParam(com.emc.storageos.vnxe.models.NfsShareModifyForShareParam) VNXeNfsShare(com.emc.storageos.vnxe.models.VNXeNfsShare) ArrayList(java.util.ArrayList) NfsShareCreateForSnapParam(com.emc.storageos.vnxe.models.NfsShareCreateForSnapParam)

Example 7 with VNXeFileSystemSnap

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

the class VNXeCreateFileSystemSnapshotJob method updateSnapshot.

/**
 * update snapshot
 *
 * @param fsId fileShare uri in vipr
 * @param dbClient DbClient
 * @param logMsgBuilder string builder for logging
 * @param vnxeApiClient VNXeApiClient
 */
private void updateSnapshot(Snapshot snapObj, DbClient dbClient, StringBuilder logMsgBuilder, VNXeApiClient vnxeApiClient) {
    VNXeFileSystemSnap vnxeSnap = null;
    vnxeSnap = vnxeApiClient.getSnapshotByName(snapObj.getName());
    if (vnxeSnap != null) {
        snapObj.setInactive(false);
        snapObj.setCreationTime(Calendar.getInstance());
        snapObj.setNativeId(vnxeSnap.getId());
        String path = "/" + snapObj.getName();
        // Set path & mountpath
        snapObj.setMountPath(path);
        snapObj.setPath(path);
        try {
            snapObj.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(dbClient, snapObj));
        } catch (IOException e) {
            logMsgBuilder.append("/n");
            logMsgBuilder.append("Exception while setting snapshot's nativeGuid");
            logMsgBuilder.append(e.getMessage());
        }
        logMsgBuilder.append("/n");
        logMsgBuilder.append(String.format("Create file system snapshot successfully for NativeId: %s, URI: %s", snapObj.getNativeId(), getTaskCompleter().getId()));
        dbClient.persistObject(snapObj);
    } else {
        logMsgBuilder.append("Could not get newly created snapshot in the VNXe, using the snapshot name: ");
        logMsgBuilder.append(snapObj.getName());
    }
}
Also used : VNXeFileSystemSnap(com.emc.storageos.vnxe.models.VNXeFileSystemSnap) IOException(java.io.IOException)

Example 8 with VNXeFileSystemSnap

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

the class FileSystemSnapRequests method getByName.

/**
 * Get snapshot details by its name
 *
 * @param name
 * @return
 */
public VNXeFileSystemSnap getByName(String name) {
    MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
    queryParams.add(VNXeConstants.FILTER, VNXeConstants.NAME_FILTER + "\"" + name + "\"");
    setQueryParameters(queryParams);
    VNXeFileSystemSnap result = null;
    List<VNXeFileSystemSnap> snapList = getDataForObjects(VNXeFileSystemSnap.class);
    // it should just return 1
    if (snapList != null && !snapList.isEmpty()) {
        result = snapList.get(0);
        _logger.info("file system snapshot found using the name: " + name);
    } else {
        _logger.info("No file system snapshot found using the name: " + name);
    }
    return result;
}
Also used : VNXeFileSystemSnap(com.emc.storageos.vnxe.models.VNXeFileSystemSnap) MultivaluedMapImpl(com.sun.jersey.core.util.MultivaluedMapImpl)

Aggregations

VNXeFileSystemSnap (com.emc.storageos.vnxe.models.VNXeFileSystemSnap)8 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)3 VNXeException (com.emc.storageos.vnxe.VNXeException)3 VNXeNfsShare (com.emc.storageos.vnxe.models.VNXeNfsShare)3 VNXeCifsShare (com.emc.storageos.vnxe.models.VNXeCifsShare)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)1 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 FileShare (com.emc.storageos.db.client.model.FileShare)1 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 OpStatusMap (com.emc.storageos.db.client.model.OpStatusMap)1 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)1 Snapshot (com.emc.storageos.db.client.model.Snapshot)1 StringMap (com.emc.storageos.db.client.model.StringMap)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 NfsShareCreateForSnapParam (com.emc.storageos.vnxe.models.NfsShareCreateForSnapParam)1 NfsShareModifyForShareParam (com.emc.storageos.vnxe.models.NfsShareModifyForShareParam)1 NFSShareDefaultAccessEnum (com.emc.storageos.vnxe.models.NfsShareParam.NFSShareDefaultAccessEnum)1 VNXeBase (com.emc.storageos.vnxe.models.VNXeBase)1