Пример #1
0
def main(argv: list):
    try:
        if sys.argv[1] == "post_install":
            Conf.init(delim='.')
            Conf.load(const.HA_GLOBAL_INDEX,
                      f"yaml://{const.SOURCE_CONFIG_FILE}")
            log_path = Conf.get(const.HA_GLOBAL_INDEX, "LOG.path")
            log_level = Conf.get(const.HA_GLOBAL_INDEX, "LOG.level")
            Log.init(service_name='ha_setup',
                     log_path=log_path,
                     level=log_level)
        else:
            ConfigManager.init("ha_setup")

        desc = "HA Setup command"
        command = Cmd.get_command(desc, argv[1:])
        command.process()

        sys.stdout.write(
            f"Mini Provisioning {sys.argv[1]} configured successfully.\n")
    except Exception as err:
        Log.error("%s\n" % traceback.format_exc())
        sys.stderr.write(
            f"Setup command:{argv[1]} failed for cortx-ha. Error: {err}\n")
        return errno.EINVAL
Пример #2
0
from cortx.utils.conf_store import Conf
from cortx.utils.log import Log
sys.path.append(os.path.join(os.path.dirname(pathlib.Path(__file__)), '..', '..', '..'))
from ha import const
from ha.core.config.config_manager import ConfigManager
from ha.core.system_health.system_health import SystemHealth
from ha.core.system_health.model.health_event import HealthEvent
from ha.const import _DELIM

def main(argv: dict):
    # TODO: Add test cases.
    pass

if __name__ == '__main__':
    # TODO: Import and use config_manager.py
    Conf.init()
    Conf.load(const.HA_GLOBAL_INDEX, f"yaml://{const.SOURCE_CONFIG_FILE}")
    log_path = Conf.get(const.HA_GLOBAL_INDEX, f"LOG{_DELIM}path")
    log_level = Conf.get(const.HA_GLOBAL_INDEX, f"LOG{_DELIM}level")
    Log.init(service_name='ha_system_health', log_path=log_path, level=log_level)

    try:
        store = ConfigManager.get_confstore()
        health = SystemHealth(store)
        """
        Test case 1
        """
        event = HealthEvent("event_id", "fault", "severity", "1", "1", "e766bd52-c19c-45b6-9c91-663fd8203c2e", "storage-set-1",
                            "2", "srvnode-1.mgmt.public", "node", "16215009572", "iem", "Description")
        health.process_event(event)
        node_info = health.get_node_status(node_id="2")
Пример #3
0
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# For any questions about this software or licensing,
# please email [email protected] or [email protected].

import os
import sys
import pathlib

from cortx.utils.conf_store import Conf
from cortx.utils.log import Log
sys.path.append(
    os.path.join(os.path.dirname(pathlib.Path(__file__)), '..', '..', '..'))
from ha import const


def main(argv: dict):
    # TODO: Add test cases.
    pass


if __name__ == '__main__':
    # TODO: Import and use config_manager.py
    Conf.init(delim='.')
    Conf.load(const.HA_GLOBAL_INDEX, f"yaml://{const.SOURCE_CONFIG_FILE}")
    log_path = Conf.get(const.HA_GLOBAL_INDEX, "LOG.path")
    log_level = Conf.get(const.HA_GLOBAL_INDEX, "LOG.level")
    Log.init(service_name='ha_system_health',
             log_path=log_path,
             level=log_level)
    sys.exit(main(sys.argv))