#
# Kontron IpmiLibrary
#
# author: Michael Walle <michael.walle@kontron.com>
# author: Heiko Thiery <heiko.thiery@kontron.com>
#

class Bmc:
    def issue_bmc_cold_reset(self):
        """Sends a _bmc cold reset_ to the given controler.
        """
        self._ipmi.cold_reset()

    def get_bmc_device_id(self):
        """Sends a _bmc get device id_ command to the given controller.
        """
        device_id = self._ipmi.get_device_id()

    def product_id_should_be(self, product_id):
        """Fails if the GetDeviceID command response does not contain
        the given `device_id`.
        """
        product_id = int_any_base(product_id)
        device_id = self._ipmi.get_device_id()
        asserts.fail_unless_equal(device_id.product_id, product_id)

    def manufacturer_id_should_be(self, manufacturer_id):
        """Fails if the GetDeviceID command response does not contain
        the given `manufacturer_id`.
        """
        manufacturer_id = int_any_base(manufacturer_id)
        device_id = self._ipmi.get_device_id()
        asserts.fail_unless_equal(device_id.manufacturer_id, manufacturer_id)

    def start_watchdog_timer(self, value, action):
        """Sets and starts IPMI watchdog timer.

        The watchdog is set to `value` and after that it is started.

        The maximum value is 6553 seconds. `value` is given in Robot
        Framework's time format (e.g. 1 minute 20 seconds) that is explained in
        the User Guide.
        """

        config = pyipmi.bmc.Watchdog()
        config.timer_use = pyipmi.bmc.Watchdog.TIMER_USE_SMS_OS
        config.dont_stop = 1
        config.dont_log = 0
        config.pre_timeout_interval = 0
        config.pre_timeout_interrupt = 0
        config.timer_use_expiration_flags = 8
        # convert to 100ms
        config.initial_countdown = int(utils.timestr_to_secs(value) * 10)
        if (config.initial_countdown > 0xffff):
            raise RuntimeError('Watchdog value out of range')
        config.timeout_action = find_watchdog_action(action)
        # set watchdog
        self._ipmi.set_watchdog_timer(config)
        # start watchdog
        self._ipmi.reset_watchdog_timer()



@@ -1768,9 +1768,12 @@
 s = 
-8
+0xff
 %0A   
@@ -2127,32 +2127,32 @@
  start watchdog%0A
-
         self._ip
@@ -2178,9 +2178,1742 @@
 imer()%0A%0A
+    def stop_watchdog_timer(self, msg=None):%0A        %22%22%22Stops the IPMI wachtdog timer.%0A        %22%22%22%0A        ac = self._active_connection%0A%0A        config = pyipmi.bmc.Watchdog()%0A        config.timer_use = pyipmi.bmc.Watchdog.TIMER_USE_OEM%0A        config.dont_stop = 0%0A        config.dont_log = 0%0A        config.pre_timeout_interval = 0%0A        config.pre_timeout_interrupt = 0%0A        # 0xff means clear all expiration flags%0A        config.timer_use_expiration_flags = 0xff%0A        config.initial_countdown = 0%0A        config.timeout_action = pyipmi.bmc.Watchdog.TIMEOUT_ACTION_NO_ACTION%0A        ac._ipmi.set_watchdog_timer(config)%0A%0A    def watchdog_timeout_action_should_be(self, action, msg=None):%0A        %22%22%22Fails if the IPMI Watchdog timeout action is not %60action%60%0A        %60action%60 can be:%0A        No Action, Hard Reset, Power Down, Power Cycle%0A        %22%22%22%0A        action = find_watchdog_action(action)%0A        config = self._active_connection._ipmi.get_watchdog_timer()%0A        asserts.fail_unless_equal(action, config.timeout_action, msg)%0A%0A    def watchdog_timer_use_should_be(self, timer_use, msg=None):%0A        %22%22%22Fails if the IPMI Watchdog timer use is not %60timer_use%60%0A        %60timer_use%60 can be:%0A        OEM, SMS OS, OS Load, BIOS POST, BIOS FRB2%0A        %22%22%22%0A        timer_use = find_watchdog_timer_use(timer_use)%0A        config = self._active_connection._ipmi.get_watchdog_timer()%0A        asserts.fail_unless_equal(timer_use, config.timer_use, msg)%0A%0A    def watchdog_initial_timeout_value_should_be(self, value, msg=None):%0A        %22%22%22%0A        %22%22%22%0A        value = int_any_base(value)%0A        config = self._active_connection._ipmi.get_watchdog_timer()%0A        asserts.fail_unless_equal(value, config.initial_countdown, msg)%0A%0A
 %0A

add keywords