o
    id                     @   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 ]!}|  | rR|| d 	 D ]}|
|| d | |  qBq1W |S  tyq } z| d||f  W Y d }~|S d }~ww )	Nr   external_ipctlplane_hostnamezError parsing yaml: %sz'Could not parse yaml for node addresses)
ControllerComputehostsz#Error getting %s host addresses: %s)
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   
