Search in sources :

Example 81 with Snapshot

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

the class VNXUnityFileStorageDeviceTest method testSnapshotDelete.

/**
 * Tests snapshot delete with existing SMB shares and NFS exports.
 *
 * @throws Exception
 */
@Test
public void testSnapshotDelete() throws Exception {
    // create FS to use
    FileShare fs = new FileShare();
    fs.setId(URIUtil.createId(FileShare.class));
    fs.setLabel("test");
    fs.setCapacity(102400L);
    FileDeviceInputOutput args = new FileDeviceInputOutput();
    args.addStoragePool(_pool);
    args.addFSFileObject(fs);
    Assert.assertTrue("doCreateFS failed", _unity.doCreateFS(_device, args).getCommandStatus().equals(Operation.Status.ready.name()));
    // create snap
    Snapshot snap = new Snapshot();
    snap.setId(URIUtil.createId(Snapshot.class));
    snap.setLabel("test_snap");
    args.addSnapshotFileObject(snap);
    Assert.assertTrue("doSnapshotFS failed", _unity.doSnapshotFS(_device, args).getCommandStatus().equals(Operation.Status.ready.name()));
    // share snap with SMB
    SMBFileShare smbFileShare = new SMBFileShare("TestSMBShare", "Share created by unit test.", "allow", "change", -1);
    Assert.assertTrue("SMB share doShare() failed", _unity.doShare(_device, args, smbFileShare).getCommandStatus().equals(Operation.Status.ready.name()));
    Assert.assertTrue("SMB share doShare() failed, share not added to snap", snap.getSMBFileShares().keySet().contains(smbFileShare.getName()));
    Assert.assertTrue("SMB share doShare() failed, number of shares does not match", snap.getSMBFileShares().keySet().size() == 1);
    // add additional share
    SMBFileShare smbFileShare01 = new SMBFileShare("TestSMBShare01", "Share created by unit test.", "allow", "change", -1);
    Assert.assertTrue("SMB share doShare() failed", _unity.doShare(_device, args, smbFileShare01).getCommandStatus().equals(Operation.Status.ready.name()));
    Assert.assertTrue("SMB share doShare() failed, share not added to snap", snap.getSMBFileShares().keySet().contains(smbFileShare01.getName()));
    Assert.assertTrue("SMB share doShare() failed, number of shares does not match", snap.getSMBFileShares().keySet().size() == 2);
    // add additional share
    SMBFileShare smbFileShare02 = new SMBFileShare("TestSMBShare02", "Share created by unit test.", "allow", "change", -1);
    Assert.assertTrue("SMB share doShare() failed", _unity.doShare(_device, args, smbFileShare02).getCommandStatus().equals(Operation.Status.ready.name()));
    Assert.assertTrue("SMB share doShare() failed, share not added to snap", snap.getSMBFileShares().keySet().contains(smbFileShare02.getName()));
    Assert.assertTrue("SMB share doShare() failed, number of shares does not match", snap.getSMBFileShares().keySet().size() == 3);
    // export snap
    List<String> clients = new ArrayList<String>();
    clients.add(client1);
    FileExport export1 = new FileExport(clients, "", "sys", "root", "nobody", "nfs");
    Assert.assertTrue("doExport failed", _unity.doExport(_device, args, Arrays.asList(export1)).getCommandStatus().equals(Operation.Status.ready.name()));
    Assert.assertTrue("doExport failed, export not added to snapshot", snap.getFsExports().keySet().size() == 1);
    // add client to the same export
    clients.add(client2);
    FileExport export2 = new FileExport(clients, "", "sys", "root", "nobody", "nfs");
    Assert.assertTrue("doExport failed", _unity.doExport(_device, args, Arrays.asList(export1)).getCommandStatus().equals(Operation.Status.ready.name()));
    Assert.assertTrue("doExport failed, export not added to snapshot", snap.getFsExports().keySet().size() == 1);
    // create a new export
    clients = new ArrayList<String>();
    clients.add(client3);
    clients.add(client4);
    FileExport export3 = new FileExport(clients, "", "sys", "rw", "nobody", "nfs");
    Assert.assertTrue("doExport failed", _unity.doExport(_device, args, Arrays.asList(export3)).getCommandStatus().equals(Operation.Status.ready.name()));
    Assert.assertTrue("doExport failed, export not added to snapshot", snap.getFsExports().keySet().size() == 2);
    // delete snap
    Assert.assertTrue("doDeleteSnapshot failed", _unity.doDeleteSnapshot(_device, args).getCommandStatus().equals(Operation.Status.ready.name()));
    VNXeApiClient apiclient = _unity.getVnxUnityClient(_device);
    try {
        apiclient.getFileSystemByFSName(args.getFileObjMountPath());
        Assert.assertTrue("Snapshot delete failed: " + args.getFileObjMountPath(), false);
    } catch (VNXeException uex) {
        System.out.println("doDeleteSnapshot --- delete snapshot success: " + uex.getCause());
    }
    // delete file system
    Assert.assertTrue("doDeleteFS failed", _unity.doDeleteFS(_device, args).getCommandStatus().equals(Operation.Status.ready.name()));
    try {
        apiclient.getFileSystemByFSName(args.getFsMountPath());
        Assert.assertTrue("FS delete failed: " + args.getFsMountPath(), false);
    } catch (VNXeException uex) {
        System.out.println("doDeleteFS --- delete FS success: " + uex.getCause());
    }
}
Also used : Snapshot(com.emc.storageos.db.client.model.Snapshot) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeException(com.emc.storageos.vnxe.VNXeException) ArrayList(java.util.ArrayList) FileExport(com.emc.storageos.db.client.model.FileExport) FileDeviceInputOutput(com.emc.storageos.volumecontroller.FileDeviceInputOutput) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) Test(org.junit.Test)

Example 82 with Snapshot

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

the class FileDeviceController method unexport.

@Override
public void unexport(URI storage, URI fileUri, List<FileShareExport> exports, String opId) throws ControllerException {
    ControllerUtils.setThreadLocalLogData(fileUri, opId);
    FileObject fsObj = null;
    FileShare fs = null;
    Snapshot snapshotObj = null;
    StorageSystem storageObj = null;
    try {
        storageObj = _dbClient.queryObject(StorageSystem.class, storage);
        FileDeviceInputOutput args = new FileDeviceInputOutput();
        boolean isFile = false;
        if (URIUtil.isType(fileUri, FileShare.class)) {
            isFile = true;
            fs = _dbClient.queryObject(FileShare.class, fileUri);
            setVirtualNASinArgs(fs.getVirtualNAS(), args);
            fsObj = fs;
            args.addFSFileObject(fs);
            StoragePool pool = _dbClient.queryObject(StoragePool.class, fs.getPool());
            args.addStoragePool(pool);
        } else {
            snapshotObj = _dbClient.queryObject(Snapshot.class, fileUri);
            fsObj = snapshotObj;
            fs = _dbClient.queryObject(FileShare.class, snapshotObj.getParent());
            setVirtualNASinArgs(fs.getVirtualNAS(), args);
            args.addFileShare(fs);
            args.addSnapshotFileObject(snapshotObj);
            StoragePool pool = _dbClient.queryObject(StoragePool.class, fs.getPool());
            args.addStoragePool(pool);
        }
        args.setFileOperation(isFile);
        args.setOpId(opId);
        _log.info("Export details...  ");
        List<FileExport> fileExports = new ArrayList<FileExport>();
        List<FileExportRule> exportRules = new ArrayList<FileExportRule>();
        if (exports != null) {
            for (FileShareExport fileShareExport : exports) {
                FileExport fileExport = fileShareExport.getFileExport();
                fileExports.add(fileExport);
                _log.info("FileExport:" + fileExport.getClients() + ":" + fileExport.getStoragePortName() + ":" + fileExport.getStoragePort() + ":" + fileExport.getRootUserMapping() + ":" + fileExport.getPermissions() + ":" + fileExport.getProtocol() + ":" + fileExport.getSecurityType() + ":" + fileExport.getMountPoint() + ":" + fileExport.getMountPath() + ":" + fileExport.getPath());
                _log.info("FileShareExport: " + fileExport.getFileExportKey());
                // Per New Model : Lets create the Export Rules, So these will not get missed.
                FileExportRule rule = getFileExportRule(fileUri, fileExport, args);
                exportRules.add(rule);
            }
        } else {
            _log.info("Exports are null");
        }
        WorkflowStepCompleter.stepExecuting(opId);
        BiosCommandResult result = getDevice(storageObj.getSystemType()).doUnexport(storageObj, args, fileExports);
        if (result.getCommandPending()) {
            return;
        }
        if (!result.isCommandSuccess() && !result.getCommandPending()) {
            WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
        }
        // Set status
        fsObj.getOpStatus().updateTaskStatus(opId, result.toOperation());
        String eventMsg = result.isCommandSuccess() ? "" : result.getMessage();
        OperationTypeEnum auditType = (isFile) ? OperationTypeEnum.UNEXPORT_FILE_SYSTEM : OperationTypeEnum.UNEXPORT_FILE_SNAPSHOT;
        if (result.isCommandSuccess()) {
            // Remove Export
            for (FileExport fileExport : fileExports) {
                fsObj.getFsExports().remove(fileExport.getFileExportKey());
                _log.info("FileShareExport removed : " + fileExport.getFileExportKey());
            }
            // Query Existing Export rule and if found set to delete.
            for (FileExportRule rule : exportRules) {
                URIQueryResultList dbresult = new URIQueryResultList();
                if (!args.getFileOperation() && rule.getSnapshotExportIndex() != null) {
                    _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getSnapshotExportRuleConstraint(rule.getSnapshotExportIndex()), dbresult);
                } else if (rule.getFsExportIndex() != null) {
                    _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getFileExportRuleConstraint(rule.getFsExportIndex()), dbresult);
                }
                Iterator<URI> it = dbresult.iterator();
                while (it.hasNext()) {
                    if (dbresult.iterator().hasNext()) {
                        rule = _dbClient.queryObject(FileExportRule.class, it.next());
                        if (rule != null && !rule.getInactive()) {
                            _log.info("Existing DB Model found {}", rule);
                            rule.setInactive(true);
                            _dbClient.updateObject(rule);
                            break;
                        }
                    }
                }
            }
            FSExportMap exportsMap = fsObj.getFsExports();
            List<FileExport> fsExports = new ArrayList<FileExport>(exportsMap.values());
            if (isFile) {
                recordFileDeviceOperation(_dbClient, auditType, result.isCommandSuccess(), eventMsg, getExportClientExtensions(fsExports), fs, storageObj);
            } else {
                recordFileDeviceOperation(_dbClient, auditType, result.isCommandSuccess(), eventMsg, getExportClientExtensions(fsExports), snapshotObj, fs, storageObj);
            }
        }
        _dbClient.updateObject(fsObj);
        if (result.isCommandSuccess()) {
            WorkflowStepCompleter.stepSucceded(opId);
        }
    } catch (Exception e) {
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        WorkflowStepCompleter.stepFailed(opId, serviceError);
        String[] params = { storage.toString(), fileUri.toString(), e.getMessage() };
        _log.error("Unable to unexport file system or snapshot: storage {}, FS/snapshot URI {}: {}", params);
        for (FileShareExport fsExport : exports) {
            _log.error("{}  ", fsExport);
        }
        updateTaskStatus(opId, fsObj, e);
        if (URIUtil.isType(fileUri, FileShare.class)) {
            if ((fs != null) && (storageObj != null)) {
                recordFileDeviceOperation(_dbClient, OperationTypeEnum.UNEXPORT_FILE_SYSTEM, false, e.getMessage(), "", fs, storageObj);
            }
        } else {
            if ((fs != null) && (storageObj != null) && (snapshotObj != null)) {
                recordFileDeviceOperation(_dbClient, OperationTypeEnum.UNEXPORT_FILE_SNAPSHOT, false, e.getMessage(), "", snapshotObj, fs, storageObj);
            }
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) StoragePool(com.emc.storageos.db.client.model.StoragePool) OperationTypeEnum(com.emc.storageos.services.OperationTypeEnum) ArrayList(java.util.ArrayList) FileDeviceInputOutput(com.emc.storageos.volumecontroller.FileDeviceInputOutput) FSExportMap(com.emc.storageos.db.client.model.FSExportMap) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) URISyntaxException(java.net.URISyntaxException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) FileShareExport(com.emc.storageos.volumecontroller.FileShareExport) Snapshot(com.emc.storageos.db.client.model.Snapshot) FileExportRule(com.emc.storageos.db.client.model.FileExportRule) FileExport(com.emc.storageos.db.client.model.FileExport) FileObject(com.emc.storageos.db.client.model.FileObject) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 83 with Snapshot

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

the class FileDeviceController method syncSnapshotList.

private void syncSnapshotList(StorageSystem storageObj, FileShare fsObj, FileDeviceInputOutput args) {
    // Retrieve all snapshots from DB that belong to this file system
    URIQueryResultList results = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getFileshareSnapshotConstraint(fsObj.getId()), results);
    // Setup snapshot name-object map
    Map<String, Snapshot> snapshotsInDB = new ConcurrentHashMap<String, Snapshot>();
    while (results.iterator().hasNext()) {
        URI uri = results.iterator().next();
        Snapshot snapObj = _dbClient.queryObject(Snapshot.class, uri);
        snapshotsInDB.put(snapObj.getName(), snapObj);
    }
    // Retrieve list of valid snapshot names from the device
    List<String> snapshotsOnDevice = new ArrayList<String>();
    BiosCommandResult result = getDevice(storageObj.getSystemType()).getFSSnapshotList(storageObj, args, snapshotsOnDevice);
    Operation op = result.toOperation();
    if (!op.getStatus().equalsIgnoreCase(Operation.Status.ready.name())) {
        _log.warn("The list of snapshots could not be retrieved from the device {}.", storageObj.getId());
    } else {
        // Iterate through the snapshots in the DB and if name not found in
        // the list returned by the device, mark snapshot in DB as inactive
        Set<String> snapshotNames = snapshotsInDB.keySet();
        for (String snapshotName : snapshotNames) {
            if (!snapshotsOnDevice.contains(snapshotName)) {
                snapshotsInDB.get(snapshotName).setInactive(true);
                _dbClient.updateObject(snapshotsInDB.get(snapshotName));
            }
        }
    // Iterate through the snapshot list from device and if a
    // snapshot is found on the device but not in the DB, add the
    // newly discovered snapshot to the DB.
    }
}
Also used : Snapshot(com.emc.storageos.db.client.model.Snapshot) ArrayList(java.util.ArrayList) Operation(com.emc.storageos.db.client.model.Operation) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 84 with Snapshot

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

the class FileDeviceController method restoreFS.

@Override
public void restoreFS(URI storage, URI fs, URI snapshot, String opId) throws ControllerException {
    ControllerUtils.setThreadLocalLogData(fs, opId);
    StorageSystem storageObj = null;
    FileShare fsObj = null;
    Snapshot snapshotObj = null;
    FileDeviceInputOutput args = new FileDeviceInputOutput();
    Operation op = null;
    try {
        String[] params = { storage.toString(), snapshot.toString(), fs.toString() };
        _log.info("Restore FS: {} {} {}", params);
        storageObj = _dbClient.queryObject(StorageSystem.class, storage);
        fsObj = _dbClient.queryObject(FileShare.class, fs);
        snapshotObj = _dbClient.queryObject(Snapshot.class, snapshot);
        args.addFileShare(fsObj);
        args.addSnapshot(snapshotObj);
        args.setOpId(opId);
        WorkflowStepCompleter.stepExecuting(opId);
        // Acquire lock for VNXFILE Storage System
        acquireStepLock(storageObj, opId);
        BiosCommandResult result = getDevice(storageObj.getSystemType()).doRestoreFS(storageObj, args);
        if (result.getCommandPending()) {
            return;
        }
        if (!result.isCommandSuccess() && !result.getCommandPending()) {
            WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
        }
        if (result.isCommandSuccess()) {
            WorkflowStepCompleter.stepSucceded(opId);
        }
        op = result.toOperation();
        snapshotObj.getOpStatus().updateTaskStatus(opId, op);
        fsObj.getOpStatus().updateTaskStatus(opId, op);
        _dbClient.updateObject(fsObj);
        _dbClient.updateObject(snapshotObj);
        String eventMsg = result.isCommandSuccess() ? "" : result.getMessage();
        recordFileDeviceOperation(_dbClient, OperationTypeEnum.RESTORE_FILE_SNAPSHOT, result.isCommandSuccess(), eventMsg, "", fsObj, snapshot);
    } catch (Exception e) {
        String[] params = { storage.toString(), fs.toString(), snapshot.toString(), e.getMessage() };
        _log.error("Unable to restore file system from snapshot: storage {}, FS {}, snapshot {}: {}", params);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        WorkflowStepCompleter.stepFailed(opId, serviceError);
        updateTaskStatus(opId, snapshotObj, e);
        if ((fsObj != null) && (snapshotObj != null)) {
            recordFileDeviceOperation(_dbClient, OperationTypeEnum.RESTORE_FILE_SNAPSHOT, false, e.getMessage(), "", fsObj, snapshotObj);
        }
    }
    if ((op != null) && (!(op.getStatus().equalsIgnoreCase(Operation.Status.error.name())))) {
        try {
            // Synchronize snapshot list in DB with the list on the device
            syncSnapshotList(storageObj, fsObj, args);
        } catch (Exception ex) {
            String[] params = { storage.toString(), fs.toString(), snapshot.toString() };
            _log.warn("Restore succeeded but failed to sync snapshot list in DB with list on the device: storage {}, FS {}, snapshot {}", params);
        }
    }
}
Also used : Snapshot(com.emc.storageos.db.client.model.Snapshot) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) FileDeviceInputOutput(com.emc.storageos.volumecontroller.FileDeviceInputOutput) Operation(com.emc.storageos.db.client.model.Operation) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) URISyntaxException(java.net.URISyntaxException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 85 with Snapshot

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

the class FileDeviceController method share.

@Override
public void share(URI storage, URI uri, FileSMBShare smbShare, String opId) throws ControllerException {
    ControllerUtils.setThreadLocalLogData(uri, opId);
    FileObject fileObject = null;
    StorageSystem storageObj = null;
    FileShare fsObj = null;
    Snapshot snapshotObj = null;
    try {
        storageObj = _dbClient.queryObject(StorageSystem.class, storage);
        _log.info(String.format("Create SMB share details --- name: %1$s, description: %2$s, permissionType: %3$s, permission: %4$s , maxUsers: %5$s", smbShare.getName(), smbShare.getDescription(), smbShare.getPermissionType(), smbShare.getPermission(), (smbShare.getMaxUsers() > 0) ? smbShare.getMaxUsers() : "unlimited"));
        _log.info("Path {}", smbShare.getPath());
        // get db object for smb share
        SMBFileShare smbFileShare = smbShare.getSMBFileShare();
        FileDeviceInputOutput args = new FileDeviceInputOutput();
        args.setOpId(opId);
        if (URIUtil.isType(uri, FileShare.class)) {
            fsObj = _dbClient.queryObject(FileShare.class, uri);
            fileObject = fsObj;
            args.addFSFileObject(fsObj);
            args.setFileOperation(true);
            setVirtualNASinArgs(fsObj.getVirtualNAS(), args);
            // Acquire lock for VNXFILE Storage System
            WorkflowStepCompleter.stepExecuting(opId);
            acquireStepLock(storageObj, opId);
            BiosCommandResult result = getDevice(storageObj.getSystemType()).doShare(storageObj, args, smbFileShare);
            if (result.getCommandPending()) {
                return;
            }
            if (!result.isCommandSuccess() && !result.getCommandPending()) {
                WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
            }
            fsObj.getOpStatus().updateTaskStatus(opId, result.toOperation());
            _dbClient.updateObject(fsObj);
            List<SMBFileShare> shares = new ArrayList<SMBFileShare>();
            shares.add(smbFileShare);
            if (result.isCommandSuccess()) {
                _log.info("File share created successfully");
                createDefaultACEForSMBShare(uri, smbShare, storageObj.getSystemType());
                WorkflowStepCompleter.stepSucceded(opId);
            }
            String eventMsg = result.isCommandSuccess() ? "" : result.getMessage();
            recordFileDeviceOperation(_dbClient, OperationTypeEnum.CREATE_FILE_SYSTEM_SHARE, result.isCommandSuccess(), eventMsg, getShareNameExtensions(shares), fsObj, smbShare);
        } else {
            snapshotObj = _dbClient.queryObject(Snapshot.class, uri);
            fileObject = snapshotObj;
            args.addSnapshotFileObject(snapshotObj);
            fsObj = _dbClient.queryObject(FileShare.class, snapshotObj.getParent());
            args.addFileShare(fsObj);
            args.setFileOperation(false);
            setVirtualNASinArgs(fsObj.getVirtualNAS(), args);
            WorkflowStepCompleter.stepExecuting(opId);
            // Acquire lock for VNXFILE Storage System
            acquireStepLock(storageObj, opId);
            BiosCommandResult result = getDevice(storageObj.getSystemType()).doShare(storageObj, args, smbFileShare);
            if (result.getCommandPending()) {
                return;
            }
            if (!result.isCommandSuccess() && !result.getCommandPending()) {
                WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
            }
            snapshotObj.getOpStatus().updateTaskStatus(opId, result.toOperation());
            _dbClient.updateObject(snapshotObj);
            List<SMBFileShare> shares = new ArrayList<SMBFileShare>();
            shares.add(smbFileShare);
            if (result.isCommandSuccess()) {
                _log.info("File snapshot share created successfully");
                WorkflowStepCompleter.stepSucceded(opId);
                createDefaultACEForSMBShare(uri, smbShare, storageObj.getSystemType());
            }
            String eventMsg = result.isCommandSuccess() ? "" : result.getMessage();
            recordFileDeviceOperation(_dbClient, OperationTypeEnum.CREATE_FILE_SNAPSHOT_SHARE, result.isCommandSuccess(), eventMsg, getShareNameExtensions(shares), snapshotObj, fsObj, smbShare);
        }
    } catch (Exception e) {
        String[] params = { storage.toString(), uri.toString(), smbShare.getName(), e.getMessage() };
        _log.error("Unable to create file system or snapshot share: storage {}, FS/snapshot URI {}, SMB share {}: {}", params);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        WorkflowStepCompleter.stepFailed(opId, serviceError);
        updateTaskStatus(opId, fileObject, e);
        if (URIUtil.isType(uri, FileShare.class)) {
            if ((fsObj != null) && (storageObj != null)) {
                recordFileDeviceOperation(_dbClient, OperationTypeEnum.CREATE_FILE_SYSTEM_SHARE, false, e.getMessage(), "", fsObj, smbShare, storageObj);
            }
        } else {
            if ((fsObj != null) && (storageObj != null) && (snapshotObj != null)) {
                recordFileDeviceOperation(_dbClient, OperationTypeEnum.CREATE_FILE_SNAPSHOT_SHARE, false, e.getMessage(), "", snapshotObj, fsObj, smbShare, storageObj);
            }
        }
    }
}
Also used : Snapshot(com.emc.storageos.db.client.model.Snapshot) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ArrayList(java.util.ArrayList) FileDeviceInputOutput(com.emc.storageos.volumecontroller.FileDeviceInputOutput) FileObject(com.emc.storageos.db.client.model.FileObject) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) URISyntaxException(java.net.URISyntaxException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

Snapshot (com.emc.storageos.db.client.model.Snapshot)92 FileShare (com.emc.storageos.db.client.model.FileShare)59 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)52 URI (java.net.URI)36 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)34 ControllerException (com.emc.storageos.volumecontroller.ControllerException)34 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)32 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)31 ArrayList (java.util.ArrayList)24 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)23 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)22 FileObject (com.emc.storageos.db.client.model.FileObject)21 URISyntaxException (java.net.URISyntaxException)21 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)19 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)19 WorkflowException (com.emc.storageos.workflow.WorkflowException)19 MapFileSnapshot (com.emc.storageos.api.mapper.functions.MapFileSnapshot)18 Path (javax.ws.rs.Path)18 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)17 Produces (javax.ws.rs.Produces)17