Search in sources :

Example 1 with FileReplicaPolicyTargetMap

use of com.emc.storageos.db.client.model.FileReplicaPolicyTargetMap 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());
}
Also used : NASServer(com.emc.storageos.db.client.model.NASServer) VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) FileReplicaPolicyTargetMap(com.emc.storageos.db.client.model.FileReplicaPolicyTargetMap) FileReplicaPolicyTarget(com.emc.storageos.db.client.model.FileReplicaPolicyTarget) PolicyStorageResource(com.emc.storageos.db.client.model.PolicyStorageResource) PhysicalNAS(com.emc.storageos.db.client.model.PhysicalNAS) FileShare(com.emc.storageos.db.client.model.FileShare) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 2 with FileReplicaPolicyTargetMap

use of com.emc.storageos.db.client.model.FileReplicaPolicyTargetMap 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;
}
Also used : NASServer(com.emc.storageos.db.client.model.NASServer) FileReplicaPolicyTargetMap(com.emc.storageos.db.client.model.FileReplicaPolicyTargetMap) FileReplicaPolicyTarget(com.emc.storageos.db.client.model.FileReplicaPolicyTarget) PolicyStorageResource(com.emc.storageos.db.client.model.PolicyStorageResource) PhysicalNAS(com.emc.storageos.db.client.model.PhysicalNAS)

Example 3 with FileReplicaPolicyTargetMap

use of com.emc.storageos.db.client.model.FileReplicaPolicyTargetMap 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;
}
Also used : FileReplicaPolicyTargetMap(com.emc.storageos.db.client.model.FileReplicaPolicyTargetMap) FileReplicaPolicyTarget(com.emc.storageos.db.client.model.FileReplicaPolicyTarget) PolicyStorageResource(com.emc.storageos.db.client.model.PolicyStorageResource)

Aggregations

FileReplicaPolicyTarget (com.emc.storageos.db.client.model.FileReplicaPolicyTarget)3 FileReplicaPolicyTargetMap (com.emc.storageos.db.client.model.FileReplicaPolicyTargetMap)3 PolicyStorageResource (com.emc.storageos.db.client.model.PolicyStorageResource)3 NASServer (com.emc.storageos.db.client.model.NASServer)2 PhysicalNAS (com.emc.storageos.db.client.model.PhysicalNAS)2 FileShare (com.emc.storageos.db.client.model.FileShare)1 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)1 VirtualNAS (com.emc.storageos.db.client.model.VirtualNAS)1