o
    O6uf  ã                   @   s,   d dl Z d dlmZ dZG dd„ deƒZdS )é    N)ÚClusterz9/var/lib/mistral/overcloud/tripleo-ansible-inventory.yamlc                   @   s,   e Zd ZdZdZg d¢Zdd„ Zdd„ ZdS )	Úrhospaü  
    This cluster profile is for use with Red Hat OpenStack Platform
    environments.

    Different types of nodes may be enumerated by toggling the various profile
    options such as Controllers and Compute nodes. By default, only Controller
    nodes are enumerated.

    Node enumeration is done by inspecting the ansible inventory file used for
    deployment of the environment. This is canonically located at
    /var/lib/mistral/overcloud/tripleo-ansible-inventory.yaml. Similarly, the
    presence of this file on the primary node is what triggers the automatic
    enablement of this profile.

    Special consideration should be taken for where `sos collect` is being run
    from, in that the hostnames of the enumerated nodes must be resolveable
    from that system - not just from the primary node from which those nodes
    are discovered. If this is not possible, consider enabling the `use-ip`
    cluster option to instead have this profile source the IP addresses of the
    nodes in question.
    zRed Hat OpenStack Platform))úuse-ipFz0use IP addresses instead of hostnames to connect)Ú
controllerTz%collect reports from controller nodes)ÚcomputeFz"collect reports from compute nodesc                 C   s   | j jtdd�S )NT)Ú	need_root)ÚprimaryÚfile_existsÚ	INVENTORY)Úself© r   úB/usr/lib/python3/dist-packages/sos/collector/clusters/openstack.pyÚcheck_enabled0   s   zrhosp.check_enabledc              
   C   sê   g }|   d¡r	dnd}zt | j t¡¡}W n ty. } z|  d|› �¡ tdƒ‚d }~ww z'dD ]!}|   | ¡ ¡rS|| d  	¡ D ]}| 
|| d | | ¡ qCq2W |S  tyt } z|  d|› d	|› �¡ W Y d }~|S d }~ww )
Nr   Úexternal_ipÚctlplane_hostnamezError parsing yaml: z'Could not parse yaml for node addresses)Ú
ControllerÚComputeÚhostszError getting z host addresses: )Ú
get_optionÚyamlÚ	safe_loadr   Ú	read_filer
   Ú	ExceptionÚlog_infoÚlowerÚkeysÚappendÚ	log_error)r   Ú_nodesÚ_addr_fieldÚ_invÚerrÚ_tÚhostr   r   r   Ú	get_nodes3   s0   ÿ€þ€üþ €þzrhosp.get_nodesN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úcluster_nameÚoption_listr   r$   r   r   r   r   r      s    r   )r   Úsos.collector.clustersr   r
   r   r   r   r   r   Ú<module>   s   
