use of com.emc.storageos.db.client.constraint.ContainmentConstraint in project coprhd-controller by CoprHD.
the class RPDeviceController method doDisableImageCopies.
/**
* It is possible that RP snapshots are exported to more than one host and hence part of more than one ExportGroup.
* If the same snapshot
* is part of more than one active ExportGroup, do not disable Image Access on the RP CG.
*
* @param snapshot
* snapshot to be unexported
* @return true if it is safe to disable image access on the CG, false otherwise
*/
public boolean doDisableImageCopies(BlockSnapshot snapshot) {
ContainmentConstraint constraint = ContainmentConstraint.Factory.getBlockObjectExportGroupConstraint(snapshot.getId());
URIQueryResultList exportGroupIdsForSnapshot = new URIQueryResultList();
_dbClient.queryByConstraint(constraint, exportGroupIdsForSnapshot);
Iterator<URI> exportGroupIdsForSnapshotIter = exportGroupIdsForSnapshot.iterator();
Set<URI> exportGroupURIs = new HashSet<URI>();
while (exportGroupIdsForSnapshotIter.hasNext()) {
exportGroupURIs.add(exportGroupIdsForSnapshotIter.next());
}
if (exportGroupURIs.size() > 1) {
_log.info(String.format("Snapshot %s is in %d active exportGroups. Not safe to disable the CG", snapshot.getEmName(), exportGroupURIs.size()));
return false;
}
_log.info("Safe to disable image access on the CG");
return true;
}
use of com.emc.storageos.db.client.constraint.ContainmentConstraint in project coprhd-controller by CoprHD.
the class FileDeviceController method queryFileExports.
private List<FileExportRule> queryFileExports(FileDeviceInputOutput args) {
List<FileExportRule> fileExportRules = null;
try {
ContainmentConstraint containmentConstraint;
if (args.getFileOperation()) {
FileShare fs = args.getFs();
_log.info("Querying all ExportRules Using FsId {}", fs.getId());
containmentConstraint = ContainmentConstraint.Factory.getFileExportRulesConstraint(fs.getId());
} else {
URI snapshotId = args.getSnapshotId();
_log.info("Querying all ExportRules Using Snapshot Id {}", snapshotId);
containmentConstraint = ContainmentConstraint.Factory.getSnapshotExportRulesConstraint(snapshotId);
}
fileExportRules = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, FileExportRule.class, containmentConstraint);
} catch (Exception e) {
_log.error("Error while querying {}", e);
}
return fileExportRules;
}
use of com.emc.storageos.db.client.constraint.ContainmentConstraint in project coprhd-controller by CoprHD.
the class FileDeviceController method resetReplicationFileSystemsRelation.
protected void resetReplicationFileSystemsRelation(FilePolicy filePolicy, PolicyStorageResource policyResource) {
URI storageSystem = policyResource.getStorageSystem();
String policyPath = policyResource.getResourcePath();
// Remove the source - target relationship
if (filePolicy.getFilePolicyType().equalsIgnoreCase(FilePolicyType.file_replication.name())) {
ContainmentConstraint containmentConstraint = ContainmentConstraint.Factory.getStorageDeviceFileshareConstraint(storageSystem);
List<FileShare> fileshares = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, FileShare.class, containmentConstraint);
List<FileShare> modifiedFileshares = new ArrayList<>();
for (FileShare fileshare : fileshares) {
// should be decoupled!!!
if (fileshare.getNativeId().startsWith(policyPath)) {
if (fileshare.getPersonality() != null && fileshare.getPersonality().equalsIgnoreCase(PersonalityTypes.SOURCE.toString())) {
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.constraint.ContainmentConstraint in project coprhd-controller by CoprHD.
the class FileDeviceController method queryAllNfsACLInDB.
/**
* To get all the ACLs of File System or a mention subDir.
*
* @param fs
* File System
* @param subDir
* Sub directory
* @return List of NFS ACL present in DB.
*/
private List<NFSShareACL> queryAllNfsACLInDB(FileShare fs, String subDir, FileDeviceInputOutput args) {
List<NFSShareACL> allNfsShareAcl = null;
List<NFSShareACL> returnNfsShareAcl = null;
List<NFSShareACL> fsNfsShareAcl = new ArrayList<NFSShareACL>();
List<NFSShareACL> subDirNfsShareAcl = new ArrayList<NFSShareACL>();
_log.info("Querying all Nfs File System ACL Using FsId {}", fs.getId());
try {
ContainmentConstraint containmentConstraint = null;
if (args.getFileOperation()) {
containmentConstraint = ContainmentConstraint.Factory.getFileNfsAclsConstraint(fs.getId());
} else {
containmentConstraint = ContainmentConstraint.Factory.getSnapshotNfsAclsConstraint(args.getSnapshotId());
}
allNfsShareAcl = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, NFSShareACL.class, containmentConstraint);
} catch (Exception e) {
_log.error("Error while querying {}", e);
}
returnNfsShareAcl = fsNfsShareAcl;
String absolutefsPath = fs.getPath();
String absoluteDirPath = "";
if (subDir != null && !subDir.isEmpty()) {
absoluteDirPath = absolutefsPath + "/" + subDir;
returnNfsShareAcl = subDirNfsShareAcl;
}
for (NFSShareACL nfsAcl : allNfsShareAcl) {
if (nfsAcl.getFileSystemPath().equals(absoluteDirPath)) {
subDirNfsShareAcl.add(nfsAcl);
} else if (nfsAcl.getFileSystemPath().equals(absolutefsPath)) {
fsNfsShareAcl.add(nfsAcl);
}
}
return returnNfsShareAcl;
}
use of com.emc.storageos.db.client.constraint.ContainmentConstraint in project coprhd-controller by CoprHD.
the class FileOrchestrationUtils method getFSExportRuleMap.
/**
* This method generates export map for the file system export rules.
*
* @param fs File System Object
* @param dbClient
* @return
*/
public static HashMap<String, List<ExportRule>> getFSExportRuleMap(FileShare fs, DbClient dbClient) {
ContainmentConstraint containmentConstraint = ContainmentConstraint.Factory.getFileExportRulesConstraint(fs.getId());
List<FileExportRule> fileExportRules = CustomQueryUtility.queryActiveResourcesByConstraint(dbClient, FileExportRule.class, containmentConstraint);
HashMap<String, List<ExportRule>> exportRulesMap = new HashMap<String, List<ExportRule>>();
for (FileExportRule fileExportRule : fileExportRules) {
if (exportRulesMap.get(fileExportRule.getExportPath()) == null) {
List<ExportRule> exportRules = new ArrayList<ExportRule>();
ExportRule exportRule = convertFileExportRuleToExportRule(fileExportRule);
exportRules.add(exportRule);
exportRulesMap.put(fileExportRule.getExportPath(), exportRules);
} else {
List<ExportRule> exportRules = exportRulesMap.get(fileExportRule.getExportPath());
ExportRule exportRule = convertFileExportRuleToExportRule(fileExportRule);
exportRules.add(exportRule);
}
}
return exportRulesMap;
}
Aggregations