use of com.emc.storageos.xtremio.restapi.model.response.XtremIOConsistencyGroup in project coprhd-controller by CoprHD.
the class XtremIOUnManagedVolumeDiscoverer method addObjectToUnManagedConsistencyGroup.
/**
* Adds the passed in unmanaged volume or unmanaged snapshot
* to an unmanaged consistency group object
*
* @param xtremIOClient - connection to xtremio REST interface
* @param unManagedVolume - either and unmanaged volume or unmanaged snapshot
* associated with a consistency group
* @param cgNameToProcess - consistency group being processed
* @param storageSystem - storage system the objects are on
* @param xioClusterName - name of the xtremio cluster being managed by the xtremio XMS
* @param dbClient - dbclient
* @throws Exception
*/
private void addObjectToUnManagedConsistencyGroup(XtremIOClient xtremIOClient, UnManagedVolume unManagedVolume, String cgNameToProcess, StorageSystem storageSystem, String xioClusterName, DbClient dbClient) throws Exception {
// Check if the current CG is in the list of unsupported CGs
if (!unSupportedCG.isEmpty() && unSupportedCG.contains(cgNameToProcess.toString())) {
// leave the for loop and do nothing
log.warn("Skipping CG {} as it contains volumes belonging to multiple CGs and this is not supported", cgNameToProcess.toString());
return;
}
log.info("Unmanaged volume {} belongs to consistency group {} on the array", unManagedVolume.getLabel(), cgNameToProcess);
// Update the unManagedVolume object with CG information
unManagedVolume.getVolumeCharacterstics().put(SupportedVolumeCharacterstics.IS_VOLUME_ADDED_TO_CONSISTENCYGROUP.toString(), Boolean.TRUE.toString());
// Get the unmanaged CG details from the array
XtremIOConsistencyGroup xioCG = xtremIOClient.getConsistencyGroupDetails(cgNameToProcess.toString(), xioClusterName);
// determine the native guid for the unmanaged CG (storage system id + xio cg guid)
String unManagedCGNativeGuid = NativeGUIDGenerator.generateNativeGuidForCG(storageSystem.getNativeGuid(), xioCG.getGuid());
// determine if the unmanaged CG already exists in the unManagedCGToUpdateMap or in the database
// if the the unmanaged CG is not in either create a new one
UnManagedConsistencyGroup unManagedCG = null;
if (unManagedCGToUpdateMap.containsKey(unManagedCGNativeGuid)) {
unManagedCG = unManagedCGToUpdateMap.get(unManagedCGNativeGuid);
log.info("Unmanaged consistency group {} was previously added to the unManagedCGToUpdateMap", unManagedCG.getLabel());
} else {
unManagedCG = DiscoveryUtils.checkUnManagedCGExistsInDB(dbClient, unManagedCGNativeGuid);
if (null == unManagedCG) {
// unmanaged CG does not exist in the database, create it
unManagedCG = createUnManagedCG(unManagedCGNativeGuid, xioCG, storageSystem.getId(), dbClient);
log.info("Created unmanaged consistency group: {}", unManagedCG.getId().toString());
} else {
log.info("Unmanaged consistency group {} was previously added to the database", unManagedCG.getLabel());
// clean out the list of unmanaged volumes if this unmanaged cg was already
// in the database and its first time being used in this discovery operation
// the list should be re-populated by the current discovery operation
log.info("Cleaning out unmanaged volume map from unmanaged consistency group: {}", unManagedCG.getLabel());
unManagedCG.getUnManagedVolumesMap().clear();
}
}
log.info("Adding unmanaged volume {} to unmanaged consistency group {}", unManagedVolume.getLabel(), unManagedCG.getLabel());
// set the uri of the unmanaged CG in the unmanaged volume object
unManagedVolume.getVolumeInformation().put(SupportedVolumeInformation.UNMANAGED_CONSISTENCY_GROUP_URI.toString(), unManagedCG.getId().toString());
// add the unmanaged volume object to the unmanaged CG
unManagedCG.getUnManagedVolumesMap().put(unManagedVolume.getNativeGuid(), unManagedVolume.getId().toString());
// add the unmanaged CG to the map of unmanaged CGs to be updated in the database once all volumes have been processed
unManagedCGToUpdateMap.put(unManagedCGNativeGuid, unManagedCG);
// add the unmanaged CG to the current set of CGs being discovered on the array. This is for book keeping later.
allCurrentUnManagedCgURIs.add(unManagedCG.getId());
}
use of com.emc.storageos.xtremio.restapi.model.response.XtremIOConsistencyGroup in project coprhd-controller by CoprHD.
the class XtremIOSnapshotOperations method createGroupSnapshots.
@Override
public void createGroupSnapshots(StorageSystem storage, List<URI> snapshotList, Boolean createInactive, Boolean readOnly, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
XtremIOClient client = XtremIOProvUtils.getXtremIOClient(dbClient, storage, xtremioRestClientFactory);
List<BlockSnapshot> snapObjs = dbClient.queryObject(BlockSnapshot.class, snapshotList);
BlockSnapshot snapshotObj = snapObjs.get(0);
BlockConsistencyGroup blockCG = dbClient.queryObject(BlockConsistencyGroup.class, snapshotObj.getConsistencyGroup());
// Check if the CG for which we are creating snapshot exists on the array
String clusterName = client.getClusterDetails(storage.getSerialNumber()).getName();
String snapsetLabel = snapshotObj.getSnapsetLabel();
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, blockCG.getCgNameOnStorageSystem(storage.getId())));
return;
}
String snapType = readOnly ? XtremIOConstants.XTREMIO_READ_ONLY_TYPE : XtremIOConstants.XTREMIO_REGULAR_TYPE;
String snapshotSetTagName = XtremIOProvUtils.createTagsForVolumeAndSnaps(client, getVolumeFolderName(snapshotObj.getProject().getURI(), storage), clusterName).get(XtremIOConstants.SNAPSHOT_KEY);
snapsetLabel = snapsetLabel + "_" + new SimpleDateFormat("yyyyMMddhhmmssSSS").format(new Date());
client.createConsistencyGroupSnapshot(cgName, snapsetLabel, "", snapType, clusterName);
// tag the created the snapshotSet
client.tagObject(snapshotSetTagName, XTREMIO_ENTITY_TYPE.SnapshotSet.name(), snapsetLabel, clusterName);
_log.info("Snapset label :{}", snapsetLabel);
// Create mapping of volume.deviceLabel to BlockSnapshot object
Map<String, BlockSnapshot> volumeToSnapMap = new HashMap<String, BlockSnapshot>();
for (BlockSnapshot snapshot : snapObjs) {
Volume volume = dbClient.queryObject(Volume.class, snapshot.getParent());
volumeToSnapMap.put(volume.getDeviceLabel(), snapshot);
}
// Get the snapset details
XtremIOConsistencyGroup snapset = client.getSnapshotSetDetails(snapsetLabel, clusterName);
for (List<Object> snapDetails : snapset.getVolList()) {
XtremIOVolume xioSnap = client.getSnapShotDetails(snapDetails.get(1).toString(), clusterName);
_log.info("XIO Snap : {}", xioSnap);
BlockSnapshot snapshot = volumeToSnapMap.get(xioSnap.getAncestoVolInfo().get(1));
if (snapshot != null) {
processSnapshot(xioSnap, snapshot, storage);
snapshot.setReplicationGroupInstance(snapsetLabel);
dbClient.updateObject(snapshot);
}
}
taskCompleter.ready(dbClient);
} catch (Exception e) {
_log.error("Snapshot creation failed", e);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
taskCompleter.error(dbClient, serviceError);
}
}
use of com.emc.storageos.xtremio.restapi.model.response.XtremIOConsistencyGroup 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 = DeviceControllerException.errors.jobFailed(e);
taskCompleter.error(dbClient, serviceError);
}
}
use of com.emc.storageos.xtremio.restapi.model.response.XtremIOConsistencyGroup 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 = DeviceControllerException.errors.jobFailed(e);
taskCompleter.error(dbClient, serviceError);
}
}
use of com.emc.storageos.xtremio.restapi.model.response.XtremIOConsistencyGroup in project coprhd-controller by CoprHD.
the class XtremIOStorageDevice method doAddToConsistencyGroup.
@Override
public void doAddToConsistencyGroup(StorageSystem storage, URI consistencyGroupId, String replicationGroupName, List<URI> blockObjects, TaskCompleter taskCompleter) throws DeviceControllerException {
_log.info("{} doAddToConsistencyGroup START ...", storage.getSerialNumber());
BlockConsistencyGroup consistencyGroup = dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroupId);
try {
// Check if the consistency group exists
XtremIOClient client = XtremIOProvUtils.getXtremIOClient(dbClient, storage, xtremioRestClientFactory);
if (!client.isVersion2()) {
_log.info("Nothing to add to consistency group {}", consistencyGroup.getLabel());
taskCompleter.ready(dbClient);
return;
}
String clusterName = client.getClusterDetails(storage.getSerialNumber()).getName();
String cgName = replicationGroupName != null ? replicationGroupName : consistencyGroup.getLabel();
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(consistencyGroup.getLabel(), consistencyGroup.getCgNameOnStorageSystem(storage.getId())));
return;
}
List<BlockObject> updatedBlockObjects = new ArrayList<BlockObject>();
for (URI uri : blockObjects) {
BlockObject blockObject = BlockObject.fetch(dbClient, uri);
if (blockObject != null) {
if (blockObject.getClass().isInstance(Volume.class)) {
Volume volume = (Volume) blockObject;
if (volume.checkForRp() || RPHelper.isAssociatedToRpVplexType(volume, dbClient, PersonalityTypes.METADATA, PersonalityTypes.TARGET)) {
// This causes issues with local array snapshots of RP+VPlex volumes.
continue;
}
}
client.addVolumeToConsistencyGroup(blockObject.getLabel(), cgName, clusterName);
blockObject.setConsistencyGroup(consistencyGroupId);
updatedBlockObjects.add(blockObject);
}
}
dbClient.updateAndReindexObject(updatedBlockObjects);
taskCompleter.ready(dbClient);
_log.info("{} doAddToConsistencyGroup END ...", storage.getSerialNumber());
} catch (Exception e) {
_log.error(String.format("Add To Consistency Group operation failed %s", e));
// Remove any references to the consistency group
for (URI blockObjectURI : blockObjects) {
BlockObject blockObject = BlockObject.fetch(dbClient, blockObjectURI);
if (blockObject != null) {
blockObject.setConsistencyGroup(NullColumnValueGetter.getNullURI());
}
dbClient.persistObject(blockObject);
}
taskCompleter.error(dbClient, DeviceControllerException.exceptions.failedToAddMembersToConsistencyGroup(consistencyGroup.getLabel(), consistencyGroup.getLabel(), e.getMessage()));
}
}
Aggregations