diff --git a/insights/parsers/saphostctrl.py b/insights/parsers/saphostctrl.py index d628eba81..66c41fd67 100644 --- a/insights/parsers/saphostctrl.py +++ b/insights/parsers/saphostctrl.py @@ -108,8 +108,12 @@ def parse_content(self, content): inst[fields[0]] = fields[2] if fields[0] == 'InstanceName': + short_type = fields[2].strip('0123456789') + # Back forward compatible: a short InstanceType was from the InstanceName + if 'InstanceType' not in inst: + inst.update(dict(InstanceType=short_type)) self.instances.append(fields[2]) - _types.add(fields[2].strip('0123456789')) + _types.add(short_type) _sids.add(fields[2]) if fields[0] == 'SID' else None if len(self) < 1: diff --git a/insights/tests/parsers/test_saphostctrl.py b/insights/tests/parsers/test_saphostctrl.py index 3dfe629a6..bd0a6859e 100644 --- a/insights/tests/parsers/test_saphostctrl.py +++ b/insights/tests/parsers/test_saphostctrl.py @@ -25,6 +25,28 @@ SapVersionInfo , String , 749, patch 211, changelist 1754007 ''' +SAPHOSTCTRL_HOSTINSTANCES_DOCS_OLD = ''' +********************************************************* + CreationClassName , String , SAPInstance + SID , String , D89 + SystemNumber , String , 88 + InstanceType , String , HANA Test + InstanceName , String , HDB88 + Hostname , String , lu0417 + FullQualifiedHostname , String , lu0417.example.com + IPAddress , String , 10.0.0.88 + SapVersionInfo , String , 749, patch 211, changelist 1754007 +********************************************************* + CreationClassName , String , SAPInstance + SID , String , D90 + SystemNumber , String , 90 + InstanceName , String , HDB90 + Hostname , String , lu0418 + FullQualifiedHostname , String , lu0418.example.com + IPAddress , String , 10.0.0.90 + SapVersionInfo , String , 749, patch 211, changelist 1754007 +''' + SAPHOSTCTRL_HOSTINSTANCES_GOOD = ''' ********************************************************* SID , String , D89 @@ -157,6 +179,13 @@ def test_saphostctrl(): ]) +def test_saphostctrl_old(): + sap = SAPHostCtrlInstances(context_wrap(SAPHOSTCTRL_HOSTINSTANCES_DOCS_OLD)) + assert sap.types == ['HDB'] # short types only + assert sap[0]['InstanceType'] == 'HANA Test' + assert sap[1]['InstanceType'] == 'HDB' + + def test_saphostctrl_bad(): with pytest.raises(SkipException): SAPHostCtrlInstances(context_wrap(''))