def _integrate_table_row( table_row: TableRow, inventory_tree: StructuredDataTree, status_data_tree: StructuredDataTree, ) -> None: def _find_matching_row_index(rows, key_columns): for index, row in enumerate(rows): if all(k in row and row[k] == v for k, v in key_columns.items()): return index return None leg_path = ".".join(table_row.path) + ":" inv_rows = inventory_tree.get_list(leg_path) idx = _find_matching_row_index(inv_rows, table_row.key_columns) if idx is None: inv_rows.append({ **table_row.key_columns, **table_row.inventory_columns }) else: inv_rows[idx].update(table_row.inventory_columns) sd_rows = status_data_tree.get_list(leg_path) idx = _find_matching_row_index(sd_rows, table_row.key_columns) if idx is None: sd_rows.append({**table_row.key_columns, **table_row.status_columns}) else: sd_rows[idx].update(table_row.status_columns)
def _do_inv_for_cluster(host_config: config.HostConfig, inventory_tree: StructuredDataTree) -> None: if host_config.nodes is None: return inv_node = inventory_tree.get_list("software.applications.check_mk.cluster.nodes:") for node_name in host_config.nodes: inv_node.append({ "name": node_name, })
def _do_inv_for_cluster(host_config: config.HostConfig) -> InventoryTrees: inventory_tree = StructuredDataTree() _set_cluster_property(inventory_tree, host_config) if not host_config.nodes: return InventoryTrees(inventory_tree, StructuredDataTree()) inv_node = inventory_tree.get_list("software.applications.check_mk.cluster.nodes:") for node_name in host_config.nodes: inv_node.append({ "name": node_name, }) inventory_tree.normalize_nodes() return InventoryTrees(inventory_tree, StructuredDataTree())