use of com.emc.storageos.xtremio.restapi.XtremIOClient in project coprhd-controller by CoprHD.
the class XtremIOCommunicationInterface method scan.
@Override
public void scan(AccessProfile accessProfile) throws BaseCollectionException {
_logger.info("Scanning started for provider: {}", accessProfile.getSystemId());
StorageProvider.ConnectionStatus cxnStatus = StorageProvider.ConnectionStatus.CONNECTED;
StorageProvider provider = _dbClient.queryObject(StorageProvider.class, accessProfile.getSystemId());
XtremIOClient xtremIOClient = null;
try {
xtremIOClient = (XtremIOClient) xtremioRestClientFactory.getXtremIOV1Client(URI.create(XtremIOConstants.getXIOBaseURI(accessProfile.getIpAddress(), accessProfile.getPortNumber())), accessProfile.getUserName(), accessProfile.getPassword(), true);
String xmsVersion = xtremIOClient.getXtremIOXMSVersion();
String minimumSupportedVersion = VersionChecker.getMinimumSupportedVersion(StorageSystem.Type.xtremio).replace("-", ".");
String compatibility = (VersionChecker.verifyVersionDetails(minimumSupportedVersion, xmsVersion) < 0) ? StorageSystem.CompatibilityStatus.INCOMPATIBLE.name() : StorageSystem.CompatibilityStatus.COMPATIBLE.name();
provider.setCompatibilityStatus(compatibility);
provider.setVersionString(xmsVersion);
String systemType = StorageSystem.Type.xtremio.name();
List<XtremIOSystem> xioSystems = xtremIOClient.getXtremIOSystemInfo();
_logger.info("Found {} clusters during scan of XMS {}", xioSystems.size(), accessProfile.getIpAddress());
Map<String, StorageSystemViewObject> storageSystemsCache = accessProfile.getCache();
for (XtremIOSystem system : xioSystems) {
String arrayNativeGUID = NativeGUIDGenerator.generateNativeGuid(DiscoveredDataObject.Type.xtremio.name(), system.getSerialNumber());
StorageSystemViewObject viewObject = storageSystemsCache.get(arrayNativeGUID);
if (viewObject == null) {
viewObject = new StorageSystemViewObject();
}
viewObject.setDeviceType(systemType);
viewObject.addprovider(accessProfile.getSystemId().toString());
viewObject.setProperty(StorageSystemViewObject.SERIAL_NUMBER, system.getSerialNumber());
viewObject.setProperty(StorageSystemViewObject.VERSION, system.getVersion());
viewObject.setProperty(StorageSystemViewObject.STORAGE_NAME, arrayNativeGUID);
storageSystemsCache.put(arrayNativeGUID, viewObject);
}
} catch (Exception ex) {
_logger.error("Error scanning XMS", ex);
cxnStatus = StorageProvider.ConnectionStatus.NOTCONNECTED;
// throw exception only if system discovery failed.
throw XtremIOApiException.exceptions.discoveryFailed(provider.toString());
} finally {
provider.setConnectionStatus(cxnStatus.name());
_dbClient.persistObject(provider);
if (xtremIOClient != null) {
xtremIOClient.close();
}
_logger.info("Completed scan of XtremIO StorageProvider. IP={}", accessProfile.getIpAddress());
}
}
use of com.emc.storageos.xtremio.restapi.XtremIOClient in project coprhd-controller by CoprHD.
the class XtremIOCommunicationInterface method discoverArrayAffinity.
@Override
public void discoverArrayAffinity(AccessProfile accessProfile) throws BaseCollectionException {
_logger.info("XtremIO Array Affinity discovery started for : {}", accessProfile.toString());
boolean errorOccurred = false;
StringBuilder errorStrBldr = new StringBuilder();
try {
XtremIOClient xtremIOClient = (XtremIOClient) xtremioRestClientFactory.getXtremIOV1Client(URI.create(XtremIOConstants.getXIOBaseURI(accessProfile.getIpAddress(), accessProfile.getPortNumber())), accessProfile.getUserName(), accessProfile.getPassword(), true);
List<XtremIOSystem> xioSystems = xtremIOClient.getXtremIOSystemInfo();
_logger.info("Found {} clusters for XMS {}", xioSystems.size(), accessProfile.getIpAddress());
for (XtremIOSystem xioSystem : xioSystems) {
try {
String sysNativeGuid = NativeGUIDGenerator.generateNativeGuid(DiscoveredDataObject.Type.xtremio.name(), xioSystem.getSerialNumber());
// check if system registered in ViPR
List<StorageSystem> systems = CustomQueryUtility.getActiveStorageSystemByNativeGuid(_dbClient, sysNativeGuid);
if (systems.isEmpty()) {
_logger.info("No Storage System found in database for {}, hence skipping..", sysNativeGuid);
continue;
}
StorageSystem system = systems.get(0);
// Host based array affinity discovery
if (accessProfile.getProps() != null && accessProfile.getProps().get(Constants.HOST_IDS) != null) {
String hostIdsStr = accessProfile.getProps().get(Constants.HOST_IDS);
_logger.info("Array Affinity Discovery started for Hosts {}, for XtremIO system {}", hostIdsStr, system.getNativeGuid());
String[] hostIds = hostIdsStr.split(Constants.ID_DELIMITER);
for (String hostId : hostIds) {
_logger.info("Processing Host {}", hostId);
Host host = _dbClient.queryObject(Host.class, URI.create(hostId));
if (host != null && !host.getInactive()) {
arrayAffinityDiscoverer.findAndUpdatePreferredPoolsForHost(system, host, _dbClient);
}
}
} else {
// Storage system based array affinity discovery
_logger.info("Array Affinity Discovery started for XtremIO system {}", system.getNativeGuid());
arrayAffinityDiscoverer.findAndUpdatePreferredPools(system, _dbClient, _partitionManager);
}
} catch (Exception ex) {
String errMsg = String.format("Error discovering Array Affinity for XtremIO system %s. Reason: %s", xioSystem.getSerialNumber(), ex.getMessage());
_logger.error(errMsg, ex);
errorOccurred = true;
errorStrBldr.append(errMsg);
}
}
} catch (Exception e) {
_logger.error("Error discovering Array Affinity for XtremIO Provider {}", accessProfile.getIpAddress(), e);
throw XtremIOApiException.exceptions.discoveryFailed(accessProfile.getIpAddress());
} finally {
if (errorOccurred) {
_logger.error("Array Affinity discovery for XtremIO Provider {} failed. {}", accessProfile.getIpAddress(), errorStrBldr.toString());
throw XtremIOApiException.exceptions.discoveryFailed(accessProfile.getIpAddress());
}
}
_logger.info("XtremIO Array Affinity discovery ended");
}
use of com.emc.storageos.xtremio.restapi.XtremIOClient in project coprhd-controller by CoprHD.
the class XtremIOMetricsCollector method collectMetrics.
/**
* Collect metrics.
*
* @param system the system
* @param dbClient the db client
* @throws Exception
*/
public void collectMetrics(StorageSystem system, DbClient dbClient) throws Exception {
log.info("Collecting statistics for XtremIO system {}", system.getNativeGuid());
XtremIOClient xtremIOClient = XtremIOProvUtils.getXtremIOClient(dbClient, system, xtremioRestClientFactory);
// Performance API is available from v2.0 onwards
if (!xtremIOClient.isVersion2()) {
throw XtremIOApiException.exceptions.meteringNotSupportedFor3xVersions();
}
String xtremIOClusterName = xtremIOClient.getClusterDetails(system.getSerialNumber()).getName();
// TODO Full support for Metering collection.
// Currently only the XEnv's CPU Utilization will be collected and
// used for resource placement to choose the best XtremIO Cluster.
// Reason for CPU over port metrics: Some port metrics like KBytesTransferred are not available for XtremIO.
// XtremIO team also suggested to consider CPU usage over IOPs, Bandwidth, Latency.
collectXEnvCPUUtilization(system, dbClient, xtremIOClient, xtremIOClusterName);
}
use of com.emc.storageos.xtremio.restapi.XtremIOClient in project coprhd-controller by CoprHD.
the class XtremIOExportMaskInitiatorsValidator method validate.
/**
* Get list of initiators associated with the IG.
*
* a. If there are unknown initiators in IG, fail the operation
* b. i) If Cluster export:
* - - - If there are additional initiators other than the ones in ExportMask:
* - - - check if all of them belong to different host but same cluster (Single IG with all cluster initiators)
* - ii) Host export: Check additional initiators belong to same host or different host
* - - -- If different host, fail the operation
*
* Reason for failing: We do not want to cause DU by choosing an operation when additional initiators
* are present in the IG. Better fail the operation explaining the situation instead of resulting in DU.
*/
@Override
public boolean validate() throws Exception {
log.info("Initiating initiators validation of XtremIO ExportMask: " + id);
try {
XtremIOClient client = XtremIOProvUtils.getXtremIOClient(getDbClient(), storage, getClientFactory());
String xioClusterName = client.getClusterDetails(storage.getSerialNumber()).getName();
if (knownInitiatorToIGMap == null) {
knownInitiatorToIGMap = ArrayListMultimap.create();
}
// Don't validate against backing masks or RP
if (ExportMaskUtils.isBackendExportMask(getDbClient(), exportMask)) {
log.info("validation against backing mask for VPLEX or RP is disabled.");
return true;
}
List<Initiator> knownInitiatorsInIGs = new ArrayList<Initiator>();
List<String> allInitiatorsInIGs = new ArrayList<String>();
List<XtremIOInitiator> initiators = client.getXtremIOInitiatorsInfo(xioClusterName);
for (XtremIOInitiator initiator : initiators) {
String igNameInInitiator = initiator.getInitiatorGroup().get(1);
if (initiatorToIGMap.keySet().contains(igNameInInitiator)) {
allInitiatorsInIGs.add(Initiator.normalizePort(initiator.getPortAddress()));
Initiator knownInitiator = NetworkUtil.getInitiator(initiator.getPortAddress(), getDbClient());
if (knownInitiator != null) {
knownInitiatorsInIGs.add(knownInitiator);
knownInitiatorToIGMap.put(igNameInInitiator, knownInitiator);
}
}
}
log.info("Initiators present in IG: {}", allInitiatorsInIGs);
// Fail the operation if there are unknown initiators in the IG (not registered in ViPR)
if (knownInitiatorsInIGs.size() < allInitiatorsInIGs.size()) {
Collection<String> knownInitiatorNames = Collections2.transform(knownInitiatorsInIGs, CommonTransformerFunctions.fctnInitiatorToPortName());
Set<String> differences = Sets.difference(Sets.newHashSet(allInitiatorsInIGs), Sets.newHashSet(knownInitiatorNames));
for (String diff : differences) {
getLogger().logDiff(exportMask.getId().toString(), "initiators", ValidatorLogger.NO_MATCHING_ENTRY, diff);
}
checkForErrors();
}
for (String igName : initiatorToIGMap.keySet()) {
List<Initiator> requestedInitiatorsInIG = initiatorToIGMap.get(igName);
List<Initiator> initiatorsInIG = knownInitiatorToIGMap.get(igName);
String hostName = null;
String clusterName = null;
for (Initiator initiator : requestedInitiatorsInIG) {
if (null != initiator.getHostName()) {
// initiators already grouped by Host
hostName = initiator.getHostName();
clusterName = initiator.getClusterName();
break;
}
}
Collection<String> knownInitiators = Collections2.transform(Lists.newArrayList(initiatorsInIG), CommonTransformerFunctions.fctnInitiatorToPortName());
Collection<String> requestedInitiators = Collections2.transform(requestedInitiatorsInIG, CommonTransformerFunctions.fctnInitiatorToPortName());
log.info("Validation requested initiators: {}", requestedInitiators);
log.info("Validation discovered initiators: {}", knownInitiators);
knownInitiators.removeAll(requestedInitiators);
log.info("Validation unknown initiators in IG: {}", knownInitiators);
if (!knownInitiators.isEmpty()) {
List<String> listToIgnore = new ArrayList<String>();
log.info("There are other initiators present in the IG - {}. Checking if they all belong to same host or different host but same cluster.", knownInitiators);
log.info("Host name: {}, Cluster name: {}", hostName, clusterName);
// check if the other initiators belong to different host
for (Initiator ini : initiatorsInIG) {
if (NullColumnValueGetter.isNotNullValue(clusterName) && ini.getHostName() != null && !ini.getHostName().equalsIgnoreCase(hostName)) {
// check if they belong to same cluster
if (ini.getClusterName() != null && clusterName != null && !clusterName.isEmpty() && ini.getClusterName().equalsIgnoreCase(clusterName)) {
listToIgnore.add(Initiator.normalizePort(ini.getInitiatorPort()));
}
} else if (ini.getHostName() != null && ini.getHostName().equalsIgnoreCase(hostName)) {
listToIgnore.add(Initiator.normalizePort(ini.getInitiatorPort()));
}
}
log.info("Validation initiators that belong to same host or cluster: {}", listToIgnore);
knownInitiators.removeAll(listToIgnore);
log.info("Validation remaining initiators that are not managed by controller: {}", knownInitiators);
for (String knownInitiator : knownInitiators) {
getLogger().logDiff(exportMask.getId().toString(), "initiators", ValidatorLogger.NO_MATCHING_ENTRY, knownInitiator);
}
}
}
} catch (Exception ex) {
log.error("Unexpected exception validating ExportMask initiators: " + ex.getMessage(), ex);
if (getConfig().isValidationEnabled()) {
throw DeviceControllerException.exceptions.unexpectedCondition("Unexpected exception validating ExportMask initiators: " + ex.getMessage());
}
}
checkForErrors();
log.info("Completed initiator validation of XtremIO ExportMask: " + id);
return true;
}
use of com.emc.storageos.xtremio.restapi.XtremIOClient in project coprhd-controller by CoprHD.
the class XtremIOStorageDevice method doDeleteConsistencyGroup.
@Override
public void doDeleteConsistencyGroup(StorageSystem storage, final URI consistencyGroupId, String replicationGroupName, Boolean keepRGName, Boolean markInactive, final TaskCompleter taskCompleter) throws DeviceControllerException {
_log.info("{} doDeleteConsistencyGroup START ...", storage.getSerialNumber());
ServiceError serviceError = null;
try {
// Check if the consistency group exists
BlockConsistencyGroup consistencyGroup = dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroupId);
URI systemURI = storage.getId();
if (consistencyGroup == null || consistencyGroup.getInactive()) {
_log.info(String.format("%s is inactive or deleted", consistencyGroupId));
return;
}
String groupName = replicationGroupName != null ? replicationGroupName : consistencyGroup.getLabel();
// This will be null, if consistencyGroup references no system CG's for storage.
if (groupName == null) {
_log.info(String.format("%s contains no system CG for %s. Assuming it has already been deleted.", consistencyGroupId, systemURI));
// Clean up the system consistency group references
BlockConsistencyGroupUtils.cleanUpCGAndUpdate(consistencyGroup, storage.getId(), groupName, markInactive, dbClient);
return;
}
XtremIOClient client = XtremIOProvUtils.getXtremIOClient(dbClient, storage, xtremioRestClientFactory);
// We still need throw exception for standard CG.
if (!client.isVersion2() && consistencyGroup.isProtectedCG()) {
StringSet cgTypes = consistencyGroup.getTypes();
cgTypes.remove(BlockConsistencyGroup.Types.LOCAL.name());
consistencyGroup.setTypes(cgTypes);
_log.info("{} Operation deleteConsistencyGroup not supported for the xtremio array version");
} else {
String clusterName = client.getClusterDetails(storage.getSerialNumber()).getName();
Project cgProject = dbClient.queryObject(Project.class, consistencyGroup.getProject());
XtremIOTag tagDetails = XtremIOProvUtils.isTagAvailableInArray(client, cgProject.getLabel(), XtremIOConstants.XTREMIO_ENTITY_TYPE.ConsistencyGroup.name(), clusterName);
// If the tag has no references, delete the tag completely
if (null != tagDetails && Integer.parseInt(tagDetails.getNumberOfDirectObjs()) == 0) {
_log.info("Deleting the CG tag {} as no references found.", cgProject.getLabel());
client.deleteTag(cgProject.getLabel(), XtremIOConstants.XTREMIO_ENTITY_TYPE.ConsistencyGroup.name(), clusterName);
} else if (null != tagDetails && Integer.parseInt(tagDetails.getNumberOfDirectObjs()) > 0) {
deleteEntityTag(client, cgProject.getLabel(), groupName, clusterName);
}
// Finally remove the CG.
if (null != XtremIOProvUtils.isCGAvailableInArray(client, groupName, clusterName)) {
client.removeConsistencyGroup(groupName, clusterName);
}
if (keepRGName) {
return;
}
// Clean up the system consistency group references
BlockConsistencyGroupUtils.cleanUpCG(consistencyGroup, storage.getId(), groupName, markInactive, dbClient);
}
dbClient.updateObject(consistencyGroup);
_log.info("{} doDeleteConsistencyGroup END ...", storage.getSerialNumber());
} catch (Exception e) {
_log.error(String.format("Delete Consistency Group operation failed %s", e));
serviceError = DeviceControllerException.errors.jobFailed(e);
} finally {
if (serviceError != null) {
taskCompleter.error(dbClient, serviceError);
} else {
taskCompleter.ready(dbClient);
}
}
}
Aggregations