Search in sources :

Example 56 with VNXeException

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

the class VNXUnityFileStorageDevice method doConnect.

@Override
public void doConnect(StorageSystem storage) throws ControllerException {
    try {
        _logger.info("doConnect {} - start", storage.getId());
        VNXeApiClient client = getVnxUnityClient(storage);
        client.getStorageSystem();
        String msg = String.format("doConnect %1$s - complete", storage.getId());
        _logger.info(msg);
    } catch (VNXeException e) {
        _logger.error("doConnect failed.", e);
        throw DeviceControllerException.exceptions.connectStorageFailed(e);
    }
}
Also used : VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeException(com.emc.storageos.vnxe.VNXeException)

Example 57 with VNXeException

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

the class VNXUnityFileStorageDevice method doDisconnect.

@Override
public void doDisconnect(StorageSystem storage) {
    try {
        _logger.info("doConnect {} - start", storage.getId());
        VNXeApiClient client = getVnxUnityClient(storage);
        client.logout();
        String msg = String.format("doDisconnect %1$s - complete", storage.getId());
        _logger.info(msg);
    } catch (VNXeException e) {
        _logger.error("doDisconnect failed.", e);
        throw DeviceControllerException.exceptions.disconnectStorageFailed(e);
    }
}
Also used : VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeException(com.emc.storageos.vnxe.VNXeException)

Example 58 with VNXeException

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

the class VNXUnityFileStorageDevice method doDeleteShare.

@Override
public BiosCommandResult doDeleteShare(StorageSystem storage, FileDeviceInputOutput args, SMBFileShare smbFileShare) throws ControllerException {
    _logger.info(String.format(String.format("Deleting smbShare: %s, nativeId: %s", smbFileShare.getName(), smbFileShare.getNativeId())));
    VNXeApiClient apiClient = getVnxUnityClient(storage);
    String shareId = smbFileShare.getNativeId();
    VNXeCommandJob job = null;
    VNXeFileTaskCompleter completer = null;
    boolean isFile = args.getFileOperation();
    FileSMBShare newShare = new FileSMBShare(smbFileShare);
    try {
        if (isFile) {
            String fsId = args.getFs().getNativeId();
            job = apiClient.removeCifsShare(shareId, fsId);
        } else {
            job = apiClient.deleteCifsShareForSnapshot(shareId);
        }
        if (job != null) {
            if (isFile) {
                completer = new VNXeFileTaskCompleter(FileShare.class, args.getFsId(), args.getOpId());
            } else {
                completer = new VNXeFileTaskCompleter(Snapshot.class, args.getSnapshotId(), args.getOpId());
            }
            VNXeDeleteShareJob deleteShareJob = new VNXeDeleteShareJob(job.getId(), storage.getId(), completer, newShare, isFile);
            ControllerServiceImpl.enqueueJob(new QueueJob(deleteShareJob));
        } else {
            _logger.error("No job returned from deleteCifsShare");
            ServiceError error = DeviceControllerErrors.vnxe.jobFailed("deleteShare", "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("delete 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("Delete 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) VNXeDeleteShareJob(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeDeleteShareJob) 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) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob)

Example 59 with VNXeException

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

the class VNXUnityFileStorageDevice method doExport.

@Override
public BiosCommandResult doExport(StorageSystem storage, FileDeviceInputOutput args, List<FileExport> exportList) throws ControllerException {
    _logger.info("exporting the file system: " + args.getFsName());
    if (args.getFileObjExports() == null || args.getFileObjExports().isEmpty()) {
        args.initFileObjExports();
    }
    for (FileExport exp : exportList) {
        VNXeApiClient apiClient = getVnxUnityClient(storage);
        String fsId = args.getFs().getNativeId();
        String fsName = args.getFsName();
        String permission = exp.getPermissions();
        String path = "/";
        String subdirName = "";
        String mountPathArg = exp.getMountPath();
        String comments = exp.getComments();
        VNXeCommandJob job = null;
        VNXeFileTaskCompleter completer = null;
        String exportKey = exp.getFileExportKey();
        FileShareExport newExport = new FileShareExport(exp);
        try {
            AccessEnum access = null;
            List<String> roClients = null;
            List<String> rwClients = null;
            List<String> rootClients = null;
            FileExport existingExport = null;
            if (args.getFileOperation()) {
                FSExportMap exportMap = args.getFileObjExports();
                existingExport = exportMap.get(exportKey);
            } else {
                FSExportMap exportMap = args.getSnapshotExports();
                existingExport = exportMap.get(exportKey);
            }
            if (existingExport != null) {
                if (permission.equalsIgnoreCase(FileShareExport.Permissions.rw.name())) {
                    access = AccessEnum.READWRITE;
                    if (existingExport.getClients() != null && !existingExport.getClients().isEmpty()) {
                        if (rwClients == null) {
                            rwClients = new ArrayList<String>();
                        }
                        rwClients.addAll(existingExport.getClients());
                    }
                } else if (permission.equalsIgnoreCase(FileShareExport.Permissions.ro.name())) {
                    access = AccessEnum.READ;
                    if (existingExport.getClients() != null && !existingExport.getClients().isEmpty()) {
                        if (roClients == null) {
                            roClients = new ArrayList<String>();
                        }
                        roClients.addAll(existingExport.getClients());
                    }
                } else if (permission.equalsIgnoreCase(FileShareExport.Permissions.root.name())) {
                    access = AccessEnum.ROOT;
                    if (existingExport.getClients() != null && !existingExport.getClients().isEmpty()) {
                        if (rootClients == null) {
                            rootClients = new ArrayList<String>();
                        }
                        rootClients.addAll(existingExport.getClients());
                    }
                }
            }
            if (permission.equalsIgnoreCase(FileShareExport.Permissions.rw.name())) {
                access = AccessEnum.READWRITE;
                if (exp.getClients() != null && !exp.getClients().isEmpty()) {
                    if (rwClients == null) {
                        rwClients = new ArrayList<String>();
                    }
                    rwClients.addAll(exp.getClients());
                }
            } else if (permission.equalsIgnoreCase(FileShareExport.Permissions.ro.name())) {
                access = AccessEnum.READ;
                if (exp.getClients() != null && !exp.getClients().isEmpty()) {
                    if (roClients == null) {
                        roClients = new ArrayList<String>();
                    }
                    roClients.addAll(exp.getClients());
                }
            } else if (permission.equalsIgnoreCase(FileShareExport.Permissions.root.name())) {
                access = AccessEnum.ROOT;
                if (exp.getClients() != null && !exp.getClients().isEmpty()) {
                    if (rootClients == null) {
                        rootClients = new ArrayList<String>();
                    }
                    rootClients.addAll(exp.getClients());
                }
            }
            if (args.getFileOperation()) {
                String mountPathFs = args.getFsMountPath();
                if (!mountPathArg.equals(mountPathFs)) {
                    // subdirectory specified.
                    subdirName = mountPathArg.substring(mountPathFs.length() + 1);
                    path += subdirName;
                }
                String shareName = VNXeUtils.buildNfsShareName(fsName, subdirName);
                job = apiClient.exportFileSystem(fsId, roClients, rwClients, rootClients, access, path, shareName, null, comments);
                if (job != null) {
                    completer = new VNXeFileTaskCompleter(FileShare.class, args.getFsId(), args.getOpId());
                    VNXeExportFileSystemJob exportFSJob = new VNXeExportFileSystemJob(job.getId(), storage.getId(), completer, newExport, shareName, true);
                    ControllerServiceImpl.enqueueJob(new QueueJob(exportFSJob));
                } else {
                    _logger.error("No job returned from exportFileSystem");
                    ServiceError error = DeviceControllerErrors.vnxe.jobFailed("exportFileSystem", "No Job returned from exportFileSystem");
                    return BiosCommandResult.createErrorResult(error);
                }
            } else {
                String snapId = args.getSnapNativeId();
                String snapName = args.getSnapshotName();
                String shareName = VNXeUtils.buildNfsShareName(snapName, path);
                job = apiClient.createNfsShareForSnap(snapId, roClients, rwClients, rootClients, access, path, shareName, comments);
                if (job != null) {
                    completer = new VNXeFileTaskCompleter(Snapshot.class, args.getSnapshotId(), args.getOpId());
                    VNXeExportFileSystemJob exportFSJob = new VNXeExportFileSystemJob(job.getId(), storage.getId(), completer, newExport, shareName, false);
                    ControllerServiceImpl.enqueueJob(new QueueJob(exportFSJob));
                } else {
                    _logger.error("No job returned from exportFileSystem");
                    ServiceError error = DeviceControllerErrors.vnxe.jobFailed("exportFileSystem", "No Job returned from exportFileSystem");
                    return BiosCommandResult.createErrorResult(error);
                }
            }
        } catch (VNXeException e) {
            _logger.error("Export file system got the exception", e);
            if (completer != null) {
                completer.error(dbClient, e);
            }
            return BiosCommandResult.createErrorResult(e);
        } catch (Exception ex) {
            _logger.error("export file system got the exception", ex);
            ServiceError error = DeviceControllerErrors.vnxe.jobFailed("exportFileSystem", ex.getMessage());
            if (completer != null) {
                completer.error(dbClient, error);
            }
            return BiosCommandResult.createErrorResult(error);
        }
        _logger.info("Export job submitted");
    }
    return BiosCommandResult.createPendingResult();
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) ArrayList(java.util.ArrayList) VNXeFileTaskCompleter(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFileTaskCompleter) FSExportMap(com.emc.storageos.db.client.model.FSExportMap) 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) VNXeExportFileSystemJob(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeExportFileSystemJob) VNXeException(com.emc.storageos.vnxe.VNXeException) FileExport(com.emc.storageos.db.client.model.FileExport) AccessEnum(com.emc.storageos.vnxe.models.AccessEnum) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob)

Example 60 with VNXeException

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

the class FileSystemSnapRequestsTest method deleteSnap.

/*
     * @Test
     * public void getFileSystemSnap() {
     * 
     * FileSystemSnapRequests req = new FileSystemSnapRequests(_client);
     * 
     * VNXeFileSystemSnap response = null;
     * try {
     * response = req.getByName("test-file-01-snap");
     * } catch (VNXeException e) {
     * // TODO Auto-generated catch block
     * logger.error("VNXeException occured", e);
     * }
     * 
     * System.out.println(response.getId());
     * 
     * 
     * }
     */
// @Test
public void deleteSnap() {
    FileSystemSnapRequests req = new FileSystemSnapRequests(_client);
    VNXeCommandJob response = null;
    try {
        response = req.deleteFileSystemSnap("98784247867", "3.1.0");
    } catch (VNXeException e) {
        logger.error("VNXeException occured", e);
    }
    System.out.println(response.getId());
}
Also used : VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) 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 FileExport (com.emc.storageos.db.client.model.FileExport)12 URI (java.net.URI)12 Test (org.junit.Test)10 FileShareExport (com.emc.storageos.volumecontroller.FileShareExport)8 HashMap (java.util.HashMap)8 StringSet (com.emc.storageos.db.client.model.StringSet)6