def _process_node_attributes()

in src/modules/get_cluster_status_db.py [0:0]


    def _process_node_attributes(self, cluster_status_xml: ET.Element) -> Dict[str, Any]:
        """
        Processes node attributes and identifies primary and secondary nodes.

        :param cluster_status_xml: XML element containing node attributes.
        :type cluster_status_xml: ET.Element
        :return: Dictionary with primary and secondary node information.
        :rtype: Dict[str, Any]
        """
        result = {
            "primary_node": "",
            "secondary_node": "",
            "cluster_status": {"primary": {}, "secondary": {}},
            "operation_mode": "",
            "replication_mode": "",
            "primary_site_name": "",
        }
        node_attributes = cluster_status_xml.find("node_attributes")
        attribute_map = {
            f"hana_{self.database_sid}_op_mode": "operation_mode",
            f"hana_{self.database_sid}_srmode": "replication_mode",
        }

        for node in node_attributes:
            node_name = node.attrib["name"]
            node_states = {}
            node_attributes_dict = {}

            for attribute in node:
                attr_name = attribute.attrib["name"]
                attr_value = attribute.attrib["value"]
                node_attributes_dict[attr_name] = attr_value

                if attr_name in attribute_map:
                    result[attribute_map[attr_name]] = attr_value

                if attr_name == f"hana_{self.database_sid}_clone_state":
                    node_states["clone_state"] = attr_value
                elif attr_name == f"hana_{self.database_sid}_sync_state":
                    node_states["sync_state"] = attr_value

            if (
                node_states.get("clone_state") == "PROMOTED"
                and node_states.get("sync_state") == "PRIM"
            ):
                result["primary_node"] = node_name
                result["cluster_status"]["primary"] = node_attributes_dict
                result["primary_site_name"] = node_attributes_dict.get(
                    f"hana_{self.database_sid}_site", ""
                )
            elif (
                node_states.get("clone_state") == "DEMOTED"
                and node_states.get("sync_state") == "SOK"
            ):
                result["secondary_node"] = node_name
                result["cluster_status"]["secondary"] = node_attributes_dict

        self.result.update(result)
        return result