Search in sources :

Example 1 with WaitOnRebuildResult

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);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Volume(com.emc.storageos.db.client.model.Volume) WaitOnRebuildResult(com.emc.storageos.vplex.api.VPlexVirtualVolumeInfo.WaitOnRebuildResult) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) VPlexApiClient(com.emc.storageos.vplex.api.VPlexApiClient) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 2 with WaitOnRebuildResult

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());
        }
    }
}
Also used : StringTokenizer(java.util.StringTokenizer) WaitOnRebuildResult(com.emc.storageos.vplex.api.VPlexVirtualVolumeInfo.WaitOnRebuildResult) VolumeInfo(com.emc.storageos.vplex.api.clientdata.VolumeInfo) Test(org.junit.Test)

Aggregations

WaitOnRebuildResult (com.emc.storageos.vplex.api.VPlexVirtualVolumeInfo.WaitOnRebuildResult)2 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)1 Volume (com.emc.storageos.db.client.model.Volume)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)1 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)1 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)1 ControllerException (com.emc.storageos.volumecontroller.ControllerException)1 VPlexApiClient (com.emc.storageos.vplex.api.VPlexApiClient)1 VPlexApiException (com.emc.storageos.vplex.api.VPlexApiException)1 VolumeInfo (com.emc.storageos.vplex.api.clientdata.VolumeInfo)1 WorkflowException (com.emc.storageos.workflow.WorkflowException)1 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 StringTokenizer (java.util.StringTokenizer)1 Test (org.junit.Test)1