use of com.emc.storageos.isilon.restapi.IsilonException 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());
}
}
use of com.emc.storageos.isilon.restapi.IsilonException in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method doShare.
@Override
public BiosCommandResult doShare(StorageSystem storage, FileDeviceInputOutput args, SMBFileShare smbFileShare) throws ControllerException {
// Snapshot Share operation is not supported by ISILON.
if (args.getFileOperation() == false) {
return BiosCommandResult.createErrorResult(DeviceControllerErrors.isilon.unSupportedOperation(SHARE_OP_NAME));
}
try {
_log.info("IsilonFileStorageDevice doShare() - start");
IsilonApi isi = getIsilonDevice(storage);
isiShare(isi, args, smbFileShare);
_log.info("IsilonFileStorageDevice doShare() - complete");
return BiosCommandResult.createSuccessfulResult();
} catch (IsilonException e) {
_log.error("doShare failed.", e);
return BiosCommandResult.createErrorResult(e);
} catch (Exception e) {
_log.error("doShare failed.", e);
// convert this to a ServiceError and create/or reuse a service
// code
ServiceError serviceError = DeviceControllerErrors.isilon.unableToCreateFileShare();
return BiosCommandResult.createErrorResult(serviceError);
}
}
use of com.emc.storageos.isilon.restapi.IsilonException in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method deleteExportRules.
@Override
public BiosCommandResult deleteExportRules(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
BiosCommandResult result = new BiosCommandResult();
List<ExportRule> allExports = args.getExistingDBExportRules();
String subDir = args.getSubDirectory();
boolean allDirs = args.isAllDir();
String exportPath;
String subDirExportPath = "";
subDir = args.getSubDirectory();
if (!args.getFileOperation()) {
exportPath = args.getSnapshotPath();
if (subDir != null && subDir.length() > 0) {
subDirExportPath = args.getSnapshotPath() + "/" + subDir;
}
} else {
exportPath = args.getFs().getPath();
if (subDir != null && subDir.length() > 0) {
subDirExportPath = args.getFs().getPath() + "/" + subDir;
}
}
_log.info("exportPath : {}", exportPath);
args.setExportPath(exportPath);
_log.info("Number of existing exports found {}", allExports.size());
try {
IsilonApi isi = getIsilonDevice(storage);
String zoneName = getZoneName(args.getvNAS());
if (allDirs) {
// ALL EXPORTS
_log.info("Deleting all exports specific to filesystem at device and rules from DB including sub dirs rules and exports");
for (ExportRule rule : allExports) {
_log.info("Delete IsilonExport id {} for path {}", rule.getDeviceExportId(), rule.getExportPath());
if (zoneName != null) {
isi.deleteExport(rule.getDeviceExportId(), zoneName);
} else {
isi.deleteExport(rule.getDeviceExportId());
}
}
} else if (subDir != null && !subDir.isEmpty()) {
// Filter for a specific Sub Directory export
_log.info("Deleting all subdir exports rules at ViPR and sub directory export at device {}", subDir);
for (ExportRule rule : allExports) {
_log.info("Delete IsilonExport id for path {} f containing subdirectory {}", rule.getDeviceExportId() + ":" + rule.getExportPath(), subDir);
String fsExportPathWithSub = args.getFsPath() + "/" + subDir;
if (rule.getExportPath().equalsIgnoreCase(fsExportPathWithSub)) {
_log.info("Delete IsilonExport id {} for path {}", rule.getDeviceExportId(), rule.getExportPath());
if (zoneName != null) {
isi.deleteExport(rule.getDeviceExportId(), zoneName);
} else {
isi.deleteExport(rule.getDeviceExportId());
}
}
}
} else {
// Filter for No SUBDIR - main export rules with no sub dirs
_log.info("Deleting all export rules from DB and export at device not included sub dirs");
for (ExportRule rule : allExports) {
if (rule.getExportPath().equalsIgnoreCase(exportPath)) {
_log.info("Delete IsilonExport id {} for path {}", rule.getDeviceExportId(), rule.getExportPath());
if (zoneName != null) {
isi.deleteExport(rule.getDeviceExportId(), zoneName);
} else {
isi.deleteExport(rule.getDeviceExportId());
}
}
}
}
} catch (IsilonException ie) {
_log.info("Exception: {}", ie);
throw new DeviceControllerException("Exception while performing export for {0} ", new Object[] { args.getFsId() });
}
_log.info("IsilonFileStorageDevice exportFS {} - complete", args.getFsId());
result.setCommandSuccess(true);
result.setCommandStatus(Operation.Status.ready.name());
return result;
}
use of com.emc.storageos.isilon.restapi.IsilonException in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method checkFilePolicyPathHasResourceLabel.
@Override
public BiosCommandResult checkFilePolicyPathHasResourceLabel(StorageSystem system, FileDeviceInputOutput args) {
_log.info("Inside checkFilePolicyPathHasResourceLabel()");
try {
FilePolicy filePolicy = args.getFileProtectionPolicy();
String filePolicyBasePath = getFilePolicyPath(system, filePolicy.getApplyAt(), args);
checkAppliedResourceNamePartOfFilePolicyPath(filePolicyBasePath, filePolicy, args);
_log.info("checkFilePolicyPathHasResourceLabel successful.");
return BiosCommandResult.createSuccessfulResult();
} catch (IsilonException e) {
_log.error("checkFilePolicyPathHasResourceLabel failed.", e);
return BiosCommandResult.createErrorResult(e);
}
}
use of com.emc.storageos.isilon.restapi.IsilonException in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method createIsilonSyncPolicy.
private String createIsilonSyncPolicy(StorageSystem storageObj, StorageSystem targetStorage, FilePolicy filePolicy, String sourcePath, String targetPath, String syncPolicyName, FileDeviceInputOutput sourceSystemArgs, FileDeviceInputOutput targetSystemArgs) {
String scheduleValue = getIsilonPolicySchedule(filePolicy);
_log.info("File replication policy : {} creation started", filePolicy.toString());
try {
VirtualNAS targetVNas = targetSystemArgs.getvNAS();
URI targetVNasURI = null;
if (targetVNas != null) {
targetVNasURI = targetVNas.getId();
}
String targetHost = FileOrchestrationUtils.getTargetHostPortForReplication(_dbClient, targetStorage.getId(), targetSystemArgs.getVarray().getId(), targetVNasURI);
IsilonApi isi = getIsilonDevice(storageObj);
isi.createDir(sourcePath, true);
IsilonSyncPolicy replicationPolicy = new IsilonSyncPolicy(syncPolicyName, sourcePath, targetPath, targetHost, Action.sync);
if (scheduleValue != null && !scheduleValue.isEmpty()) {
replicationPolicy.setSchedule(scheduleValue);
}
if (filePolicy.getFilePolicyDescription() != null) {
replicationPolicy.setDescription(filePolicy.getFilePolicyDescription());
}
if (filePolicy.getNumWorkerThreads() != null && filePolicy.getNumWorkerThreads() > 0) {
replicationPolicy.setWorkersPerNode(filePolicy.getNumWorkerThreads().intValue());
}
replicationPolicy.setEnabled(true);
replicationPolicy.setSchedule(scheduleValue);
String scheduleId;
if (VersionChecker.verifyVersionDetails(ONEFS_V8, storageObj.getFirmwareVersion()) >= 0) {
IsilonSyncPolicy8Above replicationPolicyCopy = new IsilonSyncPolicy8Above();
replicationPolicyCopy = replicationPolicyCopy.copy(replicationPolicy);
if (filePolicy.getPriority() != null) {
replicationPolicyCopy.setPriority(FilePolicyPriority.valueOf(filePolicy.getPriority()).ordinal());
}
scheduleId = isi.createReplicationPolicy8above(replicationPolicyCopy);
} else {
scheduleId = isi.createReplicationPolicy(replicationPolicy);
}
FileOrchestrationUtils.updatePolicyStorageResource(_dbClient, storageObj, filePolicy, sourceSystemArgs, sourcePath, syncPolicyName, scheduleId, targetStorage, targetSystemArgs.getvNAS(), targetPath);
return scheduleId;
} catch (IsilonException e) {
throw e;
}
}
Aggregations