Repository: RedHatInsights/insights-core

Issue:
SMDA* is not business SAP instances
~~~
# cat insights_commands/usr.sap.hostctrl.exe.saphostctrl_-function_GetCIMObject_-enuminstances_SAPInstance
*********************************************************
 CreationClassName , String , SAPInstance
 SID , String , SMA
 SystemNumber , String , 98
 InstanceName , String , SMDA98
 Hostname , String , li-ld-1846
 FullQualifiedHostname , String , li-ld-1846.hag.hilti.com
 SapVersionInfo , String , 749, patch 200, changelist 1746260
~~~

From Rolf:
> the reported instance SMDA98 is the Solution Manager agent, which the customer wants use to monitor that system [1]. With newer systems, that can alternatively also be the diagnostic agent (instance name DAA*98).
* here is a typo, DAA should be SID name


Discussion:

Resolving patch:
diff --git a/insights/combiners/sap.py b/insights/combiners/sap.py
--- a/insights/combiners/sap.py
+++ b/insights/combiners/sap.py
@@ -52,6 +52,8 @@ class Sap(LegacyItemAccess):
         'lu0417'
         >>> 'D22' in saps.local_instances
         False
+        >>> len(saps.business_instances)
+        2
         >>> saps.is_hana
         True
         >>> saps.is_netweaver
@@ -60,14 +62,19 @@ class Sap(LegacyItemAccess):
         False
 
     Attributes:
-        all_instances (list): List all the SAP instances listed by the command.
-        local_instances (list): List SAP instances which are running on the system.
+        all_instances (list): List of all the SAP instances listed by the command.
+        local_instances (list): List of SAP instances which are running on the system.
+        function_instances (list): List of function SAP instances running on the system.
+                                   E.g. Diagnostics Agents SMDA97/SMDA98
+        business_instances (list): List of business SAP instances running on the system.
+                                   E.g. HANA, NetWeaver, ASCS, or others
     """
-
     def __init__(self, hostname, insts, lssap):
         hn = hostname.hostname
         self.data = {}
         self.local_instances = []
+        self.business_instances = []
+        self.function_instances = []
         self.all_instances = []
         self._types = set()
         if insts:
@@ -100,6 +107,10 @@ def __init__(self, hostname, insts, lssap):
         else:
             raise SkipException('No SAP instance.')
 
+        FUNC_INSTS = ('SMDA')
+        for i in self.local_instances:
+            (self.function_instances if i.startswith(FUNC_INSTS) else self.business_instances).append(i)
+
     def version(self, instance):
         """str: Returns the version of the ``instance``."""
         return self.data[instance].version if instance in self.data else None
@@ -122,7 +133,7 @@ def number(self, instance):
 
     @property
     def is_netweaver(self):
-        """bool: SAP Netweaver is running on the system."""
+        """bool: SAP NetWeaver is running on the system."""
         return 'D' in self._types
 
     @property


Test patch:
diff --git a/insights/combiners/tests/test_sap.py b/insights/combiners/tests/test_sap.py
--- a/insights/combiners/tests/test_sap.py
+++ b/insights/combiners/tests/test_sap.py
@@ -1,11 +1,11 @@
-from ...parsers.hostname import Hostname
-from ...parsers import SkipException
-from ...parsers.lssap import Lssap
-from ...parsers.saphostctrl import SAPHostCtrlInstances
-from ...combiners import sap
-from ...combiners.sap import Sap
-from ...combiners.hostname import hostname
-from ...tests import context_wrap
+from insights.parsers.hostname import Hostname
+from insights.parsers import SkipException
+from insights.parsers.lssap import Lssap
+from insights.parsers.saphostctrl import SAPHostCtrlInstances
+from insights.combiners import sap
+from insights.combiners.sap import Sap
+from insights.combiners.hostname import hostname
+from insights.tests import context_wrap
 import pytest
 import doctest
 
@@ -214,6 +214,8 @@ def test_saphostcrtl_hana_2():
     sap = Sap(hn, inst, lssap)
     assert 'D50' not in sap
     assert sorted(sap.local_instances) == sorted(['HDB88', 'HDB90', 'SMDA91'])
+    assert sorted(sap.business_instances) == sorted(['HDB88', 'HDB90'])
+    assert sorted(sap.function_instances) == sorted(['SMDA91'])
     assert 'ASCS52' in sap.all_instances
     assert sap['HDB88'].number == '88'
     assert sap['HDB90'].hostname == 'li-ld-1810'