use of com.emc.storageos.db.client.model.NASServer in project coprhd-controller by CoprHD.
the class UnManagedFilesystemService method doesNASServerSupportVPoolProtocols.
/**
* Checks the NAS server protocols with vpool protocols
*
* @param nasUri the NAS server ID
* @param vpoolProtocols the protocols configured in vpool
* @return true if NAS server protocols matches with vpool protocols; false otherwise
*/
private boolean doesNASServerSupportVPoolProtocols(String nasUri, StringSet vpoolProtocols) {
NASServer nasServer = null;
boolean supports = false;
boolean isVNAS = false;
if (StringUtils.equals("VirtualNAS", URIUtil.getTypeName(nasUri))) {
nasServer = _dbClient.queryObject(VirtualNAS.class, URI.create(nasUri));
isVNAS = true;
} else {
nasServer = _dbClient.queryObject(PhysicalNAS.class, URI.create(nasUri));
}
if (nasServer != null) {
StringSet nasProtocols = nasServer.getProtocols();
if (isVNAS) {
if (VirtualNasState.LOADED.name().equals(nasServer.getNasState())) {
_logger.info("NAS server is: {}. Supported protocols: {}. Vpool protocols: {}", nasServer.getNasName(), nasProtocols, vpoolProtocols);
supports = nasProtocols.containsAll(vpoolProtocols);
} else {
_logger.warn("NAS server: {} not in LOADED state. So this vNAS server is not supported.", nasServer.getNasName());
supports = false;
}
} else {
// Perform check on Physical NAS
supports = nasProtocols.containsAll(vpoolProtocols);
}
}
return supports;
}
use of com.emc.storageos.db.client.model.NASServer in project coprhd-controller by CoprHD.
the class FileSnapshotPolicyMigration method updatePolicyStorageResouce.
private void updatePolicyStorageResouce(StorageSystem system, FilePolicy fileSnapshotPolicy, FileShare fs) {
logger.info("Creating policy storage resource for storage {} fs {} and policy {} ", system.getLabel(), fs.getLabel(), fileSnapshotPolicy.getFilePolicyName());
PolicyStorageResource policyStorageResource = new PolicyStorageResource();
policyStorageResource.setId(URIUtil.createId(PolicyStorageResource.class));
policyStorageResource.setFilePolicyId(fileSnapshotPolicy.getId());
policyStorageResource.setStorageSystem(system.getId());
policyStorageResource.setPolicyNativeId(fileSnapshotPolicy.getFilePolicyName() + "_" + 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(), fileSnapshotPolicy.getFilePolicyType(), fs.getNativeId()));
}
dbClient.createObject(policyStorageResource);
fileSnapshotPolicy.addPolicyStorageResources(policyStorageResource.getId());
fileSnapshotPolicy.addAssignedResources(fs.getId());
logger.info("PolicyStorageResource object created successfully for {} ", system.getLabel() + policyStorageResource.getAppliedAt());
}
use of com.emc.storageos.db.client.model.NASServer 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.NASServer in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method doApplyFileReplicationPolicy.
private BiosCommandResult doApplyFileReplicationPolicy(FilePolicy filePolicy, FileDeviceInputOutput args, FileShare fs, StorageSystem storageObj) {
IsilonApi isi = getIsilonDevice(storageObj);
FileShare targetFS = null;
String sourcePath = generatePathForPolicy(filePolicy, fs, args);
String scheduleValue = getIsilonPolicySchedule(filePolicy);
String targetPath = null;
String targetHost = null;
StorageSystem targetSystem = null;
NASServer targetNasServer = null;
if (fs.getPersonality() != null && PersonalityTypes.SOURCE.name().equalsIgnoreCase(fs.getPersonality())) {
String targetFs = fs.getMirrorfsTargets().iterator().next();
targetFS = _dbClient.queryObject(FileShare.class, URI.create(targetFs));
targetPath = generatePathForPolicy(filePolicy, targetFS, args);
// Add the suffix only for local replication policy at higher level
if (filePolicy.getFileReplicationType().equalsIgnoreCase(FileReplicationType.LOCAL.name()) && !FilePolicyApplyLevel.file_system.name().equalsIgnoreCase(filePolicy.getApplyAt())) {
targetPath = targetPath + "_localTarget";
}
// Get the target smart connect zone!!
targetHost = FileOrchestrationUtils.getTargetHostPortForReplication(_dbClient, targetFS);
targetSystem = _dbClient.queryObject(StorageSystem.class, targetFS.getStorageDevice());
if (targetFS.getVirtualNAS() != null) {
targetNasServer = _dbClient.queryObject(VirtualNAS.class, targetFS.getVirtualNAS());
}
}
IsilonApi isiApiOfTarget = getIsilonDevice(targetSystem);
String targetClusterName = isiApiOfTarget.getClusterConfig().getName();
String sourceClustername = isi.getClusterConfig().getName();
String policyName = FileOrchestrationUtils.generateNameForSyncIQPolicy(sourceClustername, targetClusterName, filePolicy, fs, args, sourcePath);
IsilonSyncPolicy isiSynIQPolicy = getEquivalentIsilonSyncIQPolicy(isi, sourcePath);
PolicyStorageResource policyStorageResource = null;
if (isiSynIQPolicy != null) {
boolean validPolicy = validateIsilonReplicationPolicy(isiSynIQPolicy, filePolicy, targetPath, targetSystem, storageObj);
if (validPolicy) {
_log.info("File Policy {} is already applied and running.", filePolicy.toString());
// Verify the policy was mapped to FileStorageResource
if (null == FileOrchestrationUtils.findPolicyStorageResourceByNativeId(_dbClient, storageObj, filePolicy, args, sourcePath)) {
_log.info("Isilon policy found for {}, creating policy storage resouce to further management", filePolicy.getFilePolicyName());
// update the policy object in DB
policyStorageResource = FileOrchestrationUtils.updatePolicyStorageResource(_dbClient, storageObj, filePolicy, args, sourcePath, isiSynIQPolicy.getName(), isiSynIQPolicy.getId(), targetSystem, targetNasServer, targetPath);
// for existing policy's on device
// label - label is generated from ViPR
policyStorageResource.setLabel(policyName);
_dbClient.updateObject(policyStorageResource);
}
return BiosCommandResult.createSuccessfulResult();
} else {
throw DeviceControllerException.exceptions.assignFilePolicyFailed(filePolicy.getFilePolicyName(), filePolicy.getApplyAt(), "File policy and Isilon syncIQ policy differs for path: " + sourcePath);
}
} else {
IsilonSyncPolicy policy = new IsilonSyncPolicy(policyName, sourcePath, targetPath, targetHost, IsilonSyncPolicy.Action.sync);
IsilonSyncPolicy8Above policycopy = new IsilonSyncPolicy8Above();
if (scheduleValue != null && !scheduleValue.isEmpty()) {
policy.setSchedule(scheduleValue);
}
if (filePolicy.getFilePolicyDescription() != null) {
policy.setDescription(filePolicy.getFilePolicyDescription());
}
if (filePolicy.getNumWorkerThreads() != null && filePolicy.getNumWorkerThreads() > 0) {
policy.setWorkersPerNode(filePolicy.getNumWorkerThreads().intValue());
}
policy.setEnabled(true);
String policyId = null;
if (VersionChecker.verifyVersionDetails(ONEFS_V8, storageObj.getFirmwareVersion()) >= 0) {
if (filePolicy.getPriority() != null) {
policycopy = policycopy.copy(policy);
policycopy.setPriority(FilePolicyPriority.valueOf(filePolicy.getPriority()).ordinal());
}
policyId = isi.createReplicationPolicy8above(policycopy);
} else {
policyId = isi.createReplicationPolicy(policy);
}
if (policyId != null) {
_log.info("Isilon File Policy {} created successfully with id {}", policyName, policyId);
// update the policy object in DB
FileOrchestrationUtils.updatePolicyStorageResource(_dbClient, storageObj, filePolicy, args, sourcePath, policyName, policyId, targetSystem, targetNasServer, targetPath);
return BiosCommandResult.createSuccessfulResult();
}
}
return BiosCommandResult.createSuccessfulResult();
}
use of com.emc.storageos.db.client.model.NASServer in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method getNasServerForFileSystem.
/**
* To get NasServer form for the file system
*
* @param args
* @param storage
* @return NASServer if found or null value
*/
private NASServer getNasServerForFileSystem(FileDeviceInputOutput args, StorageSystem storage) {
NASServer nas = null;
// Check VirtualNAS is associated with file system or not.
if (args.getvNAS() != null) {
nas = args.getvNAS();
} else {
// mean it file is created on system access zone.
// We do not have direct reference of physical nas servers from StorageSystem or fsobj
URIQueryResultList pNasURIs = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDevicePhysicalNASConstraint(storage.getId()), pNasURIs);
if (pNasURIs.iterator().hasNext()) {
// storage system should have only one PhysicalNAS instance.
URI pNasURI = pNasURIs.iterator().next();
nas = _dbClient.queryObject(PhysicalNAS.class, pNasURI);
}
}
return nas;
}
Aggregations