generate_config.py 2.6 KB
Newer Older
R
Rongfeng Fu 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
# coding: utf-8
# OceanBase Deploy.
# Copyright (C) 2021 OceanBase
#
# This file is part of OceanBase Deploy.
#
# OceanBase Deploy is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OceanBase Deploy is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OceanBase Deploy.  If not, see <https://www.gnu.org/licenses/>.


from __future__ import absolute_import, division, print_function


R
Rongfeng Fu 已提交
24 25 26 27
def generate_config(plugin_context, generate_config_mini=False, auto_depend=False, return_generate_keys=False, *args, **kwargs):
    if return_generate_keys:
        return plugin_context.return_true(generate_keys=['skip_proxy_sys_private_check', 'enable_strict_kernel_release', 'enable_cluster_checkout', 'proxy_mem_limited'])

R
Rongfeng Fu 已提交
28 29
    cluster_config = plugin_context.cluster_config
    stdio = plugin_context.stdio
R
Rongfeng Fu 已提交
30 31
    generate_configs = {'global': {}}
    plugin_context.set_variable('generate_configs', generate_configs)
R
Rongfeng Fu 已提交
32 33
    stdio.start_loading('Generate obproxy configuration')

R
Rongfeng Fu 已提交
34 35
    global_config = cluster_config.get_original_global_conf()
    if 'skip_proxy_sys_private_check' not in global_config:
R
Rongfeng Fu 已提交
36
        generate_configs['global']['skip_proxy_sys_private_check'] = True
R
Rongfeng Fu 已提交
37
        cluster_config.update_global_conf('skip_proxy_sys_private_check', True, False)
R
Rongfeng Fu 已提交
38

R
Rongfeng Fu 已提交
39
    if 'enable_strict_kernel_release' not in global_config:
R
Rongfeng Fu 已提交
40
        generate_configs['global']['enable_strict_kernel_release'] = False
R
Rongfeng Fu 已提交
41
        cluster_config.update_global_conf('enable_strict_kernel_release', False, False)
R
Rongfeng Fu 已提交
42 43 44 45

    if 'enable_cluster_checkout' not in global_config:
        generate_configs['global']['enable_cluster_checkout'] = False
        cluster_config.update_global_conf('enable_cluster_checkout', False, False)
F
v1.6.0  
frf12 已提交
46
    
R
Rongfeng Fu 已提交
47
    if generate_config_mini:
F
v1.6.0  
frf12 已提交
48
        if 'proxy_mem_limited' not in global_config:
R
Rongfeng Fu 已提交
49
            generate_configs['global']['proxy_mem_limited'] = '500M'
R
Rongfeng Fu 已提交
50
            cluster_config.update_global_conf('proxy_mem_limited', '500M', False)
R
Rongfeng Fu 已提交
51

F
v1.6.0  
frf12 已提交
52 53 54 55 56
    if auto_depend:
        for depend in ['oceanbase', 'oceanbase-ce']:
            if cluster_config.add_depend_component(depend):
                stdio.stop_loading('succeed')
                return plugin_context.return_true()
R
Rongfeng Fu 已提交
57

R
Rongfeng Fu 已提交
58 59
    stdio.stop_loading('succeed')
    return plugin_context.return_true()