use of com.emc.storageos.db.client.constraint.ContainmentConstraint in project coprhd-controller by CoprHD.
the class ExportUtils method validateConsistencyGroupBookmarksExported.
/**
* Validates the given consistency group to ensure there are no RecoverPoint snapshots that have been
* exported. If any RecoverPoint snapshots associated with the consistency group have been exported,
* an exception will be thrown.
*
* @param dbClient the database client
* @param consistencyGroupUri the consistency group URI
*/
public static void validateConsistencyGroupBookmarksExported(DbClient dbClient, URI consistencyGroupUri) {
if (consistencyGroupUri == null) {
// If the consistency group URI is null we cannot proceed with this validation so fail.
throw APIException.badRequests.invalidConsistencyGroup();
}
_log.info(String.format("Performing validation to ensure no RP bookmarks have been exported for consistency group %s.", consistencyGroupUri));
URIQueryResultList snapshotUris = new URIQueryResultList();
ContainmentConstraint constraint = ContainmentConstraint.Factory.getBlockSnapshotByConsistencyGroup(consistencyGroupUri);
dbClient.queryByConstraint(constraint, snapshotUris);
List<BlockSnapshot> blockSnapshots = dbClient.queryObject(BlockSnapshot.class, snapshotUris);
for (BlockSnapshot snapshot : blockSnapshots) {
if (TechnologyType.RP.name().equalsIgnoreCase(snapshot.getTechnologyType())) {
_log.info(String.format("Examining RP bookmark %s to see if it has been exported.", snapshot.getId()));
// We have found an RP bookmark. Now lets see if that bookmark has been exported. Using the same
// call that BlockSnapshotService uses to get snapshot exports.
ContainmentConstraint exportGroupConstraint = ContainmentConstraint.Factory.getBlockObjectExportGroupConstraint(snapshot.getId());
URIQueryResultList exportGroupIdsForSnapshot = new URIQueryResultList();
dbClient.queryByConstraint(exportGroupConstraint, exportGroupIdsForSnapshot);
Iterator<URI> exportGroupIdsForSnapshotIter = exportGroupIdsForSnapshot.iterator();
if (exportGroupIdsForSnapshotIter != null && exportGroupIdsForSnapshotIter.hasNext()) {
// The consistency group has a bookmark that is already exported so fail the operation.
throw APIException.badRequests.cannotPerformOperationWithExportedBookmarks(snapshot.getId(), consistencyGroupUri);
}
}
}
_log.info(String.format("No RP bookmarks have been exported for consistency group %s.", consistencyGroupUri));
}
use of com.emc.storageos.db.client.constraint.ContainmentConstraint in project coprhd-controller by CoprHD.
the class FileDeviceController method queryDBShareAcls.
private List<CifsShareACL> queryDBShareAcls(FileDeviceInputOutput args) {
List<CifsShareACL> acls = new ArrayList<CifsShareACL>();
try {
ContainmentConstraint containmentConstraint = null;
if (args.getFileOperation()) {
FileShare fs = args.getFs();
_log.info("Querying DB for Share ACLs of share {} of filesystemId {} ", args.getShareName(), fs.getId());
containmentConstraint = ContainmentConstraint.Factory.getFileCifsShareAclsConstraint(fs.getId());
} else {
URI snapshotId = args.getSnapshotId();
_log.info("Querying DB for Share ACLs of share {} of snapshotId {} ", args.getShareName(), snapshotId);
containmentConstraint = ContainmentConstraint.Factory.getSnapshotCifsShareAclsConstraint(snapshotId);
}
List<CifsShareACL> shareAclList = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, CifsShareACL.class, containmentConstraint);
Iterator<CifsShareACL> shareAclIter = shareAclList.iterator();
while (shareAclIter.hasNext()) {
CifsShareACL shareAcl = shareAclIter.next();
if (shareAcl != null && args.getShareName().equals(shareAcl.getShareName())) {
acls.add(shareAcl);
}
}
} catch (Exception e) {
_log.error("Error while querying DB for ACL(s) of a share {}", e);
}
return acls;
}
use of com.emc.storageos.db.client.constraint.ContainmentConstraint in project coprhd-controller by CoprHD.
the class FileDeviceController method checkIfMountExistsOnHost.
public void checkIfMountExistsOnHost(URI fsId, String opId) {
try {
WorkflowStepCompleter.stepExecuting(opId);
ContainmentConstraint containmentConstraint = ContainmentConstraint.Factory.getFileMountsConstraint(fsId);
List<FileMountInfo> fsDBMounts = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, FileMountInfo.class, containmentConstraint);
FileShare fs = _dbClient.queryObject(FileShare.class, fsId);
for (FileMountInfo fsMount : fsDBMounts) {
LinuxMountUtils mountUtils = new LinuxMountUtils(_dbClient.queryObject(Host.class, fsMount.getHostId()));
ExportRule export = FileOperationUtils.findExport(fs, fsMount.getSubDirectory(), fsMount.getSecurityType(), _dbClient);
if (mountUtils.verifyMountPoints(export.getMountPoint(), fsMount.getMountPath())) {
String errMsg = new String("delete file system from ViPR database failed because mounts exist for file system " + fs.getLabel() + " and once deleted the mounts cannot be ingested into ViPR");
final ServiceCoded serviceCoded = DeviceControllerException.errors.jobFailedOpMsg(OperationTypeEnum.DELETE_FILE_SYSTEM.toString(), errMsg);
WorkflowStepCompleter.stepFailed(opId, serviceCoded);
}
}
for (FileMountInfo fsMount : fsDBMounts) {
fsMount.setInactive(true);
}
_dbClient.updateObject(fsDBMounts);
WorkflowStepCompleter.stepSucceded(opId);
} catch (ControllerException ex) {
WorkflowStepCompleter.stepFailed(opId, ex);
_log.error("Couldn't verify dependencies: ", fsId);
throw ex;
}
}
use of com.emc.storageos.db.client.constraint.ContainmentConstraint in project coprhd-controller by CoprHD.
the class FileDeviceController method queryExports.
private List<ExportRule> queryExports(FileDeviceInputOutput args) {
List<ExportRule> rules = 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);
}
List<FileExportRule> fileExportRules = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, FileExportRule.class, containmentConstraint);
rules = new ArrayList<>();
for (FileExportRule fileExportRule : fileExportRules) {
ExportRule rule = new ExportRule();
getExportRule(fileExportRule, rule);
rules.add(rule);
}
} catch (Exception e) {
_log.error("Error while querying {}", e);
}
return rules;
}
use of com.emc.storageos.db.client.constraint.ContainmentConstraint in project coprhd-controller by CoprHD.
the class FileDeviceController method queryFileQuotaDirs.
private List<QuotaDirectory> queryFileQuotaDirs(FileDeviceInputOutput args) {
if (args.getFileOperation()) {
FileShare fs = args.getFs();
_log.info("Querying all quota directories Using FsId {}", fs.getId());
try {
ContainmentConstraint containmentConstraint = ContainmentConstraint.Factory.getQuotaDirectoryConstraint(fs.getId());
List<QuotaDirectory> fsQuotaDirs = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, QuotaDirectory.class, containmentConstraint);
return fsQuotaDirs;
} catch (Exception e) {
_log.error("Error while querying {}", e);
}
}
return null;
}
Aggregations