Пример #1
0
def doInstall():
    status, output = common.doBash("depmod -a")
    checkDriver()
    installDevice()
    status, output = common.doBash(
        "systemctl status flnet_s8930_54n-platform-main.service | grep inactive"
    )
    return
Пример #2
0
    def checkPsuStatus(self):
        psu_result = common.PASS
        psu_bus = DEVICE_BUS['psu']
        psu_alert = STATUS_ALERT['psu']
        psu_led = LED_COMMAND['pwr_led']
        psu_normal = 'green'
        psu_abnormal = 'blink_amber'
        led_bus = DEVICE_BUS['status_led']
        led_path = common.I2C_PREFIX + led_bus[0] + '/' + LED_NODES[1]

        status, output = common.doBash("ls " + common.I2C_PREFIX)
        if output.find(psu_bus[0]) != -1 and output.find(psu_bus[1]) != -1:
            for nodes in psu_bus:
                for alert_type in psu_alert:
                    path = common.I2C_PREFIX + nodes + "/" + alert_type
                    result = common.readFile(path)
                    if result != 'Error':
                        psu_result += int(result)
        if psu_result != common.PASS:
            if self.psu_led_status != psu_abnormal:
                common.writeFile(led_path, psu_led[psu_abnormal])
                self.psu_led_status = psu_abnormal
                common.syslog.syslog(common.syslog.LOG_ERR,
                                     'PSU Status Error !!!')
            return common.FAIL

        if self.psu_led_status != psu_normal:
            common.writeFile(led_path, psu_led[psu_normal])
            self.psu_led_status = psu_normal
            common.syslog.syslog(common.syslog.LOG_ERR,
                                 'PSU Status Normal !!!')
        return common.PASS
Пример #3
0
    def checkFanStatus(self):
        fan_result = common.PASS
        fan_bus = DEVICE_BUS['fan']
        fan_alert = STATUS_ALERT['fan']
        fan_led = LED_COMMAND['fan_led']
        fan_normal = 'green'
        fan_abnormal = 'blink_amber'
        led_bus = DEVICE_BUS['status_led']
        led_path = common.I2C_PREFIX + led_bus[0] + '/' + LED_NODES[3]

        status, output = common.doBash("ls " + common.I2C_PREFIX)
        if output.find(fan_bus[0]) != -1:
            for num in range(0, FAN_NUM):
                for alert_type in fan_alert:
                    path = common.I2C_PREFIX + fan_bus[0] + "/fan" + str(
                        num + 1) + "_" + alert_type
                    result = common.readFile(path)
                    if result != 'Error':
                        fan_result += int(result)
        if fan_result != common.PASS:
            if self.fan_led_status != fan_abnormal:
                common.writeFile(led_path, fan_led[fan_abnormal])
                self.fan_led_status = fan_abnormal
                common.syslog.syslog(common.syslog.LOG_ERR,
                                     'FAN Status Error !!!')
            return common.FAIL

        if self.fan_led_status != fan_normal:
            common.writeFile(led_path, fan_led[fan_normal])
            self.fan_led_status = fan_normal
            common.syslog.syslog(common.syslog.LOG_ERR,
                                 'FAN Status Normal !!!')
        return common.PASS
Пример #4
0
def checkDevicePosition(num):
    for i in range(0, len(I2C_CHECK_NODE)):
        status, output = common.doBash("echo " + MODULE_ID[num] + " " +
                                       DEVICE_ADDRESS[num] + " > " +
                                       common.I2C_PREFIX + I2C_CHECK_NODE[i] +
                                       "/new_device")
        status, output = common.doBash("ls " + common.I2C_PREFIX +
                                       DEVICE_NODE[num])
        DEVICE_NODE[num] = I2C_CHECK_NODE[i]

        if status:
            status, output = common.doBash("echo " + DEVICE_ADDRESS[num] +
                                           " > " + common.I2C_PREFIX +
                                           I2C_CHECK_NODE[i] +
                                           "/delete_device")
        else:
            return
    return
Пример #5
0
def installDevice():
    for i in range(0, len(MODULE_ID)):
        if MODULE_ID[i] == "pca9544":
            checkDevicePosition(i)
        else:
            status, output = common.doBash("echo " + MODULE_ID[i] + " " +
                                           DEVICE_ADDRESS[i] + " > " +
                                           common.I2C_PREFIX + DEVICE_NODE[i] +
                                           "/new_device")
    return
Пример #6
0
def doUninstall():
    for i in range(0, len(KERNEL_MODULE)):
        status, output = common.doBash("modprobe -rq " + KERNEL_MODULE[i])
    for i in range(0, len(MODULE_ID)):
        if MODULE_ID[i] == "pca9544":
            for node in range(0, len(I2C_CHECK_NODE)):
                status, output = common.doBash("ls " + common.I2C_PREFIX +
                                               str(node) +
                                               UNINSTALL_CHECK_NODE[i])
                if not status:
                    status, output = common.doBash("echo " +
                                                   DEVICE_ADDRESS[i] + " > " +
                                                   common.I2C_PREFIX +
                                                   I2C_CHECK_NODE[node] +
                                                   "/delete_device")
        else:
            status, output = common.doBash("echo " + DEVICE_ADDRESS[i] +
                                           " > " + common.I2C_PREFIX +
                                           DEVICE_NODE[i] + "/delete_device")
    return
Пример #7
0
def doInstall():
    status, output = common.doBash("depmod -a")
    checkDriver()
    installDevice()
    return
Пример #8
0
def checkDriver():
    for i in range(0, len(KERNEL_MODULE)):
        status, output = common.doBash("lsmod | grep " + KERNEL_MODULE[i])
        if status:
            status, output = common.doBash("modprobe " + KERNEL_MODULE[i])
    return