Search in sources :

Example 21 with FSExportMap

use of com.emc.storageos.db.client.model.FSExportMap in project coprhd-controller by CoprHD.

the class VNXeUnexportFileSystemJob method updateFSExport.

/**
 * update FileShare after unexport finished in vnxe
 *
 * @param fsOjb fileShare object in vipr
 * @param dbClient DbClient
 * @param vnxeApiClient VNXeApiClient
 */
private void updateFSExport(FileShare fsObj, DbClient dbClient, VNXeApiClient apiClient) {
    _logger.info("upading file export. ");
    FSExportMap exports = fsObj.getFsExports();
    if (exports == null) {
        _logger.info("No exports found in the file system. ");
        return;
    }
    if (exportInfo != null) {
        FileExport export = exportInfo.getFileExport();
        FileExport existExport = exports.get(export.getFileExportKey());
        if (existExport != null) {
            exports.remove(existExport.getFileExportKey());
            dbClient.persistObject(fsObj);
        }
    }
}
Also used : FileExport(com.emc.storageos.db.client.model.FileExport) FSExportMap(com.emc.storageos.db.client.model.FSExportMap)

Example 22 with FSExportMap

use of com.emc.storageos.db.client.model.FSExportMap in project coprhd-controller by CoprHD.

the class NetAppClusterModeDevice method doExport.

@Override
public BiosCommandResult doExport(StorageSystem storage, FileDeviceInputOutput args, List<FileExport> exportList) throws ControllerException {
    _log.info("NetAppClusterModeDevice doExport - start");
    // Verify inputs.
    validateExportArgs(exportList);
    List<String> rootHosts = new ArrayList<String>();
    List<String> rwHosts = new ArrayList<String>();
    List<String> roHosts = new ArrayList<String>();
    BiosCommandResult result = new BiosCommandResult();
    if (args.getFileObjExports() == null || args.getFileObjExports().isEmpty()) {
        args.initFileObjExports();
    }
    FSExportMap existingExpMap = args.getFileObjExports();
    List<FileExport> existingExportList = new ArrayList<FileExport>();
    FileExport existingExport = null;
    Iterator<String> it = existingExpMap.keySet().iterator();
    while (it.hasNext()) {
        existingExport = existingExpMap.get(it.next());
        if (existingExport.getMountPath().equals(args.getFsMountPath())) {
            _log.info("Existing export FileExport key : {} ", existingExport.getFileExportKey());
            existingExportList.add(existingExport);
        }
    }
    // If it's a sub-directory no need to take existing hosts.
    boolean isSubDir = checkIfSubDirectory(args.getFsMountPath(), exportList.get(0).getMountPath());
    if (isSubDir) {
        existingExportList = null;
        if (exportList.get(0).getMountPath().contains(SNAPSHOT)) {
            _log.error("NetAppClusterModeDevice::doExport {} : Snapshot export is not Supported", args.getSnapshotId());
            ServiceError serviceError = DeviceControllerErrors.netappc.unableToExportSnapshot();
            serviceError.setMessage(genDetailedMessage("doExport", args.getSnapshotId().toString(), "Snapshot export is not Supported"));
            result = BiosCommandResult.createErrorResult(serviceError);
            return result;
        }
    }
    // TODO: Revisit once new Data Model for Exports is implemented.
    Map<String, List<String>> existingHosts = null;
    if ((null != existingExportList) && (!existingExportList.isEmpty())) {
        existingHosts = sortHostsFromCurrentExports(existingExportList);
    }
    if (null != existingHosts) {
        if ((null != existingHosts.get(ROOT_HOSTS)) && (!existingHosts.get(ROOT_HOSTS).isEmpty())) {
            addNewHostsOnly(rootHosts, existingHosts.get(ROOT_HOSTS));
        }
        if ((null != existingHosts.get(RW_HOSTS)) && (!existingHosts.get(RW_HOSTS).isEmpty())) {
            addNewHostsOnly(rwHosts, existingHosts.get(RW_HOSTS));
        }
        if ((null != existingHosts.get(RO_HOSTS)) && (!existingHosts.get(RO_HOSTS).isEmpty())) {
            addNewHostsOnly(roHosts, existingHosts.get(RO_HOSTS));
        }
    }
    try {
        for (int expCount = 0; expCount < exportList.size(); expCount++) {
            FileExport export = exportList.get(expCount);
            FileExport fileExport = new FileExport(export.getClients(), export.getStoragePortName(), export.getMountPoint(), export.getSecurityType(), export.getPermissions(), export.getRootUserMapping(), export.getProtocol(), export.getStoragePort(), export.getPath(), export.getMountPath(), export.getSubDirectory(), export.getComments());
            String portGroup = null;
            FileShare fileshare = null;
            if (args.getFileOperation() == true) {
                fileshare = args.getFs();
                portGroup = findSVMName(fileshare);
            } else {
                _log.error("NetAppClusterModeDevice::doExport {} : Snapshot export is not Supported", args.getFsId());
                ServiceError serviceError = DeviceControllerErrors.netappc.unableToExportSnapshot();
                serviceError.setMessage(genDetailedMessage("doExport", args.getSnapshotId().toString(), "Snapshot export is not Supported"));
                result = BiosCommandResult.createErrorResult(serviceError);
                return result;
            }
            NetAppClusterApi ncApi = new NetAppClusterApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).svm(portGroup).build();
            List<String> endpointsList = export.getClients();
            if (endpointsList == null) {
                _log.error("NetAppClusterModeDevice::doExport {} failed:  No endpoints specified", args.getFsId());
                ServiceError serviceError = DeviceControllerErrors.netappc.unableToExportFileSystem();
                serviceError.setMessage(FileSystemConstants.FS_ERR_NO_ENDPOINTS_SPECIFIED);
                result = BiosCommandResult.createErrorResult(serviceError);
                return result;
            }
            sortNewEndPoints(rootHosts, rwHosts, roHosts, endpointsList, export.getPermissions());
            String root_user = export.getRootUserMapping();
            String mountPath = export.getMountPath();
            String exportPath = export.getPath();
            String fsName = fileshare.getName();
            String qtreeName = null;
            if (isSubDir) {
                if (ncApi.isQtree(fileshare.getName(), export.getSubDirectory())) {
                    qtreeName = export.getSubDirectory();
                    exportPath = constructQtreePath(fileshare.getName(), export.getSubDirectory());
                } else {
                    _log.error("NetAppClusterModeDevice::doExport {} : Sub-directory export is not Supported", args.getFsId());
                    ServiceError serviceError = DeviceControllerErrors.netappc.unableToExportFileSystem();
                    serviceError.setMessage(genDetailedMessage("doExport", args.getFsId().toString(), "Sub-directory export is not Supported"));
                    result = BiosCommandResult.createErrorResult(serviceError);
                    return result;
                }
            }
            if (!ncApi.exportFS(fsName, qtreeName, exportPath, mountPath, rootHosts, rwHosts, roHosts, root_user, export.getSecurityType())) {
                _log.error("NetAppClusterModeDevice::doExport {} failed", args.getFsId());
                ServiceError serviceError = DeviceControllerErrors.netappc.unableToExportFileSystem();
                serviceError.setMessage(genDetailedMessage("doExport", args.getFsId().toString()));
                result = BiosCommandResult.createErrorResult(serviceError);
                return result;
            }
            args.getFileObjExports().put(fileExport.getFileExportKey(), fileExport);
            result = BiosCommandResult.createSuccessfulResult();
        }
    } catch (NetAppCException e) {
        _log.error("NetAppClusterModeDevice::doExport failed with a NetAppCException", e);
        ServiceError serviceError = DeviceControllerErrors.netappc.unableToExportFileSystem();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    } catch (Exception e) {
        _log.error("NetAppClusterModeDevice::doExport failed with an Exception", e);
        ServiceError serviceError = DeviceControllerErrors.netappc.unableToExportFileSystem();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    }
    _log.info("NetAppClusterModeDevice::doExport {} - complete", args.getFsId());
    return result;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ArrayList(java.util.ArrayList) FSExportMap(com.emc.storageos.db.client.model.FSExportMap) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) ControllerException(com.emc.storageos.volumecontroller.ControllerException) NetAppCException(com.emc.storageos.netappc.NetAppCException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) NetAppException(com.emc.storageos.netapp.NetAppException) NetAppClusterApi(com.emc.storageos.netappc.NetAppClusterApi) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) NetAppCException(com.emc.storageos.netappc.NetAppCException) FileExport(com.emc.storageos.db.client.model.FileExport) ArrayList(java.util.ArrayList) List(java.util.List)

Example 23 with FSExportMap

use of com.emc.storageos.db.client.model.FSExportMap in project coprhd-controller by CoprHD.

the class VNXeExportFileSystemJob method updateFSExport.

/**
 * update FileShare after exported in VNXe
 *
 * @param fsOjb fileShare object in vipr
 * @param dbClient DbClient
 * @param vnxeApiClient VNXeApiClient
 */
private void updateFSExport(FileShare fsObj, DbClient dbClient, VNXeApiClient apiClient, FileExport newExport) {
    _logger.info("upading file export. ");
    FSExportMap exports = fsObj.getFsExports();
    if (exports == null) {
        exports = new FSExportMap();
    }
    VNXeNfsShare nfsShare = apiClient.findNfsShare(fsObj.getNativeId(), shareName);
    String nfsShareId = nfsShare.getId();
    newExport.setIsilonId(nfsShareId);
    exports.put(newExport.getFileExportKey(), newExport);
    fsObj.setFsExports(exports);
    updateExportRules(fsObj.getId(), newExport, dbClient);
    dbClient.persistObject(fsObj);
}
Also used : VNXeNfsShare(com.emc.storageos.vnxe.models.VNXeNfsShare) FSExportMap(com.emc.storageos.db.client.model.FSExportMap)

Example 24 with FSExportMap

use of com.emc.storageos.db.client.model.FSExportMap in project coprhd-controller by CoprHD.

the class VNXeExportFileSystemJob method updateSnapExport.

/**
 * update snapshot if the export job is for snapshot export
 *
 * @param dbClient
 * @param apiClient
 * @return Snapshot instance
 */
private Snapshot updateSnapExport(DbClient dbClient, VNXeApiClient apiClient, FileExport newExport) {
    _logger.info("upading snap export. ");
    URI snapId = getTaskCompleter().getId();
    Snapshot snapObj = dbClient.queryObject(Snapshot.class, snapId);
    FSExportMap exports = snapObj.getFsExports();
    if (exports == null) {
        exports = new FSExportMap();
    }
    VNXeNfsShare nfsShare = apiClient.findSnapNfsShare(snapObj.getNativeId(), shareName);
    String nfsShareId = nfsShare.getId();
    newExport.setIsilonId(nfsShareId);
    exports.put(newExport.getFileExportKey(), newExport);
    snapObj.setFsExports(exports);
    updateExportRules(snapObj.getId(), newExport, dbClient);
    dbClient.persistObject(snapObj);
    return snapObj;
}
Also used : Snapshot(com.emc.storageos.db.client.model.Snapshot) VNXeNfsShare(com.emc.storageos.vnxe.models.VNXeNfsShare) FSExportMap(com.emc.storageos.db.client.model.FSExportMap) URI(java.net.URI)

Example 25 with FSExportMap

use of com.emc.storageos.db.client.model.FSExportMap in project coprhd-controller by CoprHD.

the class VNXeModifyExportJob method updateSnapshotExport.

private void updateSnapshotExport(Snapshot snapObj, DbClient dbClient, FileExport newExport) {
    _logger.info("updating file export. ");
    FSExportMap exports = snapObj.getFsExports();
    if (exports == null) {
        exports = new FSExportMap();
    }
    FileExport exportToBeUpdated = exports.get(newExport.getFileExportKey());
    if (exportToBeUpdated != null) {
        List<String> clients = new ArrayList<String>();
        if (rule.getReadOnlyHosts() != null) {
            clients.addAll(rule.getReadOnlyHosts());
        }
        if (rule.getReadWriteHosts() != null) {
            clients.addAll(rule.getReadWriteHosts());
        }
        if (rule.getRootHosts() != null) {
            clients.addAll(rule.getRootHosts());
        }
        exportToBeUpdated.setClients(clients);
        exports.put(newExport.getFileExportKey(), exportToBeUpdated);
        snapObj.setFsExports(exports);
        dbClient.persistObject(snapObj);
    }
}
Also used : FileExport(com.emc.storageos.db.client.model.FileExport) ArrayList(java.util.ArrayList) FSExportMap(com.emc.storageos.db.client.model.FSExportMap)

Aggregations

FSExportMap (com.emc.storageos.db.client.model.FSExportMap)46 FileExport (com.emc.storageos.db.client.model.FileExport)33 ArrayList (java.util.ArrayList)22 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)20 FileShare (com.emc.storageos.db.client.model.FileShare)18 SMBShareMap (com.emc.storageos.db.client.model.SMBShareMap)15 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)12 ControllerException (com.emc.storageos.volumecontroller.ControllerException)12 Snapshot (com.emc.storageos.db.client.model.Snapshot)11 URI (java.net.URI)11 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)10 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)9 WorkflowException (com.emc.storageos.workflow.WorkflowException)7 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)6 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)6 FileShareExport (com.emc.storageos.volumecontroller.FileShareExport)6 List (java.util.List)6 Path (javax.ws.rs.Path)6 Produces (javax.ws.rs.Produces)6 FileExportRule (com.emc.storageos.db.client.model.FileExportRule)5