Remove unused methods in alarm manager

Below unused methods are removed -
1. _determine_version_cap definition is unused and there are no
   references to it in the code
2. 'summary' uses invalid decorator -
   @index.when(method='summary', template='json').
3. _get_alarm_summary method was only used by 'summary'
   method which is removed

Test plan:
1. Pass: Run UT coverage with this change.
         Coverage improved from 73% to 97%.
2. Pass: Run 'dcmanager alarm summary' command.
         There is no functional impact.

Story: 2007082
Task: 49564

Change-Id: I552d62a4c160ea52a1d17167d095d569786d254f
Signed-off-by: Susendra Selvaraj <susendra.selvaraj@windriver.com>
This commit is contained in:
Susendra Selvaraj 2024-02-12 01:22:07 -05:00
parent bff2f0aa2f
commit 7a6bdbd8eb

View File

@ -21,7 +21,6 @@ from pecan import expose
from dcmanager.api.controllers import restcomm
from dcmanager.api.policies import alarm_manager as alarm_manager_policy
from dcmanager.api import policy
from dcmanager.common import consts
from dcmanager.db import api as db_api
LOG = logging.getLogger(__name__)
@ -35,11 +34,6 @@ class SubcloudAlarmController(object):
def __init__(self, *args, **kwargs):
super(SubcloudAlarmController, self).__init__(*args, **kwargs)
# to do the version compatibility for future purpose
def _determine_version_cap(self, target):
version_cap = 1.0
return version_cap
@expose(generic=True, template='json')
def index(self):
# Route the request to specific methods with parameters
@ -68,21 +62,3 @@ class SubcloudAlarmController(object):
policy.authorize(alarm_manager_policy.POLICY_ROOT % "get", {},
restcomm.extract_credentials_for_policy())
return self._get_alarm_aggregates()
def _get_alarm_summary(self):
alarms = self._get_alarm_aggregates()
summary = {consts.ALARM_CRITICAL_STATUS: 0,
consts.ALARM_DEGRADED_STATUS: 0,
consts.ALARM_OK_STATUS: 0}
for alarm in alarms['alarm_summary']:
summary[alarm['cloud_status']] += 1
return summary
@index.when(method='summary', template='json')
def summary(self):
"""Get an agregate of all subcloud status
"""
policy.authorize(alarm_manager_policy.POLICY_ROOT % "get", {},
restcomm.extract_credentials_for_policy())
return self._get_alarm_summary()