Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
EOS-27348: Remove CortxConf
Browse files Browse the repository at this point in the history
Signed-off-by: Rohit Dwivedi <[email protected]>
  • Loading branch information
rohit-k-dwivedi committed Jan 20, 2022
1 parent f531f4b commit f8034b7
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 31 deletions.
1 change: 1 addition & 0 deletions py-utils/src/utils/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 7 additions & 5 deletions py-utils/src/utils/setup/kafka/kafka_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@
# 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.conf_store import MappedConf
from cortx.utils.setup.kafka import KafkaSetupError


Expand Down Expand Up @@ -205,10 +206,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_store = MappedConf(command.cluster_conf)
log_dir = cluster_conf_store.get('cortx>common>storage>log')
log_dir = log_dir if log_dir else cluster_conf_store.get('log_dir')
log_path = os.path.join(log_dir, f'utils/{Conf.machine_id}')
log_level = cluster_conf_store.get('utils>log_level', 'INFO')
Log.init('kafka_setup', log_path, level=log_level, backup_count=5, \
file_size_in_mb=5)

Expand Down
7 changes: 4 additions & 3 deletions py-utils/src/utils/setup/openldap/setupcmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
from cortx.utils.validator.v_path import PathV
from cortx.utils.process import SimpleProcess
from cortx.utils.log import Log
from cortx.utils.common import CortxConf
from cortx.utils.conf_store import MappedConf
from cortx.utils.const import CLUSTER_CONF

class OpenldapPROVError(Exception):

Expand All @@ -51,8 +52,8 @@ class SetupCmd(object):
rootdn_pass_key = 'cluster_config>rootdn_password'
cluster_id_key = 'cluster_config>cluster_id'
Log.init('OpenldapProvisioning','/var/log/cortx/utils/openldap',level='DEBUG')
CortxConf.init(cluster_conf='yaml:///etc/cortx/cluster.conf')
util_install_path = CortxConf.get('install_path')
mappedConf = MappedConf(CLUSTER_CONF)
util_install_path = mappedConf.get('install_path')
openldap_prov_config = path.join(util_install_path, "cortx/utils/conf", "openldap_prov_config.yaml")
openldap_config_file = path.join(util_install_path, "cortx/utils/conf", "openldap_config.yaml")
utils_tmp_dir = path.join(util_install_path, "cortx/utils/tmp")
Expand Down
26 changes: 14 additions & 12 deletions py-utils/src/utils/support_framework/bundle_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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}"
Expand All @@ -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}")

Expand All @@ -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')
mappedConf = MappedConf(config_url)
log_path = os.path.join(mappedConf.get('log_dir'), \
f'utils/{Conf.machine_id}/support')
log_level = mappedConf.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
Expand All @@ -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(mappedConf.get('install_path'),\
const.SUPPORT_YAML)
try:
support_bundle_config = Yaml(cmd_setup_file).load()
Expand Down
15 changes: 8 additions & 7 deletions py-utils/src/utils/utils_server/utils_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@
# 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.conf_store import MappedConf
from cortx.utils.message_bus import MessageBus


Expand Down Expand Up @@ -75,15 +76,15 @@ def __init__(self, message_server_endpoints):
args=parser.parse_args()
cluster_conf = args.cluster_conf
Conf.load('config', cluster_conf, skip_reload=True)
CortxConf.init(cluster_conf=cluster_conf)
mappedConf = MappedConf(cluster_conf)
# Get the log path
log_dir = CortxConf.get_storage_path('log')
log_dir = mappedConf.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 = mappedConf.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')
Expand Down
8 changes: 4 additions & 4 deletions py-utils/test/discovery/test_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@

from cortx.utils.conf_store import Conf
from cortx.utils.discovery import Discovery
from cortx.utils.discovery.error import DiscoveryError
from cortx.utils.conf_store import MappedConf
from cortx.utils.kv_store import KvStoreFactory
from cortx.utils.common import CortxConf
from cortx.utils.discovery.error import DiscoveryError

# Load cortx common config
store_type = "json"
CortxConf.init(cluster_conf='yaml:///etc/cortx/cluster.conf')
local_storage_path = CortxConf.get_storage_path('local')
mappedConf = MappedConf('yaml:///etc/cortx/cluster.conf')
local_storage_path = mappedConf.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()
Expand Down

0 comments on commit f8034b7

Please sign in to comment.