use of com.emc.storageos.xtremio.restapi.XtremIOClient 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);
}
}
use of com.emc.storageos.xtremio.restapi.XtremIOClient 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.XtremIOClient in project coprhd-controller by CoprHD.
the class XtremIOArrayAffinityDiscoverer method findAndUpdatePreferredPools.
/**
* Find and update preferred pools information for all Hosts.
*
* @param system the system
* @param dbClient the db client
* @param partitionManager
* @throws Exception the exception
*/
public void findAndUpdatePreferredPools(StorageSystem system, DbClient dbClient, PartitionManager partitionManager) throws Exception {
/**
* Get all initiators on array,
* Group initiators by IG, also maintain a map of Host to IGs, and a map of IG to Hosts.
* For each Host in the DB:
* - Find if any of its IG has volumes,
* - Find the mask type for the host.
*/
XtremIOClient xtremIOClient = XtremIOProvUtils.getXtremIOClient(dbClient, system, xtremioRestClientFactory);
String xioClusterName = xtremIOClient.getClusterDetails(system.getSerialNumber()).getName();
// Group all the initiators and their initiator groups based on ViPR host.
ArrayListMultimap<String, Initiator> igNameToInitiatorsMap = ArrayListMultimap.create();
Map<URI, Set<String>> hostToIGNamesMap = new HashMap<URI, Set<String>>();
Map<String, Set<String>> igNameToHostsMap = new HashMap<String, Set<String>>();
List<XtremIOInitiator> initiators = xtremIOClient.getXtremIOInitiatorsInfo(xioClusterName);
for (XtremIOInitiator initiator : initiators) {
String initiatorNetworkId = initiator.getPortAddress();
// check if a host initiator exists for this id
Initiator knownInitiator = NetworkUtil.getInitiator(initiatorNetworkId, dbClient);
if (knownInitiator == null) {
log.debug("Skipping XtremIO initiator {} as it is not found in database", initiatorNetworkId);
continue;
}
URI hostId = knownInitiator.getHost();
String hostName = knownInitiator.getHostName();
if (!NullColumnValueGetter.isNullURI(hostId)) {
log.info("Found a host {}({}) in ViPR for initiator {}", hostId.toString(), knownInitiator.getHostName(), initiatorNetworkId);
String igName = initiator.getInitiatorGroup().get(1);
igNameToInitiatorsMap.put(igName, knownInitiator);
Set<String> hostIGNames = hostToIGNamesMap.get(hostId);
if (hostIGNames == null) {
hostIGNames = new HashSet<String>();
hostToIGNamesMap.put(hostId, hostIGNames);
}
hostIGNames.add(igName);
Set<String> igHostNames = igNameToHostsMap.get(igName);
if (igHostNames == null) {
igHostNames = new HashSet<String>();
igNameToHostsMap.put(igName, igHostNames);
}
igHostNames.add(hostName);
} else {
log.info("No host in ViPR found configured for initiator {}", initiatorNetworkId);
}
}
log.info("IG name to Initiators Map: {}", Joiner.on(",").join(igNameToInitiatorsMap.asMap().entrySet()));
log.info("IG name to Hosts Map: {}", Joiner.on(",").join(igNameToHostsMap.entrySet()));
log.info("Host to IG names Map: {}", Joiner.on(",").join(hostToIGNamesMap.entrySet()));
// map of IG name to Volume names mapped
Map<String, Set<String>> igToVolumesMap = getIgToVolumesMap(xtremIOClient, xioClusterName);
// As XtremIO array has only one storage pool, add the pool directly.
// get the storage pool associated with the XtremIO system
StoragePool storagePool = XtremIOProvUtils.getXtremIOStoragePool(system.getId(), dbClient);
List<Host> hostsToUpdate = new ArrayList<Host>();
List<URI> hostURIs = dbClient.queryByType(Host.class, true);
Iterator<Host> hosts = dbClient.queryIterativeObjectFields(Host.class, ArrayAffinityDiscoveryUtils.HOST_PROPERTIES, hostURIs);
while (hosts.hasNext()) {
Host host = hosts.next();
if (host != null && !host.getInactive()) {
log.info("Processing Host {}", host.getLabel());
Map<String, String> preferredPoolMap = new HashMap<String, String>();
Set<String> volumeNames = getVolumesForHost(hostToIGNamesMap.get(host.getId()), igToVolumesMap);
// consider only unmanaged volumes
filterKnownVolumes(system, dbClient, xtremIOClient, xioClusterName, volumeNames);
if (!volumeNames.isEmpty()) {
log.info("UnManaged Volumes found for this Host: {}", volumeNames);
if (storagePool != null) {
String maskType = getMaskTypeForHost(xtremIOClient, xioClusterName, igNameToInitiatorsMap, igNameToHostsMap, hostToIGNamesMap.get(host.getId()), volumeNames);
ArrayAffinityDiscoveryUtils.addPoolToPreferredPoolMap(preferredPoolMap, storagePool.getId().toString(), maskType);
}
} else {
log.info("No UnManaged Volumes found for this Host");
}
if (ArrayAffinityDiscoveryUtils.updatePreferredPools(host, Sets.newHashSet(system.getId().toString()), dbClient, preferredPoolMap)) {
hostsToUpdate.add(host);
}
}
}
if (!hostsToUpdate.isEmpty()) {
partitionManager.updateAndReIndexInBatches(hostsToUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, HOST);
}
}
use of com.emc.storageos.xtremio.restapi.XtremIOClient in project coprhd-controller by CoprHD.
the class XtremIOExportOperations method addInitiators.
@Override
public void addInitiators(StorageSystem storage, URI exportMaskURI, List<URI> volumeURIs, List<Initiator> initiators, List<URI> targets, TaskCompleter taskCompleter) throws DeviceControllerException {
_log.info("{} addInitiators START...", storage.getSerialNumber());
try {
_log.info("addInitiators: Export mask id: {}", exportMaskURI);
if (volumeURIs != null) {
_log.info("addInitiators: volumes : {}", Joiner.on(',').join(volumeURIs));
}
_log.info("addInitiators: initiators : {}", Joiner.on(',').join(initiators));
_log.info("addInitiators: targets : {}", Joiner.on(",").join(targets));
ExportOperationContext context = new XtremIOExportOperationContext();
// Prime the context object
taskCompleter.updateWorkflowStepContext(context);
ExportMask exportMask = dbClient.queryObject(ExportMask.class, exportMaskURI);
if (exportMask == null || exportMask.getInactive()) {
throw new DeviceControllerException("Invalid ExportMask URI: " + exportMaskURI);
}
XtremIOClient client = XtremIOProvUtils.getXtremIOClient(dbClient, storage, xtremioRestClientFactory);
String xioClusterName = client.getClusterDetails(storage.getSerialNumber()).getName();
List<Initiator> initiatorsToBeCreated = new ArrayList<Initiator>();
ArrayListMultimap<String, Initiator> initiatorToIGMap = XtremIOProvUtils.mapInitiatorToInitiatorGroup(storage.getSerialNumber(), initiators, initiatorsToBeCreated, xioClusterName, client);
XtremIOExportMaskVolumesValidator volumeValidator = (XtremIOExportMaskVolumesValidator) validator.addInitiators(storage, exportMask, volumeURIs);
volumeValidator.setIgNames(initiatorToIGMap.keySet());
volumeValidator.validate();
Map<URI, Integer> map = new HashMap<URI, Integer>();
for (URI volumeURI : volumeURIs) {
String hlu = exportMask.getVolumes().get(volumeURI.toString());
if (NullColumnValueGetter.isNotNullValue(hlu)) {
map.put(volumeURI, Integer.parseInt(hlu));
}
}
// to make it uniform , using these structures
VolumeURIHLU[] volumeLunArray = ControllerUtils.getVolumeURIHLUArray(storage.getSystemType(), map, dbClient);
runLunMapCreationAlgorithm(storage, exportMask, volumeLunArray, initiators, targets, client, xioClusterName, initiatorToIGMap, initiatorsToBeCreated, taskCompleter);
} catch (final Exception ex) {
_log.error("Problem in addInitiators: ", ex);
ServiceError serviceError = DeviceControllerErrors.xtremio.operationFailed("addInitiators", ex.getMessage());
taskCompleter.error(dbClient, serviceError);
}
_log.info("{} addInitiators END...", storage.getSerialNumber());
}
use of com.emc.storageos.xtremio.restapi.XtremIOClient in project coprhd-controller by CoprHD.
the class XtremIOStorageDevice method doResyncSnapshot.
@Override
public void doResyncSnapshot(StorageSystem storage, URI volume, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
_log.info("SnapShot resync..... Started");
List<BlockSnapshot> snapshots = dbClient.queryObject(BlockSnapshot.class, Arrays.asList(snapshot));
XtremIOClient client = XtremIOProvUtils.getXtremIOClient(dbClient, storage, xtremioRestClientFactory);
if (client.isVersion2() && ControllerUtils.checkSnapshotsInConsistencyGroup(snapshots, dbClient, taskCompleter)) {
snapshotOperations.resyncGroupSnapshots(storage, volume, snapshot, taskCompleter);
} else {
snapshotOperations.resyncSingleVolumeSnapshot(storage, volume, snapshot, taskCompleter);
}
_log.info("SnapShot resync..... End");
}
Aggregations