Search in sources :

Example 1 with VNXeException

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

the class VNXUnityFileStorageDevice method doDeleteQuotaDirectory.

@Override
public BiosCommandResult doDeleteQuotaDirectory(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    _logger.info("Deleting file system {} quota directory {} ", args.getFsName(), args.getQuotaDirectoryName());
    VNXeApiClient apiClient = getVnxUnityClient(storage);
    VNXeCommandJob job = null;
    VNXUnityQuotaDirectoryTaskCompleter completer = null;
    try {
        job = apiClient.deleteQuotaDirectory(args.getQuotaDirectoryNativeId());
        if (job != null) {
            completer = new VNXUnityQuotaDirectoryTaskCompleter(QuotaDirectory.class, args.getQuotaDirectoryId(), args.getOpId());
            VNXUnityDeleteFileSystemQuotaDirectoryJob quotaJob = new VNXUnityDeleteFileSystemQuotaDirectoryJob(job.getId(), storage.getId(), completer);
            ControllerServiceImpl.enqueueJob(new QueueJob(quotaJob));
        } else {
            _logger.error("No job returned from deleteQuotaDirectory");
            ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeleteFileSystemQuota", "No Job returned from deleteQuotaDirectory");
            return BiosCommandResult.createErrorResult(error);
        }
    } catch (VNXeException e) {
        _logger.error("Delete file system quota directory got an exception", e);
        if (completer != null) {
            completer.error(dbClient, e);
        }
        return BiosCommandResult.createErrorResult(e);
    } catch (Exception ex) {
        _logger.error("Delete file system quota directory got an exception", ex);
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeleteFileSystemQuota", ex.getMessage());
        if (completer != null) {
            completer.error(dbClient, error);
        }
        return BiosCommandResult.createErrorResult(error);
    }
    StringBuilder logMsgBuilder = new StringBuilder(String.format("Delete filesystem quota job submitted - Array:%s, fileSystem: %s, quota: %s", storage.getSerialNumber(), args.getFsName(), args.getQuotaDirectoryName()));
    _logger.info(logMsgBuilder.toString());
    return BiosCommandResult.createPendingResult();
}
Also used : VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeException(com.emc.storageos.vnxe.VNXeException) QuotaDirectory(com.emc.storageos.db.client.model.QuotaDirectory) VNXUnityDeleteFileSystemQuotaDirectoryJob(com.emc.storageos.volumecontroller.impl.vnxunity.job.VNXUnityDeleteFileSystemQuotaDirectoryJob) VNXUnityQuotaDirectoryTaskCompleter(com.emc.storageos.volumecontroller.impl.vnxunity.job.VNXUnityQuotaDirectoryTaskCompleter) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) VNXeException(com.emc.storageos.vnxe.VNXeException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException)

Example 2 with VNXeException

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

the class VNXUnityFileStorageDevice method doExpandFS.

@Override
public BiosCommandResult doExpandFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    _logger.info("expanding file system: ", args.getFsName());
    VNXeApiClient apiClient = getVnxUnityClient(storage);
    VNXeCommandJob job = null;
    VNXeFileTaskCompleter completer = null;
    try {
        job = apiClient.expandFileSystem(args.getFsNativeId(), args.getNewFSCapacity());
        if (job != null) {
            completer = new VNXeFileTaskCompleter(FileShare.class, args.getFsId(), args.getOpId());
            VNXeExpandFileSystemJob expandFSJob = new VNXeExpandFileSystemJob(job.getId(), storage.getId(), completer);
            ControllerServiceImpl.enqueueJob(new QueueJob(expandFSJob));
        } else {
            _logger.error("No job returned from expandFileSystem");
            ServiceError error = DeviceControllerErrors.vnxe.jobFailed("expandFileSystem", "No Job returned from expandFileSystem");
            return BiosCommandResult.createErrorResult(error);
        }
    } catch (VNXeException e) {
        _logger.error("Expand file system got the exception", e);
        if (completer != null) {
            completer.error(dbClient, e);
        }
        return BiosCommandResult.createErrorResult(e);
    } catch (Exception ex) {
        _logger.error("Expand file system got the exception", ex);
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("ExpandFileSystem", ex.getMessage());
        if (completer != null) {
            completer.error(dbClient, error);
        }
        return BiosCommandResult.createErrorResult(error);
    }
    StringBuilder logMsgBuilder = new StringBuilder(String.format("Expand filesystem job submitted - Array:%s, fileSystem: %s, new size: %d", storage.getSerialNumber(), args.getFsName(), args.getNewFSCapacity()));
    _logger.info(logMsgBuilder.toString());
    return BiosCommandResult.createPendingResult();
}
Also used : VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeException(com.emc.storageos.vnxe.VNXeException) VNXeFileTaskCompleter(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFileTaskCompleter) VNXeExpandFileSystemJob(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeExpandFileSystemJob) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) VNXeException(com.emc.storageos.vnxe.VNXeException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException)

Example 3 with VNXeException

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

the class VNXUnityFileStorageDevice method doShare.

@Override
public BiosCommandResult doShare(StorageSystem storage, FileDeviceInputOutput args, SMBFileShare smbFileShare) throws ControllerException {
    _logger.info("creating smbShare: " + smbFileShare.getName());
    VNXeApiClient apiClient = getVnxUnityClient(storage);
    String permission = smbFileShare.getPermission();
    String shareName = smbFileShare.getName();
    String path = "/";
    VNXeCommandJob job = null;
    VNXeFileTaskCompleter completer = null;
    FileSMBShare newShare = new FileSMBShare(smbFileShare);
    String absolutePath = smbFileShare.getPath();
    newShare.setStoragePortNetworkId(smbFileShare.getStoragePortNetworkId());
    newShare.setStoragePortName(smbFileShare.getStoragePortName());
    try {
        if (args.getFileOperation()) {
            if (newShare.isSubDirPath()) {
                String basePath = args.getFsPath();
                /*
                     * The below line will allow us to get the relative path of subdir
                     * For example: absolutePath = /vnxeShare1/subdir1
                     * Then, the below line will assign path = subdir
                     * VNXe takes the relative path of the sub-directory. Not the absolute path
                     */
                path = "/" + new File(basePath).toURI().relativize(new File(absolutePath).toURI()).getPath();
            }
            String fsNativeId = args.getFs().getNativeId();
            _logger.info("Creating CIFS share for path {}", path);
            job = apiClient.createCIFSShare(fsNativeId, shareName, permission, path);
            if (job != null) {
                newShare.setNetBIOSName(apiClient.getNetBios());
                completer = new VNXeFileTaskCompleter(FileShare.class, args.getFsId(), args.getOpId());
                VNXeCreateShareJob createShareJob = new VNXeCreateShareJob(job.getId(), storage.getId(), completer, newShare, true);
                ControllerServiceImpl.enqueueJob(new QueueJob(createShareJob));
            } else {
                _logger.error("No job returned from creaetCifsShare");
                ServiceError error = DeviceControllerErrors.vnxe.jobFailed("createShare", "No Job returned");
                return BiosCommandResult.createErrorResult(error);
            }
        } else {
            // create share for a snapshot
            if (newShare.isSubDirPath()) {
                String basePath = args.getSnapshotPath();
                /*
                     * The below line will allow us to get the relative path of subdir
                     * For example: absolutePath = /vnxeShare1/subdir1
                     * Then, the below line will assign path = subdir
                     * VNXe takes the relative path of the sub-directory. Not the absolute path
                     */
                path = "/" + new File(basePath).toURI().relativize(new File(absolutePath).toURI()).getPath();
            }
            String fsNativeId = args.getFs().getNativeId();
            String snapId = args.getSnapNativeId();
            job = apiClient.createCifsShareForSnap(snapId, shareName, permission, path, fsNativeId);
            if (job != null) {
                newShare.setNetBIOSName(apiClient.getNetBios());
                completer = new VNXeFileTaskCompleter(Snapshot.class, args.getSnapshotId(), args.getOpId());
                VNXeCreateShareJob createShareJob = new VNXeCreateShareJob(job.getId(), storage.getId(), completer, newShare, false);
                ControllerServiceImpl.enqueueJob(new QueueJob(createShareJob));
            } else {
                _logger.error("No job returned from creaetCifsShare");
                ServiceError error = DeviceControllerErrors.vnxe.jobFailed("createShare", "No Job returned");
                return BiosCommandResult.createErrorResult(error);
            }
        }
    } catch (VNXeException e) {
        _logger.error("Create share got the exception", e);
        if (completer != null) {
            completer.error(dbClient, e);
        }
        return BiosCommandResult.createErrorResult(e);
    } catch (Exception ex) {
        _logger.error("create share got the exception", ex);
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("create share", ex.getMessage());
        if (completer != null) {
            completer.error(dbClient, error);
        }
        return BiosCommandResult.createErrorResult(error);
    }
    StringBuilder logMsgBuilder = new StringBuilder(String.format("Create share job submitted - Array:%s, share: %s", storage.getSerialNumber(), smbFileShare.getName()));
    _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) FileSMBShare(com.emc.storageos.volumecontroller.FileSMBShare) 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) Snapshot(com.emc.storageos.db.client.model.Snapshot) VNXeException(com.emc.storageos.vnxe.VNXeException) VNXeCreateShareJob(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeCreateShareJob) File(java.io.File) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob)

Example 4 with VNXeException

use of com.emc.storageos.vnxe.VNXeException 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 5 with VNXeException

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

the class VNXUnityFileStorageDevice method getFSSnapshotList.

@Override
public BiosCommandResult getFSSnapshotList(StorageSystem storage, FileDeviceInputOutput fd, List<String> snapshots) throws ControllerException {
    _logger.info("getFSSnapshotList {} - start", fd.getFsId());
    VNXeApiClient client = getVnxUnityClient(storage);
    try {
        List<VNXeFileSystemSnap> snaps = client.getFileSystemSnaps(fd.getFsNativeId());
        for (VNXeFileSystemSnap snap : snaps) {
            snapshots.add(snap.getName());
        }
        return BiosCommandResult.createSuccessfulResult();
    } catch (VNXeException e) {
        _logger.error("getFSSnapshotList failed.", e);
        return BiosCommandResult.createErrorResult(e);
    }
}
Also used : VNXeFileSystemSnap(com.emc.storageos.vnxe.models.VNXeFileSystemSnap) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeException(com.emc.storageos.vnxe.VNXeException)

Aggregations

VNXeException (com.emc.storageos.vnxe.VNXeException)67 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)60 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)41 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)40 VNXeCommandJob (com.emc.storageos.vnxe.models.VNXeCommandJob)40 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)36 ControllerException (com.emc.storageos.volumecontroller.ControllerException)34 FileShare (com.emc.storageos.db.client.model.FileShare)22 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)22 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)22 Snapshot (com.emc.storageos.db.client.model.Snapshot)20 VNXeFileTaskCompleter (com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFileTaskCompleter)18 ArrayList (java.util.ArrayList)17 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)16 URI (java.net.URI)13 FileExport (com.emc.storageos.db.client.model.FileExport)12 Test (org.junit.Test)10 HashMap (java.util.HashMap)9 FileShareExport (com.emc.storageos.volumecontroller.FileShareExport)8 List (java.util.List)7