Search in sources :

Example 11 with VNXeFileTaskCompleter

use of com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFileTaskCompleter in project coprhd-controller by CoprHD.

the class VNXUnityFileStorageDevice method deleteExportRules.

@Override
public BiosCommandResult deleteExportRules(StorageSystem storage, FileDeviceInputOutput args) {
    List<ExportRule> allExports = args.getExistingDBExportRules();
    String subDir = args.getSubDirectory();
    boolean allDirs = args.isAllDir();
    VNXeCommandJob job = null;
    VNXeFileTaskCompleter completer = null;
    boolean isFile = args.getFileOperation();
    boolean ifRulePresent = false;
    String exportPath;
    String subDirExportPath = "";
    subDir = args.getSubDirectory();
    if (!args.getFileOperation()) {
        exportPath = args.getSnapshotPath();
        if (subDir != null && subDir.length() > 0) {
            subDirExportPath = args.getSnapshotPath() + "/" + subDir;
        }
    } else {
        exportPath = args.getFs().getPath();
        if (subDir != null && subDir.length() > 0) {
            subDirExportPath = args.getFs().getPath() + "/" + subDir;
        }
    }
    _logger.info("exportPath : {}", exportPath);
    args.setExportPath(exportPath);
    _logger.info("Number of existing exports found {}", allExports.size());
    try {
        VNXeApiClient apiClient = getVnxUnityClient(storage);
        if (allDirs) {
            // ALL EXPORTS
            _logger.info("Deleting all exports specific to filesystem at device and rules from DB including sub dirs rules and exports");
            for (ExportRule rule : allExports) {
                FileShareExport fsExport = null;
                if (args.getFileObjExports() != null) {
                    Collection<FileExport> expList = args.getFileObjExports().values();
                    Iterator<FileExport> it = expList.iterator();
                    FileExport exp = null;
                    while (it.hasNext()) {
                        FileExport export = it.next();
                        if (export.getPath().equalsIgnoreCase(rule.getExportPath())) {
                            exp = export;
                        }
                    }
                    fsExport = new FileShareExport(exp);
                }
                String vnxeShareId = rule.getDeviceExportId();
                _logger.info("Delete UnityExport id {} for path {}", rule.getDeviceExportId(), rule.getExportPath());
                if (isFile) {
                    String fsId = args.getFs().getNativeId();
                    job = apiClient.removeNfsShare(vnxeShareId, fsId);
                } else {
                    job = apiClient.deleteNfsShareForSnapshot(vnxeShareId);
                }
                if (job != null) {
                    if (isFile) {
                        completer = new VNXeFileTaskCompleter(FileShare.class, args.getFsId(), args.getOpId());
                    } else {
                        completer = new VNXeFileTaskCompleter(Snapshot.class, args.getSnapshotId(), args.getOpId());
                    }
                    VNXeUnexportFileSystemJob unexportFSJob = new VNXeUnexportFileSystemJob(job.getId(), storage.getId(), completer, fsExport, rule.getExportPath(), isFile);
                    ControllerServiceImpl.enqueueJob(new QueueJob(unexportFSJob));
                } else {
                    _logger.error("No job returned from exportFileSystem");
                    ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeleteFileSystem", "No Job returned from deleteFileSystem");
                    return BiosCommandResult.createErrorResult(error);
                }
            }
        } else if (subDir != null && !subDir.isEmpty()) {
            // Filter for a specific Sub Directory export
            _logger.info("Deleting all subdir exports rules at ViPR and  sub directory export at device {}", subDir);
            FileShareExport fsExport = null;
            String vnxeShareId = null;
            if (args.getFileObjExports() != null) {
                Collection<FileExport> expList = args.getFileObjExports().values();
                Iterator<FileExport> it = expList.iterator();
                FileExport exp = null;
                while (it.hasNext()) {
                    FileExport export = it.next();
                    if (export.getPath().equalsIgnoreCase(subDirExportPath)) {
                        exp = export;
                        break;
                    }
                }
                fsExport = new FileShareExport(exp);
            }
            for (ExportRule rule : allExports) {
                _logger.info("Delete UnityExport id for path {} f containing subdirectory {}", rule.getDeviceExportId() + ":" + rule.getExportPath(), subDir);
                if (rule.getExportPath().equalsIgnoreCase(subDirExportPath)) {
                    ifRulePresent = true;
                    vnxeShareId = rule.getDeviceExportId();
                }
            }
            if (!ifRulePresent) {
                if (fsExport != null) {
                    vnxeShareId = fsExport.getIsilonId();
                }
            }
            _logger.info("Delete UnityExport id {} for path {}", vnxeShareId, subDirExportPath);
            if (isFile) {
                String fsId = args.getFs().getNativeId();
                job = apiClient.removeNfsShare(vnxeShareId, fsId);
            } else {
                job = apiClient.deleteNfsShareForSnapshot(vnxeShareId);
            }
            if (job != null) {
                if (isFile) {
                    completer = new VNXeFileTaskCompleter(FileShare.class, args.getFsId(), args.getOpId());
                } else {
                    completer = new VNXeFileTaskCompleter(Snapshot.class, args.getSnapshotId(), args.getOpId());
                }
                VNXeUnexportFileSystemJob unexportFSJob = new VNXeUnexportFileSystemJob(job.getId(), storage.getId(), completer, fsExport, subDirExportPath, isFile);
                ControllerServiceImpl.enqueueJob(new QueueJob(unexportFSJob));
            } else {
                _logger.error("No job returned from exportFileSystem");
                ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeleteFileSystem", "No Job returned from deleteFileSystem");
                return BiosCommandResult.createErrorResult(error);
            }
        } else {
            // Filter for No SUBDIR - main export rules with no sub dirs
            _logger.info("Deleting all export rules  from DB and export at device not included sub dirs");
            FileShareExport fsExport = null;
            String vnxeShareId = null;
            if (args.getFileObjExports() != null) {
                Collection<FileExport> expList = args.getFileObjExports().values();
                Iterator<FileExport> it = expList.iterator();
                FileExport exp = null;
                while (it.hasNext()) {
                    FileExport export = it.next();
                    if (export.getPath().equalsIgnoreCase(exportPath)) {
                        exp = export;
                        break;
                    }
                }
                fsExport = new FileShareExport(exp);
            }
            for (ExportRule rule : allExports) {
                if (rule.getExportPath().equalsIgnoreCase(exportPath)) {
                    ifRulePresent = true;
                    vnxeShareId = rule.getDeviceExportId();
                }
            }
            if (!ifRulePresent) {
                if (fsExport != null) {
                    vnxeShareId = fsExport.getIsilonId();
                }
            }
            _logger.info("Delete UnityExport id {} for path {}", vnxeShareId, fsExport.getPath());
            if (isFile) {
                String fsId = args.getFs().getNativeId();
                job = apiClient.removeNfsShare(vnxeShareId, fsId);
            } else {
                job = apiClient.deleteNfsShareForSnapshot(vnxeShareId);
            }
            if (job != null) {
                if (isFile) {
                    completer = new VNXeFileTaskCompleter(FileShare.class, args.getFsId(), args.getOpId());
                } else {
                    completer = new VNXeFileTaskCompleter(Snapshot.class, args.getSnapshotId(), args.getOpId());
                }
                VNXeUnexportFileSystemJob unexportFSJob = new VNXeUnexportFileSystemJob(job.getId(), storage.getId(), completer, fsExport, fsExport.getPath(), isFile);
                ControllerServiceImpl.enqueueJob(new QueueJob(unexportFSJob));
            } else {
                _logger.error("No job returned from exportFileSystem");
                ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeleteFileSystem", "No Job returned from deleteFileSystem");
                return BiosCommandResult.createErrorResult(error);
            }
        }
    } catch (VNXeException e) {
        _logger.error("Unexport file system got the exception", e);
        if (completer != null) {
            completer.error(dbClient, e);
        }
        return BiosCommandResult.createErrorResult(e);
    } catch (Exception ex) {
        _logger.error("Delete file system got the exception", ex);
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeleteFileSystem", ex.getMessage());
        if (completer != null) {
            completer.error(dbClient, error);
        }
        return BiosCommandResult.createErrorResult(error);
    }
    if (job != null) {
        StringBuilder logMsgBuilder = new StringBuilder(String.format("Unexport filesystem job submitted - Array:%s, fileSystem: %s", storage.getSerialNumber(), args.getFsName()));
        _logger.info(logMsgBuilder.toString());
        return BiosCommandResult.createPendingResult();
    } else {
        StringBuilder logMsgBuilder = new StringBuilder(String.format("No export found - Array:%s, fileSystem: %s", storage.getSerialNumber(), args.getFsName()));
        _logger.info(logMsgBuilder.toString());
        return BiosCommandResult.createSuccessfulResult();
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeFileTaskCompleter(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFileTaskCompleter) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) VNXeException(com.emc.storageos.vnxe.VNXeException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) FileShareExport(com.emc.storageos.volumecontroller.FileShareExport) Snapshot(com.emc.storageos.db.client.model.Snapshot) VNXeException(com.emc.storageos.vnxe.VNXeException) FileExport(com.emc.storageos.db.client.model.FileExport) Iterator(java.util.Iterator) ExportRule(com.emc.storageos.model.file.ExportRule) Collection(java.util.Collection) VNXeUnexportFileSystemJob(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeUnexportFileSystemJob) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob)

Example 12 with VNXeFileTaskCompleter

use of com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFileTaskCompleter in project coprhd-controller by CoprHD.

the class VNXeStorageDevice method deleteExportRules.

@Override
public BiosCommandResult deleteExportRules(StorageSystem storage, FileDeviceInputOutput args) {
    List<ExportRule> allExports = args.getExistingDBExportRules();
    String subDir = args.getSubDirectory();
    boolean allDirs = args.isAllDir();
    VNXeCommandJob job = null;
    VNXeFileTaskCompleter completer = null;
    boolean isFile = args.getFileOperation();
    boolean ifRulePresent = false;
    String exportPath;
    String subDirExportPath = "";
    subDir = args.getSubDirectory();
    if (!args.getFileOperation()) {
        exportPath = args.getSnapshotPath();
        if (subDir != null && subDir.length() > 0) {
            subDirExportPath = args.getSnapshotPath() + "/" + subDir;
        }
    } else {
        exportPath = args.getFs().getPath();
        if (subDir != null && subDir.length() > 0) {
            subDirExportPath = args.getFs().getPath() + "/" + subDir;
        }
    }
    _logger.info("exportPath : {}", exportPath);
    args.setExportPath(exportPath);
    _logger.info("Number of existing exports found {}", allExports.size());
    try {
        VNXeApiClient apiClient = getVnxeClient(storage);
        if (allDirs) {
            // ALL EXPORTS
            _logger.info("Deleting all exports specific to filesystem at device and rules from DB including sub dirs rules and exports");
            for (ExportRule rule : allExports) {
                FileShareExport fsExport = null;
                if (args.getFileObjExports() != null) {
                    Collection<FileExport> expList = args.getFileObjExports().values();
                    Iterator<FileExport> it = expList.iterator();
                    FileExport exp = null;
                    while (it.hasNext()) {
                        FileExport export = it.next();
                        if (export.getPath().equalsIgnoreCase(rule.getExportPath())) {
                            exp = export;
                        }
                    }
                    fsExport = new FileShareExport(exp);
                }
                String vnxeShareId = rule.getDeviceExportId();
                _logger.info("Delete IsilonExport id {} for path {}", rule.getDeviceExportId(), rule.getExportPath());
                if (isFile) {
                    String fsId = args.getFs().getNativeId();
                    job = apiClient.removeNfsShare(vnxeShareId, fsId);
                } else {
                    job = apiClient.deleteNfsShareForSnapshot(vnxeShareId);
                }
                if (job != null) {
                    if (isFile) {
                        completer = new VNXeFileTaskCompleter(FileShare.class, args.getFsId(), args.getOpId());
                    } else {
                        completer = new VNXeFileTaskCompleter(Snapshot.class, args.getSnapshotId(), args.getOpId());
                    }
                    VNXeUnexportFileSystemJob unexportFSJob = new VNXeUnexportFileSystemJob(job.getId(), storage.getId(), completer, fsExport, rule.getExportPath(), isFile);
                    ControllerServiceImpl.enqueueJob(new QueueJob(unexportFSJob));
                } else {
                    _logger.error("No job returned from exportFileSystem");
                    ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeleteFileSystem", "No Job returned from deleteFileSystem");
                    return BiosCommandResult.createErrorResult(error);
                }
            }
        } else if (subDir != null && !subDir.isEmpty()) {
            // Filter for a specific Sub Directory export
            _logger.info("Deleting all subdir exports rules at ViPR and  sub directory export at device {}", subDir);
            FileShareExport fsExport = null;
            String vnxeShareId = null;
            if (args.getFileObjExports() != null) {
                Collection<FileExport> expList = args.getFileObjExports().values();
                Iterator<FileExport> it = expList.iterator();
                FileExport exp = null;
                while (it.hasNext()) {
                    FileExport export = it.next();
                    if (export.getPath().equalsIgnoreCase(subDirExportPath)) {
                        exp = export;
                        break;
                    }
                }
                fsExport = new FileShareExport(exp);
            }
            for (ExportRule rule : allExports) {
                _logger.info("Delete IsilonExport id for path {} f containing subdirectory {}", rule.getDeviceExportId() + ":" + rule.getExportPath(), subDir);
                if (rule.getExportPath().equalsIgnoreCase(subDirExportPath)) {
                    ifRulePresent = true;
                    vnxeShareId = rule.getDeviceExportId();
                }
            }
            if (!ifRulePresent) {
                if (fsExport != null) {
                    vnxeShareId = fsExport.getIsilonId();
                }
            }
            _logger.info("Delete IsilonExport id {} for path {}", vnxeShareId, subDirExportPath);
            if (isFile) {
                String fsId = args.getFs().getNativeId();
                job = apiClient.removeNfsShare(vnxeShareId, fsId);
            } else {
                job = apiClient.deleteNfsShareForSnapshot(vnxeShareId);
            }
            if (job != null) {
                if (isFile) {
                    completer = new VNXeFileTaskCompleter(FileShare.class, args.getFsId(), args.getOpId());
                } else {
                    completer = new VNXeFileTaskCompleter(Snapshot.class, args.getSnapshotId(), args.getOpId());
                }
                VNXeUnexportFileSystemJob unexportFSJob = new VNXeUnexportFileSystemJob(job.getId(), storage.getId(), completer, fsExport, subDirExportPath, isFile);
                ControllerServiceImpl.enqueueJob(new QueueJob(unexportFSJob));
            } else {
                _logger.error("No job returned from exportFileSystem");
                ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeleteFileSystem", "No Job returned from deleteFileSystem");
                return BiosCommandResult.createErrorResult(error);
            }
        } else {
            // Filter for No SUBDIR - main export rules with no sub dirs
            _logger.info("Deleting all export rules  from DB and export at device not included sub dirs");
            FileShareExport fsExport = null;
            String vnxeShareId = null;
            if (args.getFileObjExports() != null) {
                Collection<FileExport> expList = args.getFileObjExports().values();
                Iterator<FileExport> it = expList.iterator();
                FileExport exp = null;
                while (it.hasNext()) {
                    FileExport export = it.next();
                    if (export.getPath().equalsIgnoreCase(exportPath)) {
                        exp = export;
                        break;
                    }
                }
                fsExport = new FileShareExport(exp);
            }
            for (ExportRule rule : allExports) {
                if (rule.getExportPath().equalsIgnoreCase(exportPath)) {
                    ifRulePresent = true;
                    vnxeShareId = rule.getDeviceExportId();
                }
            }
            if (!ifRulePresent) {
                if (fsExport != null) {
                    vnxeShareId = fsExport.getIsilonId();
                }
            }
            _logger.info("Delete IsilonExport id {} for path {}", vnxeShareId, fsExport.getPath());
            if (isFile) {
                String fsId = args.getFs().getNativeId();
                job = apiClient.removeNfsShare(vnxeShareId, fsId);
            } else {
                job = apiClient.deleteNfsShareForSnapshot(vnxeShareId);
            }
            if (job != null) {
                if (isFile) {
                    completer = new VNXeFileTaskCompleter(FileShare.class, args.getFsId(), args.getOpId());
                } else {
                    completer = new VNXeFileTaskCompleter(Snapshot.class, args.getSnapshotId(), args.getOpId());
                }
                VNXeUnexportFileSystemJob unexportFSJob = new VNXeUnexportFileSystemJob(job.getId(), storage.getId(), completer, fsExport, fsExport.getPath(), isFile);
                ControllerServiceImpl.enqueueJob(new QueueJob(unexportFSJob));
            } else {
                _logger.error("No job returned from exportFileSystem");
                ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeleteFileSystem", "No Job returned from deleteFileSystem");
                return BiosCommandResult.createErrorResult(error);
            }
        }
    } catch (VNXeException e) {
        _logger.error("Unexport file system got the exception", e);
        if (completer != null) {
            completer.error(_dbClient, e);
        }
        return BiosCommandResult.createErrorResult(e);
    } catch (Exception ex) {
        _logger.error("Delete file system got the exception", ex);
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeleteFileSystem", ex.getMessage());
        if (completer != null) {
            completer.error(_dbClient, error);
        }
        return BiosCommandResult.createErrorResult(error);
    }
    if (job != null) {
        StringBuilder logMsgBuilder = new StringBuilder(String.format("Unexport filesystem job submitted - Array:%s, fileSystem: %s", storage.getSerialNumber(), args.getFsName()));
        _logger.info(logMsgBuilder.toString());
        return BiosCommandResult.createPendingResult();
    } else {
        StringBuilder logMsgBuilder = new StringBuilder(String.format("No export found - Array:%s, fileSystem: %s", storage.getSerialNumber(), args.getFsName()));
        _logger.info(logMsgBuilder.toString());
        return BiosCommandResult.createSuccessfulResult();
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeFileTaskCompleter(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFileTaskCompleter) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) VNXeException(com.emc.storageos.vnxe.VNXeException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) FileShareExport(com.emc.storageos.volumecontroller.FileShareExport) Snapshot(com.emc.storageos.db.client.model.Snapshot) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) VNXeException(com.emc.storageos.vnxe.VNXeException) FileExport(com.emc.storageos.db.client.model.FileExport) Iterator(java.util.Iterator) ExportRule(com.emc.storageos.model.file.ExportRule) Collection(java.util.Collection) VNXeUnexportFileSystemJob(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeUnexportFileSystemJob) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob)

Example 13 with VNXeFileTaskCompleter

use of com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFileTaskCompleter in project coprhd-controller by CoprHD.

the class VNXeStorageDevice method doCreateFS.

@Override
public BiosCommandResult doCreateFS(StorageSystem storage, FileDeviceInputOutput fileInOut) throws ControllerException {
    _logger.info("creating file system: ", fileInOut.getFsName());
    Long fsSize = fileInOut.getFsCapacity();
    if (fsSize < 1) {
        // Invalid size throw an error
        _logger.error("doCreateFS failed : FileSystem size in bytes is not valid {}", fileInOut.getFsCapacity());
        ServiceError error = DeviceControllerErrors.vnxe.unableToCreateFileSystem("FileSystem size in bytes is not valid");
        return BiosCommandResult.createErrorResult(error);
    }
    VNXeFileTaskCompleter completer = null;
    VNXeApiClient apiClient = getVnxeClient(storage);
    VNXeCommandJob job = null;
    try {
        FileShare fs = fileInOut.getFs();
        URI port = fs.getStoragePort();
        if (port == null) {
            _logger.error("No storageport uri found in the fs");
            ServiceError error = DeviceControllerErrors.vnxe.unableToCreateFileSystem("No storageport uri found in the fs");
            return BiosCommandResult.createErrorResult(error);
        }
        StoragePort portObj = _dbClient.queryObject(StoragePort.class, port);
        URI haDomainUri = portObj.getStorageHADomain();
        StorageHADomain haDomainObj = _dbClient.queryObject(StorageHADomain.class, haDomainUri);
        StringSet protocols = fs.getProtocol();
        if (protocols.contains(StorageProtocol.File.NFS_OR_CIFS.name())) {
            /*
                 * the protocol is set to NFS_OR_CIFS, only if virtual pool's protocol is not set
                 * and the pool's protocol is set to NFS_OR_CIFS, since pool's protocol is set based on
                 * storageHADomain's protocol, setting the protocols to the selected StorageHADomain.
                 */
            protocols = haDomainObj.getFileSharingProtocols();
        }
        VNXeFSSupportedProtocolEnum protocolEnum = null;
        if (protocols.contains(StorageProtocol.File.NFS.name()) && protocols.contains(StorageProtocol.File.CIFS.name())) {
            protocolEnum = VNXeFSSupportedProtocolEnum.NFS_CIFS;
        } else if (protocols.contains(StorageProtocol.File.NFS.name())) {
            protocolEnum = VNXeFSSupportedProtocolEnum.NFS;
        } else if (protocols.contains(StorageProtocol.File.CIFS.name())) {
            protocolEnum = VNXeFSSupportedProtocolEnum.CIFS;
        } else {
            _logger.error("protocol is not support: " + protocols);
            ServiceError error = DeviceControllerErrors.vnxe.unableToCreateFileSystem("protocol is not support:" + protocols);
            return BiosCommandResult.createErrorResult(error);
        }
        job = apiClient.createFileSystem(fileInOut.getFsName(), fsSize, fileInOut.getPoolNativeId(), haDomainObj.getSerialNumber(), fileInOut.getThinProvision(), protocolEnum);
        if (job != null) {
            _logger.info("opid:" + fileInOut.getOpId());
            completer = new VNXeFileTaskCompleter(FileShare.class, fileInOut.getFsId(), fileInOut.getOpId());
            if (fileInOut.getFs() == null) {
                _logger.error("Could not find the fs object");
            }
            VNXeCreateFileSystemJob createFSJob = new VNXeCreateFileSystemJob(job.getId(), storage.getId(), completer, fileInOut.getPoolId());
            ControllerServiceImpl.enqueueJob(new QueueJob(createFSJob));
        } else {
            _logger.error("No job returned from creatFileSystem");
            ServiceError error = DeviceControllerErrors.vnxe.unableToCreateFileSystem("No Job returned from createFileSystem");
            return BiosCommandResult.createErrorResult(error);
        }
    } catch (VNXeException e) {
        _logger.error("Create file system got the exception", e);
        if (completer != null) {
            completer.error(_dbClient, e);
        }
        return BiosCommandResult.createErrorResult(e);
    } catch (Exception ex) {
        _logger.error("Create file system got the exception", ex);
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("CreateFileSystem", ex.getMessage());
        if (completer != null) {
            completer.error(_dbClient, error);
        }
        return BiosCommandResult.createErrorResult(error);
    }
    StringBuilder logMsgBuilder = new StringBuilder(String.format("Create filesystem job submitted - Array:%s, Pool:%s, fileSystem: %s", storage.getSerialNumber(), fileInOut.getPoolNativeId(), fileInOut.getFsName()));
    _logger.info(logMsgBuilder.toString());
    return BiosCommandResult.createPendingResult();
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VNXeFSSupportedProtocolEnum(com.emc.storageos.vnxe.models.VNXeFSSupportedProtocolEnum) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) StoragePort(com.emc.storageos.db.client.model.StoragePort) VNXeFileTaskCompleter(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFileTaskCompleter) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) URI(java.net.URI) VNXeCreateFileSystemJob(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeCreateFileSystemJob) VNXeException(com.emc.storageos.vnxe.VNXeException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) VNXeException(com.emc.storageos.vnxe.VNXeException) StringSet(com.emc.storageos.db.client.model.StringSet) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob)

Example 14 with VNXeFileTaskCompleter

use of com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFileTaskCompleter in project coprhd-controller by CoprHD.

the class VNXUnityFileStorageDevice method doUnexport.

@Override
public BiosCommandResult doUnexport(StorageSystem storage, FileDeviceInputOutput args, List<FileExport> exportList) throws ControllerException {
    _logger.info("unexporting the file system: " + args.getFsName());
    boolean isFile = args.getFileOperation();
    for (FileExport exp : exportList) {
        VNXeApiClient apiClient = getVnxUnityClient(storage);
        String vnxeShareId = exp.getIsilonId();
        VNXeCommandJob job = null;
        VNXeFileTaskCompleter completer = null;
        try {
            if (isFile) {
                String fsId = args.getFs().getNativeId();
                job = apiClient.removeNfsShare(vnxeShareId, fsId);
            } else {
                job = apiClient.deleteNfsShareForSnapshot(vnxeShareId);
            }
            if (job != null) {
                if (isFile) {
                    completer = new VNXeFileTaskCompleter(FileShare.class, args.getFsId(), args.getOpId());
                } else {
                    completer = new VNXeFileTaskCompleter(Snapshot.class, args.getSnapshotId(), args.getOpId());
                }
                FileShareExport export = new FileShareExport(exp);
                VNXeUnexportFileSystemJob unexportFSJob = new VNXeUnexportFileSystemJob(job.getId(), storage.getId(), completer, export, export.getPath(), isFile);
                ControllerServiceImpl.enqueueJob(new QueueJob(unexportFSJob));
            } else {
                _logger.error("No job returned from exportFileSystem");
                ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeleteFileSystem", "No Job returned from deleteFileSystem");
                return BiosCommandResult.createErrorResult(error);
            }
        } catch (VNXeException e) {
            _logger.error("Unexport file system got the exception", e);
            if (completer != null) {
                completer.error(dbClient, e);
            }
            return BiosCommandResult.createErrorResult(e);
        } catch (Exception ex) {
            _logger.error("Delete file system got the exception", ex);
            ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeleteFileSystem", ex.getMessage());
            if (completer != null) {
                completer.error(dbClient, error);
            }
            return BiosCommandResult.createErrorResult(error);
        }
        StringBuilder logMsgBuilder = new StringBuilder(String.format("Unexport filesystem job submitted - Array:%s, fileSystem: %s", storage.getSerialNumber(), args.getFsName()));
        _logger.info(logMsgBuilder.toString());
    }
    return BiosCommandResult.createPendingResult();
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeFileTaskCompleter(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFileTaskCompleter) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) VNXeException(com.emc.storageos.vnxe.VNXeException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) FileShareExport(com.emc.storageos.volumecontroller.FileShareExport) Snapshot(com.emc.storageos.db.client.model.Snapshot) VNXeException(com.emc.storageos.vnxe.VNXeException) FileExport(com.emc.storageos.db.client.model.FileExport) VNXeUnexportFileSystemJob(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeUnexportFileSystemJob) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob)

Example 15 with VNXeFileTaskCompleter

use of com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFileTaskCompleter in project coprhd-controller by CoprHD.

the class VNXUnityFileStorageDevice method doCreateFS.

@Override
public BiosCommandResult doCreateFS(StorageSystem storage, FileDeviceInputOutput fileInOut) throws ControllerException {
    _logger.info("creating file system: ", fileInOut.getFsName());
    Long fsSize = fileInOut.getFsCapacity();
    if (fsSize < 1) {
        // Invalid size throw an error
        _logger.error("doCreateFS failed : FileSystem size in bytes is not valid {}", fileInOut.getFsCapacity());
        ServiceError error = DeviceControllerErrors.vnxe.unableToCreateFileSystem("FileSystem size in bytes is not valid");
        return BiosCommandResult.createErrorResult(error);
    }
    VNXeFileTaskCompleter completer = null;
    VNXeApiClient apiClient = getVnxUnityClient(storage);
    VNXeCommandJob job = null;
    try {
        FileShare fs = fileInOut.getFs();
        URI port = fs.getStoragePort();
        if (port == null) {
            _logger.error("No storageport uri found in the fs");
            ServiceError error = DeviceControllerErrors.vnxe.unableToCreateFileSystem("No storageport uri found in the fs");
            return BiosCommandResult.createErrorResult(error);
        }
        StoragePort portObj = dbClient.queryObject(StoragePort.class, port);
        URI haDomainUri = portObj.getStorageHADomain();
        StorageHADomain haDomainObj = dbClient.queryObject(StorageHADomain.class, haDomainUri);
        StringSet protocols = fs.getProtocol();
        if (protocols.contains(StorageProtocol.File.NFS_OR_CIFS.name())) {
            /*
                 * the protocol is set to NFS_OR_CIFS, only if virtual pool's protocol is not set
                 * and the pool's protocol is set to NFS_OR_CIFS, since pool's protocol is set based on
                 * storageHADomain's protocol, setting the protocols to the selected StorageHADomain.
                 */
            protocols = haDomainObj.getFileSharingProtocols();
        }
        VNXeFSSupportedProtocolEnum protocolEnum = null;
        if (protocols.contains(StorageProtocol.File.NFS.name()) && protocols.contains(StorageProtocol.File.CIFS.name())) {
            protocolEnum = VNXeFSSupportedProtocolEnum.NFS_CIFS;
        } else if (protocols.contains(StorageProtocol.File.NFS.name())) {
            protocolEnum = VNXeFSSupportedProtocolEnum.NFS;
        } else if (protocols.contains(StorageProtocol.File.CIFS.name())) {
            protocolEnum = VNXeFSSupportedProtocolEnum.CIFS;
        } else {
            _logger.error("The protocol is not supported: " + protocols);
            ServiceError error = DeviceControllerErrors.vnxe.unableToCreateFileSystem("The protocol is not supported:" + protocols);
            return BiosCommandResult.createErrorResult(error);
        }
        job = apiClient.createFileSystem(fileInOut.getFsName(), fsSize, fileInOut.getPoolNativeId(), haDomainObj.getSerialNumber(), fileInOut.getThinProvision(), protocolEnum);
        if (job != null) {
            _logger.info("opid:" + fileInOut.getOpId());
            completer = new VNXeFileTaskCompleter(FileShare.class, fileInOut.getFsId(), fileInOut.getOpId());
            if (fileInOut.getFs() == null) {
                _logger.error("Could not find the fs object");
            }
            VNXeCreateFileSystemJob createFSJob = new VNXeCreateFileSystemJob(job.getId(), storage.getId(), completer, fileInOut.getPoolId());
            ControllerServiceImpl.enqueueJob(new QueueJob(createFSJob));
        } else {
            _logger.error("No job returned from creatFileSystem");
            ServiceError error = DeviceControllerErrors.vnxe.unableToCreateFileSystem("No Job returned from createFileSystem");
            return BiosCommandResult.createErrorResult(error);
        }
    } catch (VNXeException e) {
        _logger.error("Create file system got an exception", e);
        if (completer != null) {
            completer.error(dbClient, e);
        }
        return BiosCommandResult.createErrorResult(e);
    } catch (Exception ex) {
        _logger.error("Create file system got an exception", ex);
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("CreateFileSystem", ex.getMessage());
        if (completer != null) {
            completer.error(dbClient, error);
        }
        return BiosCommandResult.createErrorResult(error);
    }
    StringBuilder logMsgBuilder = new StringBuilder(String.format("Create filesystem job submitted - Array:%s, Pool:%s, fileSystem: %s", storage.getSerialNumber(), fileInOut.getPoolNativeId(), fileInOut.getFsName()));
    _logger.info(logMsgBuilder.toString());
    return BiosCommandResult.createPendingResult();
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VNXeFSSupportedProtocolEnum(com.emc.storageos.vnxe.models.VNXeFSSupportedProtocolEnum) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) StoragePort(com.emc.storageos.db.client.model.StoragePort) VNXeFileTaskCompleter(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFileTaskCompleter) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) URI(java.net.URI) VNXeCreateFileSystemJob(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeCreateFileSystemJob) VNXeException(com.emc.storageos.vnxe.VNXeException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) VNXeException(com.emc.storageos.vnxe.VNXeException) StringSet(com.emc.storageos.db.client.model.StringSet) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob)

Aggregations

DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)18 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)18 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)18 VNXeException (com.emc.storageos.vnxe.VNXeException)18 VNXeCommandJob (com.emc.storageos.vnxe.models.VNXeCommandJob)18 ControllerException (com.emc.storageos.volumecontroller.ControllerException)18 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)18 VNXeFileTaskCompleter (com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFileTaskCompleter)18 FileShare (com.emc.storageos.db.client.model.FileShare)16 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)16 Snapshot (com.emc.storageos.db.client.model.Snapshot)14 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)9 FileExport (com.emc.storageos.db.client.model.FileExport)8 FileShareExport (com.emc.storageos.volumecontroller.FileShareExport)8 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)7 VNXeUnexportFileSystemJob (com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeUnexportFileSystemJob)6 ExportRule (com.emc.storageos.model.file.ExportRule)4 AccessEnum (com.emc.storageos.vnxe.models.AccessEnum)4 FileSMBShare (com.emc.storageos.volumecontroller.FileSMBShare)4 ArrayList (java.util.ArrayList)4