use of com.emc.storageos.volumecontroller.TaskCompleter in project coprhd-controller by CoprHD.
the class SRDFDeviceController method createListReplicas.
public boolean createListReplicas(URI systemURI, List<URI> sourceURIs, List<URI> targetURIs, URI vpoolChangeUri, boolean addWaitForCopyState, String opId) {
log.info("START Creating list of replicas");
TaskCompleter completer = null;
try {
WorkflowStepCompleter.stepExecuting(opId);
StorageSystem system = getStorageSystem(systemURI);
List<URI> combined = new ArrayList<>();
combined.addAll(sourceURIs);
combined.addAll(targetURIs);
completer = new SRDFMirrorCreateCompleter(combined, vpoolChangeUri, opId);
log.info("Sources: {}", Joiner.on(',').join(sourceURIs));
log.info("Targets: {}", Joiner.on(',').join(targetURIs));
log.info("OpId: {}", opId);
getRemoteMirrorDevice().doCreateListReplicas(system, sourceURIs, targetURIs, addWaitForCopyState, completer);
} catch (Exception e) {
return completeAsError(completer, DeviceControllerException.errors.jobFailed(e), opId);
}
return true;
}
use of com.emc.storageos.volumecontroller.TaskCompleter in project coprhd-controller by CoprHD.
the class FileDeviceController method performFileReplicationOperation.
@Override
public void performFileReplicationOperation(URI storage, URI sourceFSURI, String opType, String opId) throws ControllerException {
StorageSystem system = _dbClient.queryObject(StorageSystem.class, storage);
FileShare fileShare = _dbClient.queryObject(FileShare.class, sourceFSURI);
TaskCompleter completer = null;
BiosCommandResult result = new BiosCommandResult();
WorkflowStepCompleter.stepExecuting(opId);
_log.info("file replication operation {} started for file systerm {}", opType, fileShare.getName());
try {
if ("pause".equalsIgnoreCase(opType)) {
completer = new MirrorFilePauseTaskCompleter(FileShare.class, sourceFSURI, opId);
result = getDevice(system.getSystemType()).doPauseLink(system, fileShare);
} else if ("resume".equalsIgnoreCase(opType)) {
completer = new MirrorFileResumeTaskCompleter(FileShare.class, sourceFSURI, opId);
result = getDevice(system.getSystemType()).doResumeLink(system, fileShare, completer);
} else if ("start".equalsIgnoreCase(opType)) {
completer = new MirrorFileStartTaskCompleter(FileShare.class, sourceFSURI, opId);
result = getDevice(system.getSystemType()).doStartMirrorLink(system, fileShare, completer);
} else if ("refresh".equalsIgnoreCase(opType)) {
completer = new MirrorFileRefreshTaskCompleter(FileShare.class, sourceFSURI, opId);
result = getDevice(system.getSystemType()).doRefreshMirrorLink(system, fileShare);
} else if ("resync".equalsIgnoreCase(opType)) {
completer = new MirrorFileResyncTaskCompleter(FileShare.class, sourceFSURI, opId);
result = getDevice(system.getSystemType()).doResyncLink(system, fileShare, completer);
}
if (result.getCommandSuccess()) {
_log.info("file replication operation {} finished successfully for file systerm {}", opType, fileShare.getName());
completer.ready(_dbClient);
} else if (result.getCommandPending()) {
completer.statusPending(_dbClient, result.getMessage());
} else {
completer.error(_dbClient, result.getServiceCoded());
}
} catch (Exception e) {
_log.error("unable to perform mirror operation {} on file system {} ", opType, sourceFSURI, e);
updateTaskStatus(opId, fileShare, e);
ServiceError error = DeviceControllerException.errors.jobFailed(e);
WorkflowStepCompleter.stepFailed(opId, error);
}
}
use of com.emc.storageos.volumecontroller.TaskCompleter in project coprhd-controller by CoprHD.
the class VcenterControllerImpl method createOrUpdateVcenterCluster.
private void createOrUpdateVcenterCluster(boolean createCluster, AsyncTask task, URI clusterUri, URI[] addHostUris, URI[] removeHostUris, URI[] volumeUris) throws InternalException {
TaskCompleter completer = null;
try {
_log.info("createOrUpdateVcenterCluster " + createCluster + " " + task + " " + clusterUri + " " + addHostUris + " " + removeHostUris);
if (task == null) {
_log.error("AsyncTask is null");
throw new Exception("AsyncTask is null");
}
URI vcenterDataCenterId = task._id;
VcenterDataCenter vcenterDataCenter = _dbClient.queryObject(VcenterDataCenter.class, vcenterDataCenterId);
if (clusterUri == null) {
_log.error("Cluster URI is null");
throw new Exception("Cluster URI is null");
}
Cluster cluster = _dbClient.queryObject(Cluster.class, clusterUri);
Vcenter vcenter = _dbClient.queryObject(Vcenter.class, vcenterDataCenter.getVcenter());
_log.info("Request to create or update cluster " + vcenter.getIpAddress() + "/" + vcenterDataCenter.getLabel() + "/" + cluster.getLabel());
Collection<Host> addHosts = new ArrayList<Host>();
if (addHostUris == null || addHostUris.length == 0) {
_log.info("Add host URIs is null or empty - Cluster will be created without hosts");
} else {
for (URI hostUri : addHostUris) {
_log.info("createOrUpdateVcenterCluster " + clusterUri + " with add host " + hostUri);
}
addHosts = _dbClient.queryObject(Host.class, addHostUris);
}
Collection<Host> removeHosts = new ArrayList<Host>();
if (removeHostUris == null || removeHostUris.length == 0) {
_log.info("Remove host URIs is null or empty - Cluster will have no removed hosts");
} else {
for (URI hostUri : removeHostUris) {
_log.info("createOrUpdateVcenterCluster " + clusterUri + " with remove host " + hostUri);
}
removeHosts = _dbClient.queryObject(Host.class, removeHostUris);
}
Collection<Volume> volumes = new ArrayList<Volume>();
if (volumeUris == null || volumeUris.length == 0) {
_log.info("Volume URIs is null or empty - Cluster will be created without datastores");
} else {
for (URI volumeUri : volumeUris) {
_log.info("createOrUpdateVcenterCluster " + clusterUri + " with volume " + volumeUri);
}
volumes = _dbClient.queryObject(Volume.class, volumeUris);
}
completer = new VcenterClusterCompleter(vcenterDataCenterId, task._opId, OperationTypeEnum.CREATE_UPDATE_VCENTER_CLUSTER, "VCENTER_CONTROLLER");
Workflow workflow = _workflowService.getNewWorkflow(this, "CREATE_UPDATE_VCENTER_CLUSTER_WORKFLOW", true, task._opId);
String clusterStep = workflow.createStep("CREATE_UPDATE_VCENTER_CLUSTER_STEP", String.format("vCenter cluster operation in vCenter datacenter %s", vcenterDataCenterId), null, vcenterDataCenterId, vcenterDataCenterId.toString(), this.getClass(), new Workflow.Method("createUpdateVcenterClusterOperation", createCluster, vcenter.getId(), vcenterDataCenter.getId(), cluster.getId()), null, null);
String lastStep = clusterStep;
if (!removeHosts.isEmpty()) {
for (Host host : removeHosts) {
String hostStep = workflow.createStep("VCENTER_CLUSTER_REMOVE_HOST", String.format("vCenter cluster remove host operation %s", host.getId()), clusterStep, vcenterDataCenterId, vcenterDataCenterId.toString(), this.getClass(), new Workflow.Method("vcenterClusterRemoveHostOperation", vcenter.getId(), vcenterDataCenter.getId(), cluster.getId(), host.getId()), null, null);
// add host will wait on last of these
lastStep = hostStep;
}
}
if (!addHosts.isEmpty()) {
for (Host host : addHosts) {
String hostStep = workflow.createStep("VCENTER_CLUSTER_ADD_HOST", String.format("vCenter cluster add host operation %s", host.getId()), lastStep, vcenterDataCenterId, vcenterDataCenterId.toString(), this.getClass(), new Workflow.Method("vcenterClusterAddHostOperation", vcenter.getId(), vcenterDataCenter.getId(), cluster.getId(), host.getId()), null, null);
}
}
workflow.executePlan(completer, "Success");
} catch (Exception e) {
_log.error("createOrUpdateVcenterCluster caught an exception.", e);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
completer.error(_dbClient, serviceError);
}
}
use of com.emc.storageos.volumecontroller.TaskCompleter in project coprhd-controller by CoprHD.
the class FileOrchestrationDeviceController method updateShareACLs.
@Override
public void updateShareACLs(URI storage, URI uri, String shareName, CifsShareACLUpdateParams param, String opId) throws ControllerException {
FileObject fileObj = null;
String stepDescription = null;
String successMessage = null;
String opName = null;
TaskCompleter completer = null;
if (URIUtil.isType(uri, FileShare.class)) {
completer = new FileWorkflowCompleter(uri, opId);
fileObj = s_dbClient.queryObject(FileShare.class, uri);
stepDescription = String.format("Updating file system : %s share : %s ACLs: %s", uri, shareName, param.toString());
successMessage = String.format("Updating file system : %s share : %s ACLs: %s finished successfully.", uri, shareName, param.toString());
opName = ResourceOperationTypeEnum.UPDATE_FILE_SYSTEM_SHARE_ACL.getName();
} else {
completer = new FileSnapshotWorkflowCompleter(uri, opId);
fileObj = s_dbClient.queryObject(Snapshot.class, uri);
stepDescription = String.format("Updating file system snapshot : %s share : %s ACLs: %s", uri, shareName, param.toString());
successMessage = String.format("Updating file system snapshot : %s share : %s ACLs: %s finished successfully.", uri, shareName, param.toString());
opName = ResourceOperationTypeEnum.UPDATE_FILE_SNAPSHOT_SHARE_ACL.getName();
}
try {
Workflow workflow = _workflowService.getNewWorkflow(this, UPDATE_FILESYSTEM_CIFS_SHARE_ACLS_WF_NAME, false, opId, completer);
String shareACLUpdateStep = workflow.createStepId();
Object[] args = new Object[] { storage, uri, shareName, param };
_fileDeviceController.createMethod(workflow, null, UPDATE_FILESYSTEM_SHARE_ACLS_METHOD, shareACLUpdateStep, stepDescription, storage, args);
workflow.executePlan(completer, successMessage);
} catch (Exception ex) {
s_logger.error(String.format("Updating file system : %s share : %s ACLs: %s failed.", uri, shareName, param.toString()), ex);
ServiceError serviceError = DeviceControllerException.errors.updateFileShareCIFSACLsFailed(fileObj.toString(), opName, ex);
completer.error(s_dbClient, _locker, serviceError);
}
}
use of com.emc.storageos.volumecontroller.TaskCompleter 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);
}
}
Aggregations