Search in sources :

Example 1 with VNXeApiClient

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

the class VNXUnityFileStorageDeviceTest method getStorageHADomain.

public List<StorageHADomain> getStorageHADomain() {
    VNXeApiClient apiclient = _unity.getVnxUnityClient(_device);
    List<VNXeNasServer> nasServers = apiclient.getNasServers();
    List<StorageHADomain> haDomains = new ArrayList<StorageHADomain>();
    List<String> proto = new ArrayList<String>();
    proto.add("CIFS");
    StringSet protocols = new StringSet(proto);
    for (VNXeNasServer nasServer : nasServers) {
        StorageHADomain haDomain = new StorageHADomain();
        haDomain.setId(URIUtil.createId(StorageHADomain.class));
        String adapterNativeGuid = NativeGUIDGenerator.generateNativeGuid(_device, nasServer.getName(), NativeGUIDGenerator.ADAPTER);
        haDomain.setNativeGuid(adapterNativeGuid);
        haDomain.setStorageDeviceURI(_device.getId());
        haDomain.setAdapterName(nasServer.getName());
        haDomain.setName(nasServer.getName());
        haDomain.setSerialNumber(nasServer.getId());
        haDomain.setFileSharingProtocols(protocols);
        haDomain.setVirtual(true);
        haDomains.add(haDomain);
    }
    return haDomains;
}
Also used : VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeNasServer(com.emc.storageos.vnxe.models.VNXeNasServer) ArrayList(java.util.ArrayList) StringSet(com.emc.storageos.db.client.model.StringSet) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain)

Example 2 with VNXeApiClient

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

the class VNXUnityFileStorageDeviceTest method testSnapshots.

/**
 * Tests snapshot create, smb share, nfs exports, snapshot delete.
 *
 * @throws Exception
 */
@Test
public void testSnapshots() 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);
    // delete one SMB share for the snap
    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 snap", snap.getSMBFileShares().keySet().contains(smbFileShare.getName()));
    Assert.assertTrue("SMB share doDeleteShare() failed, number of shares does not match", snap.getSMBFileShares().keySet().size() == 2);
    // delete all SMB shares for snap
    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 snap", snap.getSMBFileShares().isEmpty());
    // 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);
    // 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 snapshot", snap.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 snapshot", snap.getFsExports().keySet().isEmpty());
    // 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 3 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 4 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 5 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)

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)37 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)14