Search in sources :

Example 66 with VNXeException

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

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

the class VNXUnityFileStorageDeviceTest method testFileSystemDelete.

/**
 * Tests file system delete with existing smb shares and nfs exports.
 *
 * @throws Exception
 */
@Test
public void testFileSystemDelete() throws Exception {
    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()));
    // 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);
    // 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);
    // 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);
    // 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)

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