Search in sources :

Example 36 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 37 with VNXeException

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

the class FileSystemSnapRequestsTest method createFileSystemSnap.

// @Test
public void createFileSystemSnap() {
    FileSystemSnapCreateParam parm = new FileSystemSnapCreateParam();
    VNXeBase resource = new VNXeBase();
    resource.setId("res_12");
    parm.setStorageResource(resource);
    parm.setName("test-snap");
    parm.setIsReadOnly(false);
    FileSystemSnapRequests req = new FileSystemSnapRequests(_client);
    VNXeCommandJob response = null;
    try {
        response = req.createFileSystemSnap(parm);
    } catch (VNXeException e) {
        // TODO Auto-generated catch block
        logger.error("VNXeException occured", e);
    }
    System.out.println(response.getId() + "state: " + response.getState());
}
Also used : VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) VNXeException(com.emc.storageos.vnxe.VNXeException) FileSystemSnapCreateParam(com.emc.storageos.vnxe.models.FileSystemSnapCreateParam)

Example 38 with VNXeException

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

the class FileSystemActionRequestTest method createFileSystem.

@Test
public void createFileSystem() {
    CreateFileSystemParam parm = new CreateFileSystemParam();
    parm.setName("test-file-03");
    FileSystemParam fsParm = new FileSystemParam();
    fsParm.setIsThinEnabled(true);
    VNXeBase nasServer = new VNXeBase();
    nasServer.setId("nas_1");
    fsParm.setNasServer(nasServer);
    VNXeBase pool = new VNXeBase();
    pool.setId("pool_1");
    fsParm.setPool(pool);
    fsParm.setSize(2200000000L);
    fsParm.setSupportedProtocols(0);
    fsParm.setIsCacheDisabled(true);
    fsParm.setSupportedProtocols(VNXeFSSupportedProtocolEnum.NFS_CIFS.getValue());
    parm.setFsParameters(fsParm);
    FileSystemActionRequest req = new FileSystemActionRequest(_client);
    VNXeCommandJob response = null;
    try {
        response = req.createFileSystemAsync(parm);
    } catch (VNXeException e) {
        // TODO Auto-generated catch block
        logger.error("VNXeException occured", e);
    }
    System.out.println(response.getId() + "state: " + response.getState());
}
Also used : VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) ModifyFileSystemParam(com.emc.storageos.vnxe.models.ModifyFileSystemParam) FileSystemParam(com.emc.storageos.vnxe.models.FileSystemParam) CreateFileSystemParam(com.emc.storageos.vnxe.models.CreateFileSystemParam) VNXeException(com.emc.storageos.vnxe.VNXeException) CreateFileSystemParam(com.emc.storageos.vnxe.models.CreateFileSystemParam) Test(org.junit.Test)

Example 39 with VNXeException

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

the class VNXeExportOperations method deleteExportMask.

@Override
public void deleteExportMask(StorageSystem storage, URI exportMaskUri, List<URI> volumeURIList, List<URI> targetURIList, List<Initiator> initiatorList, TaskCompleter taskCompleter) throws DeviceControllerException {
    _logger.info("{} deleteExportMask START...", storage.getSerialNumber());
    boolean removeLastInitiator = false;
    List<URI> volumesToBeUnmapped = new ArrayList<URI>();
    try {
        _logger.info("Export mask id: {}", exportMaskUri);
        if (volumeURIList != null) {
            _logger.info("deleteExportMask: volumes:  {}", Joiner.on(',').join(volumeURIList));
        }
        if (targetURIList != null) {
            _logger.info("deleteExportMask: assignments: {}", Joiner.on(',').join(targetURIList));
        }
        if (initiatorList != null) {
            if (!initiatorList.isEmpty()) {
                removeLastInitiator = true;
                _logger.info("deleteExportMask: initiators: {}", Joiner.on(',').join(initiatorList));
            }
        }
        // Get the context from the task completer, in case this is a rollback.
        boolean isRollback = WorkflowService.getInstance().isStepInRollbackState(taskCompleter.getOpId());
        if (isRollback) {
            List<URI> addedVolumes = new ArrayList<URI>();
            ExportOperationContext context = (ExportOperationContext) WorkflowService.getInstance().loadStepData(taskCompleter.getOpId());
            if (context != null && context.getOperations() != null) {
                _logger.info("Handling deleteExportMask as a result of rollback");
                ListIterator li = context.getOperations().listIterator(context.getOperations().size());
                while (li.hasPrevious()) {
                    ExportOperationContextOperation operation = (ExportOperationContextOperation) li.previous();
                    if (operation != null && VNXeExportOperationContext.OPERATION_ADD_VOLUMES_TO_HOST_EXPORT.equals(operation.getOperation())) {
                        addedVolumes = (List<URI>) operation.getArgs().get(0);
                        _logger.info("Removing volumes {} as part of rollback", Joiner.on(',').join(addedVolumes));
                    }
                }
            }
            volumesToBeUnmapped = addedVolumes;
            if (volumesToBeUnmapped == null || volumesToBeUnmapped.isEmpty()) {
                _logger.info("There was no context found for add volumes. So there is nothing to rollback.");
                taskCompleter.ready(_dbClient);
                return;
            }
        } else {
            volumesToBeUnmapped = volumeURIList;
        }
        ExportMask exportMask = _dbClient.queryObject(ExportMask.class, exportMaskUri);
        if (exportMask == null || exportMask.getInactive()) {
            throw new DeviceControllerException("Invalid ExportMask URI: " + exportMaskUri);
        }
        if (initiatorList.isEmpty()) {
            initiatorList = ExportUtils.getExportMaskInitiators(exportMask, _dbClient);
        }
        VNXeApiClient apiClient = getVnxeClient(storage);
        String hostId = getHostIdFromInitiators(initiatorList, apiClient);
        Set<String> allExportedVolumes = new HashSet<>();
        if (hostId != null) {
            ExportMaskValidationContext ctx = new ExportMaskValidationContext();
            ctx.setStorage(storage);
            ctx.setExportMask(exportMask);
            ctx.setBlockObjects(volumeURIList, _dbClient);
            ctx.setInitiators(initiatorList);
            // Allow exceptions to be thrown when not rolling back
            ctx.setAllowExceptions(!isRollback);
            AbstractVNXeValidator deleteMaskValidator = (AbstractVNXeValidator) validator.exportMaskDelete(ctx);
            deleteMaskValidator.setHostId(hostId);
            deleteMaskValidator.validate();
            if (removeLastInitiator) {
                ctx = new ExportMaskValidationContext();
                ctx.setStorage(storage);
                ctx.setExportMask(exportMask);
                ctx.setBlockObjects(volumeURIList, _dbClient);
                ctx.setAllowExceptions(!isRollback);
                AbstractVNXeValidator removeInitiatorsValidator = (AbstractVNXeValidator) validator.removeInitiators(ctx);
                removeInitiatorsValidator.setHostId(hostId);
                removeInitiatorsValidator.validate();
                boolean hasSharedInitiator = false;
                for (String strUri : exportMask.getInitiators()) {
                    if (ExportUtils.isInitiatorSharedByMasks(_dbClient, exportMask, URI.create(strUri))) {
                        hasSharedInitiator = true;
                        _logger.info("Initiators are used by multiple export masks");
                        break;
                    }
                }
                if (hasSharedInitiator) {
                    // if any initiator is shared, all initiators have to be shared, and each mask should have same set of initiators
                    // Otherwise, removing initiator will not be allowed, user can delete individual export mask
                    Collection<ExportMask> masksWithSharedInitiators = validateAllMasks(_dbClient, exportMask, apiClient, hostId);
                    _logger.info("Masks use the same initiators {}", Joiner.on(", ").join(Collections2.transform(masksWithSharedInitiators, CommonTransformerFunctions.fctnDataObjectToForDisplay())));
                    // need to unexport all volumes of all export masks
                    // except shared export co-exists with exclusive export, don't touch exclusive export
                    // in case of multiple shared exports (e.g., with different projects), all exported LUNs will be unmapped, regardless exclusive export
                    String exportType = ExportMaskUtils.getExportType(_dbClient, exportMask);
                    if (ExportGroupType.Cluster.name().equals(exportType)) {
                        Iterator<ExportMask> maskIter = masksWithSharedInitiators.iterator();
                        while (maskIter.hasNext()) {
                            ExportMask mask = maskIter.next();
                            if (!ExportGroupType.Cluster.name().equals(ExportMaskUtils.getExportType(_dbClient, mask))) {
                                _logger.info("Ignore exclusive export {}", mask.getMaskName());
                                maskIter.remove();
                            }
                        }
                    }
                    volumesToBeUnmapped.addAll(getExportedVolumes(_dbClient, storage.getId(), masksWithSharedInitiators));
                }
            }
            allExportedVolumes = ExportUtils.getAllLUNsForHost(_dbClient, exportMask);
        }
        String opId = taskCompleter.getOpId();
        Set<String> processedCGs = new HashSet<String>();
        for (URI volUri : volumesToBeUnmapped) {
            if (hostId != null) {
                BlockObject blockObject = BlockObject.fetch(_dbClient, volUri);
                String nativeId = blockObject.getNativeId();
                String cgName = VNXeUtils.getBlockObjectCGName(blockObject, _dbClient);
                if (cgName != null && !processedCGs.contains(cgName)) {
                    processedCGs.add(cgName);
                    VNXeUtils.getCGLock(workflowService, storage, cgName, opId);
                }
                if (URIUtil.isType(volUri, Volume.class)) {
                    apiClient.unexportLun(hostId, nativeId);
                } else if (URIUtil.isType(volUri, BlockSnapshot.class)) {
                    if (BlockObject.checkForRP(_dbClient, volUri)) {
                        _logger.info(String.format("BlockObject %s is a RecoverPoint bookmark. Un-exporting associated lun %s instead of snap.", volUri, nativeId));
                        apiClient.unexportLun(hostId, nativeId);
                    } else {
                        apiClient.unexportSnap(hostId, nativeId);
                        setSnapWWN(apiClient, blockObject, nativeId);
                    }
                }
            }
            // update the exportMask object
            exportMask.removeVolume(volUri);
        }
        // check if there are LUNs on array
        // initiator will not be able to removed if there are LUNs belongs to other masks (if initiator is shared), or unknown to ViPR
        Set<String> lunIds = new HashSet<>();
        if (hostId != null) {
            lunIds = apiClient.getHostLUNIds(hostId);
            _logger.info("Mapped resources {}", Joiner.on(", ").join(lunIds));
        }
        boolean hasLUN = lunIds.isEmpty() ? false : true;
        lunIds.removeAll(allExportedVolumes);
        boolean hasUnknownLUN = lunIds.isEmpty() ? false : true;
        _logger.info("Export mask deletion - hasLUN {}, hasUnknownLUN {}", hasLUN, hasUnknownLUN);
        for (Initiator initiator : initiatorList) {
            _logger.info("Processing initiator {}", initiator.getLabel());
            if (hostId != null && (!hasLUN || (!hasUnknownLUN && !ExportUtils.isInitiatorSharedByMasks(_dbClient, exportMask, initiator.getId())))) {
                String initiatorId = initiator.getInitiatorPort();
                if (Protocol.FC.name().equals(initiator.getProtocol())) {
                    initiatorId = initiator.getInitiatorNode() + ":" + initiatorId;
                }
                try {
                    if (hasLUN) {
                        // move and delete initiator
                        apiClient.deleteInitiators(new ArrayList<String>(Arrays.asList(initiatorId)));
                    } else {
                        apiClient.deleteInitiator(initiatorId);
                    }
                } catch (VNXeException e) {
                    _logger.warn("Error on deleting initiator: {}", e.getMessage());
                }
            }
            exportMask.removeFromExistingInitiators(initiator);
            exportMask.removeFromUserCreatedInitiators(initiator);
        }
        _dbClient.updateObject(exportMask);
        if (hostId != null) {
            List<VNXeHostInitiator> vnxeInitiators = apiClient.getInitiatorsByHostId(hostId);
            if (vnxeInitiators.isEmpty()) {
                Set<String> vnxeLUNIds = apiClient.getHostLUNIds(hostId);
                if ((vnxeLUNIds.isEmpty())) {
                    try {
                        apiClient.deleteHost(hostId);
                    } catch (VNXeException e) {
                        _logger.warn("Error on deleting host: {}", e.getMessage());
                    }
                }
            }
        }
        List<ExportGroup> exportGroups = ExportMaskUtils.getExportGroups(_dbClient, exportMask);
        if (exportGroups != null) {
            // Remove the mask references in the export group
            for (ExportGroup exportGroup : exportGroups) {
                // Remove this mask from the export group
                exportGroup.removeExportMask(exportMask.getId().toString());
            }
            // Update all of the export groups in the DB
            _dbClient.updateObject(exportGroups);
        }
        taskCompleter.ready(_dbClient);
    } catch (Exception e) {
        _logger.error("Unexpected error: deleteExportMask failed.", e);
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("deleteExportMask", e.getMessage());
        taskCompleter.error(_dbClient, error);
    }
    _logger.info("{} deleteExportMask END...", storage.getSerialNumber());
}
Also used : VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) ArrayList(java.util.ArrayList) VNXeHostInitiator(com.emc.storageos.vnxe.models.VNXeHostInitiator) URI(java.net.URI) Initiator(com.emc.storageos.db.client.model.Initiator) VNXeHostInitiator(com.emc.storageos.vnxe.models.VNXeHostInitiator) ExportOperationContext(com.emc.storageos.volumecontroller.impl.utils.ExportOperationContext) ExportOperationContextOperation(com.emc.storageos.volumecontroller.impl.utils.ExportOperationContext.ExportOperationContextOperation) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) BlockObject(com.emc.storageos.db.client.model.BlockObject) HashSet(java.util.HashSet) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ExportMask(com.emc.storageos.db.client.model.ExportMask) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) ListIterator(java.util.ListIterator) VNXeException(com.emc.storageos.vnxe.VNXeException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ExportMaskValidationContext(com.emc.storageos.volumecontroller.impl.validators.contexts.ExportMaskValidationContext) ExportGroup(com.emc.storageos.db.client.model.ExportGroup) AbstractVNXeValidator(com.emc.storageos.volumecontroller.impl.validators.vnxe.AbstractVNXeValidator) VNXeException(com.emc.storageos.vnxe.VNXeException)

Example 40 with VNXeException

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

the class VNXeSnapshotOperation method restoreGroupSnapshots.

@Override
public void restoreGroupSnapshots(StorageSystem storage, URI volume, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshot);
        VNXeApiClient apiClient = getVnxeClient(storage);
        VNXeLunGroupSnap lunGroupSnap = apiClient.getLunGroupSnapshot(snapshotObj.getReplicationGroupInstance());
        // Error out if the snapshot is attached
        if (lunGroupSnap.getIsAttached()) {
            _log.error("Snapshot {})is attached and cannot be used for restore", snapshotObj.getLabel());
            ServiceError error = DeviceControllerErrors.vnxe.cannotRestoreAttachedSnapshot(snapshot.toString());
            taskCompleter.error(_dbClient, error);
        }
        VNXeCommandJob job = apiClient.restoreLunGroupSnap(lunGroupSnap.getId());
        if (job != null) {
            ControllerServiceImpl.enqueueJob(new QueueJob(new VNXeBlockRestoreSnapshotJob(job.getId(), storage.getId(), taskCompleter)));
        }
    } catch (VNXeException e) {
        _log.error("Restore group snapshot got the exception", e);
        taskCompleter.error(_dbClient, e);
    } catch (Exception ex) {
        _log.error("Restore group snapshot got the exception", ex);
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("RestoreSnapshotJob", ex.getMessage());
        taskCompleter.error(_dbClient, error);
    }
}
Also used : VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) VNXeLunGroupSnap(com.emc.storageos.vnxe.models.VNXeLunGroupSnap) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeBlockRestoreSnapshotJob(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeBlockRestoreSnapshotJob) VNXeException(com.emc.storageos.vnxe.VNXeException) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) VNXeException(com.emc.storageos.vnxe.VNXeException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

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