forked from Seagate/cortx-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EOS-27348: replace use of CortxConf class to MappedConf (Seagate#716)
* EOS-27348: Remove CortxConf Signed-off-by: Rohit Dwivedi <[email protected]> * renamed variable from cluster_conf_mapped to cluster_conf Signed-off-by: Rohit Dwivedi <[email protected]> Co-authored-by: Sachin Punadikar <[email protected]> Signed-off-by: suryakumar.kumaravelan <[email protected]>
- Loading branch information
1 parent
745af13
commit c37b3ea
Showing
10 changed files
with
72 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
# For any questions about this software or licensing, | ||
# please email [email protected] or [email protected]. | ||
|
||
CLUSTER_CONF = 'yaml:///etc/cortx/cluster.conf' | ||
CORTX_HA_INSTALL_PATH = "/etc/cortx/ha/" | ||
RULES_FILE_PATH = "rules_engine_schema.json" | ||
CONF_FILE_PATH = "decision_monitor_conf.json" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,23 +15,23 @@ | |
# For any questions about this software or licensing, | ||
# please email [email protected] or [email protected]. | ||
|
||
import errno | ||
import os | ||
import psutil | ||
import re | ||
import time | ||
import errno | ||
import psutil | ||
from datetime import datetime | ||
|
||
from cortx.utils import const | ||
from cortx.utils.conf_store import MappedConf | ||
from cortx.utils.kv_store import KvStoreFactory | ||
from cortx.utils.discovery.error import DiscoveryError | ||
from cortx.utils.discovery.resource import Resource, ResourceFactory | ||
from cortx.utils.kv_store import KvStoreFactory | ||
from cortx.utils.common import CortxConf | ||
|
||
# Load cortx common config | ||
store_type = "json" | ||
CortxConf.init(cluster_conf='yaml:///etc/cortx/cluster.conf') | ||
local_storage_path = CortxConf.get_storage_path('local') | ||
cluster_conf = MappedConf(const.CLUSTER_CONF) | ||
local_storage_path = cluster_conf.get('cortx>common>storage>local') | ||
config_url = "%s://%s" % (store_type, os.path.join(local_storage_path, 'utils/conf/cortx.conf')) | ||
common_config = KvStoreFactory.get_instance(config_url) | ||
common_config.load() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,16 +14,18 @@ | |
# For any questions about this software or licensing, | ||
# please email [email protected] or [email protected]. | ||
|
||
import os | ||
import sys | ||
import errno | ||
import argparse | ||
import inspect | ||
import traceback | ||
|
||
from cortx.utils.log import Log | ||
from cortx.utils.common import CortxConf | ||
from cortx.utils.conf_store import Conf | ||
from cortx.utils.setup.kafka import Kafka | ||
from cortx.utils.const import CLUSTER_CONF | ||
from cortx.utils.conf_store import MappedConf | ||
from cortx.utils.setup.kafka import KafkaSetupError | ||
|
||
|
||
|
@@ -85,7 +87,7 @@ def add_args(parser: str, cls: str, name: str): | |
parser1 = parser.add_parser(cls.name, help='setup %s' % name) | ||
parser1.add_argument('--config', help='Conf Store URL', type=str) | ||
parser1.add_argument('--cluster_conf', help='cluster.conf url', | ||
type=str, default='yaml:///etc/cortx/cluster.conf') | ||
type=str, default=CLUSTER_CONF) | ||
cls._add_extended_args(parser1) | ||
parser1.add_argument('args', nargs='*', default=[], help='args') | ||
parser1.set_defaults(command=cls) | ||
|
@@ -205,10 +207,11 @@ def main(argv: dict): | |
Conf.load(kafka_config, command.url) | ||
kafka_servers = Conf.get(kafka_config, 'cortx>software>kafka>servers') | ||
# Get log path and initialise Log | ||
CortxConf.init(cluster_conf=command.cluster_conf) | ||
log_dir = CortxConf.get_storage_path('log') | ||
log_path = CortxConf.get_log_path(base_dir=log_dir) | ||
log_level = CortxConf.get('utils>log_level', 'INFO') | ||
cluster_conf = MappedConf(command.cluster_conf) | ||
log_dir = cluster_conf.get('cortx>common>storage>log') | ||
log_dir = log_dir if log_dir else cluster_conf.get('log_dir') | ||
log_path = os.path.join(log_dir, f'utils/{Conf.machine_id}') | ||
log_level = cluster_conf.get('utils>log_level', 'INFO') | ||
Log.init('kafka_setup', log_path, level=log_level, backup_count=5, \ | ||
file_size_in_mb=5) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,16 +16,17 @@ | |
# please email [email protected] or [email protected]. | ||
|
||
import os | ||
import asyncio | ||
import shutil | ||
from datetime import datetime | ||
import asyncio | ||
from typing import List | ||
from cortx.utils.schema.payload import Yaml, Tar | ||
from cortx.utils.support_framework import const | ||
from datetime import datetime | ||
|
||
from cortx.utils.log import Log | ||
from cortx.utils.process import SimpleProcess | ||
from cortx.utils.conf_store import MappedConf | ||
from cortx.utils.support_framework import const | ||
from cortx.utils.schema.payload import Yaml, Tar | ||
from cortx.utils.conf_store.conf_store import Conf | ||
from cortx.utils.log import Log | ||
from cortx.utils.common import CortxConf | ||
|
||
ERROR = 'error' | ||
INFO = 'info' | ||
|
@@ -97,7 +98,7 @@ async def _exc_components_cmd(commands: List, bundle_id: str, path: str, \ | |
for command in commands: | ||
# SB Framework will not parse additional filters until all the components | ||
# accept filters in their respective support bundle scripts. | ||
|
||
# Log.info(f"Executing command -> {command} -b {bundle_id} -t {path}" | ||
# f" -c {config_url} -s {services} --duration {duration}" | ||
# f" --size_limit {size_limit} --binlogs {binlogs}" | ||
|
@@ -106,7 +107,7 @@ async def _exc_components_cmd(commands: List, bundle_id: str, path: str, \ | |
# cmd_proc = SimpleProcess(f"{command} -b {bundle_id} -t {path} -c {config_url}" | ||
# f" -s {services} --duration {duration} --size_limit {size_limit}" | ||
# f" --binlogs {binlogs} --coredumps {coredumps} --stacktrace {stacktrace}") | ||
|
||
Log.info(f"Executing command -> {command} -b {bundle_id} -t {path}" | ||
f" -c {config_url} -s {services}") | ||
|
||
|
@@ -128,9 +129,10 @@ async def init(bundle_obj, node_id, config_url, **kwargs): | |
command: cli Command Object :type: command | ||
return: None | ||
""" | ||
CortxConf.init(cluster_conf=config_url) | ||
log_path = CortxConf.get_log_path('support') | ||
log_level = CortxConf.get('utils>log_level', 'INFO') | ||
cluster_conf = MappedConf(config_url) | ||
log_path = os.path.join(cluster_conf.get('log_dir'), \ | ||
f'utils/{Conf.machine_id}/support') | ||
log_level = cluster_conf.get('utils>log_level', 'INFO') | ||
Log.init('support_bundle_node', log_path, level=log_level, \ | ||
backup_count=5, file_size_in_mb=5) | ||
bundle_id = bundle_obj.bundle_id | ||
|
@@ -150,7 +152,7 @@ async def init(bundle_obj, node_id, config_url, **kwargs): | |
f"{node_name}, {const.SB_COMMENT}: {comment}, " | ||
f"{const.SB_COMPONENTS}: {components_list}, {const.SOS_COMP}")) | ||
# Read support_bundle.Yaml and Check's If It Exists. | ||
cmd_setup_file = os.path.join(CortxConf.get('install_path'),\ | ||
cmd_setup_file = os.path.join(cluster_conf.get('install_path'),\ | ||
const.SUPPORT_YAML) | ||
try: | ||
support_bundle_config = Yaml(cmd_setup_file).load() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,15 +15,17 @@ | |
# For any questions about this software or licensing, | ||
# please email [email protected] or [email protected]. | ||
|
||
import argparse | ||
import os | ||
import errno | ||
from argparse import RawTextHelpFormatter | ||
import argparse | ||
from aiohttp import web | ||
from argparse import RawTextHelpFormatter | ||
|
||
from cortx.utils.log import Log | ||
from cortx.utils.common import CortxConf | ||
from cortx.utils.conf_store import Conf | ||
from cortx.utils.errors import UtilsError | ||
from cortx.utils.const import CLUSTER_CONF | ||
from cortx.utils.conf_store import MappedConf | ||
from cortx.utils.message_bus import MessageBus | ||
|
||
|
||
|
@@ -70,24 +72,23 @@ def __init__(self, message_server_endpoints, message_server_port=28300): | |
parser = argparse.ArgumentParser(description='Utils server CLI', | ||
formatter_class=RawTextHelpFormatter) | ||
parser.add_argument('-c', '--config', dest='cluster_conf',\ | ||
help="Cluster config file path for Support Bundle",\ | ||
default='yaml:///etc/cortx/cluster.conf') | ||
help="Cluster config file path for Support Bundle", \ | ||
default=CLUSTER_CONF) | ||
args=parser.parse_args() | ||
cluster_conf = args.cluster_conf | ||
Conf.load('config', cluster_conf, skip_reload=True) | ||
CortxConf.init(cluster_conf=cluster_conf) | ||
cluster_conf_url = args.cluster_conf | ||
cluster_conf = MappedConf(cluster_conf_url) | ||
# Get the log path | ||
log_dir = CortxConf.get_storage_path('log') | ||
log_dir = cluster_conf.get('cortx>common>storage>log') | ||
if not log_dir: | ||
raise UtilsServerError(errno.EINVAL, "Fail to initialize logger."+\ | ||
" Unable to find log_dir path entry") | ||
utils_log_path = CortxConf.get_log_path('utils_server', base_dir=log_dir) | ||
utils_log_path = os.path.join(log_dir, f'utils/{Conf.machine_id}/utils_server') | ||
# Get the log level | ||
log_level = CortxConf.get('utils>log_level', 'INFO') | ||
log_level = cluster_conf.get('utils>log_level', 'INFO') | ||
Log.init('utils_server', utils_log_path, level=log_level, backup_count=5, \ | ||
file_size_in_mb=5) | ||
message_bus_backend = Conf.get('config', 'cortx>utils>message_bus_backend') | ||
message_server_endpoints = Conf.get('config',\ | ||
f'cortx>external>{message_bus_backend}>endpoints') | ||
message_server_port = Conf.get('config', 'cortx>utils>message_server_port') | ||
message_bus_backend = cluster_conf.get('cortx>utils>message_bus_backend') | ||
message_server_endpoints = cluster_conf.get( | ||
f'cortx>external>{message_bus_backend}>endpoints') | ||
message_server_port = cluster_conf.get('cortx>utils>message_server_port') | ||
MessageServer(message_server_endpoints, message_server_port) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters