use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.
the class VPlexUtil method getSharedExportMaskInDb.
/**
* Returns the shared export mask in the export group i:e single ExportMask in database for multiple hosts
* corresponding to the single storage view on VPLEX with multiple hosts.
*
* At-least there should be two host in the exportMask to be called as sharedExportMask. Also there shouldn't be more than one
* exportMask for the exportGroup for a VPLEX cluster.
*
* Note : This is applicable from Darth release onwards.
*
* @param exportGroup ExportGroup object
* @param vplexURI URI of the VPLEX system
* @param dbClient database client instance
* @param varrayUri Varray we want the Export Mask in
* @param vplexCluster Vplex Cluster we want ExportMask for
* @param hostInitiatorMap Map of host to initiators that are not yet added to the storage view on VPLEX
* @return shared ExportMask for a exportGroup
* @throws Exception
*/
public static ExportMask getSharedExportMaskInDb(ExportGroup exportGroup, URI vplexURI, DbClient dbClient, URI varrayUri, String vplexCluster, Map<URI, List<Initiator>> hostInitiatorMap) throws Exception {
ExportMask sharedExportMask = null;
if (exportGroup.getExportMasks() == null) {
return null;
}
StringSet exportGrouphosts = exportGroup.getHosts();
// Get all the exportMasks for the VPLEX from the export group
List<ExportMask> exportMasks = ExportMaskUtils.getExportMasks(dbClient, exportGroup, vplexURI);
// exportMasks list could have mask for both the VPLEX cluster for the same initiators for the cross-connect case
// for the cross-connect case hence get the ExportMask for the specific VPLEX cluster.
List<ExportMask> exportMasksForVplexCluster = getExportMasksForVplexCluster(vplexURI, dbClient, varrayUri, vplexCluster, exportMasks);
// and we found only one exportMask in database for the VPLEX cluster
if (exportGrouphosts != null && exportGrouphosts.size() > 1 && exportMasksForVplexCluster.size() == 1) {
ExportMask exportMask = exportMasksForVplexCluster.get(0);
ArrayList<String> exportMaskInitiators = new ArrayList<>(exportMask.getInitiators());
Map<URI, List<Initiator>> exportMaskHostInitiatorsMap = makeHostInitiatorsMap(URIUtil.toURIList(exportMaskInitiators), dbClient);
// Remove the host which is not yet added by CorpHD
if (hostInitiatorMap != null) {
for (Entry<URI, List<Initiator>> entry : hostInitiatorMap.entrySet()) {
exportMaskHostInitiatorsMap.remove(entry.getKey());
}
}
// If we found more than one host in the exportMask then its a sharedExportMask
if (exportMaskHostInitiatorsMap.size() > 1) {
sharedExportMask = exportMask;
}
}
return sharedExportMask;
}
use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.
the class FileOrchestrationDeviceController method doFailBackMirrorSessionWF.
/**
* Child Workflow for failback
*
* @param systemURI
* @param fsURI source FS URI
* @param taskId
*/
public void doFailBackMirrorSessionWF(URI systemURI, URI fsURI, String taskId) {
TaskCompleter taskCompleter = null;
String stepDescription;
String stepId;
Object[] args;
try {
FileShare sourceFS = s_dbClient.queryObject(FileShare.class, fsURI);
StorageSystem primarysystem = s_dbClient.queryObject(StorageSystem.class, systemURI);
StringSet targets = sourceFS.getMirrorfsTargets();
List<URI> targetFSURI = new ArrayList<>();
for (String target : targets) {
targetFSURI.add(URI.create(target));
}
FileShare targetFS = s_dbClient.queryObject(FileShare.class, targetFSURI.get(0));
StorageSystem secondarySystem = s_dbClient.queryObject(StorageSystem.class, targetFS.getStorageDevice());
taskCompleter = new MirrorFileFailbackTaskCompleter(FileShare.class, sourceFS.getId(), taskId);
Workflow workflow = _workflowService.getNewWorkflow(this, FAILBACK_FILE_SYSTEM_METHOD, false, taskId, taskCompleter);
s_logger.info("Generating steps for failback to source file share: {} from target file share: {}", fsURI, targetFS.getId());
/*
* Step 1. Creates a mirror replication policy for the secondary cluster i.e Resync-prep on primary cluster , this will disable
* primary cluster replication policy.
*/
stepDescription = String.format("source resync-prep : creating mirror policy on target system: %s", secondarySystem.getId());
stepId = workflow.createStepId();
args = new Object[] { primarysystem.getId(), sourceFS.getId(), "resync" };
String waitFor = _fileDeviceController.createMethod(workflow, null, FILE_REPLICATION_OPERATIONS_METHOD, stepId, stepDescription, primarysystem.getId(), args);
/*
* Step 2. Start the mirror replication policy manually, this will replicate new data (written during failover) from secondary
* cluster to primary cluster.
*/
stepDescription = String.format("start mirror policy: replicate target file share: %s, data to source file share:%s", targetFS.getId(), sourceFS.getId());
stepId = workflow.createStepId();
args = new Object[] { secondarySystem.getId(), targetFS.getId(), "start" };
waitFor = _fileDeviceController.createMethod(workflow, waitFor, FILE_REPLICATION_OPERATIONS_METHOD, stepId, stepDescription, secondarySystem.getId(), args);
/*
* Step 3. Allow Write on Primary Cluster local target after replication from step 2
* i.e Fail over to Primary Cluster
*/
stepDescription = String.format("failover on source file system : allow write on source file share: %s", sourceFS.getId());
stepId = workflow.createStepId();
List<URI> combined = Arrays.asList(sourceFS.getId(), targetFS.getId());
MirrorFileFailoverTaskCompleter failoverCompleter = new MirrorFileFailoverTaskCompleter(FileShare.class, combined, stepId);
args = new Object[] { primarysystem.getId(), sourceFS.getId(), failoverCompleter };
waitFor = _fileDeviceController.createMethod(workflow, waitFor, FAILOVER_FILE_SYSTEM_METHOD, stepId, stepDescription, primarysystem.getId(), args);
/*
* Step 4. Resync-Prep on secondary cluster , same as step 1 but will be executed on secondary cluster instead of primary
* cluster.
*/
stepDescription = String.format(" target resync-prep : disabling mirror policy on target system: %s", secondarySystem.getId());
stepId = workflow.createStepId();
args = new Object[] { secondarySystem.getId(), targetFS.getId(), "resync" };
_fileDeviceController.createMethod(workflow, waitFor, FILE_REPLICATION_OPERATIONS_METHOD, stepId, stepDescription, secondarySystem.getId(), args);
String successMsg = String.format("Failback of %s to %s successful", sourceFS.getId(), targetFS.getId());
workflow.executePlan(taskCompleter, successMsg);
} catch (Exception ex) {
s_logger.error("Could not replicate source filesystem CIFS shares: " + fsURI, ex);
String opName = ResourceOperationTypeEnum.FILE_PROTECTION_ACTION_FAILBACK.getName();
ServiceError serviceError = DeviceControllerException.errors.createFileSharesFailed(fsURI.toString(), opName, ex);
taskCompleter.error(s_dbClient, this._locker, serviceError);
}
}
use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.
the class FileOrchestrationDeviceController method getProjectLevelPolices.
/**
* Get the valid policy templates which are applied at project level
*
* @param vpool
* @param project
* @return list of project level policies on the given vpool
*/
private static List<FilePolicy> getProjectLevelPolices(VirtualPool vpool, Project project) {
StringSet projectPolicies = project.getFilePolicies();
List<FilePolicy> filePoliciesToCreate = new ArrayList<FilePolicy>();
if (!CollectionUtils.isEmpty(projectPolicies)) {
for (String projectFilePolicy : projectPolicies) {
FilePolicy filePolicy = s_dbClient.queryObject(FilePolicy.class, URIUtil.uri(projectFilePolicy));
if (filePolicy != null && !filePolicy.getInactive()) {
// The policy should be of for the given vpool as well.
if (NullColumnValueGetter.isNullURI(filePolicy.getFilePolicyVpool()) || !filePolicy.getFilePolicyVpool().toString().equals(vpool.getId().toString())) {
continue;
}
filePoliciesToCreate.add(filePolicy);
}
}
}
return filePoliciesToCreate;
}
use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.
the class FileOrchestrationUtils method getReplicationPolices.
/**
* Gives list of replication policies assigned at vpool/project/fs levels
*
* @param dbClient
* @param vpool
* @param project
* @param fs
* @return
*/
public static List<FilePolicy> getReplicationPolices(DbClient dbClient, VirtualPool vpool, Project project, FileShare fs) {
List<FilePolicy> replicationPolicies = new ArrayList<FilePolicy>();
StringSet filePolicies = new StringSet();
// vPool policies
if (vpool.getFilePolicies() != null && !vpool.getFilePolicies().isEmpty()) {
filePolicies.addAll(vpool.getFilePolicies());
}
// Project policies
if (project.getFilePolicies() != null && !project.getFilePolicies().isEmpty()) {
for (String strPolicy : project.getFilePolicies()) {
FilePolicy policy = dbClient.queryObject(FilePolicy.class, URI.create(strPolicy));
if (!NullColumnValueGetter.isNullURI(policy.getFilePolicyVpool()) && policy.getFilePolicyVpool().toString().equalsIgnoreCase(vpool.getId().toString())) {
filePolicies.add(policy.getId().toString());
}
}
}
// fs policies
if (fs != null && fs.getFilePolicies() != null && !fs.getFilePolicies().isEmpty()) {
for (String strPolicy : fs.getFilePolicies()) {
FilePolicy policy = dbClient.queryObject(FilePolicy.class, URI.create(strPolicy));
if (!NullColumnValueGetter.isNullURI(policy.getFilePolicyVpool()) && policy.getFilePolicyVpool().toString().equalsIgnoreCase(vpool.getId().toString())) {
filePolicies.add(policy.getId().toString());
}
}
}
if (filePolicies != null && !filePolicies.isEmpty()) {
for (String strPolicy : filePolicies) {
FilePolicy filePolicy = dbClient.queryObject(FilePolicy.class, URIUtil.uri(strPolicy));
if (FilePolicyType.file_replication.name().equalsIgnoreCase(filePolicy.getFilePolicyType())) {
replicationPolicies.add(filePolicy);
}
}
} else {
if (fs != null) {
_log.info("No replication policy assigned to vpool {} , project {} and fs {}", vpool.getLabel(), project.getLabel(), fs.getLabel());
} else {
_log.info("No replication policy assigned to vpool {} and project {} ", vpool.getLabel(), project.getLabel());
}
}
return replicationPolicies;
}
use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.
the class FileOrchestrationUtils method getAllProjectLevelPolices.
/**
* Return list of policies to be applied at project
*
* @param dbClient
* @param project
* @param storageSystem
* @return
*/
public static List<FilePolicy> getAllProjectLevelPolices(DbClient dbClient, Project project, VirtualPool vpool, URI storageSystem, URI nasServer) {
List<FilePolicy> filePoliciesToCreate = new ArrayList<FilePolicy>();
StringSet fileProjectPolicies = project.getFilePolicies();
if (fileProjectPolicies != null && !fileProjectPolicies.isEmpty()) {
for (String fileProjectPolicy : fileProjectPolicies) {
FilePolicy filePolicy = dbClient.queryObject(FilePolicy.class, URIUtil.uri(fileProjectPolicy));
if (NullColumnValueGetter.isNullURI(filePolicy.getFilePolicyVpool()) || !filePolicy.getFilePolicyVpool().toString().equals(vpool.getId().toString())) {
continue;
}
filePoliciesToCreate.add(filePolicy);
StringSet policyStrRes = filePolicy.getPolicyStorageResources();
if (policyStrRes != null && !policyStrRes.isEmpty()) {
for (String policyStrRe : policyStrRes) {
PolicyStorageResource strRes = dbClient.queryObject(PolicyStorageResource.class, URIUtil.uri(policyStrRe));
if (strRes != null && strRes.getAppliedAt().toString().equals(project.getId().toString()) && strRes.getStorageSystem().toString().equals(storageSystem.toString()) && strRes.getNasServer().toString().equalsIgnoreCase(nasServer.toString())) {
_log.info("File Policy {} is already exists for project {} , storage system {} and nas server {}", filePolicy.getFilePolicyName(), project.getLabel(), storageSystem.toString(), strRes);
filePoliciesToCreate.remove(filePolicy);
break;
}
}
}
}
}
return filePoliciesToCreate;
}
Aggregations