Search in sources :

Example 41 with IsilonException

use of com.emc.storageos.isilon.restapi.IsilonException in project coprhd-controller by CoprHD.

the class IsilonFileStorageDevice method listSanpshotByPolicy.

@Override
public BiosCommandResult listSanpshotByPolicy(StorageSystem storageObj, FileDeviceInputOutput args) {
    FilePolicy sp = args.getFileProtectionPolicy();
    FileShare fs = args.getFs();
    String snapshotScheduleName = sp.getFilePolicyName() + "_" + args.getFsName();
    if (sp.getPolicyStorageResources() != null && !sp.getPolicyStorageResources().isEmpty()) {
        for (String uriResource : sp.getPolicyStorageResources()) {
            PolicyStorageResource policyRes = _dbClient.queryObject(PolicyStorageResource.class, URI.create(uriResource));
            if (policyRes != null && policyRes.getStorageSystem().equals(storageObj.getId())) {
                snapshotScheduleName = policyRes.getPolicyNativeId();
                break;
            }
        }
    }
    IsilonApi isi = getIsilonDevice(storageObj);
    String resumeToken = null;
    try {
        do {
            IsilonList<IsilonSnapshot> snapshots = isi.listSnapshotsCreatedByPolicy(resumeToken, snapshotScheduleName);
            if (snapshots != null) {
                for (IsilonSnapshot islon_snap : snapshots.getList()) {
                    _log.info("file policy snapshot is  : " + islon_snap.getName());
                    Snapshot snap = new Snapshot();
                    snap.setLabel(islon_snap.getName());
                    snap.setMountPath(islon_snap.getPath());
                    snap.setName(islon_snap.getName());
                    snap.setId(URIUtil.createId(Snapshot.class));
                    snap.setOpStatus(new OpStatusMap());
                    snap.setProject(new NamedURI(fs.getProject().getURI(), islon_snap.getName()));
                    snap.setMountPath(getSnapshotPath(islon_snap.getPath(), islon_snap.getName()));
                    snap.setParent(new NamedURI(fs.getId(), islon_snap.getName()));
                    StringMap map = new StringMap();
                    Long createdTime = Long.parseLong(islon_snap.getCreated()) * SEC_IN_MILLI;
                    String expiresTime = "Never";
                    if (islon_snap.getExpires() != null && !islon_snap.getExpires().isEmpty()) {
                        Long expTime = Long.parseLong(islon_snap.getExpires()) * SEC_IN_MILLI;
                        expiresTime = expTime.toString();
                    }
                    map.put("created", createdTime.toString());
                    map.put("expires", expiresTime);
                    map.put("schedule", sp.getFilePolicyName());
                    snap.setExtensions(map);
                    _dbClient.updateObject(snap);
                }
                resumeToken = snapshots.getToken();
            }
        } while (resumeToken != null && !resumeToken.equalsIgnoreCase("null"));
    } catch (IsilonException e) {
        _log.error("listing snapshot by file policy failed.", e);
        return BiosCommandResult.createErrorResult(e);
    }
    Task task = TaskUtils.findTaskForRequestId(_dbClient, fs.getId(), args.getOpId());
    // set task to completed and progress to 100 and store in DB, so waiting thread in apisvc can read it.
    task.ready();
    task.setProgress(100);
    _dbClient.updateObject(task);
    return BiosCommandResult.createSuccessfulResult();
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) Task(com.emc.storageos.db.client.model.Task) FilePolicy(com.emc.storageos.db.client.model.FilePolicy) NamedURI(com.emc.storageos.db.client.model.NamedURI) OpStatusMap(com.emc.storageos.db.client.model.OpStatusMap) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) PolicyStorageResource(com.emc.storageos.db.client.model.PolicyStorageResource) Snapshot(com.emc.storageos.db.client.model.Snapshot) IsilonSnapshot(com.emc.storageos.isilon.restapi.IsilonSnapshot) IsilonSnapshot(com.emc.storageos.isilon.restapi.IsilonSnapshot) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 42 with IsilonException

use of com.emc.storageos.isilon.restapi.IsilonException in project coprhd-controller by CoprHD.

the class IsilonFileStorageDevice method doModifyFS.

@Override
public BiosCommandResult doModifyFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    try {
        _log.info("IsilonFileStorageDevice doModifyFS {} - start", args.getFsId());
        IsilonApi isi = getIsilonDevice(storage);
        String quotaId = null;
        if (args.getFsExtensions() != null && args.getFsExtensions().get(QUOTA) != null) {
            quotaId = args.getFsExtensions().get(QUOTA);
        } else {
            final ServiceError serviceError = DeviceControllerErrors.isilon.unableToUpdateFileSystem(args.getFsId());
            _log.error(serviceError.getMessage());
            return BiosCommandResult.createErrorResult(serviceError);
        }
        IsilonSmartQuota expandedQuota = getExpandedQuota(isi, args, args.getFsCapacity());
        isi.modifyQuota(quotaId, expandedQuota);
        _log.info("IsilonFileStorageDevice doModifyFS {} - complete", args.getFsId());
        return BiosCommandResult.createSuccessfulResult();
    } catch (IsilonException e) {
        _log.error("doModifyFS failed.", e);
        return BiosCommandResult.createErrorResult(e);
    } catch (Exception e) {
        _log.error("doModifyFS failed.", e);
        // convert this to a ServiceError and create/or reuse a service
        // code
        ServiceError serviceError = DeviceControllerErrors.isilon.unableToUpdateFileSystem(args.getFsId());
        return BiosCommandResult.createErrorResult(serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) IsilonSmartQuota(com.emc.storageos.isilon.restapi.IsilonSmartQuota) 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 43 with IsilonException

use of com.emc.storageos.isilon.restapi.IsilonException in project coprhd-controller by CoprHD.

the class IsilonFileStorageDevice method doConnect.

@Override
public void doConnect(StorageSystem storage) throws ControllerException {
    try {
        _log.info("doConnect {} - start", storage.getId());
        IsilonApi isi = getIsilonDevice(storage);
        isi.getClusterInfo();
        String msg = String.format("doConnect %1$s - complete", storage.getId());
        _log.info(msg);
    } catch (IsilonException e) {
        _log.error("doConnect failed.", e);
        throw DeviceControllerException.exceptions.connectStorageFailed(e);
    }
}
Also used : IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 44 with IsilonException

use of com.emc.storageos.isilon.restapi.IsilonException in project coprhd-controller by CoprHD.

the class IsilonFileStorageDevice method doUnexport.

@Override
public BiosCommandResult doUnexport(StorageSystem storage, FileDeviceInputOutput args, List<FileExport> exportList) throws ControllerException {
    try {
        _log.info("IsilonFileStorageDevice doUnexport: {} - start", args.getFileObjId());
        IsilonApi isi = getIsilonDevice(storage);
        isiUnexport(isi, args, exportList);
        _log.info("IsilonFileStorageDevice doUnexport {} - complete", args.getFileObjId());
        return BiosCommandResult.createSuccessfulResult();
    } catch (IsilonException e) {
        _log.error("doUnexport failed.", e);
        return BiosCommandResult.createErrorResult(e);
    }
}
Also used : IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 45 with IsilonException

use of com.emc.storageos.isilon.restapi.IsilonException in project coprhd-controller by CoprHD.

the class IsilonFileStorageDevice method doExport.

@Override
public BiosCommandResult doExport(StorageSystem storage, FileDeviceInputOutput args, List<FileExport> exportList) throws ControllerException {
    // Snapshot Export operation is not supported by ISILON.
    if (args.getFileOperation() == false) {
        return BiosCommandResult.createErrorResult(DeviceControllerErrors.isilon.unSupportedOperation(EXPORT_OP_NAME));
    }
    try {
        _log.info("IsilonFileStorageDevice doExport {} - start", args.getFileObjId());
        IsilonApi isi = getIsilonDevice(storage);
        isiExport(isi, args, exportList);
        _log.info("IsilonFileStorageDevice doExport {} - complete", args.getFileObjId());
        return BiosCommandResult.createSuccessfulResult();
    } catch (IsilonException e) {
        _log.error("doExport failed.", e);
        return BiosCommandResult.createErrorResult(e);
    }
}
Also used : IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) 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