Search in sources :

Example 21 with IsilonException

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

the class IsilonFileStorageDevice method doSnapshotFS.

@Override
public BiosCommandResult doSnapshotFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    try {
        _log.info("IsilonFileStorageDevice doSnapshotFS {} {} - start", args.getSnapshotId(), args.getSnapshotName());
        IsilonApi isi = getIsilonDevice(storage);
        // To Do - add timestamp for uniqueness
        String snapId = isi.createSnapshot(args.getSnapshotName(), args.getFsMountPath());
        if (args.getSnapshotExtensions() == null) {
            args.initSnapshotExtensions();
        }
        args.getSnapshotExtensions().put("id", snapId);
        args.setSnapNativeId(snapId);
        String path = getSnapshotPath(args.getFsMountPath(), args.getSnapshotName());
        args.setSnapshotMountPath(path);
        args.setSnapshotPath(path);
        _log.info("IsilonFileStorageDevice doSnapshotFS {} - complete", args.getSnapshotId());
        return BiosCommandResult.createSuccessfulResult();
    } catch (IsilonException e) {
        _log.error("doSnapshotFS failed.", e);
        return BiosCommandResult.createErrorResult(e);
    }
}
Also used : IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 22 with IsilonException

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

the class IsilonFileStorageDevice method doDeleteSnapshot.

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

Example 23 with IsilonException

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

the class IsilonFileStorageDevice method doCheckFSDependencies.

@Override
public BiosCommandResult doCheckFSDependencies(StorageSystem storage, FileDeviceInputOutput args) {
    _log.info("Checking file system {} has dependencies in storage array: {}", args.getFsName(), storage.getLabel());
    boolean hasDependency = true;
    String vnasName = null;
    VirtualNAS vNas = args.getvNAS();
    if (vNas != null) {
        vnasName = vNas.getNasName();
    }
    try {
        String fsMountPath = args.getFsMountPath();
        hasDependency = doesNFSExportExistsForFSPath(storage, vnasName, fsMountPath);
        if (!hasDependency) {
            hasDependency = doesCIFSShareExistsForFSPath(storage, vnasName, fsMountPath);
        }
        if (!hasDependency) {
            hasDependency = doesSnapshotExistsForFSPath(storage, vnasName, fsMountPath);
        }
        if (hasDependency) {
            _log.error("File system has dependencies on array: {}", args.getFsName());
            DeviceControllerException e = DeviceControllerException.exceptions.fileSystemHasDependencies(fsMountPath);
            return BiosCommandResult.createErrorResult(e);
        }
        _log.info("File system has no dependencies on array: {}", args.getFsName());
        return BiosCommandResult.createSuccessfulResult();
    } catch (IsilonException e) {
        _log.error("Checking FS dependencies failed.", e);
        throw e;
    }
}
Also used : VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 24 with IsilonException

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

the class IsilonFileStorageDevice method updateNfsACLs.

@Override
public BiosCommandResult updateNfsACLs(StorageSystem storage, FileDeviceInputOutput args) {
    try {
        // read nameToSid flag from controller config.
        Boolean sidEnable = customConfigHandler.getComputedCustomConfigBooleanValue(CustomConfigConstants.ISILON_USER_TO_SID_MAPPING_FOR_NFS_ENABLED, storage.getSystemType(), null);
        // get sid mapping based on Controller config and it belong to VirtualNAS.
        if (sidEnable && args.getvNAS() != null) {
            updateSidInfoForNfsACE(args, storage);
        }
        IsilonNFSACL isilonAcl = new IsilonNFSACL();
        ArrayList<Acl> aclCompleteList = new ArrayList<Acl>();
        List<NfsACE> aceToAdd = args.getNfsAclsToAdd();
        for (NfsACE nfsACE : aceToAdd) {
            Acl acl = getIsilonAclFromNfsACE(nfsACE);
            acl.setOp("add");
            aclCompleteList.add(acl);
        }
        List<NfsACE> aceToModify = args.getNfsAclsToModify();
        for (NfsACE nfsACE : aceToModify) {
            Acl acl = getIsilonAclFromNfsACE(nfsACE);
            acl.setOp("replace");
            aclCompleteList.add(acl);
        }
        List<NfsACE> aceToDelete = args.getNfsAclsToDelete();
        for (NfsACE nfsACE : aceToDelete) {
            Acl acl = getIsilonAclFromNfsACE(nfsACE);
            acl.setOp("delete");
            aclCompleteList.add(acl);
        }
        isilonAcl.setAction("update");
        isilonAcl.setAuthoritative("acl");
        isilonAcl.setAcl(aclCompleteList);
        String path = args.getFileSystemPath();
        if (args.getSubDirectory() != null && !args.getSubDirectory().isEmpty()) {
            path = path + "/" + args.getSubDirectory();
        }
        // Process new ACLs
        IsilonApi isi = getIsilonDevice(storage);
        _log.info("Calling Isilon API: modify NFS Acl for {}, acl  {}", args.getFileSystemPath(), isilonAcl);
        isi.modifyNFSACL(path, isilonAcl);
        _log.info("End updateNfsACLs");
        BiosCommandResult result = BiosCommandResult.createSuccessfulResult();
        return result;
    } catch (IsilonException e) {
        _log.error("updateNfsACLs failed ", e);
        return BiosCommandResult.createErrorResult(e);
    } catch (Exception e) {
        _log.error("updateNfsACLs failed ", e);
        final ServiceCoded serviceCoded = DeviceControllerException.errors.jobFailedOpMsg(OperationTypeEnum.UPDATE_FILE_SYSTEM_NFS_ACL.toString(), e.getMessage());
        return BiosCommandResult.createErrorResult(serviceCoded);
    }
}
Also used : NfsACE(com.emc.storageos.model.file.NfsACE) ArrayList(java.util.ArrayList) Acl(com.emc.storageos.isilon.restapi.IsilonNFSACL.Acl) 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) IsilonNFSACL(com.emc.storageos.isilon.restapi.IsilonNFSACL) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 25 with IsilonException

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

the class IsilonMirrorOperations method doStopReplicationPolicy.

/**
 * Call to device to stop policy
 *
 * @param system
 * @param policyName
 * @return
 */
public BiosCommandResult doStopReplicationPolicy(IsilonApi isi, String policyName) {
    try {
        IsilonSyncPolicy policy = isi.getReplicationPolicy(policyName);
        if (policy.getLastJobState().equals(JobState.running)) {
            BiosCommandResult cmdResult = doCancelReplicationPolicy(isi, policyName);
            if (!cmdResult.isCommandSuccess()) {
                return cmdResult;
            } else {
                // if the replication still running through exception
                policy = isi.getReplicationPolicy(policyName);
                if (policy.getLastJobState().equals(JobState.running)) {
                    ServiceError error = DeviceControllerErrors.isilon.jobFailed("Unable Stop Replication policy and policy state  :" + policy.getLastJobState().toString());
                    return BiosCommandResult.createErrorResult(error);
                }
            }
        }
        // disable the policy
        if (policy.getEnabled()) {
            IsilonSyncPolicy modifiedPolicy = new IsilonSyncPolicy();
            modifiedPolicy.setEnabled(false);
            isi.modifyReplicationPolicy(policyName, modifiedPolicy);
            _log.info("Sleeping for 40 seconds for stop operation to complete...");
            TimeUnit.SECONDS.sleep(40);
            _log.info("Replication Policy -{}  disabled successfully.", policy.toString());
            return BiosCommandResult.createSuccessfulResult();
        } else {
            _log.info("Replication Policy - {} can't be STOPPED because policy is already DISABLED", policy.toString());
            return BiosCommandResult.createSuccessfulResult();
        }
    } catch (IsilonException e) {
        return BiosCommandResult.createErrorResult(e);
    } catch (InterruptedException ex) {
        _log.warn("Stoping ReplicationPolicy - {} Interrupted", policyName);
        ServiceError error = DeviceControllerErrors.isilon.jobFailed("Stoping ReplicationPolicy is Failed with Interrupt exception and message :" + ex.getMessage());
        return BiosCommandResult.createErrorResult(error);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) 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