Coverage for watcher/decision_engine/manager.py: 100%

32 statements  

« prev     ^ index     » next       coverage.py v7.8.2, created at 2025-06-17 12:22 +0000

1# -*- encoding: utf-8 -*- 

2# Copyright (c) 2015 b<>com 

3# Copyright (c) 2016 Intel Corp 

4# 

5# Authors: Jean-Emile DARTOIS <jean-emile.dartois@b-com.com> 

6# 

7# Licensed under the Apache License, Version 2.0 (the "License"); 

8# you may not use this file except in compliance with the License. 

9# You may obtain a copy of the License at 

10# 

11# http://www.apache.org/licenses/LICENSE-2.0 

12# 

13# Unless required by applicable law or agreed to in writing, software 

14# distributed under the License is distributed on an "AS IS" BASIS, 

15# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 

16# implied. 

17# See the License for the specific language governing permissions and 

18# limitations under the License. 

19 

20""" 

21This component is responsible for computing a set of potential optimization 

22:ref:`Actions <action_definition>` in order to fulfill the 

23:ref:`Goal <goal_definition>` of an :ref:`Audit <audit_definition>`. 

24 

25It first reads the parameters of the :ref:`Audit <audit_definition>` from the 

26associated :ref:`Audit Template <audit_template_definition>` and knows the 

27:ref:`Goal <goal_definition>` to achieve. 

28 

29It then selects the most appropriate :ref:`Strategy <strategy_definition>` 

30depending on how Watcher was configured for this :ref:`Goal <goal_definition>`. 

31 

32The :ref:`Strategy <strategy_definition>` is then executed and generates a set 

33of :ref:`Actions <action_definition>` which are scheduled in time by the 

34:ref:`Watcher Planner <watcher_planner_definition>` (i.e., it generates an 

35:ref:`Action Plan <action_plan_definition>`). 

36 

37See :doc:`../architecture` for more details on this component. 

38""" 

39 

40from watcher.common import service_manager 

41from watcher import conf 

42from watcher.decision_engine.messaging import audit_endpoint 

43from watcher.decision_engine.messaging import data_model_endpoint 

44from watcher.decision_engine.model.collector import manager 

45from watcher.decision_engine.strategy.strategies import base \ 

46 as strategy_endpoint 

47 

48CONF = conf.CONF 

49 

50 

51class DecisionEngineManager(service_manager.ServiceManager): 

52 

53 @property 

54 def service_name(self): 

55 return 'watcher-decision-engine' 

56 

57 @property 

58 def api_version(self): 

59 return '1.0' 

60 

61 @property 

62 def publisher_id(self): 

63 return CONF.watcher_decision_engine.publisher_id 

64 

65 @property 

66 def conductor_topic(self): 

67 return CONF.watcher_decision_engine.conductor_topic 

68 

69 @property 

70 def notification_topics(self): 

71 return CONF.watcher_decision_engine.notification_topics 

72 

73 @property 

74 def conductor_endpoints(self): 

75 return [audit_endpoint.AuditEndpoint, 

76 strategy_endpoint.StrategyEndpoint, 

77 data_model_endpoint.DataModelEndpoint] 

78 

79 @property 

80 def notification_endpoints(self): 

81 return self.collector_manager.get_notification_endpoints() 

82 

83 @property 

84 def collector_manager(self): 

85 return manager.CollectorManager()