use of com.emc.storageos.vplex.api.VPlexVirtualVolumeInfo.WaitOnRebuildResult in project coprhd-controller by CoprHD.
the class VPlexDeviceController method waitOnRebuild.
/**
* Waits for the rebuild to complete when a non-VPLEX volume is imported to a VPLEX
* distribute volume or a local VPLEX volume is upgraded to distributed.
*
* @param vplexURI
* The URI of the VPLEX system.
* @param vplexVolumeURI
* The URI of the VPLEX volume.
* @param stepId
* The workflow step identifier.
*
* @throws WorkflowException
*/
public void waitOnRebuild(URI vplexURI, URI vplexVolumeURI, String stepId) throws WorkflowException {
String volumeName = null;
try {
// Update step state to executing.
WorkflowStepCompleter.stepExecuting(stepId);
// Get the API client.
StorageSystem vplex = getDataObject(StorageSystem.class, vplexURI, _dbClient);
VPlexApiClient client = getVPlexAPIClient(_vplexApiFactory, vplex, _dbClient);
// Get the VPLEX volume that is rebuilding.
Volume vplexVolume = getDataObject(Volume.class, vplexVolumeURI, _dbClient);
volumeName = vplexVolume.getLabel();
// Check the rebuild status until it completes, fails, or we timeout waiting.
WaitOnRebuildResult rebuildResult = client.waitOnRebuildCompletion(vplexVolume.getDeviceLabel());
_log.info(String.format("Finished waiting on rebuild for virtual volume: %s path: %s rebuild-status: %s", vplexVolume.getDeviceLabel(), vplexVolume.getNativeId(), rebuildResult.name()));
if (WaitOnRebuildResult.SUCCESS == rebuildResult) {
WorkflowStepCompleter.stepSucceded(stepId);
} else {
ServiceError serviceError;
if (WaitOnRebuildResult.FAILED == rebuildResult) {
serviceError = VPlexApiException.errors.waitOnRebuildFailed(volumeName);
} else if (WaitOnRebuildResult.TIMED_OUT == rebuildResult) {
serviceError = VPlexApiException.errors.waitOnRebuildTimedOut(volumeName);
} else {
serviceError = VPlexApiException.errors.waitOnRebuildInvalid(volumeName);
}
WorkflowStepCompleter.stepFailed(stepId, serviceError);
}
} catch (VPlexApiException vae) {
_log.error("Exception checking the rebuild status: " + vae.getMessage(), vae);
WorkflowStepCompleter.stepFailed(stepId, vae);
} catch (Exception ex) {
_log.error("Exception checking the rebuild status: " + ex.getMessage(), ex);
ServiceError serviceError = VPlexApiException.errors.waitOnRebuildException(volumeName, ex);
WorkflowStepCompleter.stepFailed(stepId, serviceError);
}
}
use of com.emc.storageos.vplex.api.VPlexVirtualVolumeInfo.WaitOnRebuildResult in project coprhd-controller by CoprHD.
the class VPlexApiTest method testCreateVolumeWithDeviceMirror.
/*
* Tests creation of a distributed virtual volume from a non-distributed virtual volume
* and the addition of a new remote volume.
*/
@Test
public void testCreateVolumeWithDeviceMirror() {
VPlexVirtualVolumeInfo vvInfo = null;
VolumeInfo newVolumeInfo = null;
VPlexVirtualVolumeInfo distVolInfo = null;
try {
vvInfo = createSimpleVirtualVolume();
String volumeInfo = _properties.getProperty(DEVICE_MIRROR_TEST_VOLUME_PROP_KEY);
StringTokenizer tokenizer = new StringTokenizer(volumeInfo, ",");
String storageSystemGuid = tokenizer.nextToken();
String volumeId = tokenizer.nextToken();
String volumeNativeId = tokenizer.nextToken();
String transferSize = "8M";
newVolumeInfo = new VolumeInfo(storageSystemGuid, "vmax", volumeId, volumeNativeId, false, Collections.<String>emptyList());
distVolInfo = _client.upgradeVirtualVolumeToDistributed(vvInfo, newVolumeInfo, true, "1", transferSize);
Assert.assertNotNull(distVolInfo);
WaitOnRebuildResult goodRebuild = _client.waitOnRebuildCompletion(distVolInfo.getName());
Assert.assertEquals(WaitOnRebuildResult.SUCCESS, goodRebuild);
} catch (Exception ex) {
Assert.fail(ex.getMessage());
} finally {
try {
if (distVolInfo != null) {
_client.deleteVirtualVolume(distVolInfo.getName(), true, false);
} else if (vvInfo != null) {
_client.deleteVirtualVolume(vvInfo.getName(), true, false);
}
} catch (Exception exx) {
// ignoring exceptions
System.out.println("an ignorable exception was encountered: " + exx.getLocalizedMessage());
}
}
}
Aggregations