def test_self_hw_node_sel_event(args):
    check_sspl_ll_is_running()
    # fetch a good resource fron ipmitool
    result = run_cmd('ipmitool sdr type Fan')
    test_resource = None
    if result:
        for resource in result:
            if 'ok' in resource.decode().lower():
                # this is the first ok resource, use it
                test_resource = resource.decode().split('|')[0].strip()
                break
        # inject event into sel list and wait for alert
        print(f"Using test resource {test_resource}")
        run_cmd(f"ipmitool event '{test_resource}' lcr")
        # wait for fault alert
        start_time = time.time()
        asserted = False
        while time.time() - start_time < 60:  # wait for 60 seconds
            if wait_for_asserted_event():
                asserted = True
                break
        if not asserted:
            print("Did not get asserted event alert.")
            assert (False)
        # revert the event
        run_cmd(f"ipmitool event '{test_resource}' lcr deassert")
        # wait for alert
        start_time = time.time()
        deasserted = False
        while time.time() - start_time < 60:  # wait for 60 seconds
            if wait_for_deasserted_event():
                deasserted = True
                break
        if not deasserted:
            print("Did not get asserted event alert.")
            assert (False)
    else:
        print("ipmitool returned no results.")
        assert (False)
import json
import os
import psutil
import time
import sys
from alerts.self_hw.self_hw_utilities import run_cmd, is_virtual
from default import world
from messaging.ingress_processor_tests import IngressProcessorTests
from messaging.egress_processor_tests import EgressProcessorTests
from common import check_sspl_ll_is_running


UUID="16476007-a739-4785-b5c6-f3de189cdf11"
# Check which fans are OK
test_resource = "*" # Use * if virtual machine
result = run_cmd('ipmitool sdr type Fan')
if result and not is_virtual():
        for resource in result:
            if 'ok' in resource.decode().lower():
                # this is the first ok resource, use it in case of real HW
                test_resource = resource.decode().split('|')[0].strip()
                break

def init(args):
    pass

def test_node_fan_module_actuator(agrs):
    check_sspl_ll_is_running()
    fan_actuator_message_request("NDHW:node:fru:fan", str(test_resource))
    fan_module_actuator_msg = None
    ingressMsg = {}