Search in sources :

Example 11 with IsilonApi

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

the class IsilonFileStorageDevice method doesCIFSShareExistsForFSPath.

private boolean doesCIFSShareExistsForFSPath(final StorageSystem storageSystem, String isilonAccessZone, String path) {
    String resumeToken = null;
    URI storageSystemId = storageSystem.getId();
    _log.info("Checking CIFS share for path {}  on Isilon storage system: {} in access zone {} - start", path, storageSystem.getLabel(), isilonAccessZone);
    try {
        IsilonApi isilonApi = getIsilonDevice(storageSystem);
        do {
            IsilonApi.IsilonList<IsilonSMBShare> isilonShares = isilonApi.listShares(resumeToken, isilonAccessZone);
            List<IsilonSMBShare> isilonSMBShareList = isilonShares.getList();
            for (IsilonSMBShare share : isilonSMBShareList) {
                if (share.getPath().equals(path)) {
                    _log.info("Found CIFS share with path {} and name {} on Ision: {} in access zone: {}", path, share.getName(), storageSystem.getLabel(), isilonAccessZone);
                    return true;
                }
            }
            resumeToken = isilonShares.getToken();
        } while (resumeToken != null);
        _log.info("CIFS share not found with path {} on Ision: {} in access zone: {}", path, storageSystem.getLabel(), isilonAccessZone);
        return false;
    } catch (IsilonException ie) {
        _log.error("doesCIFSShareExistForFSPath failed. Storage system: {}", storageSystemId, ie);
        IsilonCollectionException ice = new IsilonCollectionException("doesCIFSShareExistForFSPath failed. Storage system: " + storageSystemId);
        ice.initCause(ie);
        throw ice;
    } catch (Exception e) {
        _log.error("doesCIFSShareExistForFSPath failed. Storage system: {}", storageSystemId, e);
        IsilonCollectionException ice = new IsilonCollectionException("doesCIFSShareExistForFSPath failed. Storage system: " + storageSystemId);
        ice.initCause(e);
        throw ice;
    }
}
Also used : IsilonSMBShare(com.emc.storageos.isilon.restapi.IsilonSMBShare) IsilonCollectionException(com.emc.storageos.plugins.metering.isilon.IsilonCollectionException) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) 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 12 with IsilonApi

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

the class IsilonFileStorageDevice method checkFilePolicyExistsOrCreate.

@Override
public BiosCommandResult checkFilePolicyExistsOrCreate(StorageSystem storageObj, FileDeviceInputOutput args) {
    FilePolicy filePolicy = args.getFileProtectionPolicy();
    BiosCommandResult result = null;
    try {
        IsilonApi isi = getIsilonDevice(storageObj);
        String clusterName = isi.getClusterConfig().getName();
        String filePolicyBasePath = getFilePolicyPath(storageObj, filePolicy.getApplyAt(), args);
        checkAppliedResourceNamePartOfFilePolicyPath(filePolicyBasePath, filePolicy, args);
        String snapshotPolicyScheduleName = FileOrchestrationUtils.generateNameForSnapshotIQPolicy(clusterName, filePolicy, null, args, filePolicyBasePath);
        IsilonSnapshotSchedule isilonSnapshotSchedule = getEquivalentIsilonSnapshotSchedule(isi, filePolicyBasePath);
        if (isilonSnapshotSchedule != null) {
            String filePolicySnapshotSchedule = getIsilonPolicySchedule(filePolicy);
            _log.info("Comparing snapshot schedule between CoprHD policy: {} and Isilon policy: {}.", filePolicySnapshotSchedule, isilonSnapshotSchedule.getSchedule());
            if (isilonSnapshotSchedule.getSchedule().equalsIgnoreCase(filePolicySnapshotSchedule)) {
                // Verify the policy was mapped to FileStorageResource
                if (null == FileOrchestrationUtils.findPolicyStorageResourceByNativeId(_dbClient, storageObj, filePolicy, args, filePolicyBasePath)) {
                    _log.info("Isilon policy found for {}, creating policy storage resouce to further management", filePolicy.getFilePolicyName());
                    FileOrchestrationUtils.updatePolicyStorageResource(_dbClient, storageObj, filePolicy, args, filePolicyBasePath, isilonSnapshotSchedule.getName(), isilonSnapshotSchedule.getId().toString(), null, null, null);
                }
                result = BiosCommandResult.createSuccessfulResult();
            } else {
                _log.info("Snapshot schedule differs between Isilon policy and CoprHD file policy. So, create policy in Isilon...");
                // Create snapshot policy.
                createIsilonSnapshotPolicySchedule(storageObj, filePolicy, filePolicyBasePath, snapshotPolicyScheduleName, args, filePolicyBasePath);
                result = BiosCommandResult.createSuccessfulResult();
            }
        } else {
            // Create snapshot policy.
            createIsilonSnapshotPolicySchedule(storageObj, filePolicy, filePolicyBasePath, snapshotPolicyScheduleName, args, filePolicyBasePath);
            result = BiosCommandResult.createSuccessfulResult();
        }
    } catch (IsilonException e) {
        _log.error("Assigning file policy failed.", e);
        result = BiosCommandResult.createErrorResult(e);
    }
    return result;
}
Also used : FilePolicy(com.emc.storageos.db.client.model.FilePolicy) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) IsilonSnapshotSchedule(com.emc.storageos.isilon.restapi.IsilonSnapshotSchedule) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 13 with IsilonApi

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

the class IsilonFileStorageDevice method unassignFilePolicy.

@Deprecated
@Override
public BiosCommandResult unassignFilePolicy(StorageSystem storageObj, FileDeviceInputOutput args) {
    SchedulePolicy fp = args.getFilePolicy();
    String snapshotScheduleName = fp.getPolicyName() + "_" + args.getFsName();
    IsilonApi isi = getIsilonDevice(storageObj);
    try {
        isi.deleteSnapshotSchedule(snapshotScheduleName);
    } catch (IsilonException e) {
        _log.error("unassign file policy failed.", e);
        return BiosCommandResult.createErrorResult(e);
    }
    return BiosCommandResult.createSuccessfulResult();
}
Also used : IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) SchedulePolicy(com.emc.storageos.db.client.model.SchedulePolicy) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 14 with IsilonApi

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

the class IsilonFileStorageDevice method doDeleteQuotaDirectory.

@Override
public BiosCommandResult doDeleteQuotaDirectory(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    // Get Parent FS Mount Path
    // Get Quota Directory Name
    // Get Quota Size
    // Call Delete Quota
    // Call Delete Directory recursively
    QuotaDirectory quotaDir = args.getQuotaDirectory();
    String fsMountPath = args.getFsMountPath();
    Long qDirSize = quotaDir.getSize();
    String qDirPath = fsMountPath + "/" + quotaDir.getName();
    _log.info("IsilonFileStorageDevice doDeleteQuotaDirectory {} with size {} - start", qDirPath, qDirSize);
    try {
        IsilonApi isi = getIsilonDevice(storage);
        // if the quota directory has some data in it.
        if (isi.fsDirHasData(qDirPath)) {
            // Fail to delete quota directory which has data in it!!!
            _log.error("Quota directory deletion failed as it's directory path {} has content in it", qDirPath);
            throw DeviceControllerException.exceptions.failToDeleteQuotaDirectory(qDirPath);
        }
        String quotaId = null;
        if (quotaDir.getExtensions() != null) {
            quotaId = quotaDir.getExtensions().get(QUOTA);
        }
        if (quotaId != null) {
            _log.info("IsilonFileStorageDevice doDeleteQuotaDirectory , Delete Quota {}", quotaId);
            isi.deleteQuota(quotaId);
        }
        // delete directory for the Quota Directory
        isi.deleteDir(qDirPath);
        _log.info("IsilonFileStorageDevice doDeleteQuotaDirectory {} with size {} - complete", qDirPath, qDirSize);
        return BiosCommandResult.createSuccessfulResult();
    } catch (IsilonException e) {
        _log.error("doDeleteQuotaDirectory failed.", e);
        return BiosCommandResult.createErrorResult(e);
    }
}
Also used : QuotaDirectory(com.emc.storageos.db.client.model.QuotaDirectory) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 15 with IsilonApi

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

the class IsilonFileStorageDevice method doDeleteFS.

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

Aggregations

IsilonApi (com.emc.storageos.isilon.restapi.IsilonApi)81 IsilonException (com.emc.storageos.isilon.restapi.IsilonException)64 URISyntaxException (java.net.URISyntaxException)31 URI (java.net.URI)22 IsilonCollectionException (com.emc.storageos.plugins.metering.isilon.IsilonCollectionException)21 ArrayList (java.util.ArrayList)18 IsilonSyncPolicy (com.emc.storageos.isilon.restapi.IsilonSyncPolicy)14 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)13 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)12 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)12 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)12 IOException (java.io.IOException)12 JSONException (org.codehaus.jettison.json.JSONException)12 FileShare (com.emc.storageos.db.client.model.FileShare)11 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)11 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)10 HashMap (java.util.HashMap)10 ControllerException (com.emc.storageos.volumecontroller.ControllerException)9 Test (org.junit.Test)8 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)7