use of com.emc.storageos.isilon.restapi.IsilonApi in project coprhd-controller by CoprHD.
the class IsilonCommunicationInterface method discoverAccessZoneSMBShares.
/**
* Get all SMB shares of storagesystem
*
* @param storageSystem
* @return
*/
private HashMap<String, HashSet<String>> discoverAccessZoneSMBShares(final StorageSystem storageSystem, String isilonAccessZone) {
// Discover All FileShares
String resumeToken = null;
HashMap<String, HashSet<String>> allShares = new HashMap<String, HashSet<String>>();
URI storageSystemId = storageSystem.getId();
_log.info("discoverAllShares for storage system {} - start", storageSystemId);
try {
IsilonApi isilonApi = getIsilonDevice(storageSystem);
do {
IsilonApi.IsilonList<IsilonSMBShare> isilonShares = isilonApi.listShares(resumeToken, isilonAccessZone);
List<IsilonSMBShare> isilonSMBShareList = isilonShares.getList();
HashSet<String> sharesHashSet = null;
for (IsilonSMBShare share : isilonSMBShareList) {
// get the filesystem path and shareid
String path = share.getPath();
String shareId = share.getId();
sharesHashSet = allShares.get(path);
if (null == sharesHashSet) {
sharesHashSet = new HashSet<String>();
sharesHashSet.add(shareId);
allShares.put(path, sharesHashSet);
} else {
// if shares already exist for path then add
sharesHashSet.add(shareId);
allShares.put(path, sharesHashSet);
}
_log.info("Discovered SMB Share name {} and path {}", shareId, path);
}
resumeToken = isilonShares.getToken();
} while (resumeToken != null);
_log.info("discoverd AllShares for access zone {} ", isilonAccessZone);
return allShares;
} catch (IsilonException ie) {
_log.error("discoverAllShares failed. Storage system: {}", storageSystemId, ie);
IsilonCollectionException ice = new IsilonCollectionException("discoverAllShares failed. Storage system: " + storageSystemId);
ice.initCause(ie);
throw ice;
} catch (Exception e) {
_log.error("discoverAllShares failed. Storage system: {}", storageSystemId, e);
IsilonCollectionException ice = new IsilonCollectionException("discoverAllShares failed. Storage system: " + storageSystemId);
ice.initCause(e);
throw ice;
}
}
use of com.emc.storageos.isilon.restapi.IsilonApi in project coprhd-controller by CoprHD.
the class IsilonCommunicationInterface method discoverCluster.
private void discoverCluster(StorageSystem storageSystem) throws IsilonCollectionException {
URI storageSystemId = storageSystem.getId();
try {
_log.info("discoverCluster information for storage system {} - start", storageSystemId);
IsilonApi isilonApi = getIsilonDevice(storageSystem);
IsilonClusterConfig clusterConfig = isilonApi.getClusterConfig();
storageSystem.setSerialNumber(clusterConfig.getGuid());
String nativeGuid = NativeGUIDGenerator.generateNativeGuid(DiscoveredDataObject.Type.isilon.toString(), clusterConfig.getGuid());
storageSystem.setNativeGuid(nativeGuid);
String clusterReleaseVersion = clusterConfig.getOnefs_version_info().getReleaseVersionNumber();
storageSystem.setFirmwareVersion(clusterReleaseVersion);
String minimumSupportedVersion = VersionChecker.getMinimumSupportedVersion(Type.valueOf(storageSystem.getSystemType()));
_log.info("Verifying version details : Minimum Supported Version {} - Discovered Cluster Version {}", minimumSupportedVersion, clusterReleaseVersion);
if (VersionChecker.verifyVersionDetails(minimumSupportedVersion, clusterReleaseVersion) < 0) {
storageSystem.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.INCOMPATIBLE.name());
storageSystem.setReachableStatus(false);
DiscoveryUtils.setSystemResourcesIncompatible(_dbClient, _coordinator, storageSystem.getId());
IsilonCollectionException ice = new IsilonCollectionException(String.format(" ** This version of Isilon firmware is not supported ** Should be a minimum of %s", minimumSupportedVersion));
throw ice;
}
storageSystem.setSupportSoftLimit(false);
storageSystem.setSupportNotificationLimit(false);
// Check license status for smart quota and set the support attributes as true
if (ACTIVATED.equalsIgnoreCase(isilonApi.getLicenseInfo(IsilonLicenseType.SMARTQUOTA)) || EVALUATION.equalsIgnoreCase(isilonApi.getLicenseInfo(IsilonLicenseType.SMARTQUOTA))) {
storageSystem.setSupportSoftLimit(true);
storageSystem.setSupportNotificationLimit(true);
}
storageSystem.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
storageSystem.setReachableStatus(true);
_log.info("discoverCluster information for storage system {} - complete", storageSystemId);
} catch (Exception e) {
storageSystem.setReachableStatus(false);
String errMsg = String.format("discoverCluster failed. %s", e.getMessage());
_log.error(errMsg, e);
IsilonCollectionException ice = new IsilonCollectionException(errMsg);
throw ice;
}
}
use of com.emc.storageos.isilon.restapi.IsilonApi in project coprhd-controller by CoprHD.
the class IsilonCommunicationInterface method discoverAccessZoneExports.
private HashMap<String, HashSet<Integer>> discoverAccessZoneExports(StorageSystem storageSystem, String isilonAccessZone) throws IsilonCollectionException {
HashMap<String, HashSet<Integer>> allExports = new HashMap<>();
URI storageSystemId = storageSystem.getId();
String resumeToken = null;
try {
_log.info("discoverAllExports for storage system {} - start", storageSystemId);
IsilonApi isilonApi = getIsilonDevice(storageSystem);
do {
IsilonApi.IsilonList<IsilonExport> isilonExports = isilonApi.listExports(resumeToken, isilonAccessZone);
List<IsilonExport> exports = isilonExports.getList();
for (IsilonExport exp : exports) {
_log.info("Discovered fS export {}", exp.toString());
if (exp.getPaths() == null || exp.getPaths().isEmpty()) {
_log.info("Ignoring export {} as it is not having any path", exp.getId().toString());
continue;
}
HashSet<Integer> exportIds = new HashSet<>();
// Ignore Export with multiple paths
if (exp.getPaths().size() > 1) {
_log.info("Discovered Isilon Export: {} has multiple paths so ingnoring it", exp.toString());
continue;
}
String path = exp.getPaths().get(0);
exportIds = allExports.get(path);
if (exportIds == null) {
exportIds = new HashSet<>();
}
exportIds.add(exp.getId());
allExports.put(path, exportIds);
_log.debug("Discovered fS put export Path {} Export id {}", path, exportIds.size() + ":" + exportIds);
}
resumeToken = isilonExports.getToken();
} while (resumeToken != null);
_log.info("discoverd All NFS Exports for access zone {} ", isilonAccessZone);
return allExports;
} catch (IsilonException ie) {
_log.error("discoverAllExports failed. Storage system: {}", storageSystemId, ie);
IsilonCollectionException ice = new IsilonCollectionException("discoverAllExports failed. Storage system: " + storageSystemId);
ice.initCause(ie);
throw ice;
} catch (Exception e) {
_log.error("discoverAllExports failed. Storage system: {}", storageSystemId, e);
IsilonCollectionException ice = new IsilonCollectionException("discoverAllExports failed. Storage system: " + storageSystemId);
ice.initCause(e);
throw ice;
}
}
use of com.emc.storageos.isilon.restapi.IsilonApi in project coprhd-controller by CoprHD.
the class IsilonFileStorageDeviceTest 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", _isi.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", _isi.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", _isi.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", _isi.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", _isi.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", _isi.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", _isi.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", _isi.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", _isi.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", _isi.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", _isi.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", _isi.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", _isi.doDeleteSnapshot(_device, args).getCommandStatus().equals(Operation.Status.ready.name()));
IsilonApi isilonApi = _isi.getIsilonDevice(_device);
try {
isilonApi.listDir(args.getFileObjMountPath(), null);
Assert.assertTrue("Snapshot delete failed: " + args.getFileObjMountPath(), false);
} catch (IsilonException iex) {
System.out.println("doDeleteSnapshot --- delete snapshot success: " + iex.getCause());
}
// delete file system
Assert.assertTrue("doDeleteFS failed", _isi.doDeleteFS(_device, args).getCommandStatus().equals(Operation.Status.ready.name()));
try {
isilonApi.listDir(args.getFsMountPath(), null);
Assert.assertTrue("FS delete failed: " + args.getFsMountPath(), false);
} catch (IsilonException iex) {
System.out.println("doDeleteFS --- delete FS success: " + iex.getCause());
}
}
use of com.emc.storageos.isilon.restapi.IsilonApi in project coprhd-controller by CoprHD.
the class IsilonFileStorageDeviceTest method testFileShareCreateNegative.
/**
* Tests that we rollback file share create in case when file share quota set fails.
*
* @throws Exception
*/
@Test
public void testFileShareCreateNegative() throws Exception {
FileShare fs = new FileShare();
fs.setId(URIUtil.createId(FileShare.class));
fs.setLabel("neTest");
// set negative capacity to force failure of quota creation
fs.setCapacity(-102400L);
FileDeviceInputOutput args = new FileDeviceInputOutput();
args.addStoragePool(_pool);
args.addFSFileObject(fs);
Assert.assertTrue("doCreateFS was expected to fail due to negative quota in the test.", _isi.doCreateFS(_device, args).getCommandStatus().equals(Operation.Status.error.name()));
// verify that doCreate() was rolled back
// check that file share does not exist
// try to get list of shares for directory which we tried to create
IsilonApi isilonApi = _isi.getIsilonDevice(_device);
try {
isilonApi.listDir(args.getFileObjMountPath(), null);
Assert.assertTrue("File share create rollback failed, fs path: " + args.getFileObjMountPath(), false);
} catch (IsilonException iex) {
System.out.println("testFileShareCreateNegative --- rollback success: " + iex.getCause());
}
}
Aggregations