use of com.emc.storageos.xtremio.restapi.XtremIOClient in project coprhd-controller by CoprHD.
the class XtremIOStorageDevice method doExpandSnapshot.
@Override
public void doExpandSnapshot(StorageSystem storage, StoragePool pool, BlockSnapshot snapshot, Long sizeInBytes, TaskCompleter taskCompleter) throws DeviceControllerException {
_log.info("Expand BlockSnapshot..... Started");
try {
XtremIOClient client = XtremIOProvUtils.getXtremIOClient(dbClient, storage, xtremioRestClientFactory);
String clusterName = client.getClusterDetails(storage.getSerialNumber()).getName();
Long sizeInGB = new Long(sizeInBytes / (1024 * 1024 * 1024));
String capacityInGBStr = String.valueOf(sizeInGB).concat("g");
client.expandBlockSnapshot(snapshot.getDeviceLabel(), capacityInGBStr, clusterName);
XtremIOVolume snapshotExpandResp = client.getSnapShotDetails(snapshot.getDeviceLabel(), clusterName);
snapshot.setProvisionedCapacity(Long.parseLong(snapshotExpandResp.getAllocatedCapacity()) * 1024);
snapshot.setAllocatedCapacity(Long.parseLong(snapshotExpandResp.getAllocatedCapacity()) * 1024);
dbClient.updateObject(snapshot);
// update StoragePool capacity
try {
XtremIOProvUtils.updateStoragePoolCapacity(client, dbClient, pool);
} catch (Exception e) {
_log.warn("Error while updating pool capacity", e);
}
taskCompleter.ready(dbClient);
_log.info("Expand BlockSnapshot..... End");
} catch (Exception e) {
_log.error("Error while expanding BlockSnapshot", e);
ServiceError error = DeviceControllerErrors.xtremio.expandSnapshotFailure(e);
taskCompleter.error(dbClient, error);
}
}
use of com.emc.storageos.xtremio.restapi.XtremIOClient in project coprhd-controller by CoprHD.
the class XtremIOStorageDevice method doRemoveFromConsistencyGroup.
@Override
public void doRemoveFromConsistencyGroup(StorageSystem storage, URI consistencyGroupId, List<URI> blockObjects, TaskCompleter taskCompleter) throws DeviceControllerException {
_log.info("{} doRemoveFromConsistencyGroup START ...", storage.getSerialNumber());
BlockConsistencyGroup consistencyGroup = dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroupId);
String groupName = null;
try {
// get the group name from one of the block objects; we expect all of them to be the same group
Iterator<URI> itr = blockObjects.iterator();
while (itr.hasNext()) {
BlockObject blockObject = BlockObject.fetch(dbClient, itr.next());
if (blockObject != null && !blockObject.getInactive() && !NullColumnValueGetter.isNullValue(blockObject.getReplicationGroupInstance())) {
groupName = blockObject.getReplicationGroupInstance();
break;
}
}
// Check if the replication group exists
if (groupName != null) {
// Check if the consistency group exists
XtremIOClient client = XtremIOProvUtils.getXtremIOClient(dbClient, storage, xtremioRestClientFactory);
if (!client.isVersion2()) {
_log.info("Nothing to remove from consistency group {}", consistencyGroup.getLabel());
taskCompleter.ready(dbClient);
return;
}
String clusterName = client.getClusterDetails(storage.getSerialNumber()).getName();
XtremIOConsistencyGroup cg = XtremIOProvUtils.isCGAvailableInArray(client, groupName, clusterName);
if (cg == null) {
_log.error("The consistency group does not exist in the array: {}", storage.getSerialNumber());
taskCompleter.error(dbClient, DeviceControllerException.exceptions.consistencyGroupNotFound(groupName, consistencyGroup.getCgNameOnStorageSystem(storage.getId())));
return;
}
for (URI uri : blockObjects) {
BlockObject blockObject = BlockObject.fetch(dbClient, uri);
if (blockObject != null) {
client.removeVolumeFromConsistencyGroup(blockObject.getLabel(), blockObject.getReplicationGroupInstance(), clusterName);
blockObject.setConsistencyGroup(NullColumnValueGetter.getNullURI());
blockObject.setReplicationGroupInstance(NullColumnValueGetter.getNullStr());
dbClient.updateObject(blockObject);
}
}
}
taskCompleter.ready(dbClient);
_log.info("{} doRemoveFromConsistencyGroup END ...", storage.getSerialNumber());
} catch (Exception e) {
_log.error(String.format("Remove from Consistency Group operation failed %s", e));
taskCompleter.error(dbClient, DeviceControllerException.exceptions.failedToRemoveMembersToConsistencyGroup(consistencyGroup.getLabel(), consistencyGroup.getLabel(), e.getMessage()));
}
}
use of com.emc.storageos.xtremio.restapi.XtremIOClient in project coprhd-controller by CoprHD.
the class XtremIOUnManagedVolumeDiscoverer method discoverUnManagedObjects.
public void discoverUnManagedObjects(AccessProfile accessProfile, DbClient dbClient, PartitionManager partitionManager) throws Exception {
log.info("Started discovery of UnManagedVolumes for system {}", accessProfile.getSystemId());
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
XtremIOClient xtremIOClient = XtremIOProvUtils.getXtremIOClient(dbClient, storageSystem, xtremioRestClientFactory);
unManagedVolumesToCreate = new ArrayList<UnManagedVolume>();
unManagedVolumesToUpdate = new ArrayList<UnManagedVolume>();
unManagedCGToUpdateMap = new HashMap<String, UnManagedConsistencyGroup>();
// get the storage pool associated with the xtremio system
StoragePool storagePool = XtremIOProvUtils.getXtremIOStoragePool(storageSystem.getId(), dbClient);
if (storagePool == null) {
log.error("Skipping unmanaged volume discovery as the volume storage pool doesn't exist in ViPR");
return;
}
Map<String, List<UnManagedVolume>> igUnmanagedVolumesMap = new HashMap<String, List<UnManagedVolume>>();
Map<String, StringSet> igKnownVolumesMap = new HashMap<String, StringSet>();
Map<String, Map<String, Integer>> volumeIGHLUMap = new HashMap<String, Map<String, Integer>>();
String xioClusterName = xtremIOClient.getClusterDetails(storageSystem.getSerialNumber()).getName();
// get the xtremio volume links and process them in batches
List<XtremIOObjectInfo> volLinks = xtremIOClient.getXtremIOVolumeLinks(xioClusterName);
// Get the volume details
List<List<XtremIOObjectInfo>> volume_partitions = Lists.partition(volLinks, Constants.DEFAULT_PARTITION_SIZE);
// Set containing cgs that cannot be ingested, for now that
// means they contain volumes which belong to more than one cg
unSupportedCG = new HashSet<String>();
for (List<XtremIOObjectInfo> partition : volume_partitions) {
List<XtremIOVolume> volumes = xtremIOClient.getXtremIOVolumesForLinks(partition, xioClusterName);
for (XtremIOVolume volume : volumes) {
try {
// volumes later
if (volume.getAncestoVolInfo() != null && !volume.getAncestoVolInfo().isEmpty()) {
log.debug("Skipping volume {} as it is a snap", volume.getVolInfo().get(0));
continue;
}
// check if cgs are null before trying to access, older versions of
// the XtremIO REST client do not return cgs as part of volume response
// flag indicating the volume is part of a cg
boolean hasCGs = false;
if (volume.getConsistencyGroups() != null && !volume.getConsistencyGroups().isEmpty()) {
hasCGs = true;
if (volume.getConsistencyGroups().size() > 1) {
// volumes that belong to multiple CGs are not supported in ViPR
log.warn("Skipping volume {} as it belongs to multiple CGs and this is not supported", volume.getVolInfo().get(0));
// add all the CGs that this volume belongs to to the list that are unsupported for ingestion
for (List<Object> cg : volume.getConsistencyGroups()) {
Object cgNameToProcess = cg.get(1);
unSupportedCG.add(cgNameToProcess.toString());
log.warn("Skipping CG {} as it contains volumes belonging to multiple CGs and this is not supported", cgNameToProcess.toString());
}
continue;
}
}
UnManagedVolume unManagedVolume = null;
boolean isExported = !volume.getLunMaps().isEmpty();
boolean hasSnaps = !volume.getSnaps().isEmpty();
String managedVolumeNativeGuid = NativeGUIDGenerator.generateNativeGuidForVolumeOrBlockSnapShot(storageSystem.getNativeGuid(), volume.getVolInfo().get(0));
Volume viprVolume = DiscoveryUtils.checkStorageVolumeExistsInDB(dbClient, managedVolumeNativeGuid);
if (null != viprVolume) {
log.info("Skipping volume {} as it is already managed by ViPR", managedVolumeNativeGuid);
// export masks.
if (isExported) {
populateKnownVolsMap(volume, viprVolume, igKnownVolumesMap);
}
// retrieve snap info to be processed later
if (hasSnaps) {
StringSet vpoolUriSet = new StringSet();
vpoolUriSet.add(viprVolume.getVirtualPool().toString());
discoverVolumeSnaps(storageSystem, volume.getSnaps(), viprVolume.getNativeGuid(), vpoolUriSet, xtremIOClient, xioClusterName, dbClient, igUnmanagedVolumesMap, igKnownVolumesMap);
}
continue;
}
String unManagedVolumeNatvieGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingVolume(storageSystem.getNativeGuid(), volume.getVolInfo().get(0));
// retrieve snap info to be processed later
unManagedVolume = DiscoveryUtils.checkUnManagedVolumeExistsInDB(dbClient, unManagedVolumeNatvieGuid);
unManagedVolume = createUnManagedVolume(unManagedVolume, unManagedVolumeNatvieGuid, volume, igUnmanagedVolumesMap, storageSystem, storagePool, dbClient);
// if the volume is associated with a CG, set up the unmanaged CG
if (hasCGs) {
for (List<Object> cg : volume.getConsistencyGroups()) {
// retrieve what should be the first and only consistency group from the list
// volumes belonging to multiple cgs are not supported and were excluded above
Object cgNameToProcess = cg.get(1);
addObjectToUnManagedConsistencyGroup(xtremIOClient, unManagedVolume, cgNameToProcess.toString(), storageSystem, xioClusterName, dbClient);
}
} else {
// Make sure the unManagedVolume object does not contain CG information from previous discovery
unManagedVolume.getVolumeCharacterstics().put(SupportedVolumeCharacterstics.IS_VOLUME_ADDED_TO_CONSISTENCYGROUP.toString(), Boolean.FALSE.toString());
// set the uri of the unmanaged CG in the unmanaged volume object to empty
unManagedVolume.getVolumeInformation().put(SupportedVolumeInformation.UNMANAGED_CONSISTENCY_GROUP_URI.toString(), "");
}
if (isExported) {
Map<String, Integer> igHLUMap = new HashMap<String, Integer>();
for (List<Object> lunMapEntries : volume.getLunMaps()) {
Double hlu = (Double) lunMapEntries.get(2);
log.info("Found HLU {}", hlu);
List<Object> igDetails = (List<Object>) lunMapEntries.get(0);
// key value IG-HLU
igHLUMap.put(igDetails.get(1).toString(), Integer.valueOf(hlu.intValue()));
}
if (!igHLUMap.isEmpty()) {
volumeIGHLUMap.put(unManagedVolumeNatvieGuid, igHLUMap);
}
}
boolean hasReplicas = false;
if (hasSnaps) {
StringSet parentMatchedVPools = unManagedVolume.getSupportedVpoolUris();
StringSet discoveredSnaps = discoverVolumeSnaps(storageSystem, volume.getSnaps(), unManagedVolumeNatvieGuid, parentMatchedVPools, xtremIOClient, xioClusterName, dbClient, igUnmanagedVolumesMap, igKnownVolumesMap);
if (!discoveredSnaps.isEmpty()) {
hasReplicas = true;
// set the HAS_REPLICAS property
unManagedVolume.getVolumeCharacterstics().put(SupportedVolumeCharacterstics.HAS_REPLICAS.toString(), TRUE);
StringSetMap unManagedVolumeInformation = unManagedVolume.getVolumeInformation();
if (unManagedVolumeInformation.containsKey(SupportedVolumeInformation.SNAPSHOTS.toString())) {
log.debug("Snaps :" + Joiner.on("\t").join(discoveredSnaps));
if (null != discoveredSnaps && discoveredSnaps.isEmpty()) {
// replace with empty string set doesn't work, hence added explicit code to remove all
unManagedVolumeInformation.get(SupportedVolumeInformation.SNAPSHOTS.toString()).clear();
} else {
// replace with new StringSet
unManagedVolumeInformation.get(SupportedVolumeInformation.SNAPSHOTS.toString()).replace(discoveredSnaps);
log.info("Replaced snaps :" + Joiner.on("\t").join(unManagedVolumeInformation.get(SupportedVolumeInformation.SNAPSHOTS.toString())));
}
} else {
unManagedVolumeInformation.put(SupportedVolumeInformation.SNAPSHOTS.toString(), discoveredSnaps);
}
}
}
if (!hasReplicas) {
unManagedVolume.getVolumeCharacterstics().put(SupportedVolumeCharacterstics.HAS_REPLICAS.toString(), FALSE);
StringSet snapshots = unManagedVolume.getVolumeInformation().get(SupportedVolumeInformation.SNAPSHOTS.toString());
if (snapshots != null && !snapshots.isEmpty()) {
unManagedVolume.getVolumeInformation().get(SupportedVolumeInformation.SNAPSHOTS.toString()).clear();
}
}
allCurrentUnManagedVolumeUris.add(unManagedVolume.getId());
} catch (Exception ex) {
log.error("Error processing XIO volume {}", volume, ex);
}
}
}
if (!unManagedCGToUpdateMap.isEmpty()) {
unManagedCGToUpdate = new ArrayList<UnManagedConsistencyGroup>(unManagedCGToUpdateMap.values());
partitionManager.updateAndReIndexInBatches(unManagedCGToUpdate, unManagedCGToUpdate.size(), dbClient, UNMANAGED_CONSISTENCY_GROUP);
unManagedCGToUpdate.clear();
}
if (!unManagedVolumesToCreate.isEmpty()) {
partitionManager.insertInBatches(unManagedVolumesToCreate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_VOLUME);
unManagedVolumesToCreate.clear();
}
if (!unManagedVolumesToUpdate.isEmpty()) {
partitionManager.updateAndReIndexInBatches(unManagedVolumesToUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_VOLUME);
unManagedVolumesToUpdate.clear();
}
// Process those active unmanaged volume objects available in database but not in newly discovered items, to mark them inactive.
DiscoveryUtils.markInActiveUnManagedVolumes(storageSystem, allCurrentUnManagedVolumeUris, dbClient, partitionManager);
// Process those active unmanaged consistency group objects available in database but not in newly discovered items, to mark them
// inactive.
DiscoveryUtils.performUnManagedConsistencyGroupsBookKeeping(storageSystem, allCurrentUnManagedCgURIs, dbClient, partitionManager);
// Next discover the unmanaged export masks
discoverUnmanagedExportMasks(storageSystem.getId(), igUnmanagedVolumesMap, igKnownVolumesMap, xtremIOClient, xioClusterName, dbClient, partitionManager, volumeIGHLUMap);
}
Aggregations