Search in sources :

Example 46 with IsilonException

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

the class IsilonFileStorageDevice method doCreateFS.

@Override
public BiosCommandResult doCreateFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    Boolean fsDirExists = true;
    Boolean fsDirCreatedByMe = false;
    try {
        _log.info("IsilonFileStorageDevice doCreateFS {} with name {} - start", args.getFsId(), args.getFsName());
        IsilonApi isi = getIsilonDevice(storage);
        VirtualNAS vNAS = args.getvNAS();
        String vNASPath = null;
        // get the custom path from the controller configuration
        String customPath = getCustomPath(storage, args);
        if (vNAS != null) {
            vNASPath = vNAS.getBaseDirPath();
            _log.info("vNAS base directory path: {}", vNASPath);
        }
        String usePhysicalNASForProvisioning = customConfigHandler.getComputedCustomConfigValue(CustomConfigConstants.USE_PHYSICAL_NAS_FOR_PROVISIONING, "isilon", null);
        _log.info("Use System access zone to provision filesystem? {}", usePhysicalNASForProvisioning);
        String mountPath = null;
        String fsName = args.getFsName();
        if (args.getFs().getPersonality() != null && args.getFs().getPersonality().equalsIgnoreCase(PersonalityTypes.TARGET.name())) {
            FileShare fsParent = _dbClient.queryObject(FileShare.class, args.getFs().getParentFileShare().getURI());
            fsName = fsParent.getName();
            // Add if there is any suffix in target fs label!!
            if (args.getFs().getLabel().contains("-target")) {
                String[] fsNameSuffix = args.getFs().getLabel().split(fsParent.getName() + "-target");
                if (fsNameSuffix != null && fsNameSuffix.length > 1 && !fsNameSuffix[1].isEmpty()) {
                    fsName = fsName + fsNameSuffix[1];
                }
            } else if (args.getFs().getLabel().contains("-localTarget")) {
                String[] fsNameSuffix = args.getFs().getLabel().split(fsParent.getName() + "-localTarget");
                if (fsNameSuffix != null && fsNameSuffix.length > 1 && !fsNameSuffix[1].isEmpty()) {
                    fsName = fsName + fsNameSuffix[1];
                }
            }
        }
        // Update the mount path as required
        if (vNASPath != null && !vNASPath.trim().isEmpty()) {
            mountPath = vNASPath + FW_SLASH + customPath + FW_SLASH + fsName;
        } else if (Boolean.valueOf(usePhysicalNASForProvisioning)) {
            mountPath = IFS_ROOT + FW_SLASH + getSystemAccessZoneNamespace() + FW_SLASH + customPath + FW_SLASH + fsName;
        } else {
            _log.error("No suitable access zone found for provisioning. Provisioning on System access zone is disabled");
            throw DeviceControllerException.exceptions.createFileSystemOnPhysicalNASDisabled();
        }
        // replace extra forward slash with single one
        mountPath = mountPath.replaceAll("/+", "/");
        _log.info("Mount path to mount the Isilon File System {}", mountPath);
        args.setFsMountPath(mountPath);
        args.setFsNativeGuid(args.getFsMountPath());
        args.setFsNativeId(args.getFsMountPath());
        args.setFsPath(args.getFsMountPath());
        // Update the mount path for local target!!!
        updateLocalTargetFileSystemPath(storage, args);
        // Create the target directory only if the replication policy was not applied!!
        // If policy was applied at higher level, policy would create target file system directories!
        boolean replicationExistsOnTarget = FileOrchestrationUtils.isReplicationPolicyExistsOnTarget(_dbClient, storage, args.getVPool(), args.getProject(), args.getFs());
        if (FileOrchestrationUtils.isPrimaryFileSystemOrNormalFileSystem(args.getFs()) || !replicationExistsOnTarget) {
            if (!replicationExistsOnTarget) {
                // Verify if the path of the new policy to be created only if the policy does not exist in the storage system
                checkNewPolicyPathHasData(args.getVPool(), args.getProject(), args.getFs(), args.getvNAS(), isi);
            }
            // Verify the file system directory exists or not!!
            fsDirExists = isi.existsDir(args.getFsMountPath());
            if (!fsDirExists) {
                // create directory for the file share
                isi.createDir(args.getFsMountPath(), true);
                fsDirCreatedByMe = true;
            } else {
                // Fail to create file system, as the directory already exists!!
                _log.error("File system creation failed due to directory path {} already exists.", args.getFsMountPath());
                throw DeviceControllerException.exceptions.failToCreateFileSystem(args.getFsMountPath());
            }
            Long softGrace = null;
            if (args.getFsSoftGracePeriod() != null) {
                softGrace = Long.valueOf(args.getFsSoftGracePeriod());
            }
            // set quota - save the quota id to extensions
            String qid = createQuotaWithThreshold(args.getFsMountPath(), args.getFsCapacity(), args.getFsSoftLimit(), args.getFsNotificationLimit(), softGrace, null, isi);
            if (args.getFsExtensions() == null) {
                args.initFsExtensions();
            }
            args.getFsExtensions().put(QUOTA, qid);
        }
        // set protection level
        // String protection = args.getFSProtectionLevel();
        // Call isilon api to set protection level
        _log.info("IsilonFileStorageDevice doCreateFS {} - complete", args.getFsId());
        return BiosCommandResult.createSuccessfulResult();
    } catch (IsilonException e) {
        _log.error("doCreateFS failed.", e);
        // delete the fs directory alone!!!
        if (fsDirCreatedByMe) {
            // delete isilon directory
            _log.info("doCreateFS failed, deleting the isilon directory {} which has been created in this workflow", args.getFsMountPath());
            IsilonApi isi = getIsilonDevice(storage);
            isi.deleteDir(args.getFsMountPath());
        }
        return BiosCommandResult.createErrorResult(e);
    }
}
Also used : VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) 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)

Example 47 with IsilonException

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

the class IsilonFileStorageDevice method doCreateQuotaDirectory.

@Override
public BiosCommandResult doCreateQuotaDirectory(StorageSystem storage, FileDeviceInputOutput args, QuotaDirectory quotaDir) throws ControllerException {
    // Get Parent FS mount path
    // Get Quota Directory Name
    // Get Quota Size
    // Call create Directory
    // Call create Quota (Aways use that quota for updating the size)
    String fsMountPath = args.getFsMountPath();
    Long qDirSize = quotaDir.getSize();
    String qDirPath = fsMountPath + "/" + quotaDir.getName();
    _log.info("IsilonFileStorageDevice doCreateQuotaDirectory {} with size {} - start", qDirPath, qDirSize);
    Boolean fsDirCreatedByMe = false;
    try {
        IsilonApi isi = getIsilonDevice(storage);
        // Verify the quota directory path exists or not!!
        if (!isi.existsDir(qDirPath)) {
            // create directory for the quota directory
            isi.createDir(qDirPath, true);
            fsDirCreatedByMe = true;
        } else {
            // Fail to create quota directory, as the directory already exists!!
            _log.error("Quota directory creation failed due to directory path {} already exists.", qDirPath);
            throw DeviceControllerException.exceptions.failToCreateQuotaDirectory(qDirPath);
        }
        String qid = checkThresholdAndcreateQuota(quotaDir, qDirSize, qDirPath, args.getFsCapacity(), isi);
        if (args.getQuotaDirExtensions() == null) {
            args.initQuotaDirExtensions();
        }
        args.getQuotaDirExtensions().put(QUOTA, qid);
        _log.info("IsilonFileStorageDevice doCreateQuotaDirectory {} with size {} - complete", qDirPath, qDirSize);
        return BiosCommandResult.createSuccessfulResult();
    } catch (IsilonException e) {
        // delete the directory alone with recursive false!!!
        if (fsDirCreatedByMe) {
            // delete isilon directory
            _log.info("doCreateQuotaDirectory failed, deleting the isilon directory {} which has been created in this workflow", qDirPath);
            IsilonApi isi = getIsilonDevice(storage);
            isi.deleteDir(qDirPath);
        }
        _log.error("doCreateQuotaDirectory failed.", e);
        return BiosCommandResult.createErrorResult(e);
    }
}
Also used : IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 48 with IsilonException

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

the class IsilonFileStorageDevice method doCheckFSExists.

@Override
public boolean doCheckFSExists(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    _log.info("checking file system existence on array: {}", args.getFsName());
    // setting true by default for safer side
    boolean isFSExists = true;
    try {
        IsilonApi isi = getIsilonDevice(storage);
        isFSExists = isi.existsDir(args.getFsMountPath());
    } catch (IsilonException e) {
        _log.error("Querying FS failed", e);
    }
    return isFSExists;
}
Also used : IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 49 with IsilonException

use of com.emc.storageos.isilon.restapi.IsilonException 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 50 with IsilonException

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

the class IsilonMirrorOperations method doCancelReplicationPolicy.

/**
 * Cancel the replication policy
 *
 * @param isi
 * @param policyName
 * @return
 */
public BiosCommandResult doCancelReplicationPolicy(IsilonApi isi, String policyName) {
    try {
        _log.info("Canceling Replication Policy  -{} because policy is in running state ", policyName);
        IsilonSyncJob syncJob = new IsilonSyncJob();
        syncJob.setState(JobState.canceled.name());
        isi.modifyReplicationJob(policyName, syncJob);
        _log.info("Sleeping for 40 seconds for cancel operation to complete...");
        TimeUnit.SECONDS.sleep(40);
        return BiosCommandResult.createSuccessfulResult();
    } catch (IsilonException e) {
        return BiosCommandResult.createErrorResult(e);
    } catch (InterruptedException ex) {
        _log.warn("Canceling ReplicationPolicy - {} Interrupted", policyName);
        ServiceError error = DeviceControllerErrors.isilon.jobFailed("Canceling ReplicationPolicy is Failed with Interrupt exception and message :" + ex.getMessage());
        return BiosCommandResult.createErrorResult(error);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) IsilonSyncJob(com.emc.storageos.isilon.restapi.IsilonSyncJob) 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