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);
}
}
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);
}
}
Aggregations