@@ -91,25 +91,38 @@ class SCSClusterStatusChecker(BaseClusterStatusChecker):
9191 Class to check the status of a pacemaker cluster in an SAP SCS environment.
9292 """
9393
94- def __init__ (self , sap_sid : str , ansible_os_family : str = "" ):
94+ def __init__ (
95+ self ,
96+ sap_sid : str ,
97+ ansible_os_family : str = "" ,
98+ ascs_instance_number : str = "00" ,
99+ ers_instance_number : str = "01" ,
100+ ):
95101 super ().__init__ (ansible_os_family )
96102 self .sap_sid = sap_sid
103+ self .ascs_instance_number = ascs_instance_number
104+ self .ers_instance_number = ers_instance_number
97105 self .result .update (
98106 {
99107 "ascs_node" : "" ,
100108 "ers_node" : "" ,
101109 }
102110 )
103111
104- def _process_node_attributes (self , node_attributes : ET .Element ) -> Dict [str , Any ]:
112+ def _process_node_attributes (self , cluster_status_xml : ET .Element ) -> Dict [str , Any ]:
105113 """
106114 Processes node attributes and identifies ASCS and ERS nodes.
107115
108- :param node_attributes : XML element containing node attributes.
109- :type node_attributes : ET.Element
116+ :param cluster_status_xml : XML element containing node attributes.
117+ :type cluster_status_xml : ET.Element
110118 :return: Dictionary with ASCS and ERS node information.
111119 :rtype: Dict[str, Any]
112120 """
121+ resources = cluster_status_xml .find ("resources" )
122+ node_attributes = cluster_status_xml .find ("node_attributes" )
123+ ascs_resource_id = f"rsc_sap_{ self .sap_sid .upper ()} _ASCS{ self .ascs_instance_number } "
124+ ers_resource_id = f"rsc_sap_{ self .sap_sid .upper ()} _ERS{ self .ers_instance_number } "
125+
113126 all_nodes = [node .attrib .get ("name" ) for node in node_attributes ]
114127 for node in node_attributes :
115128 node_name = node .attrib ["name" ]
@@ -120,20 +133,42 @@ def _process_node_attributes(self, node_attributes: ET.Element) -> Dict[str, Any
120133 else :
121134 self .result ["ascs_node" ] = node_name
122135
123- if self .result ["ascs_node" ] == "" and self .result ["ers_node" ] != "" :
124- self .result ["ascs_node" ] = next (
125- (n for n in all_nodes if n != self .result ["ers_node" ]), ""
126- )
136+ if resources is not None :
137+ ascs_resource = resources .find (f"./resource[@id='{ ascs_resource_id } ']" )
138+ ers_resource = resources .find (f"./resource[@id='{ ers_resource_id } ']" )
139+
140+ if ascs_resource is not None :
141+ is_failed = ascs_resource .attrib .get ("is_failed" , "false" ).lower () == "true"
142+ if not is_failed :
143+ node_element = ascs_resource .find ("node" )
144+ if node_element is not None :
145+ self .result ["ascs_node" ] = node_element .attrib .get (
146+ "name" , self .result ["ascs_node" ]
147+ )
148+ else :
149+ self .result ["ascs_node" ] = ""
150+
151+ if ers_resource is not None :
152+ is_failed = ers_resource .attrib .get ("is_failed" , "false" ).lower () == "true"
153+ if not is_failed :
154+ node_element = ers_resource .find ("node" )
155+ if node_element is not None :
156+ self .result ["ers_node" ] = node_element .attrib .get (
157+ "name" , self .result ["ers_node" ]
158+ )
159+ else :
160+ self .result ["ers_node" ] = ""
161+
127162 return self .result
128163
129164 def _is_cluster_ready (self ) -> bool :
130165 """
131- Check if the cluster is ready by verifying the ASCS node .
166+ Check if the cluster is ready by verifying at least one of ASCS or ERS nodes .
132167
133- :return: True if the cluster is ready , False otherwise.
168+ :return: True if either ASCS or ERS node is available , False otherwise.
134169 :rtype: bool
135170 """
136- return self .result ["ascs_node" ] != ""
171+ return self .result ["ascs_node" ] != "" or self . result [ "ers_node" ] != ""
137172
138173 def _is_cluster_stable (self ) -> bool :
139174 """
@@ -151,6 +186,8 @@ def run_module() -> None:
151186 """
152187 module_args = dict (
153188 sap_sid = dict (type = "str" , required = True ),
189+ ascs_instance_number = dict (type = "str" , required = False ),
190+ ers_instance_number = dict (type = "str" , required = False ),
154191 ansible_os_family = dict (type = "str" , required = False ),
155192 )
156193
0 commit comments