Search in sources :

Example 21 with VNXeApiClient

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

the class VNXUnityFileStorageDeviceTest method setPools.

public void setPools() {
    VNXeApiClient apiclient = _unity.getVnxUnityClient(_device);
    List<VNXePool> pools = apiclient.getPools();
    VNXePool pool = pools.get(0);
    List<String> proto = new ArrayList<String>();
    proto.add("CIFS");
    StringSet protocols = new StringSet(proto);
    String poolNativeGuid = NativeGUIDGenerator.generateNativeGuid(_device, pool.getId(), NativeGUIDGenerator.POOL);
    _pool.setId(URIUtil.createId(StoragePool.class));
    _pool.setLabel(poolNativeGuid);
    _pool.setNativeGuid(poolNativeGuid);
    _pool.setProtocols(protocols);
    _pool.setOperationalStatus(StoragePool.PoolOperationalStatus.READY.name());
    _pool.setPoolServiceType(PoolServiceType.block_file.toString());
    _pool.setStorageDevice(_device.getId());
    _pool.setNativeId(pool.getId());
    _pool.setPoolName(pool.getName());
    _pool.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
    _pool.setSupportedResourceTypes(StoragePool.SupportedResourceTypes.THIN_AND_THICK.toString());
    _pool.setPoolClassName(StoragePool.PoolClassNames.VNXe_Pool.name());
    _pool.setPoolServiceType(StoragePool.PoolServiceType.block_file.name());
    _pool.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
    _dbClient.updateObject(_pool);
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) ArrayList(java.util.ArrayList) StringSet(com.emc.storageos.db.client.model.StringSet) VNXePool(com.emc.storageos.vnxe.models.VNXePool)

Example 22 with VNXeApiClient

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

the class VNXUnityFileStorageDeviceTest method testDiscoverUnityStoragePools.

/**
 * Tests Unity storage pool discovery
 *
 * @throws Exception
 */
@Test
public void testDiscoverUnityStoragePools() {
    try {
        VNXeApiClient apiclient = _unity.getVnxUnityClient(_device);
        List<? extends VNXePool> unityStoragePools = apiclient.getPools();
        Assert.assertTrue("Unity Storage Pool discovery failed " + unityStoragePools.size(), true);
    } catch (VNXeException uex) {
        System.out.println("Unity Storage pool discovery failed: " + uex.getCause());
    }
}
Also used : VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeException(com.emc.storageos.vnxe.VNXeException) Test(org.junit.Test)

Example 23 with VNXeApiClient

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

the class VNXUnityFileStorageDeviceTest method testDiscoverUnityStoragePorts.

/**
 * Tests Unity storage port discovery
 *
 * @throws Exception
 */
@Test
public void testDiscoverUnityStoragePorts() {
    try {
        VNXeApiClient apiclient = _unity.getVnxUnityClient(_device);
        List<VNXeFileInterface> unityStoragePorts = apiclient.getFileInterfaces();
        Assert.assertTrue("Unity Storage Port discovery failed " + unityStoragePorts.size(), true);
    } catch (VNXeException uex) {
        System.out.println("Unity Storage port discovery failed: " + uex.getCause());
    }
}
Also used : VNXeFileInterface(com.emc.storageos.vnxe.models.VNXeFileInterface) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeException(com.emc.storageos.vnxe.VNXeException) Test(org.junit.Test)

Example 24 with VNXeApiClient

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

the class VNXUnityFileStorageDeviceTest method testFileShares.

/**
 * Tests file system create, expand, smb share, nfs exports, file system delete.
 *
 * @throws Exception
 */
@Test
public void testFileShares() throws Exception {
    FileShare fs = new FileShare();
    fs.setId(URIUtil.createId(FileShare.class));
    fs.setLabel("test");
    fs.setCapacity(204800L);
    FileDeviceInputOutput args = new FileDeviceInputOutput();
    args.addStoragePool(_pool);
    args.addFSFileObject(fs);
    Assert.assertTrue("doCreateFS failed", _unity.doCreateFS(_device, args).getCommandStatus().equals(Operation.Status.ready.name()));
    // test expand capacity
    args.setNewFSCapacity(102400L);
    Assert.assertTrue("doExpandFS failed", _unity.doExpandFS(_device, args).getCommandStatus().equals(Operation.Status.error.name()));
    args.setNewFSCapacity(307200L);
    Assert.assertTrue("doExpandFS failed", _unity.doExpandFS(_device, args).getCommandStatus().equals(Operation.Status.ready.name()));
    // share file system 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 FS", fs.getSMBFileShares().keySet().contains(smbFileShare.getName()));
    Assert.assertTrue("SMB share doShare() failed, number of shares does not match", fs.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 FS", fs.getSMBFileShares().keySet().contains(smbFileShare01.getName()));
    Assert.assertTrue("SMB share doShare() failed, number of shares does not match", fs.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 FS", fs.getSMBFileShares().keySet().contains(smbFileShare02.getName()));
    Assert.assertTrue("SMB share doShare() failed, number of shares does not match", fs.getSMBFileShares().keySet().size() == 3);
    // modify SMB share
    smbFileShare02.setDescription("Share was modified.");
    Assert.assertTrue("SMB share doShare() for modify failed", _unity.doShare(_device, args, smbFileShare02).getCommandStatus().equals(Operation.Status.ready.name()));
    Assert.assertTrue("SMB share doShare() failed, share not added to FS", fs.getSMBFileShares().keySet().contains(smbFileShare02.getName()));
    Assert.assertTrue("SMB share doShare() failed, share was not modified", fs.getSMBFileShares().get(smbFileShare02.getName()).getDescription().equals("Share was modified."));
    Assert.assertTrue("SMB share doShare() failed, number of shares does not match", fs.getSMBFileShares().keySet().size() == 3);
    // delete one SMB share for FS
    Assert.assertTrue("SMB share doDeleteShare() failed", _unity.doDeleteShare(_device, args, smbFileShare).getCommandStatus().equals(Operation.Status.ready.name()));
    Assert.assertFalse("SMB share doDeleteShare() failed, share was not deleted from FS", fs.getSMBFileShares().keySet().contains(smbFileShare.getName()));
    Assert.assertTrue("SMB share doDeleteShare() failed, number of shares does not match", fs.getSMBFileShares().keySet().size() == 2);
    // delete all SMB shareds for FS
    Assert.assertTrue("SMB share doDeleteShares() failed", _unity.doDeleteShares(_device, args).getCommandStatus().equals(Operation.Status.ready.name()));
    Assert.assertTrue("SMB share doDeleteShares() failed, shares were not deleted from FS", fs.getSMBFileShares().isEmpty());
    // export
    List<String> clients = new ArrayList<String>();
    clients.add(client1);
    FileExport export1 = new FileExport(clients, "port1", "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 FS", fs.getFsExports().keySet().size() == 1);
    // add client
    clients.add(client2);
    FileExport export2 = new FileExport(clients, "port1", "sys", "root", "nobody", "nfs");
    Assert.assertTrue("doExport failed", _unity.doExport(_device, args, Arrays.asList(export2)).getCommandStatus().equals(Operation.Status.ready.name()));
    Assert.assertTrue("doExport failed, export not added to FS", fs.getFsExports().keySet().size() == 1);
    // create a new export
    clients = new ArrayList<String>();
    clients.add(client3);
    FileExport export3 = new FileExport(clients, "port1", "sys", "rw", "root", "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 FS", fs.getFsExports().keySet().size() == 2);
    // unexport
    Assert.assertTrue("doUnexport failed", _unity.doUnexport(_device, args, Arrays.asList(export1)).getCommandStatus().equals(Operation.Status.ready.name()));
    Assert.assertTrue("doUnexport failed, export not deleted from FS", fs.getFsExports().keySet().size() == 1);
    Assert.assertTrue("doUnexport failed", _unity.doUnexport(_device, args, Arrays.asList(export3)).getCommandStatus().equals(Operation.Status.ready.name()));
    Assert.assertTrue("doUnexport failed, export not deleted from FS", fs.getFsExports().keySet().isEmpty());
    // delete
    Assert.assertTrue("doDeleteFs failed", _unity.doDeleteFS(_device, args).getCommandStatus().equals(Operation.Status.ready.name()));
    VNXeApiClient apiclient = _unity.getVnxUnityClient(_device);
    try {
        apiclient.getFileSystemByFSName(args.getFsLabel());
        Assert.assertTrue("File system delete failed: " + args.getFsLabel(), false);
    } catch (VNXeException uex) {
        System.out.println("doDeleteFS --- delete FS success: " + uex.getCause());
    }
}
Also used : 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 25 with VNXeApiClient

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

the class VNXeStorageDevice 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 = getVnxeClient(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) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) FileShareExport(com.emc.storageos.volumecontroller.FileShareExport) Snapshot(com.emc.storageos.db.client.model.Snapshot) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) 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)

Aggregations

VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)123 VNXeException (com.emc.storageos.vnxe.VNXeException)79 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)66 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)55 VNXeCommandJob (com.emc.storageos.vnxe.models.VNXeCommandJob)48 ControllerException (com.emc.storageos.volumecontroller.ControllerException)44 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)40 URI (java.net.URI)36 ArrayList (java.util.ArrayList)34 FileShare (com.emc.storageos.db.client.model.FileShare)33 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)33 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)30 Snapshot (com.emc.storageos.db.client.model.Snapshot)27 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)24 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)23 DbClient (com.emc.storageos.db.client.DbClient)21 Volume (com.emc.storageos.db.client.model.Volume)18 VNXeFileTaskCompleter (com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFileTaskCompleter)18 FileExport (com.emc.storageos.db.client.model.FileExport)14 HashMap (java.util.HashMap)13