Пример #1
0
 def get_status_led(self):
     """
     Gets the state of the system LED
     Returns:
         A string, one of the valid LED color strings which could be
         vendor specified.
     """
     val = pci_get_value(self.pci_res, self.sysled_offset)
     if val != -1:
         val = val & 0x30
         return self.REG_TO_SYSLED_COLOR.get(val)
     return self.sys_ledcolor
Пример #2
0
    def get_status_led(self):
        """
        Gets the current system LED color

        Returns:
            A string that represents the supported color
        """
        val = hwaccess.pci_get_value(self.pci_res, self.sysled_offset)
        if val != -1:
            val = val & 0x30
            return self.REG_TO_SYSLED_COLOR.get(val)
        return self.sys_ledcolor
Пример #3
0
 def get_locator_led(self):
     """
     Gets the state of the Chassis Locator LED
     Returns:
         LOCATOR_LED_ON or LOCATOR_LED_OFF
     """
     resource = "/sys/bus/pci/devices/0000:04:00.0/resource0"
     val = pci_get_value(resource, SYSTEM_LED_REG)
     val = int(val) & SYSTEM_BEACON_LED_SET
     if not val:
         return self.LOCATOR_LED_OFF
     else:
         return self.LOCATOR_LED_ON
Пример #4
0
    def get_locator_led(self):
        """
        Gets the state of the Chassis Locator LED

        Returns:
            LOCATOR_LED_ON or LOCATOR_LED_OFF
        """
        val = hwaccess.pci_get_value(PCI_RES, SYSTEM_LED_REG)
        val = int(val) & SYSTEM_BEACON_LED_SET
        if not val:
            return self.LOCATOR_LED_OFF
        else:
            return self.LOCATOR_LED_ON
Пример #5
0
    def set_status_led(self, color):
        """
        Set system LED status based on the color type passed in the argument.
        Argument: Color to be set
        Returns:
          bool: True is specified color is set, Otherwise return False
        """

        if color not in list(self.SYSLED_COLOR_TO_REG.keys()):
            return False

        val = hwaccess.pci_get_value(self.pci_res, self.sysled_offset)
        val = (val & 0xFFCF) | self.SYSLED_COLOR_TO_REG[color]

        hwaccess.pci_set_value(self.pci_res, val, self.sysled_offset)
        self.sys_ledcolor = color
        return True
Пример #6
0
    def set_status_led(self, color):
        """
        Sets the state of the system LED
        Args:
            color: A string representing the color with which to set the
                   system LED
        Returns:
            bool: True if system LED state is set successfully, False if not
        """
        if color not in list(self.SYSLED_COLOR_TO_REG.keys()):
            return False

        val = pci_get_value(self.pci_res, self.sysled_offset)
        val = (val & 0xFFCF) | self.SYSLED_COLOR_TO_REG[color]

        pci_set_value(self.pci_res, val, self.sysled_offset)
        self.sys_ledcolor = color
        return True
Пример #7
0
 def set_locator_led(self, color):
     """
     Sets the state of the Chassis Locator LED
     Args:
         color: A string representing the color with which to set the Chassis Locator LED
     Returns:
         bool: True if the Chassis Locator LED state is set successfully, False if not
     """
     resource = "/sys/bus/pci/devices/0000:04:00.0/resource0"
     val = pci_get_value(resource, SYSTEM_LED_REG)
     if  self.LOCATOR_LED_ON == color:
         val = int(val) | SYSTEM_BEACON_LED_SET
     elif self.LOCATOR_LED_OFF == color:
         val = int(val) & SYSTEM_BEACON_LED_CLEAR
     else:
         return False
     pci_set_value(resource, val, SYSTEM_LED_REG)
     return True
Пример #8
0
    def set_locator_led(self, color):
        """
        Sets the state of the Chassis Locator LED

        Args:
            color: A string representing the color with which to set the Chassis Locator LED

        Returns:
            bool: True if the Chassis Locator LED state is set successfully, False if not

        """
        val = hwaccess.pci_get_value(PCI_RES, SYSTEM_LED_REG)
        if self.LOCATOR_LED_ON == color:
            val = int(val) | SYSTEM_BEACON_LED_SET
        elif self.LOCATOR_LED_OFF == color:
            val = int(val) & SYSTEM_BEACON_LED_CLEAR
        else:
            return False
        hwaccess.pci_set_value(PCI_RES, val, SYSTEM_LED_REG)
        return True
Пример #9
0
def get_fpga_version():
    val = hwaccess.pci_get_value('/sys/bus/pci/devices/0000:09:00.0/resource0', 0)
    return '{}.{}'.format((val >> 8) & 0xff, val & 0xff)