hybrid logging
[ta/cm-plugins.git] / recuserconfighandlers / reccaashandler / reccaashandler.py
1 #! /usr/bin/python
2 # Copyright 2019 Nokia
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #    http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 from cmframework.apis import cmuserconfig
17 from cmframework.apis import cmerror
18 from cmdatahandlers.api import configerror
19
20 """
21 This plugin is used to handle REC specific infra logging configs. Currently
22 its sole purpose is to set the default plugin (elasticsearch) for internal logging.
23 """
24
25
26 class reccaashandler(cmuserconfig.CMUserConfigPlugin):
27
28     def __init__(self):
29         super(reccaashandler, self).__init__()
30
31     def handle(self, confman):
32         try:
33             self._set_default_infra_log_store(confman)
34         except configerror.ConfigError as exp:
35             raise cmerror.CMError(str(exp))
36
37     @staticmethod
38     def _set_default_infra_log_store(confman):
39         root = 'cloud.caas'
40         log_conf = confman.get_caas_handler()
41         if not log_conf.get_caas_parameter('infra_log_store'):
42             log_conf.config[root]['infra_log_store'] = 'elasticsearch'