# Path: crmsh/constants.py
# SSH_OPTION = "-o StrictHostKeyChecking=no"
# 
# Path: crmsh/bootstrap.py
# def invoke(*args):
#     """
#     Log command execution to log file.
#     Log output from command to log file.
#     Return (boolean, stdout, stderr)
#     """
#     logger_utils.log_only_to_file("invoke: " + " ".join(args))
#     rc, stdout, stderr = utils.get_stdout_stderr(" ".join(args))
#     if stdout:
#         logger_utils.log_only_to_file("stdout: {}".format(stdout))
#     if stderr:
#         logger_utils.log_only_to_file("stderr: {}".format(stderr))
#     return rc == 0, stdout, stderr
# 
# def invokerc(*args):
#     """
#     Calling invoke, return True/False
#     """
#     rc, _, _ = invoke(*args)
#     return rc
# 
# WATCHDOG_CFG = "/etc/modules-load.d/watchdog.conf"
# 
# SYSCONFIG_SBD = "/etc/sysconfig/sbd"


import re
from . import utils
from .constants import SSH_OPTION
from .bootstrap import invoke, invokerc, WATCHDOG_CFG, SYSCONFIG_SBD
    @property
    def watchdog_device_name(self):
        return self._watchdog_device_name

    @staticmethod
    def _verify_watchdog_device(dev, ignore_error=False):
        """
        Use wdctl to verify watchdog device
        """
        rc, _, err = utils.get_stdout_stderr("wdctl {}".format(dev))
        if rc != 0:
            if ignore_error:
                return False
            else:
                utils.fatal("Invalid watchdog device {}: {}".format(dev, err))
        return True

    @staticmethod
    def _load_watchdog_driver(driver):
        """
        Load specific watchdog driver
        """
        invoke("echo {} > {}".format(driver, WATCHDOG_CFG))
        invoke("systemctl restart systemd-modules-load")

    @staticmethod
    def _get_watchdog_device_from_sbd_config():
        """
        Try to get watchdog device name from sbd config file
        """

# Path: crmsh/constants.py
# SSH_OPTION = "-o StrictHostKeyChecking=no"
# 
# Path: crmsh/bootstrap.py
# def invoke(*args):
#     """
#     Log command execution to log file.
#     Log output from command to log file.
#     Return (boolean, stdout, stderr)
#     """
#     logger_utils.log_only_to_file("invoke: " + " ".join(args))
#     rc, stdout, stderr = utils.get_stdout_stderr(" ".join(args))
#     if stdout:
#         logger_utils.log_only_to_file("stdout: {}".format(stdout))
#     if stderr:
#         logger_utils.log_only_to_file("stderr: {}".format(stderr))
#     return rc == 0, stdout, stderr
# 
# def invokerc(*args):
#     """
#     Calling invoke, return True/False
#     """
#     rc, _, _ = invoke(*args)
#     return rc
# 
# WATCHDOG_CFG = "/etc/modules-load.d/watchdog.conf"
# 
# SYSCONFIG_SBD = "/etc/sysconfig/sbd"


# Path: crmsh/watchdog.py
import re
from . import utils
from .constants import SSH_OPTION
from .bootstrap import invoke, invokerc, WATCHDOG_CFG, SYSCONFIG_SBD

    @property
    def watchdog_device_name(self):
        return self._watchdog_device_name

    @staticmethod
    def _verify_watchdog_device(dev, ignore_error=False):
        """
        Use wdctl to verify watchdog device
        """
        rc, _, err = utils.get_stdout_stderr("wdctl {}".format(dev))
        if rc != 0:
            if ignore_error:
                return False
            else:
                utils.fatal("Invalid watchdog device {}: {}".format(dev, err))
        return True

    @staticmethod
    def _load_watchdog_driver(driver):
        """
        Load specific watchdog driver
        """
        invoke("echo {} > {}".format(driver, WATCHDOG_CFG))
        invoke("systemctl restart systemd-modules-load")

    @staticmethod
    def _get_watchdog_device_from_sbd_config():
        """
        Try to get watchdog device name from sbd config file
        """

        conf = utils.parse_sysconfig(SYSCONFIG_SBD)