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

17 statements  

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

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

2# Copyright (c) 2016 b<>com 

3# 

4# Authors: Vincent FRANCOISE <vincent.francoise@b-com.com> 

5# 

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

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

8# You may obtain a copy of the License at 

9# 

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

11# 

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

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

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

15# implied. 

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

17# limitations under the License. 

18 

19from oslo_reports import guru_meditation_report as gmr 

20 

21from watcher._i18n import _ 

22from watcher.decision_engine.model.collector import manager 

23 

24 

25def register_gmr_plugins(): 

26 """Register GMR plugins that are specific to watcher-decision-engine.""" 

27 gmr.TextGuruMeditation.register_section(_('CDMCs'), show_models) 

28 

29 

30def show_models(): 

31 """Create a formatted output of all the CDMs 

32 

33 Mainly used as a Guru Meditation Report (GMR) plugin 

34 """ 

35 mgr = manager.CollectorManager() 

36 

37 output = [] 

38 for name, cdmc in mgr.get_collectors().items(): 

39 output.append("") 

40 output.append("~" * len(name)) 

41 output.append(name) 

42 output.append("~" * len(name)) 

43 output.append("") 

44 

45 cdmc_struct = cdmc.cluster_data_model.to_string() 

46 output.append(cdmc_struct) 

47 

48 return "\n".join(output)