Search in sources :

Example 36 with IsilonException

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());
    }
}
Also used : FileDeviceInputOutput(com.emc.storageos.volumecontroller.FileDeviceInputOutput) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) IsilonException(com.emc.storageos.isilon.restapi.IsilonException) Test(org.junit.Test)

Example 37 with IsilonException

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);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) IsilonException(com.emc.storageos.isilon.restapi.IsilonException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) URISyntaxException(java.net.URISyntaxException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) IsilonCollectionException(com.emc.storageos.plugins.metering.isilon.IsilonCollectionException) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 38 with IsilonException

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;
}
Also used : BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) ExportRule(com.emc.storageos.model.file.ExportRule) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 39 with IsilonException

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);
    }
}
Also used : FilePolicy(com.emc.storageos.db.client.model.FilePolicy) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 40 with IsilonException

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;
    }
}
Also used : VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) IsilonSyncPolicy8Above(com.emc.storageos.isilon.restapi.IsilonSyncPolicy8Above) IsilonSyncPolicy(com.emc.storageos.isilon.restapi.IsilonSyncPolicy) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Aggregations

IsilonException (com.emc.storageos.isilon.restapi.IsilonException)62 IsilonApi (com.emc.storageos.isilon.restapi.IsilonApi)53 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)15 URISyntaxException (java.net.URISyntaxException)15 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)12 IsilonSyncPolicy (com.emc.storageos.isilon.restapi.IsilonSyncPolicy)12 IsilonCollectionException (com.emc.storageos.plugins.metering.isilon.IsilonCollectionException)12 URI (java.net.URI)12 ArrayList (java.util.ArrayList)10 FileShare (com.emc.storageos.db.client.model.FileShare)9 Test (org.junit.Test)8 FilePolicy (com.emc.storageos.db.client.model.FilePolicy)7 ControllerException (com.emc.storageos.volumecontroller.ControllerException)7 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)7 NamedURI (com.emc.storageos.db.client.model.NamedURI)6 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)6 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)5 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)5 FileDeviceInputOutput (com.emc.storageos.volumecontroller.FileDeviceInputOutput)5 IOException (java.io.IOException)5