Search in sources :

Example 16 with PhysicalNAS

use of com.emc.storageos.db.client.model.PhysicalNAS in project coprhd-controller by CoprHD.

the class VNXFileCommunicationInterface method findPhysicalNasByNativeId.

/**
 * Find the Physical NAS by Native ID for the specified VNX File storage array
 *
 * @param system storage system information including credentials.
 * @param Native id of the specified Physical NAS
 * @return Physical NAS Server
 */
private PhysicalNAS findPhysicalNasByNativeId(StorageSystem system, String nativeId) {
    URIQueryResultList results = new URIQueryResultList();
    PhysicalNAS physicalNas = null;
    // Set storage port details to vNas
    String nasNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, nativeId, NativeGUIDGenerator.PHYSICAL_NAS);
    _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getPhysicalNasByNativeGuidConstraint(nasNativeGuid), results);
    Iterator<URI> iter = results.iterator();
    while (iter.hasNext()) {
        PhysicalNAS tmpNas = _dbClient.queryObject(PhysicalNAS.class, iter.next());
        if (tmpNas != null && !tmpNas.getInactive()) {
            physicalNas = tmpNas;
            _logger.info("found physical NAS {}", physicalNas.getNativeGuid() + ":" + physicalNas.getNasName());
            break;
        }
    }
    return physicalNas;
}
Also used : PhysicalNAS(com.emc.storageos.db.client.model.PhysicalNAS) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 17 with PhysicalNAS

use of com.emc.storageos.db.client.model.PhysicalNAS in project coprhd-controller by CoprHD.

the class VNXFileSystemStaticLoadProcessor method findPhysicalNasByNativeId.

/**
 * find DM or NAS from db using native id
 *
 * @param system
 * @param dbClient
 * @param nativeId
 * @return
 */
private PhysicalNAS findPhysicalNasByNativeId(final StorageSystem system, DbClient dbClient, String nativeId) {
    URIQueryResultList results = new URIQueryResultList();
    PhysicalNAS physicalNas = null;
    // Set storage port details to vNas
    String nasNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, nativeId, NativeGUIDGenerator.PHYSICAL_NAS);
    dbClient.queryByConstraint(AlternateIdConstraint.Factory.getPhysicalNasByNativeGuidConstraint(nasNativeGuid), results);
    Iterator<URI> iter = results.iterator();
    while (iter.hasNext()) {
        PhysicalNAS tmpNas = dbClient.queryObject(PhysicalNAS.class, iter.next());
        if (tmpNas != null && !tmpNas.getInactive()) {
            physicalNas = tmpNas;
            _logger.info("found physical NAS {}", physicalNas.getNativeGuid() + ":" + physicalNas.getNasName());
            break;
        }
    }
    return physicalNas;
}
Also used : PhysicalNAS(com.emc.storageos.db.client.model.PhysicalNAS) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 18 with PhysicalNAS

use of com.emc.storageos.db.client.model.PhysicalNAS in project coprhd-controller by CoprHD.

the class FileOrchestrationUtils method getTargetHostPortForReplication.

public static String getTargetHostPortForReplication(DbClient dbClient, URI targetStorageSystemURI, URI targetVarrayURI, URI targetVNasURI) {
    StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, targetStorageSystemURI);
    String targetHost = targetSystem.getIpAddress();
    StringSet targetNasVarraySet = null;
    StringSet targetStoragePortSet = null;
    if (targetVNasURI != null) {
        VirtualNAS targetVNas = dbClient.queryObject(VirtualNAS.class, targetVNasURI);
        targetStoragePortSet = targetVNas.getStoragePorts();
        targetNasVarraySet = targetVNas.getTaggedVirtualArrays();
    } else {
        PhysicalNAS pNAS = FileOrchestrationUtils.getSystemPhysicalNAS(dbClient, targetSystem);
        targetStoragePortSet = pNAS.getStoragePorts();
        targetNasVarraySet = pNAS.getTaggedVirtualArrays();
    }
    List<String> drPorts = new ArrayList<String>();
    for (String nasPort : targetStoragePortSet) {
        StoragePort port = dbClient.queryObject(StoragePort.class, URI.create(nasPort));
        if (port != null && !port.getInactive()) {
            StringSet varraySet = port.getTaggedVirtualArrays();
            if (varraySet == null || !varraySet.contains(targetVarrayURI.toString())) {
                continue;
            }
            if (targetNasVarraySet != null) {
                if (!targetNasVarraySet.contains(targetVarrayURI.toString())) {
                    continue;
                }
            }
            targetHost = port.getPortNetworkId();
            // iterate until dr port found!!
            if (port.getTag() != null) {
                ScopedLabelSet portTagSet = port.getTag();
                if (portTagSet != null && !portTagSet.isEmpty()) {
                    for (ScopedLabel tag : portTagSet) {
                        if ("dr_port".equals(tag.getLabel())) {
                            _log.info("DR port {} found from storage system {} for replication", port.getPortNetworkId(), targetSystem.getLabel());
                            drPorts.add(port.getPortNetworkId());
                        }
                    }
                }
            }
        }
    }
    if (!drPorts.isEmpty()) {
        Collections.shuffle(drPorts);
        return drPorts.get(0);
    }
    return targetHost;
}
Also used : VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) ScopedLabel(com.emc.storageos.db.client.model.ScopedLabel) StringSet(com.emc.storageos.db.client.model.StringSet) ArrayList(java.util.ArrayList) StoragePort(com.emc.storageos.db.client.model.StoragePort) PhysicalNAS(com.emc.storageos.db.client.model.PhysicalNAS) ScopedLabelSet(com.emc.storageos.db.client.model.ScopedLabelSet) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 19 with PhysicalNAS

use of com.emc.storageos.db.client.model.PhysicalNAS 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 20 with PhysicalNAS

use of com.emc.storageos.db.client.model.PhysicalNAS 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;
}
Also used : NASServer(com.emc.storageos.db.client.model.NASServer) PolicyStorageResource(com.emc.storageos.db.client.model.PolicyStorageResource) PhysicalNAS(com.emc.storageos.db.client.model.PhysicalNAS) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Aggregations

PhysicalNAS (com.emc.storageos.db.client.model.PhysicalNAS)24 URI (java.net.URI)14 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)9 VirtualNAS (com.emc.storageos.db.client.model.VirtualNAS)9 ArrayList (java.util.ArrayList)6 NASServer (com.emc.storageos.db.client.model.NASServer)5 StringMap (com.emc.storageos.db.client.model.StringMap)5 PolicyStorageResource (com.emc.storageos.db.client.model.PolicyStorageResource)4 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)4 StringSet (com.emc.storageos.db.client.model.StringSet)4 List (java.util.List)4 NasCifsServer (com.emc.storageos.db.client.model.NasCifsServer)3 StorageHADomain (com.emc.storageos.db.client.model.StorageHADomain)3 NamespaceList (com.emc.storageos.plugins.common.domainmodel.NamespaceList)3 HashMap (java.util.HashMap)3 LinkedList (java.util.LinkedList)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 CifsServerMap (com.emc.storageos.db.client.model.CifsServerMap)2 FileReplicaPolicyTarget (com.emc.storageos.db.client.model.FileReplicaPolicyTarget)2 FileReplicaPolicyTargetMap (com.emc.storageos.db.client.model.FileReplicaPolicyTargetMap)2