use of com.emc.storageos.db.client.model.PolicyStorageResource in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method getEquivalentPolicyStorageResource.
public static PolicyStorageResource getEquivalentPolicyStorageResource(FileShare fs, DbClient dbClient) {
FilePolicy fp = getReplicationPolicyAppliedOnFS(fs, dbClient);
if (fp != null) {
StringSet policyStrResources = fp.getPolicyStorageResources();
List<URI> policyStrURIs = new ArrayList<>();
for (String policyStrResource : policyStrResources) {
policyStrURIs.add(URI.create(policyStrResource));
}
Iterator<PolicyStorageResource> iterator = dbClient.queryIterativeObjects(PolicyStorageResource.class, policyStrURIs, true);
while (iterator.hasNext()) {
PolicyStorageResource policyRes = iterator.next();
if (policyRes.getAppliedAt().equals(fs.getId()) && policyRes.getStorageSystem().equals(fs.getStorageDevice())) {
_log.info("Found replication policy:{} corresponding storage resource: {} applied to the file system: {}.", fp.getLabel(), policyRes.toString(), fs.getId());
return policyRes;
}
}
}
return null;
}
use of com.emc.storageos.db.client.model.PolicyStorageResource in project coprhd-controller by CoprHD.
the class FileSystemReplicationUtils method getEquivalentPolicyStorageResource.
public static PolicyStorageResource getEquivalentPolicyStorageResource(FileShare fs, DbClient dbClient) {
FilePolicy fp = getReplicationPolicyAppliedOnFS(fs, dbClient);
if (fp != null) {
StringSet policyStrResources = fp.getPolicyStorageResources();
List<URI> policyStrURIs = new ArrayList<>();
for (String policyStrResource : policyStrResources) {
policyStrURIs.add(URI.create(policyStrResource));
}
Iterator<PolicyStorageResource> iterator = dbClient.queryIterativeObjects(PolicyStorageResource.class, policyStrURIs, true);
while (iterator.hasNext()) {
PolicyStorageResource policyRes = iterator.next();
if (policyRes.getAppliedAt().equals(fs.getId()) && policyRes.getStorageSystem().equals(fs.getStorageDevice())) {
return policyRes;
}
}
}
return null;
}
use of com.emc.storageos.db.client.model.PolicyStorageResource in project coprhd-controller by CoprHD.
the class FileMirrorScheduler method getRemoteMirrorRecommendationsForResources.
/* local mirror related functions */
/**
* get list Recommendation for Local Mirror
*
* @param vArray
* @param project
* @param vPool
* @param capabilities
* @return
*/
public List getRemoteMirrorRecommendationsForResources(VirtualArray vArray, Project project, VirtualPool vPool, VirtualPoolCapabilityValuesWrapper capabilities) {
List<FileRecommendation> targetFileRecommendations = null;
List<FileMirrorRecommendation> fileMirrorRecommendations = new ArrayList<FileMirrorRecommendation>();
// Get the source file system recommendations!!!
capabilities.put(VirtualPoolCapabilityValuesWrapper.PERSONALITY, VirtualPoolCapabilityValuesWrapper.FILE_REPLICATION_SOURCE);
// Verify the replication policy was applied!!
// Get the policy storage resources for applied policy
// Choose the right target for the source
List<PolicyStorageResource> storageSystemResources = null;
if (!capabilities.isVpoolProjectPolicyAssign()) {
storageSystemResources = FileOrchestrationUtils.getFilePolicyStorageResources(_dbClient, vPool, project, null);
if (storageSystemResources != null && !storageSystemResources.isEmpty()) {
_log.info("Found replication policy for vpool and project, so get all source recommedation to match target");
capabilities.put(VirtualPoolCapabilityValuesWrapper.GET_ALL_SOURCE_RECOMMENDATIONS, true);
}
}
List<FileRecommendation> sourceFileRecommendations = new ArrayList<FileRecommendation>();
// For vPool change get the recommendations from source file system!!!
if (capabilities.createMirrorExistingFileSystem()) {
sourceFileRecommendations = getFileRecommendationsForSourceFS(vArray, vPool, capabilities);
// Remove the source file system from capabilities list
// otherwise, try to find the remote pools from the same source system!!!
capabilities.removeCapabilityEntry(VirtualPoolCapabilityValuesWrapper.SOURCE_STORAGE_SYSTEM);
} else {
// Get the recommendation for source from vpool!!!
sourceFileRecommendations = _fileScheduler.getRecommendationsForResources(vArray, project, vPool, capabilities);
// otherwise, try to find the remote pools from the same source system!!!
if (capabilities.getFileProtectionSourceStorageDevice() != null) {
capabilities.removeCapabilityEntry(VirtualPoolCapabilityValuesWrapper.FILE_PROTECTION_SOURCE_STORAGE_SYSTEM);
}
}
if (capabilities.getAllSourceRecommnedations()) {
capabilities.removeCapabilityEntry(VirtualPoolCapabilityValuesWrapper.GET_ALL_SOURCE_RECOMMENDATIONS);
}
// Process the each recommendations for targets
for (FileRecommendation sourceFileRecommendation : sourceFileRecommendations) {
String srcSystemType = sourceFileRecommendation.getDeviceType();
Set<String> systemTypes = new StringSet();
systemTypes.add(srcSystemType);
// Remove the existing source nas server if any!!
if (capabilities.getSourceVirtualNasServer() != null) {
capabilities.removeCapabilityEntry(VirtualPoolCapabilityValuesWrapper.SOURCE_VIRTUAL_NAS_SERVER);
}
// add the new vnas server of current source recommendations!!!
if (sourceFileRecommendation.getvNAS() != null) {
capabilities.put(VirtualPoolCapabilityValuesWrapper.SOURCE_VIRTUAL_NAS_SERVER, sourceFileRecommendation.getvNAS());
}
// Findout is there any policy was created for the source recommendations!!!
if (capabilities.getTargetNasServer() != null) {
capabilities.removeCapabilityEntry(VirtualPoolCapabilityValuesWrapper.TARGET_NAS_SERVER);
}
if (capabilities.getTargetStorageSystem() != null) {
capabilities.removeCapabilityEntry(VirtualPoolCapabilityValuesWrapper.TARGET_STORAGE_SYSTEM);
}
if (storageSystemResources != null && !storageSystemResources.isEmpty()) {
findAndUpdateMatchedPolicyStorageResource(storageSystemResources, sourceFileRecommendation, capabilities);
}
for (String targetVArry : capabilities.getFileReplicationTargetVArrays()) {
// Process for target !!!
FileMirrorRecommendation fileMirrorRecommendation = new FileMirrorRecommendation(sourceFileRecommendation);
VirtualPool targetVPool = _dbClient.queryObject(VirtualPool.class, capabilities.getFileReplicationTargetVPool());
VirtualArray targetVArray = _dbClient.queryObject(VirtualArray.class, URI.create(targetVArry));
// Filter the target storage pools!!!
Map<String, Object> attributeMap = new HashMap<String, Object>();
attributeMap.put(Attributes.system_type.toString(), systemTypes);
attributeMap.put(Attributes.remote_copy_mode.toString(), capabilities.getFileRpCopyMode());
attributeMap.put(Attributes.source_storage_system.name(), sourceFileRecommendation.getSourceStorageSystem().toString());
capabilities.put(VirtualPoolCapabilityValuesWrapper.PERSONALITY, VirtualPoolCapabilityValuesWrapper.FILE_REPLICATION_TARGET);
// Get target recommendations!!!
targetFileRecommendations = _fileScheduler.placeFileShare(targetVArray, targetVPool, capabilities, project, attributeMap);
if (targetFileRecommendations == null || targetFileRecommendations.isEmpty()) {
_log.info("No target recommendation found, so ignore the source recommedation as well.");
continue;
}
String copyMode = capabilities.getFileRpCopyMode();
if (targetFileRecommendations != null && !targetFileRecommendations.isEmpty()) {
// prepare the target recommendation
FileRecommendation targetRecommendation = targetFileRecommendations.get(0);
prepareTargetFileRecommendation(copyMode, targetVArray, targetRecommendation, fileMirrorRecommendation);
fileMirrorRecommendations.add(fileMirrorRecommendation);
}
}
// Got sufficient number of recommendations!!
if (!capabilities.isVpoolProjectPolicyAssign() && fileMirrorRecommendations.size() >= capabilities.getResourceCount()) {
break;
}
}
return fileMirrorRecommendations;
}
use of com.emc.storageos.db.client.model.PolicyStorageResource in project coprhd-controller by CoprHD.
the class FileMirrorScheduler method findAndUpdateMatchedPolicyStorageResource.
private void findAndUpdateMatchedPolicyStorageResource(List<PolicyStorageResource> storageSystemResources, FileRecommendation sourceFileRecommendation, VirtualPoolCapabilityValuesWrapper capabilities) {
PolicyStorageResource matchedPolicyResource = findMatchedPolicyStorageResource(storageSystemResources, sourceFileRecommendation);
if (matchedPolicyResource != null) {
_log.info("Found the valid existing policy storage resource for system {} nas server {}", matchedPolicyResource.getStorageSystem(), matchedPolicyResource.getNasServer());
FileReplicaPolicyTargetMap targetMap = matchedPolicyResource.getFileReplicaPolicyTargetMap();
if (targetMap != null && !targetMap.isEmpty()) {
for (FileReplicaPolicyTarget target : targetMap.values()) {
if (target.getNasServer() != null && target.getStorageSystem() != null) {
capabilities.put(VirtualPoolCapabilityValuesWrapper.TARGET_NAS_SERVER, URI.create(target.getNasServer()));
capabilities.put(VirtualPoolCapabilityValuesWrapper.TARGET_STORAGE_SYSTEM, URI.create(target.getStorageSystem()));
break;
}
}
}
}
return;
}
Aggregations