Search in sources :

Example 61 with IsilonApi

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

the class IsilonFileStorageDevice method doExpandFS.

@Override
public BiosCommandResult doExpandFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    try {
        _log.info("IsilonFileStorageDevice doExpandFS {} - 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 {
            // when policy is applied at higher level, we will ignore the target filesystem
            FileShare fileShare = args.getFs();
            if (null != fileShare.getPersonality() && PersonalityTypes.TARGET.name().equals(fileShare.getPersonality()) && null == fileShare.getExtensions()) {
                _log.info("Quota id is not found so ignore the expand filesystem ", fileShare.getLabel());
                return BiosCommandResult.createSuccessfulResult();
            }
            final ServiceError serviceError = DeviceControllerErrors.isilon.doExpandFSFailed(args.getFsId());
            _log.error(serviceError.getMessage());
            return BiosCommandResult.createErrorResult(serviceError);
        }
        isiExpandFS(isi, quotaId, args);
        _log.info("IsilonFileStorageDevice doExpandFS {} - complete", args.getFsId());
        return BiosCommandResult.createSuccessfulResult();
    } catch (IsilonException e) {
        _log.error("doExpandFS failed.", e);
        return BiosCommandResult.createErrorResult(e);
    } catch (Exception e) {
        _log.error("doExpandFS failed.", e);
        // convert this to a ServiceError and create/or reuse a service
        // code
        ServiceError serviceError = DeviceControllerErrors.isilon.unableToExpandFileSystem();
        return BiosCommandResult.createErrorResult(serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) 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 62 with IsilonApi

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

the class IsilonMirrorOperations method doEnablePolicy.

/**
 * Enable the Isilon syncIQ policy
 *
 * @param system - storagesystem
 * @param policyName
 * @return
 */
BiosCommandResult doEnablePolicy(StorageSystem system, String policyName) {
    IsilonApi isi = getIsilonDevice(system);
    IsilonSyncPolicy policy = isi.getReplicationPolicy(policyName);
    if (null != policy && !policy.getEnabled()) {
        IsilonSyncPolicy modifiedPolicy = new IsilonSyncPolicy();
        modifiedPolicy.setEnabled(true);
        try {
            isi.modifyReplicationPolicy(policyName, modifiedPolicy);
            TimeUnit.SECONDS.sleep(33);
        } catch (InterruptedException e) {
            _log.warn("Enabling ReplicationPolicy - {} Interrupted", policyName);
            ServiceError error = DeviceControllerErrors.isilon.jobFailed("Enabling ReplicationPolicy is Failed with Interrupt exception and message :" + e.getMessage());
            return BiosCommandResult.createErrorResult(error);
        } catch (IsilonException ex) {
            return BiosCommandResult.createErrorResult(ex);
        }
    }
    return BiosCommandResult.createSuccessfulResult();
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) IsilonSyncPolicy(com.emc.storageos.isilon.restapi.IsilonSyncPolicy) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 63 with IsilonApi

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

the class IsilonMirrorOperations method dodeleteReplicationPolicy.

/**
 * Call to device to delete the policy
 *
 * @param system
 * @param policyName
 * @return
 */
public BiosCommandResult dodeleteReplicationPolicy(StorageSystem system, String policyName) {
    try {
        IsilonApi isi = getIsilonDevice(system);
        IsilonSyncPolicy policy = isi.getReplicationPolicy(policyName);
        JobState policyState = policy.getLastJobState();
        if (policyState.equals(JobState.running) || policyState.equals(JobState.paused)) {
            _log.info("Canceling Replication Policy  -{} because policy is in - {} state ", policyName, policyState);
            IsilonSyncPolicy modifiedPolicy = new IsilonSyncPolicy();
            modifiedPolicy.setName(policyName);
            modifiedPolicy.setLastJobState(JobState.canceled);
            isi.modifyReplicationPolicy(policyName, modifiedPolicy);
        }
        isi.deleteReplicationPolicy(policyName);
        _log.info("dodeleteReplicationPolicy - {} finished succesfully", policy.toString());
        _log.info("Sleeping for 10 seconds for detach mirror to complete...");
        TimeUnit.SECONDS.sleep(10);
        return BiosCommandResult.createSuccessfulResult();
    } catch (IsilonException e) {
        return BiosCommandResult.createErrorResult(e);
    } catch (InterruptedException e) {
        _log.warn("dodeleteReplicationPolicy - {} Interrupted");
        return BiosCommandResult.createSuccessfulResult();
    }
}
Also used : JobState(com.emc.storageos.isilon.restapi.IsilonSyncPolicy.JobState) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) IsilonSyncPolicy(com.emc.storageos.isilon.restapi.IsilonSyncPolicy) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 64 with IsilonApi

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

the class IsilonSyncIQJob method poll.

@Override
public JobPollResult poll(JobContext jobContext, long trackingPeriodInMillis) {
    String currentJob = _jobIds.get(0);
    try {
        IsilonApi isiApiClient = getIsilonRestClient(jobContext);
        if (isiApiClient == null) {
            String errorMessage = "No Isilon REST API client found for: " + _storageSystemUri;
            processTransientError(currentJob, trackingPeriodInMillis, errorMessage, null);
        } else {
            _pollResult.setJobName(_jobName);
            _pollResult.setJobId(_taskCompleter.getOpId());
            IsilonSyncPolicy policy = isiApiClient.getReplicationPolicy(currentJob);
            IsilonSyncPolicy.JobState policyState = policy.getLastJobState();
            if (policyState.equals(JobState.running)) {
                _status = JobStatus.IN_PROGRESS;
            } else if (policyState.equals(JobState.finished)) {
                _status = JobStatus.SUCCESS;
                _pollResult.setJobPercentComplete(100);
                _logger.info("IsilonSyncIQJob: {} succeeded", currentJob);
            } else {
                _errorDescription = isiGetReportErrMsg(isiApiClient.getReplicationPolicyReports(currentJob).getList());
                _pollResult.setJobPercentComplete(100);
                _pollResult.setErrorDescription(_errorDescription);
                _status = JobStatus.FAILED;
                _logger.error("IsilonSyncIQJob: {} failed; Details: {}", currentJob, _errorDescription);
            }
        }
    } catch (Exception e) {
        processTransientError(currentJob, trackingPeriodInMillis, e.getMessage(), e);
    } finally {
        try {
            updateStatus(jobContext);
        } catch (Exception e) {
            setErrorStatus(e.getMessage());
            _logger.error("Problem while trying to update status", e);
        }
    }
    _pollResult.setJobStatus(_status);
    return _pollResult;
}
Also used : JobState(com.emc.storageos.isilon.restapi.IsilonSyncPolicy.JobState) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) IsilonSyncPolicy(com.emc.storageos.isilon.restapi.IsilonSyncPolicy) URISyntaxException(java.net.URISyntaxException) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 65 with IsilonApi

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

the class IsilonSyncIQJob method getIsilonRestClient.

/**
 * Get Isilon API client
 *
 * @param jobContext
 * @return
 */
public IsilonApi getIsilonRestClient(JobContext jobContext) {
    StorageSystem device = jobContext.getDbClient().queryObject(StorageSystem.class, _storageSystemUri);
    if (jobContext.getIsilonApiFactory() != null) {
        IsilonApi isilonAPI;
        URI deviceURI;
        try {
            deviceURI = new URI("https", null, device.getIpAddress(), device.getPortNumber(), "/", null, null);
        } catch (URISyntaxException ex) {
            throw IsilonException.exceptions.errorCreatingServerURL(device.getIpAddress(), device.getPortNumber(), ex);
        }
        // get rest client
        if (device.getUsername() != null && !device.getUsername().isEmpty()) {
            isilonAPI = jobContext.getIsilonApiFactory().getRESTClient(deviceURI, device.getUsername(), device.getPassword());
        } else {
            isilonAPI = jobContext.getIsilonApiFactory().getRESTClient(deviceURI);
        }
        return isilonAPI;
    }
    return null;
}
Also used : URISyntaxException(java.net.URISyntaxException) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

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