use of com.emc.storageos.db.client.model.FileReplicaPolicyTarget in project coprhd-controller by CoprHD.
the class FileOrchestrationUtils method updatePolicyStorageResource.
/**
* Create/Update the File policy resource
*
* @param dbClient
* @param system
* @param filePolicy
* @param args
* @param sourcePath
* @return
*/
public static PolicyStorageResource updatePolicyStorageResource(DbClient dbClient, StorageSystem system, FilePolicy filePolicy, FileDeviceInputOutput args, String sourcePath, String name, String policyNativeId, StorageSystem targetSystem, NASServer targetNasServer, String targetPath) {
PolicyStorageResource policyStorageResource = new PolicyStorageResource();
policyStorageResource.setId(URIUtil.createId(PolicyStorageResource.class));
policyStorageResource.setFilePolicyId(filePolicy.getId());
policyStorageResource.setStorageSystem(system.getId());
policyStorageResource.setPolicyNativeId(policyNativeId);
policyStorageResource.setName(name);
policyStorageResource.setLabel(name);
policyStorageResource.setResourcePath(sourcePath);
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;
}
}
policyStorageResource.setNasServer(nasServer.getId());
setPolicyStorageAppliedAt(filePolicy, args, policyStorageResource);
policyStorageResource.setNativeGuid(NativeGUIDGenerator.generateNativeGuidForFilePolicyResource(system, nasServer.getNasName(), filePolicy.getFilePolicyType(), sourcePath, NativeGUIDGenerator.FILE_STORAGE_RESOURCE));
if (filePolicy.getFilePolicyType().equalsIgnoreCase(FilePolicy.FilePolicyType.file_replication.name())) {
// Update the target resource details!!!
FileReplicaPolicyTargetMap fileReplicaPolicyTargetMap = new FileReplicaPolicyTargetMap();
FileReplicaPolicyTarget target = new FileReplicaPolicyTarget();
if (targetNasServer != null) {
target.setNasServer(targetNasServer.getId().toString());
} else {
PhysicalNAS pNAS = FileOrchestrationUtils.getSystemPhysicalNAS(dbClient, targetSystem);
if (pNAS != null) {
target.setNasServer(pNAS.getId().toString());
}
}
target.setAppliedAt(filePolicy.getApplyAt());
target.setStorageSystem(targetSystem.getId().toString());
target.setPath(targetPath);
String key = target.getFileTargetReplicaKey();
fileReplicaPolicyTargetMap.put(key, target);
policyStorageResource.setFileReplicaPolicyTargetMap(fileReplicaPolicyTargetMap);
}
dbClient.createObject(policyStorageResource);
filePolicy.addPolicyStorageResources(policyStorageResource.getId());
dbClient.updateObject(filePolicy);
_log.info("PolicyStorageResource object created successfully for {} ", system.getLabel() + policyStorageResource.getAppliedAt());
return policyStorageResource;
}
use of com.emc.storageos.db.client.model.FileReplicaPolicyTarget in project coprhd-controller by CoprHD.
the class VirtualPoolFileReplicationPolicyMigration method updatePolicyStorageResouce.
private void updatePolicyStorageResouce(StorageSystem system, FilePolicy filePolicy, FileShare fs) {
logger.info("Creating policy storage resource for storage {} fs {} and policy {} ", system.getLabel(), fs.getLabel(), filePolicy.getFilePolicyName());
PolicyStorageResource policyStorageResource = new PolicyStorageResource();
policyStorageResource.setId(URIUtil.createId(PolicyStorageResource.class));
policyStorageResource.setFilePolicyId(filePolicy.getId());
policyStorageResource.setStorageSystem(system.getId());
policyStorageResource.setPolicyNativeId(fs.getName());
policyStorageResource.setAppliedAt(fs.getId());
policyStorageResource.setResourcePath(fs.getNativeId());
NASServer nasServer = null;
if (fs.getVirtualNAS() != null) {
nasServer = dbClient.queryObject(VirtualNAS.class, fs.getVirtualNAS());
} else {
// Get the physical NAS for the storage system!!
PhysicalNAS pNAS = getSystemPhysicalNAS(system);
if (pNAS != null) {
nasServer = pNAS;
}
}
if (nasServer != null) {
logger.info("Found NAS server {} ", nasServer.getNasName());
policyStorageResource.setNasServer(nasServer.getId());
policyStorageResource.setNativeGuid(generateNativeGuidForFilePolicyResource(system, nasServer.getNasName(), filePolicy.getFilePolicyType(), fs.getNativeId()));
}
if (fs.getMirrorfsTargets() != null && !fs.getMirrorfsTargets().isEmpty()) {
String[] targetFSs = fs.getMirrorfsTargets().toArray(new String[fs.getMirrorfsTargets().size()]);
// Today we support single target!!
FileShare fsTarget = dbClient.queryObject(FileShare.class, URI.create(targetFSs[0]));
// In older release, policy name was set to target file system lable!!
policyStorageResource.setPolicyNativeId(fsTarget.getLabel());
// Update the target resource details!!!
FileReplicaPolicyTargetMap fileReplicaPolicyTargetMap = new FileReplicaPolicyTargetMap();
FileReplicaPolicyTarget target = new FileReplicaPolicyTarget();
target.setAppliedAt(filePolicy.getApplyAt());
target.setStorageSystem(fsTarget.getStorageDevice().toString());
target.setPath(fsTarget.getNativeId());
NASServer targetNasServer = null;
if (fsTarget.getVirtualNAS() != null) {
targetNasServer = dbClient.queryObject(VirtualNAS.class, fsTarget.getVirtualNAS());
} else {
StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, fsTarget.getStorageDevice());
// Get the physical NAS for the storage system!!
PhysicalNAS pNAS = getSystemPhysicalNAS(targetSystem);
if (pNAS != null) {
targetNasServer = pNAS;
}
}
if (targetNasServer != null) {
target.setNasServer(targetNasServer.getId().toString());
}
String key = target.getFileTargetReplicaKey();
fileReplicaPolicyTargetMap.put(key, target);
policyStorageResource.setFileReplicaPolicyTargetMap(fileReplicaPolicyTargetMap);
}
dbClient.createObject(policyStorageResource);
filePolicy.addPolicyStorageResources(policyStorageResource.getId());
filePolicy.addAssignedResources(fs.getId());
logger.info("PolicyStorageResource object created successfully for {} ", system.getLabel() + policyStorageResource.getAppliedAt());
}
use of com.emc.storageos.db.client.model.FileReplicaPolicyTarget 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