-- Copyright (c) 2024 Huawei Technologies Co., Ltd.
-- openUBMC is licensed under Mulan PSL v2.
-- You can use this software according to the terms and conditions of the Mulan PSL v2.
-- You may obtain a copy of Mulan PSL v2 at: http://license.coscl.org.cn/MulanPSL2
-- THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
-- EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
-- MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
-- See the Mulan PSL v2 for more details.

-- Description: 升级相关公共函数
local fructl = require 'mcu.upgrade.fructl_handler'
local log = require 'mc.logging'

local comm_method = {}

function comm_method.get_power_state(bus)
    local power_state
    -- multihost场景，获取整机电源状态
    if fructl.is_multihost_type(bus) then
        power_state = fructl.get_chassis_power_status(bus, 1)
    else
        power_state = fructl.get_power_status(bus, 1)
    end
    log:notice('power state = %s', power_state)
    return power_state
end

return comm_method