use of com.emc.storageos.db.client.constraint.URIQueryResultList in project coprhd-controller by CoprHD.
the class FileDeviceController method getExistingNfsAclFromDB.
/**
* Get the DB object to modify it
*
* @param dbShareAcl
* the DB object which need to be searched
* @param isFile
* it is file or snapshot operation
* @return
*/
private NFSShareACL getExistingNfsAclFromDB(NFSShareACL dbShareAcl, boolean isFile) {
NFSShareACL acl = null;
String index = null;
URIQueryResultList result = new URIQueryResultList();
if (isFile) {
index = dbShareAcl.getFileSystemNfsACLIndex();
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getFileSystemNfsACLConstraint(index), result);
} else {
index = dbShareAcl.getSnapshotNfsACLIndex();
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getSnapshotNfsACLConstraint(index), result);
}
Iterator<URI> it = result.iterator();
while (it.hasNext()) {
acl = _dbClient.queryObject(NFSShareACL.class, it.next());
if (acl != null && !acl.getInactive()) {
_log.info("Existing ACE found in DB: {}", acl);
return acl;
}
}
return null;
}
use of com.emc.storageos.db.client.constraint.URIQueryResultList in project coprhd-controller by CoprHD.
the class FileDeviceController method getAvailableExportRule.
private FileExportRule getAvailableExportRule(FileExportRule exportRule, FileDeviceInputOutput args) throws URISyntaxException {
String exportIndex = exportRule.getFsExportIndex();
if (!args.getFileOperation()) {
exportIndex = exportRule.getSnapshotExportIndex();
}
_log.info("Retriving DB Model using its index {}", exportIndex);
FileExportRule rule = null;
URIQueryResultList result = new URIQueryResultList();
if (!args.getFileOperation()) {
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getSnapshotExportRuleConstraint(exportIndex), result);
} else {
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getFileExportRuleConstraint(exportIndex), result);
}
Iterator<URI> it = result.iterator();
while (it.hasNext()) {
if (result.iterator().hasNext()) {
rule = _dbClient.queryObject(FileExportRule.class, it.next());
if (rule != null && !rule.getInactive()) {
_log.info("Existing DB Model found {}", rule);
break;
}
}
}
return rule;
}
use of com.emc.storageos.db.client.constraint.URIQueryResultList in project coprhd-controller by CoprHD.
the class FileDeviceController method quotaDirectoriesExistsOnFS.
private boolean quotaDirectoriesExistsOnFS(FileShare fs) {
_log.info(" Setting Snapshots to InActive with Force Delete ");
URIQueryResultList qdIDList = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getQuotaDirectoryConstraint(fs.getId()), qdIDList);
_log.info("getQuotaDirectories : FS {}: {} ", fs.getId().toString(), qdIDList.toString());
List<QuotaDirectory> qdList = _dbClient.queryObject(QuotaDirectory.class, qdIDList);
if (qdList != null) {
for (QuotaDirectory qd : qdList) {
if (!qd.getInactive()) {
return true;
}
}
}
return false;
}
use of com.emc.storageos.db.client.constraint.URIQueryResultList in project coprhd-controller by CoprHD.
the class ControllerLockingUtil method getHostStorageLockKeys.
/**
* Returns a list of lock keys for export of Hosts to StorageSystems.
* This is constructed from a list of Initiators.
* All the host URIs are collected from the Initiators.
* If an Initiator does not have a host URI, its hostName is converted to a URI and used.
* iF export type is Cluster, the clusters are looked up, and all hosts in the
* cluster are used.
* The keys are constructed from a concatenation of the host URI and the storage system URI.
*
* @param dbClient
* @param type
* ExportGroup.ExportGroupType -- used to determine if cluster export
* @param initiatorURIs
* -- set of Initiators to consider
* @param storageURI
* -- URI of storage system
* (could be a Protection System or null in which case only host in key)
* @return List<String> where each item in list is a lockKey
*/
public static List<String> getHostStorageLockKeys(DbClient dbClient, ExportGroup.ExportGroupType type, Collection<URI> initiatorURIs, URI storageURI) {
String storageKey = getStorageKey(dbClient, storageURI);
List<String> lockKeys = new ArrayList<String>();
// Collect the needed hosts, which can be specified either by URI or string name.
Set<URI> hostURIs = new HashSet<URI>();
Set<String> hostNames = new HashSet<String>();
for (URI initiatorURI : initiatorURIs) {
Initiator initiator = dbClient.queryObject(Initiator.class, initiatorURI);
if (initiator == null || initiator.getInactive()) {
continue;
}
hostURIs.add(initiator.getHost());
hostNames.add(initiator.getHostName());
}
// If the export is type cluster, we want to add ALL the hosts in the clusters.
if (type.equals(ExportGroup.ExportGroupType.Cluster)) {
Set<URI> clusterURIs = new HashSet<URI>();
// First determine the clusters for each real host.
for (URI hostURI : hostURIs) {
Host host = dbClient.queryObject(Host.class, hostURI);
if (host == null || host.getInactive()) {
continue;
}
if (!NullColumnValueGetter.isNullURI(host.getCluster())) {
clusterURIs.add(host.getCluster());
}
}
// add those hosts if not already present.
for (URI clusterURI : clusterURIs) {
URIQueryResultList result = new URIQueryResultList();
dbClient.queryByConstraint(ContainmentConstraint.Factory.getContainedObjectsConstraint(clusterURI, Host.class, "cluster"), result);
Iterator<URI> iter = result.iterator();
while (iter.hasNext()) {
Host host = dbClient.queryObject(Host.class, iter.next());
if (host == null || host.getInactive()) {
continue;
}
hostNames.add(host.getHostName());
}
}
}
// Now make a key for every host / storage pair
for (String hostName : hostNames) {
String key = hostName + DELIMITER + storageKey;
key = key.replaceAll("\\s", "");
if (!lockKeys.contains(key)) {
lockKeys.add(key);
}
}
log.info("Lock keys: " + lockKeys.toString());
return lockKeys;
}
use of com.emc.storageos.db.client.constraint.URIQueryResultList in project coprhd-controller by CoprHD.
the class ControllerUtils method getVolumesPartOfRG.
/**
* Gets the volumes part of a given replication group.
* and add system check.
*
* @param system the storage system where the replication group resides
* @param replicationGroupInstance the replication group instance
* @param dbClient the db client
* @return the volumes part of replication group
*/
public static List<Volume> getVolumesPartOfRG(URI system, String replicationGroupInstance, DbClient dbClient) {
List<Volume> volumes = new ArrayList<Volume>();
URIQueryResultList uriQueryResultList = new URIQueryResultList();
dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVolumeReplicationGroupInstanceConstraint(replicationGroupInstance), uriQueryResultList);
Iterator<Volume> volumeIterator = dbClient.queryIterativeObjects(Volume.class, uriQueryResultList, true);
while (volumeIterator.hasNext()) {
Volume volume = volumeIterator.next();
if (volume != null && system.toString().equals(volume.getStorageController().toString())) {
volumes.add(volume);
}
}
return volumes;
}
Aggregations