id:FddlZddlmZddlmZddlmZGddeZy)N)Cluster) parse_version) ElementTreec>eZdZdZdgZdZdZgdZdZdZ dZ dZ y ) pacemakerz+Pacemaker High Availability Cluster Manager)rT))onlineTzCollect nodes listed as online)offlineTzCollect nodes listed as offline) only-corosyncFz)Only use corosync.conf to enumerate nodescg|_ |jds |j|js|j |jDcgc] }d|vs| }}|r#|j ddj|z|jS#t$r}|j d|zYd}~d}~wwxYw#t$r}|j d|zYd}~d}~wwxYwcc}w)Nr zJFalling back to sourcing corosync.conf. Could not parse crm_mon output: %sz*Could not determine nodes from cluster: %s.zWARNING: Node addresses '%s' may not resolve locally if you are not running on a node in the cluster. Try using option '-c pacemaker.only-corosync' if these connections fail.,)nodes get_optionget_nodes_from_crm Exceptionlog_warnget_nodes_from_corosync log_errorjoin)selferrn_shortss B/usr/lib/python3/dist-packages/sos/collector/clusters/pacemaker.py get_nodeszpacemaker.get_nodess  O???3N++-::,,.#jj9CqL199  MMJ((7#$  zz%!NMM#GIL#MNNN O NNG#M N N O:sKCBC C*C* B=B83C8B==C C' C""C'c&d}|jd}|ddk(rB|djdjdd}t|tdkDsd }ny |jd |zd }|ddk(r|j|dy y )zG Try to parse crm_mon output for node list and status. z--output-as=xmlzcrm_mon --versionstatusroutput-z2.0.3z--as-xmlNz crm_mon --one-shot --inactive %sT) need_root)exec_primary_cmdsplitr parse_crm_xml)rxmlopt_vercver_outs rrzpacemaker.get_nodes_from_crm9s#$$%89 >Q >'')!,2237:D &w)??# $$ . 7%  >Q    tH~ . cXtj|}|jd}|D]}|j}|j dr'|ddk(r|j j |dG|j dsY|ddk(sb|j j |dy)zA Parse the xml output string provided by crm_mon rrtruenamer falseN)r fromstringfindattribrrappend)r xmlstring_xmlrnode_nodes rr$zpacemaker.parse_crm_xmlMs%%i0 '" 1DKKEx(U8_-F !!%-0+h70J !!%-0  1r)c|jd|jjd}tjd|}|D].}|j j |dj0y)z As a fallback measure, read corosync.conf to get the node list. Note that this prevents us from separating online nodes from offline nodes. z_WARNING: unable to distinguish online nodes from offline nodes when sourcing from corosync.confz/etc/corosync/corosync.confz((\sring0_addr:)(.*))N)rprimary read_filerefindallrr1strip)rccrr4s rrz!pacemaker.get_nodes_from_corosyncZsi G H \\ # #$A B 3R8 0D JJ  d2hnn. / 0r)N) __name__ __module__ __qualname__ cluster_name sos_pluginspackagesstrict_node_list option_listrrr$rr)rrrs4@L-KHK 6/( 1 0r)r)r:sos.collector.clustersr sos.utilitiesr xml.etreerrrFr)rrJs! *'!R0R0r)