# Path: crmsh/bootstrap.py
# SYSCONFIG_SBD = "/etc/sysconfig/sbd"
# 
# SBD_SYSTEMD_DELAY_START_DIR = "/etc/systemd/system/sbd.service.d"


import os
import re
import shutil
from . import utils
from . import bootstrap
from .bootstrap import SYSCONFIG_SBD, SBD_SYSTEMD_DELAY_START_DIR
from . import log
from . import constants
from . import corosync
from . import xmlutil
        from .watchdog import Watchdog
        from .watchdog import Watchdog
        Get suitable systemd start timeout for sbd.service
        """
        # TODO 5ms, 5us, 5s, 5m, 5h are also valid for sbd sysconfig
        value = SBDManager.get_sbd_value_from_config("SBD_DELAY_START")
        if utils.is_boolean_true(value):
            return 2*SBDTimeout.get_sbd_watchdog_timeout()
        return int(value)

    @staticmethod
    def is_sbd_delay_start():
        """
        Check if SBD_DELAY_START is not no or not set
        """
        res = SBDManager.get_sbd_value_from_config("SBD_DELAY_START")
        return res and res != "no"

    def adjust_systemd_start_timeout(self):
        """
        Adjust start timeout for sbd when set SBD_DELAY_START
        """
        sbd_delay_start_value = SBDManager.get_sbd_value_from_config("SBD_DELAY_START")
        if sbd_delay_start_value == "no":
            return

        cmd = "systemctl show -p TimeoutStartUSec sbd --value"
        out = utils.get_stdout_or_raise_error(cmd)
        start_timeout = utils.get_systemd_timeout_start_in_sec(out)
        if start_timeout > int(sbd_delay_start_value):
            return


# Path: crmsh/bootstrap.py
# SYSCONFIG_SBD = "/etc/sysconfig/sbd"
# 
# SBD_SYSTEMD_DELAY_START_DIR = "/etc/systemd/system/sbd.service.d"


# Path: crmsh/sbd.py
import os
import re
import shutil
from . import utils
from . import bootstrap
from .bootstrap import SYSCONFIG_SBD, SBD_SYSTEMD_DELAY_START_DIR
from . import log
from . import constants
from . import corosync
from . import xmlutil
        from .watchdog import Watchdog
        from .watchdog import Watchdog

        Get suitable systemd start timeout for sbd.service
        """
        # TODO 5ms, 5us, 5s, 5m, 5h are also valid for sbd sysconfig
        value = SBDManager.get_sbd_value_from_config("SBD_DELAY_START")
        if utils.is_boolean_true(value):
            return 2*SBDTimeout.get_sbd_watchdog_timeout()
        return int(value)

    @staticmethod
    def is_sbd_delay_start():
        """
        Check if SBD_DELAY_START is not no or not set
        """
        res = SBDManager.get_sbd_value_from_config("SBD_DELAY_START")
        return res and res != "no"

    def adjust_systemd_start_timeout(self):
        """
        Adjust start timeout for sbd when set SBD_DELAY_START
        """
        sbd_delay_start_value = SBDManager.get_sbd_value_from_config("SBD_DELAY_START")
        if sbd_delay_start_value == "no":
            return

        cmd = "systemctl show -p TimeoutStartUSec sbd --value"
        out = utils.get_stdout_or_raise_error(cmd)
        start_timeout = utils.get_systemd_timeout_start_in_sec(out)
        if start_timeout > int(sbd_delay_start_value):
            return


        utils.mkdirp(SBD_SYSTEMD_DELAY_START_DIR)