Пример #1
0
    def __init__(self, lsblk):
        Component.__init__(self, lsblk, None)
        self.lsblk = lsblk
        self.data = {"size": self.__size(), "devname": self.lsblk["name"]}

        if not self.__is_nvme():
            self.data["smart"] = utils.get_smart_attributes(self.lsblk["name"])

        match = re.search(r"^(\S+)_(\S+_\S+)", self.__getter("model"))
        if match:
            self.vendor = match.group(1)
            self.model = match.group(2)
            self.name = match.group(1) + " " + match.group(2)
        else:
            self.model = self.__getter("model")
            self.name = self.model
            if self.lsblk["vendor"] is None:
                self.vendor = self.model.split(" ")[0]
            else:
                self.vendor = self.lsblk["vendor"].strip()

        self.serial = self.__getter("serial")
        self.firmware_version = self.__getter("firmware_version")

        if self.__is_megaraid():
            self.vendor = utils.get_smart_diskprop(self.lsblk["name"],
                                                   "vendor")

        if self.vendor.strip() == "ATA":
            self.vendor = utils.normalize_vendor(self.model)
        else:
            self.vendor = utils.normalize_vendor(self.vendor)
Пример #2
0
    def __init__(self, lshw, element):
        Component.__init__(self, lshw, element)

        self.data = {
            "slot":
            utils.xml_ev(lshw, element, "slot"),
            "size":
            str(int(int(utils.xml_ev(lshw, element, "size")) / 1024000000)) +
            "GB",
            "clock":
            int(utils.xml_ev(lshw, element, "clock")) /
            1000000 if utils.xml_ev(lshw, element, "clock") else "",
            "type":
            utils.get_dmidecode_prop(
                "0x" +
                utils.xml_ev(lshw, element, "@handle", True).split(":", 1)[1],
                "17",
                "type",
            ),
            "asset_tag":
            "Unknown",
        }

        self.name = utils.xml_ev(lshw, element, "description")
        self.model = utils.xml_ev(lshw, element, "product")
        self.vendor = utils.normalize_vendor(
            utils.xml_ev(lshw, element, "vendor"))
        self.serial = utils.xml_ev(lshw, element, "serial")
        self.firmware_version = "N/A"
Пример #3
0
    def __init__(self, lshw, element):
        Component.__init__(self, lshw, element)

        self.data = {
            "uuid":
            utils.xml_ev(
                lshw,
                lshw.getroot(),
                "node[@class='system']/configuration/setting[@id='uuid']/@value",
                True,
            ),
            "date":
            utils.xml_ev(lshw, element, "node[@id='firmware']/date"),
        }

        self.vendor = utils.normalize_vendor(
            utils.xml_ev(lshw, element, "vendor"))
        if self.vendor == "Dell Inc.":
            self.model = utils.dmidecode_string("system-product-name")
        else:
            self.model = utils.xml_ev(lshw, element, "product")

        if self.model == "X11SSE-F":
            self.model = "MBD-X11SSE-F"

        self.name = self.model
        self.serial = utils.xml_ev(lshw, element, "serial")
        self.firmware_version = utils.xml_ev(lshw, element,
                                             "node[@id='firmware']/version")
Пример #4
0
    def __init__(self, lshw, element):
        Component.__init__(self, lshw, element)

        self.name = utils.xml_ev(lshw, element, "description")
        self.model = utils.xml_ev(lshw, element, "product")
        self.serial = utils.xml_ev(lshw, element, "businfo")
        self.vendor = utils.normalize_vendor(utils.xml_ev(lshw, element, "vendor"))
        self.firmware_version = utils.xml_ev(lshw, element, "version")

        self.data = {
            "driver": utils.xml_ev(
                lshw, element, "configuration/setting[@id='driver']/@value", True
            )
        }

        if "MegaRAID" in self.model:
            self.serial = utils.get_megaraid_prop("serial")

            for prop in (
                "product_name",
                "firmware_bios",
                "firmware_ctrlr",
                "firmware_fw",
                "firmware_nvdata",
                "firmware_boot",
                "bbu",
                "memory_size",
            ):
                self.data["megaraid_" + prop] = utils.get_megaraid_prop(prop)
Пример #5
0
 def configure_name(self):
     self.name = Dataset.generate_name(self.config)
     if self.config.has_limit():
         self.sampler = Sampler(self.config)
         self.name = self.sampler.get_limited_name(self.name)
     else:
         self.name = Dataset.generate_name(self.config)
     Component.configure_name(self, self.name)
Пример #6
0
    def __init__(self):
        Component.__init__(self)

        self.data = {}

        self.model = utils.dmidecode_string("system-product-name")
        self.name = self.model + " Base Management Controller"
        self.vendor = utils.normalize_vendor(utils.get_mc_info("vendor"))
        self.serial = utils.get_mc_info("guid")
        self.firmware_version = utils.get_mc_info("firmware_version")
Пример #7
0
    def __init__(self, lshw, element):
        Component.__init__(self, lshw, element)

        self.data = {
            "cores": utils.xml_ev(
                lshw, element, "configuration/setting[@id='cores']/@value", True
            ),
            "clock": utils.xml_ev(lshw, element, "capacity"),
        }

        self.name = utils.xml_ev(lshw, element, "product")
        self.model = utils.xml_ev(lshw, element, "version")
        self.vendor = utils.normalize_vendor(utils.xml_ev(lshw, element, "vendor"))
        self.serial = utils.xml_ev(lshw, element, "slot")
        self.firmware_version = "N/A"
Пример #8
0
    def __init__(self, lshw, element):
        Component.__init__(self, lshw, element)

        self.data = {
            "rate":
            utils.xml_ev(lshw, element, "size"),
            "devname":
            utils.xml_ev(lshw, element, "logicalname"),
            "driver":
            utils.xml_ev(lshw, element,
                         "configuration/setting[@id='driver']/@value", True),
        }

        if self.data["rate"] == "":
            self.data["rate"] = utils.xml_ev(lshw, element, "capacity")

        self.name = utils.xml_ev(lshw, element, "product")
        self.model = utils.xml_ev(lshw, element, "product")
        self.serial = utils.ethtool_mac(
            utils.xml_ev(lshw, element, "logicalname"))
        self.vendor = utils.normalize_vendor(
            utils.xml_ev(lshw, element, "vendor"))
        self.firmware_version = utils.xml_ev(
            lshw, element, "configuration/setting[@id='firmware']/@value",
            True)

        if not utils.xml_ev(lshw, element, "businfo") == "":
            self.pci_id = utils.xml_ev(lshw, element, "businfo").split(":",
                                                                       1)[1]
        else:
            self.pci_id = ""

        if "Illegal Vendor ID" in self.vendor and self.pci_id != "":
            _lspci = utils.lspci(self.pci_id)
            self.vendor = utils.normalize_vendor(_lspci["vendor"])
            self.model = _lspci["device"]
            self.name = self.model

        if "Mellanox" in self.vendor and self.pci_id != "":
            try:
                self.firmware_version = utils.get_mellanox_prop(
                    self.pci_id, "firmware_version")
                self.model = utils.get_mellanox_part_number(self.pci_id)
                self.data["mellanox_psid"] = utils.get_mellanox_prop(
                    self.pci_id, "psid")
            except Exception:
                self.firmware_version = ""
                utils.log(message="get_mellanox_prop failed.")
Пример #9
0
def hardware(component_type, tinkerbell, verbose, dry, cache_file):
    lshw = etree.ElementTree(etree.fromstring(utils.lshw()))
    components = []

    for t in component_type:
        components.extend(eval(t).list(lshw))

    if verbose:
        for component in components:
            utils.log(name=component.name, contents=component)

    with open(cache_file, "w") as output:
        output.write(jsonpickle.encode(components))

    if not dry:
        Component.post_all(components, tinkerbell)
Пример #10
0
 def _update_component(self, data: dict) -> None:
     for key, value in data.items():
         if not 'entity' == key:
             try:
                 self._components[key].update(data['entity'], value)
             except KeyError:
                 self._components[key] = Component.instance(key)
                 self._components[key].update(data['entity'], value)
Пример #11
0
 def configure_name(self):
     if self.is_supervised:
         # set source name at the vector source
         error(
             "{} is supervised and needs an input bundle list.".format(
                 self.get_full_name()),
             len(self.inputs) <= 1)
         # get the longest name, most probable
         print(self.inputs.get_source_name())
         self.input_name = max(self.inputs.get_source_name(),
                               key=lambda x: len(x))
     else:
         error(
             "{} is not supervised but got an input bundle list, instead of a single bundle."
             .format(self.get_full_name()),
             len(self.inputs) <= 1)
         # get the longest name, most probable
         self.input_name = self.inputs.get_source_name()
     self.name = "{}_{}_{}".format(self.input_name, self.base_name,
                                   self.dimension)
     Component.configure_name(self, self.name)
Пример #12
0
 def setUp(self):
     self.component_list = ComponentList(
         Component.from_db('CO2'),
         Component.from_db('N2'),
         Component.from_db('H2'),
         Component.from_db('CO'),
         Component.from_db('C1'),
         Component.from_db('C2'),
         Component.from_db('C3'),
         Component.from_db('i-C4'),
         Component.from_db('n-C4'),
         Component.from_db('i-C5'),
         Component.from_db('n-C5'),
         Component.from_db('C6'),
         Component.from_db('C7'),
         Component.from_db('C8'),
     )
     self.condition = np.array([
         # first column is Pressure in bar
         # second column is Temperature in degree centigerad
         # other columns are compersibility factor for diffrent gases
         [60, -3.15, 0.84053, 0.83348, 0.79380, 0.88550, 0.82609,
          0.85380],  # noqa: E201, E241
         [60, 6.85, 0.86199, 0.85596, 0.82206, 0.90144, 0.84969,
          0.87370],  # noqa: E201, E241
         [60, 16.85, 0.88006, 0.87484, 0.84544, 0.91501, 0.86944,
          0.89052],  # noqa: E201, E241
         [60, 36.85, 0.90867, 0.90446, 0.88183, 0.93674, 0.90052,
          0.91723],  # noqa: E201, E241
         [60, 56.85, 0.93011, 0.92696, 0.90868, 0.95318, 0.92368,
          0.93730],  # noqa: E201, E241
         [120, -3.15, 0.72133, 0.71044, 0.64145, 0.81024, 0.69540,
          0.75074],  # noqa: E201, E241
         [120, 6.85, 0.76025, 0.75066, 0.68971, 0.83782, 0.73780,
          0.78586],  # noqa: E201, E241
         [120, 16.85, 0.79317, 0.78475, 0.73123, 0.86137, 0.77369,
          0.81569],  # noqa: E201, E241
         [120, 36.85, 0.84515, 0.83863, 0.79698, 0.89913, 0.83022,
          0.86311],  # noqa: E201, E241
         [120, 56.85, 0.88383, 0.87870, 0.84553, 0.92766, 0.87211,
          0.89862],  # noqa: E201, E241
     ])
     self.compositions = np.array([
         # gas molar composition:
         # rows are:
         # CO2, N2, H2, CO, C1, C2, c3, i-c, n-c, i-c, n-c, c6, c7, c8
         [0.006, 0.005, 0.015, 0.016, 0.076, 0.011],  # noqa: E201, E241
         [0.003, 0.031, 0.010, 0.100, 0.057, 0.117],  # noqa: E201, E241
         [0.00, 0.00, 0.00, 0.095, 0.00, 0.00],  # noqa: E201, E241
         [0.00, 0.00, 0.00, 0.010, 0.00, 0.00],  # noqa: E201, E241
         [0.965, 0.907, 0.859, 0.735, 0.812, 0.826],  # noqa: E201, E241
         [0.018, 0.0450, 0.085, 0.033, 0.043, 0.035],  # noqa: E201, E241
         [0.0045, 0.0084, 0.023, 0.0074, 0.009, 0.0075],  # noqa: E201, E241
         [0.001, 0.0010, 0.0035, 0.0012, 0.0015,
          0.0012],  # noqa: E201, E241
         [0.001, 0.0015, 0.0035, 0.0012, 0.0015,
          0.0012],  # noqa: E201, E241
         [0.0005, 0.0003, 0.0005, 0.0004, 0.00, 0.0004],  # noqa: E201, E241
         [0.0003, 0.0004, 0.0005, 0.0004, 0.00, 0.0004],  # noqa: E201, E241
         [0.0007, 0.0004, 0.00, 0.0002, 0.00, 0.0002],  # noqa: E201, E241
         [0.00, 0.00, 0.00, 0.0001, 0.00, 0.0001],  # noqa: E201, E241
         [0.00, 0.00, 0.00, 0.0001, 0.00, 0.00],  # noqa: E201, E241
     ])
Пример #13
0
    def __init__(self):
        self._components: Mapping[str, Type[Component]] = {}

        self._components['entity'] = Component.instance('entity')
        self._components['tag'] = Component.instance('tag')