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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations