FIX: Set default IPMI privilege level
[ta/cm-plugins.git] / recuserconfighandlers / rechosthandler / rechosthandler.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 host configs, including
22 setting default middleware reserved memory and populating default
23 IPMI privileges.
24 """
25
26
27 class rechosthandler(cmuserconfig.CMUserConfigPlugin):
28     default_middleware_reserved_memory = '4Gi'
29     default_ipmi_priv_level = 'ADMINISTRATOR'
30     
31     def __init__(self):
32         super(rechosthandler, self).__init__()
33
34     def handle(self, confman):
35         hostconf = confman.get_hosts_config_handler()
36         self._set_default_memory(hostconf)
37         self._set_default_ipmi_priv(hostconf)
38
39     def _set_default_memory(self, hostconf):
40         hostconf.set_default_reserved_memory_to_all_hosts(self.default_middleware_reserved_memory)
41
42     def _set_default_ipmi_priv(self, hostconf):
43         hostconf.set_default_ipmi_priv_level_to_all_hosts(self.default_ipmi_priv_level)