use of com.emc.storageos.xtremio.restapi.XtremIOClient in project coprhd-controller by CoprHD.
the class XtremIOExportOperations method createExportMask.
@Override
public void createExportMask(StorageSystem storage, URI exportMaskURI, VolumeURIHLU[] volumeURIHLUs, List<URI> targetURIList, List<Initiator> initiatorList, TaskCompleter taskCompleter) throws DeviceControllerException {
_log.info("{} createExportMask START...", storage.getSerialNumber());
try {
_log.info("createExportMask: Export mask id: {}", exportMaskURI);
_log.info("createExportMask: volume-HLU pairs: {}", Joiner.on(',').join(volumeURIHLUs));
_log.info("createExportMask: initiators: {}", Joiner.on(',').join(initiatorList));
_log.info("createExportMask: assignments: {}", Joiner.on(',').join(targetURIList));
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(), initiatorList, initiatorsToBeCreated, xioClusterName, client);
runLunMapCreationAlgorithm(storage, exportMask, volumeURIHLUs, initiatorList, targetURIList, client, xioClusterName, initiatorToIGMap, initiatorsToBeCreated, taskCompleter);
} catch (final Exception ex) {
_log.error("Problem in createExportMask: ", ex);
ServiceError serviceError = DeviceControllerErrors.xtremio.operationFailed("createExportMask", ex.getMessage());
taskCompleter.error(dbClient, serviceError);
}
_log.info("{} createExportMask END...", storage.getSerialNumber());
}
use of com.emc.storageos.xtremio.restapi.XtremIOClient in project coprhd-controller by CoprHD.
the class XtremIOProvUtils method refreshXtremeIOConnections.
/**
* Refresh the XIO Providers & its client connections.
*
* @param xioProviderList
* the XIO provider list
* @param dbClient
* the db client
* @return the list of active providers
*/
public static List<URI> refreshXtremeIOConnections(final List<StorageProvider> xioProviderList, DbClient dbClient, XtremIOClientFactory xtremioRestClientFactory) {
List<URI> activeProviders = new ArrayList<URI>();
for (StorageProvider provider : xioProviderList) {
try {
// For providers without version/model, let it try connecting V1 client to update connection status
XtremIOClient xioClient = (XtremIOClient) xtremioRestClientFactory.getRESTClient(URI.create(XtremIOConstants.getXIOBaseURI(provider.getIPAddress(), provider.getPortNumber())), provider.getUserName(), provider.getPassword(), provider.getVersionString(), true);
if (null != xioClient.getXtremIOXMSVersion()) {
// Now update provider status based on connection live check.
provider.setConnectionStatus(StorageProvider.ConnectionStatus.CONNECTED.toString());
activeProviders.add(provider.getId());
} else {
_log.info("XIO Connection is not active {}", provider.getProviderID());
provider.setConnectionStatus(StorageProvider.ConnectionStatus.NOTCONNECTED.toString());
}
} catch (Exception ex) {
_log.error("Exception occurred while validating XIO client for {}", provider.getProviderID(), ex);
provider.setConnectionStatus(StorageProvider.ConnectionStatus.NOTCONNECTED.toString());
} finally {
dbClient.updateObject(provider);
}
}
return activeProviders;
}
use of com.emc.storageos.xtremio.restapi.XtremIOClient in project coprhd-controller by CoprHD.
the class XtremIOExportMaskVolumesValidator method validate.
@Override
public boolean validate() throws Exception {
log.info("Initiating volume validation of XtremIO ExportMask: " + id);
try {
XtremIOClient client = XtremIOProvUtils.getXtremIOClient(getDbClient(), storage, getClientFactory());
String xioClusterName = client.getClusterDetails(storage.getSerialNumber()).getName();
Set<String> knownVolumes = new HashSet<>();
Set<String> igVols = new HashSet<>();
// get the volumes in the IGs and validate against passed impacted block objects
for (BlockObject maskVolume : blockObjects) {
knownVolumes.add(maskVolume.getDeviceLabel());
}
List<XtremIOVolume> igVolumes = new ArrayList<>();
boolean bulkApiCallFlag = Boolean.valueOf(ControllerUtils.getPropertyValueFromCoordinator(getCoordinatorClient(), XTREMIO_BULK_API_CALL));
Map<String, List<XtremIOVolume>> igNameToVolumesMap = new HashMap<>();
Set<String> igNameSet = new HashSet<>(igNames);
if (client.isVersion2() && XtremIOProvUtils.isBulkAPISupported(storage.getFirmwareVersion(), client) && bulkApiCallFlag) {
if (!igNameSet.isEmpty())
igNameToVolumesMap = XtremIOProvUtils.getLunMapAndVolumes(igNameSet, xioClusterName, client, igNameToVolumesMap);
for (Map.Entry<String, List<XtremIOVolume>> entry : igNameToVolumesMap.entrySet()) {
igVolumes.addAll(entry.getValue());
}
} else {
for (String igName : igNames) {
igVolumes.addAll(XtremIOProvUtils.getInitiatorGroupVolumes(igName, xioClusterName, client));
}
}
for (XtremIOVolume igVolume : igVolumes) {
igVols.add(igVolume.getVolInfo().get(1));
}
log.info("ViPR known volumes present in IG: {}, volumes in IG: {}", knownVolumes, igVols);
igVols.removeAll(knownVolumes);
for (String igVol : igVols) {
getLogger().logDiff(id, "volumes", ValidatorLogger.NO_MATCHING_ENTRY, igVol);
}
} catch (Exception ex) {
log.error("Unexpected exception validating ExportMask volumes: " + ex.getMessage(), ex);
if (getConfig().isValidationEnabled()) {
throw DeviceControllerException.exceptions.unexpectedCondition("Unexpected exception validating ExportMask volumes: " + ex.getMessage());
}
}
checkForErrors();
log.info("Completed volume validation of XtremIO ExportMask: " + id);
return true;
}
use of com.emc.storageos.xtremio.restapi.XtremIOClient in project coprhd-controller by CoprHD.
the class XtremIOCommunicationInterface method discover.
@Override
public void discover(AccessProfile accessProfile) throws BaseCollectionException {
_logger.info("Entered XtremIO {} -->{}", accessProfile.toString());
if (null != accessProfile.getnamespace() && (accessProfile.getnamespace().equals(StorageSystem.Discovery_Namespaces.UNMANAGED_VOLUMES.toString()))) {
discoverUnManagedVolumes(accessProfile);
} else {
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
XtremIOClient xtremIOClient = (XtremIOClient) xtremioRestClientFactory.getRESTClient(URI.create(XtremIOConstants.getXIOBaseURI(accessProfile.getIpAddress(), accessProfile.getPortNumber())), accessProfile.getUserName(), accessProfile.getPassword(), XtremIOProvUtils.getXtremIOVersion(_dbClient, storageSystem), true);
_logger.info("Discovery started for system {}", accessProfile.getSystemId());
discoverXtremIOSystem(xtremIOClient, storageSystem);
}
}
use of com.emc.storageos.xtremio.restapi.XtremIOClient 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 = 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.resyncSnapshotFailureSourceSizeMismatch(restoreFailureMsg);
}
} else {
serviceError = DeviceControllerException.errors.jobFailed(e);
}
taskCompleter.error(dbClient, serviceError);
}
}
Aggregations