use of com.emc.storageos.xtremio.restapi.model.response.XtremIOVolume 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.XtremIOVolume 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.XtremIOVolume in project coprhd-controller by CoprHD.
the class XtremIOStorageDevice method doExpandVolume.
@Override
public void doExpandVolume(StorageSystem storage, StoragePool pool, Volume volume, Long sizeInBytes, TaskCompleter taskCompleter) throws DeviceControllerException {
_log.info("Expand Volume..... Started");
try {
XtremIOClient client = XtremIOProvUtils.getXtremIOClient(dbClient, storage, xtremioRestClientFactory);
String clusterName = client.getClusterDetails(storage.getSerialNumber()).getName();
Long sizeInGB = new Long(sizeInBytes / (1024 * 1024 * 1024));
// XtremIO Rest API supports only expansion in GBs.
String capacityInGBStr = String.valueOf(sizeInGB).concat("g");
client.expandVolume(volume.getDeviceLabel(), capacityInGBStr, clusterName);
XtremIOVolume createdVolume = client.getVolumeDetails(volume.getDeviceLabel(), clusterName);
volume.setProvisionedCapacity(Long.parseLong(createdVolume.getAllocatedCapacity()) * 1024);
volume.setAllocatedCapacity(Long.parseLong(createdVolume.getAllocatedCapacity()) * 1024);
volume.setCapacity(Long.parseLong(createdVolume.getAllocatedCapacity()) * 1024);
dbClient.updateObject(volume);
// 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 Volume..... End");
} catch (Exception e) {
_log.error("Error while expanding volumes", e);
ServiceError error = DeviceControllerErrors.xtremio.expandVolumeFailure(e);
taskCompleter.error(dbClient, error);
}
}
use of com.emc.storageos.xtremio.restapi.model.response.XtremIOVolume 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);
}
use of com.emc.storageos.xtremio.restapi.model.response.XtremIOVolume in project coprhd-controller by CoprHD.
the class XtremIOProvUtils method getInitiatorGroupVolumes.
/**
* @param igName
* @param clusterName
* @param client
* @return
* @throws Exception
*/
public static List<XtremIOVolume> getInitiatorGroupVolumes(String igName, String clusterName, XtremIOClient client) throws Exception {
List<XtremIOVolume> igVolumes = new ArrayList<XtremIOVolume>();
List<XtremIOObjectInfo> igLunMaps = new ArrayList<XtremIOObjectInfo>();
if (client.isVersion2()) {
igLunMaps = client.getLunMapsForInitiatorGroup(igName, clusterName);
} else {
XtremIOInitiatorGroup ig = client.getInitiatorGroup(igName, clusterName);
if (ig == null) {
return igVolumes;
}
List<XtremIOObjectInfo> lunMaps = client.getLunMaps(clusterName);
String igIndex = ig.getIndex();
for (XtremIOObjectInfo lunMap : lunMaps) {
String[] lunInfo = lunMap.getName().split(XtremIOConstants.UNDERSCORE);
if (igIndex.equals(lunInfo[1])) {
igLunMaps.add(lunMap);
}
}
}
for (XtremIOObjectInfo igLunMap : igLunMaps) {
String[] igLunInfo = igLunMap.getName().split(XtremIOConstants.UNDERSCORE);
igVolumes.add(client.getVolumeByIndex(igLunInfo[0], clusterName));
}
return igVolumes;
}
Aggregations