# 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

    def join_watchdog(self):
        """
        In join proces, get watchdog device from config
        If that device not exist, get driver name from init node, and load that driver
        """
        self._set_watchdog_info()

        res = self._get_watchdog_device_from_sbd_config()
        if not res:
            utils.fatal("Failed to get watchdog device from {}".format(SYSCONFIG_SBD))
        self._input = res

        if not self._valid_device(self._input):
            driver = self._get_driver_through_device_remotely(self._input)
            self._load_watchdog_driver(driver)

    def init_watchdog(self):
        """
        In init process, find valid watchdog device
        """
        self._set_watchdog_info()
        self._set_input()

        # self._input is a device name
        if self._valid_device(self._input):
            self._watchdog_device_name = self._input
            return

        # self._input is invalid, exit

# 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


    def join_watchdog(self):
        """
        In join proces, get watchdog device from config
        If that device not exist, get driver name from init node, and load that driver
        """
        self._set_watchdog_info()

        res = self._get_watchdog_device_from_sbd_config()
        if not res:
            utils.fatal("Failed to get watchdog device from {}".format(SYSCONFIG_SBD))
        self._input = res

        if not self._valid_device(self._input):
            driver = self._get_driver_through_device_remotely(self._input)
            self._load_watchdog_driver(driver)

    def init_watchdog(self):
        """
        In init process, find valid watchdog device
        """
        self._set_watchdog_info()
        self._set_input()

        # self._input is a device name
        if self._valid_device(self._input):
            self._watchdog_device_name = self._input
            return

        # self._input is invalid, exit

        if not invokerc("modinfo {}".format(self._input)):