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;
}
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;
}
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);
}
}
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;
}
}
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());
}
}
}
Aggregations