Search in sources :

Example 1 with IsilonException

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

the class IsilonFileStorageDevice method doUpdateQuotaDirectory.

@Override
public BiosCommandResult doUpdateQuotaDirectory(StorageSystem storage, FileDeviceInputOutput args, QuotaDirectory quotaDir) throws ControllerException {
    // Get Parent FS mount path
    // Get Quota Directory Name
    // Get Quota Size
    // Call Update Quota (Aways use that quota for updating the size)
    QuotaDirectory quotaDirObj = null;
    String fsMountPath = args.getFsMountPath();
    Long qDirSize = quotaDir.getSize();
    String qDirPath = fsMountPath + "/" + quotaDir.getName();
    _log.info("IsilonFileStorageDevice doUpdateQuotaDirectory {} with size {} - start", qDirPath, qDirSize);
    try {
        IsilonApi isi = getIsilonDevice(storage);
        URI qtreeURI = quotaDir.getId();
        quotaDirObj = _dbClient.queryObject(QuotaDirectory.class, qtreeURI);
        String quotaId = null;
        if (quotaDirObj.getExtensions() != null) {
            quotaId = quotaDirObj.getExtensions().get(QUOTA);
        }
        if (quotaId != null) {
            // Isilon does not allow to update quota directory to zero.
            IsilonSmartQuota isiCurrentSmartQuota = isi.getQuota(quotaId);
            long quotaUsageSpace = isiCurrentSmartQuota.getUsagePhysical();
            if (qDirSize > 0 && qDirSize.compareTo(quotaUsageSpace) > 0) {
                _log.info("IsilonFileStorageDevice doUpdateQuotaDirectory , Update Quota {} with Capacity {}", quotaId, qDirSize);
                IsilonSmartQuota expandedQuota = getQuotaDirectoryExpandedSmartQuota(quotaDir, qDirSize, args.getFsCapacity(), isi);
                isi.modifyQuota(quotaId, expandedQuota);
            } else {
                Double dUsage = SizeUtil.translateSize(quotaUsageSpace, SizeUtil.SIZE_GB);
                Double dQuotaSize = SizeUtil.translateSize(qDirSize, SizeUtil.SIZE_GB);
                String msg = String.format("as requested reduced size [%.1fGB] is smaller than used capacity [%.1fGB] for filesystem %s", dQuotaSize, dUsage, args.getFs().getName());
                _log.error("doUpdateQuotaDirectory : " + msg);
                ServiceError error = DeviceControllerErrors.isilon.unableUpdateQuotaDirectory(msg);
                return BiosCommandResult.createErrorResult(error);
            }
        } else {
            // Create a new Quota
            String qid = checkThresholdAndcreateQuota(quotaDir, qDirSize, qDirPath, null, isi);
            if (args.getQuotaDirExtensions() == null) {
                args.initQuotaDirExtensions();
            }
            args.getQuotaDirExtensions().put(QUOTA, qid);
        }
        _log.info("IsilonFileStorageDevice doUpdateQuotaDirectory {} with size {} - complete", qDirPath, qDirSize);
        return BiosCommandResult.createSuccessfulResult();
    } catch (IsilonException e) {
        _log.error("doUpdateQuotaDirectory failed.", e);
        return BiosCommandResult.createErrorResult(e);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) IsilonSmartQuota(com.emc.storageos.isilon.restapi.IsilonSmartQuota) QuotaDirectory(com.emc.storageos.db.client.model.QuotaDirectory) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 2 with IsilonException

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

the class IsilonFileStorageDevice method assignFilePolicy.

@Deprecated
@Override
public BiosCommandResult assignFilePolicy(StorageSystem storage, FileDeviceInputOutput args) {
    // for isilon we need to create a new policy for each individual file system
    SchedulePolicy fp = args.getFilePolicy();
    String snapshotScheduleName = fp.getPolicyName() + "_" + args.getFsName();
    String pattern = snapshotScheduleName + "_%Y-%m-%d_%H-%M";
    String Schedulevalue = getIsilonScheduleString(fp);
    Integer expireValue = getSnapshotExpireValue(fp);
    _log.info("File Policy  name : {}", snapshotScheduleName);
    IsilonApi isi = getIsilonDevice(storage);
    try {
        isi.createSnapshotSchedule(snapshotScheduleName, args.getFileSystemPath(), Schedulevalue, pattern, expireValue);
    } catch (IsilonException e) {
        _log.error("assign 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 3 with IsilonException

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

the class IsilonFileStorageDevice method doDeleteShares.

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

Example 4 with IsilonException

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

the class IsilonFileStorageDevice method createIsilonSnapshotPolicySchedule.

private void createIsilonSnapshotPolicySchedule(StorageSystem storageObj, FilePolicy filePolicy, String path, String snapshotSchedulePolicyName, FileDeviceInputOutput args, String filePolicyBasePath) {
    String pattern = snapshotSchedulePolicyName + "_%Y-%m-%d_%H-%M";
    String scheduleValue = getIsilonPolicySchedule(filePolicy);
    Integer expireValue = getIsilonSnapshotExpireValue(filePolicy);
    _log.info("File Policy : {} creation started", filePolicy.toString());
    try {
        IsilonApi isi = getIsilonDevice(storageObj);
        isi.createDir(path, true);
        String scheduleId = isi.createSnapshotSchedule(snapshotSchedulePolicyName, path, scheduleValue, pattern, expireValue);
        _log.info("Isilon File Policy {} created successfully.", snapshotSchedulePolicyName);
        FileOrchestrationUtils.updatePolicyStorageResource(_dbClient, storageObj, filePolicy, args, filePolicyBasePath, snapshotSchedulePolicyName, scheduleId, null, null, null);
    } catch (IsilonException e) {
        throw e;
    }
}
Also used : IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 5 with IsilonException

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

the class IsilonFileStorageDevice method doesSnapshotExistsForFSPath.

private boolean doesSnapshotExistsForFSPath(StorageSystem storageSystem, String isilonAccessZone, String path) throws IsilonCollectionException {
    URI storageSystemId = storageSystem.getId();
    String resumeToken = null;
    try {
        _log.info("Checking snapshots for path {}  on Isilon storage system: {} in access zone {} - start", path, storageSystem.getLabel(), isilonAccessZone);
        IsilonApi isilonApi = getIsilonDevice(storageSystem);
        do {
            IsilonList<IsilonSnapshot> isilonSnapshots = isilonApi.listSnapshots(resumeToken, path);
            List<IsilonSnapshot> snpashots = isilonSnapshots.getList();
            for (IsilonSnapshot snapshot : snpashots) {
                if (snapshot.getPath() == null || snapshot.getPath().isEmpty()) {
                    _log.info("Ignoring snapshot {} as it is not having any path", snapshot);
                    continue;
                }
                if (snapshot.getPath().equals(path)) {
                    _log.info("Found snapshot on path {} in Ision: {}", path, storageSystem.getLabel());
                    return true;
                }
            }
            resumeToken = isilonSnapshots.getToken();
        } while (resumeToken != null);
        _log.info("Snapshots not found with path {} on Ision: {} in access zone: {}", path, storageSystem.getLabel(), isilonAccessZone);
        return false;
    } catch (IsilonException ie) {
        _log.error("doesSnapshotExistsForFSPath failed. Storage system: {}", storageSystemId, ie);
        IsilonCollectionException ice = new IsilonCollectionException("doesSnapshotExistsForFSPath failed. Storage system: " + storageSystemId);
        ice.initCause(ie);
        throw ice;
    } catch (Exception e) {
        _log.error("doesSnapshotExistsForFSPath failed. Storage system: {}", storageSystemId, e);
        IsilonCollectionException ice = new IsilonCollectionException("doesSnapshotExistsForFSPath failed. Storage system: " + storageSystemId);
        ice.initCause(e);
        throw ice;
    }
}
Also used : IsilonSnapshot(com.emc.storageos.isilon.restapi.IsilonSnapshot) 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)

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