Search in sources :

Example 86 with FileShare

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

the class VirtualPoolService method getVArraysWithVPoolResources.

/**
 * Calculate the virtual arrays which have the vpool resources.
 * 1) Get list of vpool resources
 * 2) Get the resources for each of the passed in virtual array
 * 3) If there is resource in virtual array which is also in the vpool resource list, add to the virtual array list
 *
 * @param vpool
 * @param varrays
 * @param dbClient
 * @return List of virtual arrays with vpool resources.
 */
public static Set<String> getVArraysWithVPoolResources(VirtualPool vpool, Set<String> varrays, DbClient dbClient) {
    Set<String> resourcePools = new StringSet();
    _log.debug("Getting the virtual arrays with resources of virtual pool {}.", vpool.getLabel());
    if (null != varrays && !varrays.isEmpty()) {
        Iterator<String> varrayItr = varrays.iterator();
        while (varrayItr.hasNext()) {
            String varray = varrayItr.next();
            URI varrayURI = URI.create(varray);
            URIQueryResultList varrayResourcesResultList = new URIQueryResultList();
            URIQueryResultList vpoolResourcesResultList = new URIQueryResultList();
            if (VirtualPool.Type.block.name().equals(vpool.getType())) {
                dbClient.queryByConstraint(ContainmentConstraint.Factory.getVirtualArrayVolumeConstraint(varrayURI), varrayResourcesResultList);
                dbClient.queryByConstraint(ContainmentConstraint.Factory.getVirtualPoolVolumeConstraint(vpool.getId()), vpoolResourcesResultList);
            } else if (VirtualPool.Type.file.name().equals(vpool.getType())) {
                dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVirtualArrayFileSharesConstraint(varrayURI.toString()), varrayResourcesResultList);
                dbClient.queryByConstraint(ContainmentConstraint.Factory.getVirtualPoolFileshareConstraint(vpool.getId()), vpoolResourcesResultList);
            } else if (VirtualPool.Type.object.name().equals(vpool.getType())) {
                dbClient.queryByConstraint(ContainmentConstraint.Factory.getVirtualArrayBucketsConstraint(varrayURI), varrayResourcesResultList);
                dbClient.queryByConstraint(ContainmentConstraint.Factory.getVirtualPoolBucketConstraint(vpool.getId()), vpoolResourcesResultList);
            }
            // Create a set of vpoolResourcesResultList
            HashSet<URI> vpoolResourceSet = new HashSet<URI>();
            for (URI vpoolResource : vpoolResourcesResultList) {
                vpoolResourceSet.add(vpoolResource);
            }
            // Now look up if there are varray resources in the vpool resources set.
            for (URI varrayResource : varrayResourcesResultList) {
                if (vpoolResourceSet.contains(varrayResource)) {
                    boolean inactive = false;
                    if (VirtualPool.Type.block.name().equals(vpool.getType())) {
                        Volume resource = dbClient.queryObject(Volume.class, varrayResource);
                        inactive = resource.getInactive();
                    } else if (VirtualPool.Type.file.name().equals(vpool.getType())) {
                        FileShare resource = dbClient.queryObject(FileShare.class, varrayResource);
                        inactive = resource.getInactive();
                    } else if (VirtualPool.Type.object.name().equals(vpool.getType())) {
                        Bucket resource = dbClient.queryObject(Bucket.class, varrayResource);
                        inactive = resource.getInactive();
                    }
                    if (!inactive) {
                        _log.info("Found vpool resource {} in the varray {}", varrayResource, varray);
                        resourcePools.add(varray);
                        break;
                    }
                }
            }
        }
    }
    return resourcePools;
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) Bucket(com.emc.storageos.db.client.model.Bucket) StringSet(com.emc.storageos.db.client.model.StringSet) URI(java.net.URI) FileShare(com.emc.storageos.db.client.model.FileShare) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) HashSet(java.util.HashSet)

Example 87 with FileShare

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

the class VirtualPoolService method getPoolsWithVPoolResources.

/**
 * Calculate the storage pools which have the vpool resources.
 * 1) Get list of vpool resources
 * 2) For each of the vpool's matched pool, get the pool resources
 * 3) If there is resource in storage pool which is also in the vpool resource list, add to the pool list
 *
 * @param vpool
 * @param dbClient
 * @return List of storage pools with vpool resources.
 */
public static Set<String> getPoolsWithVPoolResources(VirtualPool vpool, Set<String> pools, DbClient dbClient) {
    Set<String> resourcePools = new StringSet();
    _log.debug("Getting the storage pools with resources of virtual pool {}.", vpool.getLabel());
    if (null != pools && !pools.isEmpty()) {
        Iterator<String> poolItr = pools.iterator();
        while (poolItr.hasNext()) {
            String matchedPool = poolItr.next();
            URI poolURI = URI.create(matchedPool);
            URIQueryResultList poolResourcesResultList = new URIQueryResultList();
            URIQueryResultList vpoolResourcesResultList = new URIQueryResultList();
            if (VirtualPool.Type.block.name().equals(vpool.getType())) {
                dbClient.queryByConstraint(ContainmentConstraint.Factory.getStoragePoolVolumeConstraint(poolURI), poolResourcesResultList);
                dbClient.queryByConstraint(ContainmentConstraint.Factory.getVirtualPoolVolumeConstraint(vpool.getId()), vpoolResourcesResultList);
            } else if (VirtualPool.Type.file.name().equals(vpool.getType())) {
                dbClient.queryByConstraint(ContainmentConstraint.Factory.getStoragePoolFileshareConstraint(poolURI), poolResourcesResultList);
                dbClient.queryByConstraint(ContainmentConstraint.Factory.getVirtualPoolFileshareConstraint(vpool.getId()), vpoolResourcesResultList);
            } else if (VirtualPool.Type.object.name().equals(vpool.getType())) {
                dbClient.queryByConstraint(ContainmentConstraint.Factory.getStoragePoolBucketConstraint(poolURI), poolResourcesResultList);
                dbClient.queryByConstraint(ContainmentConstraint.Factory.getVirtualPoolBucketConstraint(vpool.getId()), vpoolResourcesResultList);
            }
            // Create a set of vpoolResourcesResultList
            HashSet<URI> vpoolResourceSet = new HashSet<URI>();
            for (URI vpoolResource : vpoolResourcesResultList) {
                vpoolResourceSet.add(vpoolResource);
            }
            // Now look up if there are pool resources in the vpool resources set.
            for (URI poolResource : poolResourcesResultList) {
                if (vpoolResourceSet.contains(poolResource)) {
                    boolean inactive = false;
                    if (VirtualPool.Type.block.name().equals(vpool.getType())) {
                        Volume resource = dbClient.queryObject(Volume.class, poolResource);
                        inactive = resource.getInactive();
                    } else if (VirtualPool.Type.file.name().equals(vpool.getType())) {
                        FileShare resource = dbClient.queryObject(FileShare.class, poolResource);
                        inactive = resource.getInactive();
                    }
                    if (!inactive) {
                        _log.info("Found vpool resource {} in the storage pool {}", poolResource, matchedPool);
                        resourcePools.add(matchedPool);
                        break;
                    }
                }
            }
        }
    }
    return resourcePools;
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) StringSet(com.emc.storageos.db.client.model.StringSet) URI(java.net.URI) FileShare(com.emc.storageos.db.client.model.FileShare) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) HashSet(java.util.HashSet)

Example 88 with FileShare

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

the class FilePolicyServiceUtils method resetReplicationFileSystemsRelation.

/**
 * Resets the filesystem relation due to replication policy assigned at higher level
 * Only to be used when delete FS is FULL type
 *
 * @param _dbClient
 * @param fileshare
 */
public static void resetReplicationFileSystemsRelation(DbClient _dbClient, FileShare fileshare) {
    List<FileShare> modifiedFileshares = new ArrayList<>();
    if (fileshare.getPersonality() != null) {
        fileshare.setMirrorStatus(NullColumnValueGetter.getNullStr());
        fileshare.setAccessState(NullColumnValueGetter.getNullStr());
        fileshare.setPersonality(NullColumnValueGetter.getNullStr());
        if (fileshare.getMirrorfsTargets() != null && !fileshare.getMirrorfsTargets().isEmpty()) {
            StringSet targets = fileshare.getMirrorfsTargets();
            for (String strTargetFs : targets) {
                FileShare targetFs = _dbClient.queryObject(FileShare.class, URI.create(strTargetFs));
                targetFs.setMirrorStatus(NullColumnValueGetter.getNullStr());
                targetFs.setAccessState(NullColumnValueGetter.getNullStr());
                targetFs.setParentFileShare(NullColumnValueGetter.getNullNamedURI());
                targetFs.setPersonality(NullColumnValueGetter.getNullStr());
                modifiedFileshares.add(targetFs);
            }
            targets.clear();
            fileshare.setMirrorfsTargets(targets);
        }
    }
    modifiedFileshares.add(fileshare);
    if (!modifiedFileshares.isEmpty()) {
        _dbClient.updateObject(modifiedFileshares);
    }
}
Also used : ArrayList(java.util.ArrayList) StringSet(com.emc.storageos.db.client.model.StringSet) FileShare(com.emc.storageos.db.client.model.FileShare)

Example 89 with FileShare

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

the class CreateMirrorFileSystemsCompleter method complete.

@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded serviceCoded) {
    super.complete(dbClient, status, serviceCoded);
    switch(status) {
        case error:
            handleFileShareErrors(dbClient);
            break;
        case ready:
            // Remove target attributes from source file system!!
            for (URI id : getIds()) {
                FileShare fileSystem = dbClient.queryObject(FileShare.class, id);
                if (fileSystem != null && !fileSystem.getInactive()) {
                    if (fileSystem.getPersonality() != null && PersonalityTypes.SOURCE.name().equalsIgnoreCase(fileSystem.getPersonality())) {
                        // Set the mirror status!!
                        fileSystem.setMirrorStatus(MirrorStatus.UNKNOWN.name());
                        dbClient.updateObject(fileSystem);
                        _log.info("CreateMirrorFileSystemsCompleter::Set the mirror status of source file system {}", fileSystem.getId());
                    }
                }
                dbClient.ready(FileShare.class, id, getOpId());
            }
            break;
        default:
            break;
    }
}
Also used : URI(java.net.URI) FileShare(com.emc.storageos.db.client.model.FileShare)

Example 90 with FileShare

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

the class FileDeleteWorkflowCompleter method complete.

@Override
protected void complete(DbClient dbClient, Status status, ServiceCoded serviceCoded) {
    super.complete(dbClient, status, serviceCoded);
    if (status == Operation.Status.ready) {
        // Remove target attributes from souce file system!!
        for (URI id : getIds()) {
            FileShare fileSystem = dbClient.queryObject(FileShare.class, id);
            if (fileSystem != null && !fileSystem.getInactive()) {
                if (fileSystem.getPersonality() != null && PersonalityTypes.SOURCE.name().equalsIgnoreCase(fileSystem.getPersonality())) {
                    // Reset the mirror attributes!!
                    StringSet targets = fileSystem.getMirrorfsTargets();
                    if (targets != null && !targets.isEmpty()) {
                        targets.clear();
                    }
                    fileSystem.setMirrorfsTargets(targets);
                    fileSystem.setMirrorStatus(MirrorStatus.DETACHED.name());
                    fileSystem.setPersonality("");
                    dbClient.updateObject(fileSystem);
                    _log.info("FileDeleteWorkflowCompleter::reset the mirror attribute of source file system {}", fileSystem.getId());
                }
            }
            dbClient.ready(FileShare.class, id, getOpId());
        }
    }
}
Also used : StringSet(com.emc.storageos.db.client.model.StringSet) URI(java.net.URI) FileShare(com.emc.storageos.db.client.model.FileShare)

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