use of com.emc.storageos.db.client.model.PolicyStorageResource in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method doRefreshMirrorLink.
@Override
public BiosCommandResult doRefreshMirrorLink(StorageSystem system, FileShare source) {
IsilonSyncPolicy syncpolicy = null;
PolicyStorageResource policyStrRes = getEquivalentPolicyStorageResource(source, _dbClient);
if (policyStrRes != null) {
syncpolicy = policyNativeIdValidation(system, policyStrRes);
String policyId = syncpolicy.getId();
return mirrorOperations.doRefreshMirrorFileShareLink(system, source, policyId);
}
ServiceError serviceError = DeviceControllerErrors.isilon.unableToCreateFileShare();
return BiosCommandResult.createErrorResult(serviceError);
}
use of com.emc.storageos.db.client.model.PolicyStorageResource in project coprhd-controller by CoprHD.
the class FileOrchestrationUtils method getFilePolicyStorageResources.
/**
* Get the set of file policy storage resource for given policy
*
* @param dbClient
* @param policy
* @return
*/
public static List<PolicyStorageResource> getFilePolicyStorageResources(DbClient dbClient, VirtualPool vpool, Project project, FileShare fs) {
// Get the replication policies for vpool/project/fs!!
List<PolicyStorageResource> policyStorageResources = new ArrayList<PolicyStorageResource>();
List<FilePolicy> replicationPolicies = getReplicationPolices(dbClient, vpool, project, fs);
if (replicationPolicies != null && !replicationPolicies.isEmpty()) {
if (replicationPolicies.size() > 1) {
_log.error("More than one replication policy could not be applied accross vpool/project/fs");
throw APIException.badRequests.moreThanOneReplicationPolicySpecified();
} else {
FilePolicy policy = replicationPolicies.get(0);
for (PolicyStorageResource strRes : getFilePolicyStorageResources(dbClient, policy)) {
if (strRes != null) {
if (FilePolicyApplyLevel.project.name().equalsIgnoreCase(policy.getApplyAt()) && strRes.getAppliedAt().toString().equals(project.getId().toString())) {
policyStorageResources.add(strRes);
} else if (FilePolicyApplyLevel.vpool.name().equalsIgnoreCase(policy.getApplyAt()) && strRes.getAppliedAt().toString().equals(vpool.getId().toString())) {
policyStorageResources.add(strRes);
}
}
}
}
}
return policyStorageResources;
}
use of com.emc.storageos.db.client.model.PolicyStorageResource in project coprhd-controller by CoprHD.
the class FileOrchestrationUtils method getFilePolicyStorageResources.
/**
* Get the set of file policy storage resource for given policy
*
* @param dbClient
* @param policy
* @return
*/
public static List<PolicyStorageResource> getFilePolicyStorageResources(DbClient dbClient, FilePolicy policy) {
URIQueryResultList policyResourceURIs = new URIQueryResultList();
dbClient.queryByConstraint(ContainmentConstraint.Factory.getFilePolicyStorageResourceConstraint(policy.getId()), policyResourceURIs);
List<PolicyStorageResource> policyStorageResources = new ArrayList<PolicyStorageResource>();
Iterator<URI> policyStorageResIter = policyResourceURIs.iterator();
while (policyStorageResIter.hasNext()) {
PolicyStorageResource policyStorageRes = dbClient.queryObject(PolicyStorageResource.class, policyStorageResIter.next());
if (policyStorageRes != null && !policyStorageRes.getInactive()) {
policyStorageResources.add(policyStorageRes);
}
}
return policyStorageResources;
}
use of com.emc.storageos.db.client.model.PolicyStorageResource in project coprhd-controller by CoprHD.
the class FileOrchestrationUtils method getAllVpoolLevelPolices.
/**
* Return list of policies to be applied at vpool
*
* @param dbClient
* @param vpool
* @param storageSystem
* @return
*/
public static List<FilePolicy> getAllVpoolLevelPolices(DbClient dbClient, VirtualPool vpool, URI storageSystem, URI nasServer) {
List<FilePolicy> filePoliciesToCreate = new ArrayList<FilePolicy>();
StringSet fileVpoolPolicies = vpool.getFilePolicies();
if (fileVpoolPolicies != null && !fileVpoolPolicies.isEmpty()) {
for (String fileVpoolPolicy : fileVpoolPolicies) {
FilePolicy filePolicy = dbClient.queryObject(FilePolicy.class, URIUtil.uri(fileVpoolPolicy));
filePoliciesToCreate.add(filePolicy);
StringSet policyStrRes = filePolicy.getPolicyStorageResources();
if (policyStrRes != null && !policyStrRes.isEmpty()) {
for (String policyStrRe : policyStrRes) {
PolicyStorageResource strRes = dbClient.queryObject(PolicyStorageResource.class, URIUtil.uri(policyStrRe));
if (strRes.getAppliedAt().toString().equals(vpool.getId().toString()) && strRes.getStorageSystem().toString().equals(storageSystem.toString()) && strRes.getNasServer().toString().equalsIgnoreCase(nasServer.toString())) {
_log.info("File Policy {} is already exists for vpool {} , storage system {} and nas server {}", filePolicy.getFilePolicyName(), vpool.getLabel(), storageSystem.toString(), strRes);
filePoliciesToCreate.remove(filePolicy);
break;
}
}
}
}
}
return filePoliciesToCreate;
}
use of com.emc.storageos.db.client.model.PolicyStorageResource in project coprhd-controller by CoprHD.
the class FileOrchestrationUtils method findPolicyStorageResourceByNativeId.
/**
* Find the file storage resource by Native ID
*
* @param dbClient
*
* @param system
* storage system
* @param filePolicy
* file policy
* @param args
*
* @param path
* storage path
* @return policy storage resource
*/
public static PolicyStorageResource findPolicyStorageResourceByNativeId(DbClient dbClient, StorageSystem system, FilePolicy filePolicy, FileDeviceInputOutput args, String path) {
URIQueryResultList results = new URIQueryResultList();
PolicyStorageResource storageRes = null;
NASServer nasServer = null;
if (args.getvNAS() != null) {
nasServer = args.getvNAS();
} else {
// Get the physical NAS for the storage system!!
PhysicalNAS pNAS = getSystemPhysicalNAS(dbClient, system);
if (pNAS != null) {
nasServer = pNAS;
} else {
_log.error("Unable to find physical NAS on storage system {}", system.getLabel());
return null;
}
}
// Set storage port details to vNas
String nasNativeGuid = NativeGUIDGenerator.generateNativeGuidForFilePolicyResource(system, nasServer.getNasName(), filePolicy.getFilePolicyType(), path, NativeGUIDGenerator.FILE_STORAGE_RESOURCE);
dbClient.queryByConstraint(AlternateIdConstraint.Factory.getPolicyStorageResourceByNativeGuidConstraint(nasNativeGuid), results);
Iterator<URI> iter = results.iterator();
PolicyStorageResource tmpStorageres = null;
while (iter.hasNext()) {
tmpStorageres = dbClient.queryObject(PolicyStorageResource.class, iter.next());
if (tmpStorageres != null && !tmpStorageres.getInactive()) {
storageRes = tmpStorageres;
_log.info("found File policy storage resource for {}", tmpStorageres.getNativeGuid() + ":" + tmpStorageres.getFilePolicyId());
break;
}
}
return storageRes;
}
Aggregations