Search in sources :

Example 96 with FileShare

use of com.emc.storageos.db.client.model.FileShare in project coprhd-controller by CoprHD.

the class IsilonFileStorageDevice method doApplyFilePolicy.

@Override
public BiosCommandResult doApplyFilePolicy(StorageSystem storageObj, FileDeviceInputOutput args) {
    FileShare fs = args.getFs();
    try {
        FilePolicy filePolicy = args.getFileProtectionPolicy();
        String policyPath = generatePathForPolicy(filePolicy, fs, args);
        // Verify the ViPR resource on which the policy is applying is present in
        // Isilon path definition.
        // Otherwise, this method throws corresponding exception.
        checkAppliedResourceNamePartOfFilePolicyPath(policyPath, filePolicy, args);
        // Otherwise applied the policy on corresponding Isilon device path.
        if (checkPolicyAppliedOnPath(storageObj, args, policyPath)) {
            String msg = String.format("File Policy template %s is already applied on storage system %s path %s", filePolicy.getFilePolicyName(), storageObj.getLabel(), policyPath);
            _log.info(msg);
            return BiosCommandResult.createSuccessfulResult();
        } else {
            if (filePolicy.getFilePolicyType().equals(FilePolicy.FilePolicyType.file_replication.name())) {
                doApplyFileReplicationPolicy(filePolicy, args, fs, storageObj);
            } else if (filePolicy.getFilePolicyType().equals(FilePolicyType.file_snapshot.name())) {
                doApplyFileSnapshotPolicy(filePolicy, args, fs, storageObj);
            }
            return BiosCommandResult.createSuccessfulResult();
        }
    } catch (IsilonException e) {
        _log.error("apply file policy failed.", e);
        return BiosCommandResult.createErrorResult(e);
    }
}
Also used : FilePolicy(com.emc.storageos.db.client.model.FilePolicy) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 97 with FileShare

use of com.emc.storageos.db.client.model.FileShare in project coprhd-controller by CoprHD.

the class IsilonFileStorageDevice method doRollbackMirrorLink.

/**
 * rollback the target filesystems
 */
@Override
public void doRollbackMirrorLink(StorageSystem system, List<URI> sources, List<URI> targets, TaskCompleter completer, String opId) {
    BiosCommandResult biosCommandResult = null;
    // delete the target objects
    if (targets != null && !targets.isEmpty()) {
        for (URI target : targets) {
            FileShare fileShare = _dbClient.queryObject(FileShare.class, target);
            StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, fileShare.getStorageDevice());
            URI uriParent = fileShare.getParentFileShare().getURI();
            if (sources.contains(uriParent) == true) {
                // Do not delete the file target file system with force flag
                biosCommandResult = rollbackCreatedFilesystem(storageSystem, target, opId, false);
                if (biosCommandResult.getCommandSuccess()) {
                    fileShare.getOpStatus().updateTaskStatus(opId, biosCommandResult.toOperation());
                    fileShare.setInactive(true);
                    _dbClient.updateObject(fileShare);
                }
            }
        }
    }
    completer.ready(_dbClient);
}
Also used : BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 98 with FileShare

use of com.emc.storageos.db.client.model.FileShare in project coprhd-controller by CoprHD.

the class IsilonFileStorageDevice method getCustomPath.

/**
 * Gets the file system custom path value from controller configuration
 *
 * @param storage
 *            Isilon storage system
 * @param args
 *            FileDeviceInputOutput object
 * @return evaluated custom path
 */
private String getCustomPath(StorageSystem storage, FileDeviceInputOutput args) {
    String path = "";
    IsilonApi isi = getIsilonDevice(storage);
    String clusterName = isi.getClusterConfig().getName();
    FileShare fs = args.getFs();
    // source cluster name should be included in target path instead of target cluster name.
    if (fs != null && fs.getPersonality() != null && fs.getPersonality().equalsIgnoreCase(PersonalityTypes.TARGET.name())) {
        FileShare sourceFS = _dbClient.queryObject(FileShare.class, fs.getParentFileShare());
        if (sourceFS != null && sourceFS.getStorageDevice() != null) {
            StorageSystem sourceSystem = _dbClient.queryObject(StorageSystem.class, sourceFS.getStorageDevice());
            if (sourceSystem != null) {
                IsilonApi sourceCluster = getIsilonDevice(sourceSystem);
                clusterName = sourceCluster.getClusterConfig().getName();
                // if the replication happens from user defined access zone to system access zone!!
                if (sourceFS.getVirtualNAS() != null) {
                    VirtualNAS sourcevNAS = _dbClient.queryObject(VirtualNAS.class, sourceFS.getVirtualNAS());
                    if (sourcevNAS != null) {
                        String vNASName = sourcevNAS.getNasName();
                        vNASName = getNameWithNoSpecialCharacters(vNASName, args);
                        clusterName = clusterName + vNASName;
                        _log.info("Source file system is on virtual NAS {}", vNASName);
                    }
                }
                _log.debug("Generating path for target and the source cluster is is  {}", clusterName);
            }
        }
    } else if (args.isTarget()) {
        if (args.getSourceSystem() != null) {
            IsilonApi sourceCluster = getIsilonDevice(args.getSourceSystem());
            clusterName = sourceCluster.getClusterConfig().getName();
        }
        // if the replication happens from user defined access zone to system access zone!!
        if (args.getSourceVNAS() != null && args.getvNAS() == null) {
            VirtualNAS sourcevNAS = args.getSourceVNAS();
            String vNASName = sourcevNAS.getNasName();
            vNASName = getNameWithNoSpecialCharacters(vNASName, args);
            clusterName = clusterName + vNASName;
        }
        _log.debug("Generating path for target and the source cluster is is  {}", clusterName);
    }
    DataSource dataSource = dataSourceFactory.createIsilonFileSystemPathDataSource(args.getProject(), args.getVPool(), args.getTenantOrg(), storage);
    dataSource.addProperty(CustomConfigConstants.ISILON_CLUSTER_NAME, clusterName);
    String configPath = customConfigHandler.getComputedCustomConfigValue(CustomConfigConstants.ISILON_PATH_CUSTOMIZATION, "isilon", dataSource);
    _log.debug("The isilon user defined custom path is  {}", configPath);
    if (configPath != null && !configPath.isEmpty()) {
        path = args.getPathWithoutSpecialCharacters(configPath);
    }
    return path;
}
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) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) DataSource(com.emc.storageos.customconfigcontroller.DataSource)

Example 99 with FileShare

use of com.emc.storageos.db.client.model.FileShare in project coprhd-controller by CoprHD.

the class IsilonFileStorageDevice method doReduceFS.

@Override
public BiosCommandResult doReduceFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    try {
        _log.info("IsilonFileStorageDevice doReduceFS {} - start", args.getFsId());
        IsilonApi isi = getIsilonDevice(storage);
        String quotaId = null;
        if (args.getFsExtensions() != null && args.getFsExtensions().get(QUOTA) != null) {
            quotaId = args.getFsExtensions().get(QUOTA);
            Long capacity = args.getNewFSCapacity();
            IsilonSmartQuota quota = isi.getQuota(quotaId);
            // new capacity should be less than usage capacity of a filehare
            if (capacity.compareTo(quota.getUsagePhysical()) < 0) {
                Double dUsageSize = SizeUtil.translateSize(quota.getUsagePhysical(), SizeUtil.SIZE_GB);
                Double dNewCapacity = SizeUtil.translateSize(capacity, SizeUtil.SIZE_GB);
                String msg = String.format("as requested reduced size [%.1fGB] is smaller than used capacity [%.1fGB] for filesystem %s", dNewCapacity, dUsageSize, args.getFs().getName());
                _log.error(msg);
                final ServiceError serviceError = DeviceControllerErrors.isilon.unableUpdateQuotaDirectory(msg);
                return BiosCommandResult.createErrorResult(serviceError);
            } else {
                isiReduceFS(isi, quotaId, args);
            }
        } 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 reduce filesystem ", fileShare.getLabel());
                return BiosCommandResult.createSuccessfulResult();
            }
            final ServiceError serviceError = DeviceControllerErrors.isilon.doReduceFSFailed(args.getFsId());
            _log.error(serviceError.getMessage());
            return BiosCommandResult.createErrorResult(serviceError);
        }
        _log.info("IsilonFileStorageDevice doReduceFS {} - complete", args.getFsId());
        return BiosCommandResult.createSuccessfulResult();
    } catch (IsilonException e) {
        _log.error("doReduceFS failed.", e);
        return BiosCommandResult.createErrorResult(e);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) IsilonSmartQuota(com.emc.storageos.isilon.restapi.IsilonSmartQuota) 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 100 with FileShare

use of com.emc.storageos.db.client.model.FileShare in project coprhd-controller by CoprHD.

the class IsilonFileStorageDevice method isiDeleteExports.

/**
 * Delete isilon export
 *
 * @param isi
 *            IsilonApi object
 * @param exportMap
 *            exports to be deleted
 * @throws IsilonException
 */
private void isiDeleteExports(IsilonApi isi, FileDeviceInputOutput args) throws IsilonException {
    FSExportMap exportMap = null;
    if (args.getFileOperation()) {
        FileShare fileObj = args.getFs();
        if (fileObj != null) {
            exportMap = fileObj.getFsExports();
        }
    } else {
        Snapshot snap = args.getFileSnapshot();
        if (snap != null) {
            exportMap = snap.getFsExports();
        }
    }
    if (exportMap == null || exportMap.isEmpty()) {
        return;
    }
    String zoneName = getZoneName(args.getvNAS());
    Set<String> deletedExports = new HashSet<String>();
    Iterator<Map.Entry<String, FileExport>> it = exportMap.entrySet().iterator();
    try {
        while (it.hasNext()) {
            Map.Entry<String, FileExport> entry = it.next();
            String key = entry.getKey();
            FileExport fsExport = entry.getValue();
            if (zoneName != null) {
                isi.deleteExport(fsExport.getIsilonId(), zoneName);
            } else {
                isi.deleteExport(fsExport.getIsilonId());
            }
            // Safe removal from the backing map. Can not do this through
            // iterator since this does not track changes and is not
            // reflected in the database.
            deletedExports.add(key);
        }
    } finally {
        // remove exports from the map in database.
        for (String key : deletedExports) {
            exportMap.remove(key);
        }
    }
}
Also used : Snapshot(com.emc.storageos.db.client.model.Snapshot) IsilonSnapshot(com.emc.storageos.isilon.restapi.IsilonSnapshot) FileExport(com.emc.storageos.db.client.model.FileExport) FSExportMap(com.emc.storageos.db.client.model.FSExportMap) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) FSExportMap(com.emc.storageos.db.client.model.FSExportMap) Map(java.util.Map) OpStatusMap(com.emc.storageos.db.client.model.OpStatusMap) HashMap(java.util.HashMap) SMBShareMap(com.emc.storageos.db.client.model.SMBShareMap) StringMap(com.emc.storageos.db.client.model.StringMap) CifsServerMap(com.emc.storageos.db.client.model.CifsServerMap) HashSet(java.util.HashSet)

Aggregations

FileShare (com.emc.storageos.db.client.model.FileShare)289 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)155 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)107 URI (java.net.URI)93 ArrayList (java.util.ArrayList)79 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)73 ControllerException (com.emc.storageos.volumecontroller.ControllerException)65 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)61 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)57 Operation (com.emc.storageos.db.client.model.Operation)56 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)56 URISyntaxException (java.net.URISyntaxException)56 Path (javax.ws.rs.Path)56 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)52 Produces (javax.ws.rs.Produces)51 Snapshot (com.emc.storageos.db.client.model.Snapshot)50 MapFileShare (com.emc.storageos.api.mapper.functions.MapFileShare)49 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)45 WorkflowException (com.emc.storageos.workflow.WorkflowException)42 NamedURI (com.emc.storageos.db.client.model.NamedURI)36