use of com.emc.storageos.isilon.restapi.IsilonException in project coprhd-controller by CoprHD.
the class IsilonMirrorOperations method doResumeReplicationPolicy.
/**
* Call to isilon to resume replication session
*
* @param system
* @param policyName
* @return
*/
public BiosCommandResult doResumeReplicationPolicy(StorageSystem system, String policyName) {
_log.info("IsilonMirrorOperations - do RESUME ReplicationPolicy started on storagesystem {}", system.getLabel());
try {
IsilonApi isi = getIsilonDevice(system);
IsilonSyncPolicy policy = isi.getReplicationPolicy(policyName);
if (!policy.getEnabled()) {
policy = doEnableReplicationPolicy(isi, policyName);
if (policy.getEnabled()) {
_log.info("Replication Policy - {} ENABLED successfully", policy.toString());
}
}
return BiosCommandResult.createSuccessfulResult();
} catch (IsilonException e) {
_log.error("doStartReplicationPolicy failed.", e);
return BiosCommandResult.createErrorResult(e);
}
}
use of com.emc.storageos.isilon.restapi.IsilonException in project coprhd-controller by CoprHD.
the class IsilonMirrorOperations method doFailover.
/**
* Call to device to failover the policy
*
* @param system
* @param policyName
* @param taskCompleter
* @return
*/
public BiosCommandResult doFailover(StorageSystem system, String policyName, TaskCompleter taskCompleter) {
_log.info("IsilonMirrorOperations - doFailover started ");
try {
IsilonApi isi = getIsilonDevice(system);
IsilonSyncTargetPolicy syncTargetPolicy = isi.getTargetReplicationPolicy(policyName);
if (syncTargetPolicy.getFoFbState().equals(FOFB_STATES.writes_enabled)) {
_log.info("can't perform failover operation on policy: {} because failover is done already", syncTargetPolicy.getName());
return BiosCommandResult.createSuccessfulResult();
}
IsilonSyncJob job = new IsilonSyncJob();
job.setId(policyName);
job.setAction(Action.allow_write);
isi.modifyReplicationJob(job);
IsilonSyncJobFailover isiSyncJobFailover = new IsilonSyncJobFailover(policyName, system.getId(), taskCompleter, policyName);
try {
ControllerServiceImpl.enqueueJob(new QueueJob(isiSyncJobFailover));
return BiosCommandResult.createPendingResult();
} catch (Exception ex) {
_log.error("Failover to Secondary Cluster Failed", ex);
ServiceError error = DeviceControllerErrors.isilon.jobFailed("Failover to Secondary Cluster Failed as :" + ex.getMessage());
if (taskCompleter != null) {
taskCompleter.error(_dbClient, error);
}
return BiosCommandResult.createErrorResult(error);
}
} catch (IsilonException e) {
return BiosCommandResult.createErrorResult(e);
}
}
use of com.emc.storageos.isilon.restapi.IsilonException 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.IsilonException 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.IsilonException 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());
}
}
Aggregations