use of com.emc.storageos.xtremio.restapi.model.response.XtremIOConsistencyGroup in project coprhd-controller by CoprHD.
the class XtremIOStorageDevice method doDeleteVolumes.
@Override
public void doDeleteVolumes(StorageSystem storageSystem, String opId, List<Volume> volumes, TaskCompleter completer) throws DeviceControllerException {
Map<String, String> failedVolumes = new HashMap<String, String>();
try {
XtremIOClient client = XtremIOProvUtils.getXtremIOClient(dbClient, storageSystem, xtremioRestClientFactory);
String clusterName = client.getClusterDetails(storageSystem.getSerialNumber()).getName();
URI projectUri = volumes.get(0).getProject().getURI();
URI poolUri = volumes.get(0).getPool();
for (Volume volume : volumes) {
String volumeName = volume.getDeviceLabel() != null ? volume.getDeviceLabel() : volume.getLabel();
try {
if (null != XtremIOProvUtils.isVolumeAvailableInArray(client, volumeName, clusterName)) {
// Remove the volume from the consistency group
if (client.isVersion2() && !NullColumnValueGetter.isNullURI(volume.getConsistencyGroup()) && NullColumnValueGetter.isNotNullValue(volume.getReplicationGroupInstance())) {
BlockConsistencyGroup consistencyGroupObj = dbClient.queryObject(BlockConsistencyGroup.class, volume.getConsistencyGroup());
String cgName = volume.getReplicationGroupInstance();
XtremIOConsistencyGroup xioCG = XtremIOProvUtils.isCGAvailableInArray(client, cgName, clusterName);
// Check if CG has volumes
if (null != xioCG && null != xioCG.getVolList() && !xioCG.getVolList().isEmpty()) {
boolean isVolRemovedFromCG = false;
// Verify if the volumes is part of the CG or not. If Exists always remove from CG
if (checkIfVolumeExistsInCG(xioCG.getVolList(), volumeName)) {
_log.info("Removing volume {} from consistency group {}", volumeName, cgName);
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_038);
client.removeVolumeFromConsistencyGroup(volumeName, cgName, clusterName);
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_039);
isVolRemovedFromCG = true;
} else {
_log.info("Volume {} doesn't exist on CG {}", volumeName, cgName);
}
// Perform remove CG only when we removed the volume from CG.
if (isVolRemovedFromCG) {
// Query the CG to reflect the latest data on array.
xioCG = XtremIOProvUtils.isCGAvailableInArray(client, cgName, clusterName);
if (null == xioCG.getVolList() || xioCG.getVolList().isEmpty()) {
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_038);
client.removeConsistencyGroup(cgName, clusterName);
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_039);
_log.info("CG is empty on array. Remove array association from the CG");
consistencyGroupObj.removeSystemConsistencyGroup(storageSystem.getId().toString(), cgName);
// clear the LOCAL type
StringSet types = consistencyGroupObj.getTypes();
if (types != null) {
types.remove(Types.LOCAL.name());
consistencyGroupObj.setTypes(types);
}
dbClient.updateObject(consistencyGroupObj);
}
}
}
}
// backing volume).
if (volume.checkForRp() || RPHelper.isAssociatedToAnyRpVplexTypes(volume, dbClient)) {
int attempt = 0;
while (attempt++ <= MAX_RP_RETRIES) {
try {
_log.info(String.format("Deleting RecoverPoint volume %s (attempt %s/%s)", volumeName, attempt, MAX_RP_RETRIES));
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_040);
client.deleteVolume(volumeName, clusterName);
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_041);
break;
} catch (XtremIOApiException e) {
// volume removed from the consistency group.
if (attempt != MAX_RP_RETRIES && e.getMessage().contains("cannot_remove_volume_that_is_in_consistency_group")) {
_log.warn(String.format("Encountered exception attempting delete RP volume %s. Waiting %s milliseconds before trying again. Error: %s", volumeName, RP_WAIT_FOR_RETRY, e.getMessage()));
try {
Thread.sleep(RP_WAIT_FOR_RETRY);
} catch (InterruptedException e1) {
Thread.currentThread().interrupt();
}
} else {
// re-throw the exception if this is not the one we care about
throw e;
}
}
}
} else {
_log.info("Deleting the volume {}", volumeName);
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_040);
client.deleteVolume(volumeName, clusterName);
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_041);
}
}
} catch (Exception e) {
_log.error("Error during volume {} delete.", volumeName, e);
failedVolumes.put(volumeName, ControllerUtils.getMessage(e));
}
}
if (!failedVolumes.isEmpty()) {
StringBuffer errMsg = new StringBuffer("Failed to delete volumes: ");
for (String failedVolume : failedVolumes.keySet()) {
errMsg.append(failedVolume).append(":").append(failedVolumes.get(failedVolume));
}
ServiceError error = DeviceControllerErrors.xtremio.deleteVolumeFailure(errMsg.toString());
completer.error(dbClient, error);
} else {
String volumeFolderName = getVolumeFolderName(projectUri, storageSystem);
XtremIOProvUtils.cleanupVolumeFoldersIfNeeded(client, clusterName, volumeFolderName, storageSystem);
completer.ready(dbClient);
}
// update StoragePool capacity for pools changed
StoragePool pool = dbClient.queryObject(StoragePool.class, poolUri);
try {
_log.info("Updating Pool {} Capacity", pool.getNativeGuid());
XtremIOProvUtils.updateStoragePoolCapacity(client, dbClient, pool);
} catch (Exception e) {
_log.warn("Error while updating pool capacity for pool {} ", poolUri, e);
}
} catch (Exception e) {
_log.error("Error while deleting volumes", e);
ServiceError error = DeviceControllerErrors.xtremio.deleteVolumeFailure(e.getMessage());
completer.error(dbClient, error);
}
}
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 createV2Snapshot.
private XtremIOVolume createV2Snapshot(XtremIOClient client, StorageSystem storage, String xioClusterName, BlockSnapshot snap, String snapLabel, Boolean readOnly, TaskCompleter taskCompleter) throws Exception {
Volume parentVolume = dbClient.queryObject(Volume.class, snap.getParent().getURI());
URI projectUri = snap.getProject().getURI();
String clusterName = client.getClusterDetails(storage.getSerialNumber()).getName();
String snapTagName = XtremIOProvUtils.createTagsForVolumeAndSnaps(client, getVolumeFolderName(projectUri, storage), clusterName).get(XtremIOConstants.SNAPSHOT_KEY);
String snapshotType = readOnly ? XtremIOConstants.XTREMIO_READ_ONLY_TYPE : XtremIOConstants.XTREMIO_REGULAR_TYPE;
client.createVolumeSnapshot(parentVolume.getDeviceLabel(), snapLabel, snapTagName, snapshotType, clusterName);
// Get the snapset details
XtremIOConsistencyGroup snapset = client.getSnapshotSetDetails(snapLabel, xioClusterName);
List<Object> snapDetails = snapset.getVolList().get(0);
XtremIOVolume xioSnap = client.getSnapShotDetails(snapDetails.get(1).toString(), xioClusterName);
// tag the created the snap
client.tagObject(snapTagName, XTREMIO_ENTITY_TYPE.SnapshotSet.name(), snapLabel, clusterName);
return xioSnap;
}
use of com.emc.storageos.xtremio.restapi.model.response.XtremIOConsistencyGroup in project coprhd-controller by CoprHD.
the class XtremIOUnManagedVolumeDiscoverer method discoverVolumeSnaps.
private StringSet discoverVolumeSnaps(StorageSystem system, List<List<Object>> snapDetails, String parentGUID, StringSet parentMatchedVPools, XtremIOClient xtremIOClient, String xioClusterName, DbClient dbClient, Map<String, List<UnManagedVolume>> igUnmanagedVolumesMap, Map<String, StringSet> igKnownVolumesMap) throws Exception {
StringSet snaps = new StringSet();
Object snapNameToProcess;
for (List<Object> snapDetail : snapDetails) {
// This can't be null
snapNameToProcess = snapDetail.get(1);
if ((null == snapNameToProcess || snapNameToProcess.toString().length() == 0) || null == snapDetail.get(2)) {
log.warn("Skipping snapshot as it is null for volume {}", parentGUID);
continue;
}
// If this name is a trigger/match for RP automated snapshots, ignore it as well
String snapName = (String) snapNameToProcess;
if ((snapName.contains(RP_SNAPSHOT_CRITERIA1) || snapName.contains(RP_SNAPSHOT_CRITERIA2)) && snapName.contains(RP_SNAPSHOT_CRITERIA3)) {
log.warn("Skipping snapshot {} because it is internal to RP for volume {}", snapName, parentGUID);
continue;
}
XtremIOVolume snap = xtremIOClient.getSnapShotDetails(snapNameToProcess.toString(), xioClusterName);
UnManagedVolume unManagedVolume = null;
boolean isExported = !snap.getLunMaps().isEmpty();
String managedSnapNativeGuid = NativeGUIDGenerator.generateNativeGuidForVolumeOrBlockSnapShot(system.getNativeGuid(), snap.getVolInfo().get(0));
BlockSnapshot viprSnap = DiscoveryUtils.checkBlockSnapshotExistsInDB(dbClient, managedSnapNativeGuid);
if (null != viprSnap) {
log.info("Skipping snapshot {} as it is already managed by ViPR", managedSnapNativeGuid);
// export masks.
if (isExported) {
populateKnownVolsMap(snap, viprSnap, igKnownVolumesMap);
}
snaps.add(managedSnapNativeGuid);
continue;
}
String unManagedVolumeNatvieGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingVolume(system.getNativeGuid(), snap.getVolInfo().get(0));
unManagedVolume = DiscoveryUtils.checkUnManagedVolumeExistsInDB(dbClient, unManagedVolumeNatvieGuid);
unManagedVolume = createUnManagedVolume(unManagedVolume, unManagedVolumeNatvieGuid, snap, igUnmanagedVolumesMap, system, null, dbClient);
populateSnapInfo(unManagedVolume, snap, parentGUID, parentMatchedVPools);
snaps.add(unManagedVolumeNatvieGuid);
allCurrentUnManagedVolumeUris.add(unManagedVolume.getId());
// is associated with a cg, if it is process the snap same as any unmanaged volume
if (snap.getSnapSetList() != null && !snap.getSnapSetList().isEmpty()) {
Object snapSetNameToProcess = null;
if (snap.getSnapSetList().size() > 1) {
// snaps that belong to multiple snap sets are not supported in ViPR
log.warn("Skipping snapshot {} as it belongs to multiple snapSets and this is not supported", snap.getVolInfo().get(0));
// add all the snap sets that this volume belongs to to the list that are unsupported for ingestion
for (List<Object> snapSet : snap.getSnapSetList()) {
snapSetNameToProcess = snapSet.get(1);
log.warn("Skipping SnapSet {} as it contains volumes belonging to multiple CGs and this is not supported", snapSetNameToProcess.toString());
}
} else {
for (List<Object> snapSet : snap.getSnapSetList()) {
snapSetNameToProcess = snapSet.get(1);
XtremIOConsistencyGroup snapSetDetails = xtremIOClient.getSnapshotSetDetails(snapSetNameToProcess.toString(), xioClusterName);
if (snapSetDetails != null && snapSetDetails.getCgName() != null) {
log.info("Snapshot {} belongs to consistency group {} on the array", snapSetNameToProcess.toString(), snapSetDetails.getCgName());
addObjectToUnManagedConsistencyGroup(xtremIOClient, unManagedVolume, snapSetDetails.getCgName(), system, xioClusterName, dbClient);
} else {
log.info("Snapshot {} does not belong to a consistency group.", snapSetNameToProcess.toString());
}
}
}
}
}
return snaps;
}
use of com.emc.storageos.xtremio.restapi.model.response.XtremIOConsistencyGroup in project coprhd-controller by CoprHD.
the class XtremIOV2Client method getConsistencyGroupDetails.
@Override
public XtremIOConsistencyGroup getConsistencyGroupDetails(String cgName, String clusterName) throws Exception {
String uriString = XtremIOConstants.XTREMIO_V2_CONSISTENCY_GROUPS_STR.concat(XtremIOConstants.getInputNameForClusterString(cgName, clusterName));
ClientResponse response = get(URI.create(uriString));
XtremIOCGResponse cgResponse = getResponseObject(XtremIOCGResponse.class, response);
XtremIOConsistencyGroup cg = cgResponse.getContent();
log.info(cg.toString());
return cg;
}
Aggregations