Search in sources :

Example 6 with XtremIOApiException

use of com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException in project coprhd-controller by CoprHD.

the class XtremIOSnapshotOperations method resyncGroupSnapshots.

@Override
public void resyncGroupSnapshots(StorageSystem storage, URI volume, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        XtremIOClient client = XtremIOProvUtils.getXtremIOClient(dbClient, storage, xtremioRestClientFactory);
        BlockSnapshot snapshotObj = dbClient.queryObject(BlockSnapshot.class, snapshot);
        BlockConsistencyGroup group = dbClient.queryObject(BlockConsistencyGroup.class, snapshotObj.getConsistencyGroup());
        // Check if the CG exists on the array
        String clusterName = client.getClusterDetails(storage.getSerialNumber()).getName();
        String cgName = ConsistencyGroupUtils.getSourceConsistencyGroupName(snapshotObj, dbClient);
        XtremIOConsistencyGroup cg = XtremIOProvUtils.isCGAvailableInArray(client, cgName, clusterName);
        if (cg == null) {
            _log.error("The consistency group does not exist in the array: {}", storage.getSerialNumber());
            taskCompleter.error(dbClient, DeviceControllerException.exceptions.consistencyGroupNotFound(cgName, group.getCgNameOnStorageSystem(storage.getId())));
            return;
        }
        // So for pre 4.0.2 version, do not use noBackup option.
        if (XtremIOProvUtils.isXtremIOVersion402OrGreater(storage.getFirmwareVersion())) {
            client.refreshSnapshotFromCG(clusterName, cgName, snapshotObj.getReplicationGroupInstance(), true);
        } else {
            client.refreshSnapshotFromCG(clusterName, cgName, snapshotObj.getReplicationGroupInstance(), false);
        }
        String newSnapsetName = null;
        // Now get the new snapshot set name by querying back the snapshot
        XtremIOVolume xioSnap = client.getSnapShotDetails(snapshotObj.getDeviceLabel(), clusterName);
        if (xioSnap != null && xioSnap.getSnapSetList() != null && !xioSnap.getSnapSetList().isEmpty()) {
            List<Object> snapsetDetails = xioSnap.getSnapSetList().get(0);
            // The REST response for the snapsetList will contain 3 elements.
            // Example - {"00a07269b55e42fa91c1aabadb6ea85c","SnapshotSet.1458111462198",27}
            // We need the 2nd element which is the snapset name.
            newSnapsetName = snapsetDetails.get(1).toString();
        }
        // Update the new snapshot set name in all the CG snapshots
        if (NullColumnValueGetter.isNotNullValue(newSnapsetName)) {
            List<BlockSnapshot> snapshots = ControllerUtils.getSnapshotsPartOfReplicationGroup(snapshotObj, dbClient);
            for (BlockSnapshot snap : snapshots) {
                _log.info("Updating replicationGroupInstance to {} in snapshot- {}:{}", newSnapsetName, snap.getLabel(), snap.getId());
                snap.setReplicationGroupInstance(newSnapsetName);
                dbClient.updateObject(snap);
            }
        }
        taskCompleter.ready(dbClient);
    } catch (Exception e) {
        _log.error("Snapshot resync failed", e);
        ServiceError serviceError = null;
        if (e instanceof XtremIOApiException) {
            XtremIOApiException xioException = (XtremIOApiException) e;
            // check for specific error key for snapshot size mismatch with source volume.
            if (null != xioException.getMessage() && xioException.getMessage().contains(XtremIOConstants.SNAP_SIZE_MISMATCH_ERROR_KEY)) {
                String restoreFailureMsg = "One or more CG snapshots size mismatch with its source volume size. " + "Use expand snapshot feature to increase the snapshot size.";
                serviceError = DeviceControllerErrors.xtremio.resyncSnapshotFailureSourceSizeMismatch(restoreFailureMsg);
            }
        } else {
            serviceError = DeviceControllerException.errors.jobFailed(e);
        }
        taskCompleter.error(dbClient, serviceError);
    }
}
Also used : XtremIOVolume(com.emc.storageos.xtremio.restapi.model.response.XtremIOVolume) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) XtremIOConsistencyGroup(com.emc.storageos.xtremio.restapi.model.response.XtremIOConsistencyGroup) XtremIOClient(com.emc.storageos.xtremio.restapi.XtremIOClient) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) XtremIOApiException(com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException) BlockObject(com.emc.storageos.db.client.model.BlockObject) XtremIOApiException(com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 7 with XtremIOApiException

use of com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException in project coprhd-controller by CoprHD.

the class XtremIOSnapshotOperations method restoreGroupSnapshots.

@Override
public void restoreGroupSnapshots(StorageSystem storage, URI volume, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        XtremIOClient client = XtremIOProvUtils.getXtremIOClient(dbClient, storage, xtremioRestClientFactory);
        BlockSnapshot snapshotObj = dbClient.queryObject(BlockSnapshot.class, snapshot);
        BlockConsistencyGroup group = dbClient.queryObject(BlockConsistencyGroup.class, snapshotObj.getConsistencyGroup());
        // Check if the CG exists on the array
        String clusterName = client.getClusterDetails(storage.getSerialNumber()).getName();
        String cgName = ConsistencyGroupUtils.getSourceConsistencyGroupName(snapshotObj, dbClient);
        XtremIOConsistencyGroup cg = XtremIOProvUtils.isCGAvailableInArray(client, cgName, clusterName);
        if (cg == null) {
            _log.error("The consistency group does not exist in the array: {}", storage.getSerialNumber());
            taskCompleter.error(dbClient, DeviceControllerException.exceptions.consistencyGroupNotFound(cgName, group.getCgNameOnStorageSystem(storage.getId())));
            return;
        }
        client.restoreCGFromSnapshot(clusterName, cgName, snapshotObj.getReplicationGroupInstance());
        taskCompleter.ready(dbClient);
    } catch (Exception e) {
        _log.error("Snapshot restore failed", e);
        ServiceError serviceError = null;
        if (e instanceof XtremIOApiException) {
            XtremIOApiException xioException = (XtremIOApiException) e;
            // check for specific error key for snapshot size mismatch with source volume.
            if (null != xioException.getMessage() && xioException.getMessage().contains(XtremIOConstants.SNAP_SIZE_MISMATCH_ERROR_KEY)) {
                String restoreFailureMsg = "One or more CG snapshots size mismatch with its source volume size. " + "Use expand snapshot feature to increase the snapshot size.";
                serviceError = DeviceControllerErrors.xtremio.restoreSnapshotFailureSourceSizeMismatch(restoreFailureMsg);
            }
        } else {
            serviceError = DeviceControllerException.errors.jobFailed(e);
        }
        taskCompleter.error(dbClient, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) XtremIOConsistencyGroup(com.emc.storageos.xtremio.restapi.model.response.XtremIOConsistencyGroup) XtremIOClient(com.emc.storageos.xtremio.restapi.XtremIOClient) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) XtremIOApiException(com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException) XtremIOApiException(com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Aggregations

XtremIOApiException (com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException)7 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)5 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)5 XtremIOClient (com.emc.storageos.xtremio.restapi.XtremIOClient)5 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)4 XtremIOVolume (com.emc.storageos.xtremio.restapi.model.response.XtremIOVolume)4 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)3 Volume (com.emc.storageos.db.client.model.Volume)3 XtremIOConsistencyGroup (com.emc.storageos.xtremio.restapi.model.response.XtremIOConsistencyGroup)3 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)2 ClientResponse (com.sun.jersey.api.client.ClientResponse)2 URI (java.net.URI)2 BlockObject (com.emc.storageos.db.client.model.BlockObject)1 StoragePool (com.emc.storageos.db.client.model.StoragePool)1 StringSet (com.emc.storageos.db.client.model.StringSet)1 XtremIOAuthInfo (com.emc.storageos.xtremio.restapi.model.XtremIOAuthInfo)1 HashMap (java.util.HashMap)1 JSONObject (org.codehaus.jettison.json.JSONObject)1