U
    -_g                     @   s^   d dl Z d dlmZmZmZmZmZ G dd deZG dd deeeZG dd deeZ	dS )	    N)PluginRedHatPluginDebianPluginUbuntuPlugin	PluginOptc                   @   sL   e Zd ZdZdZdZeddddgZdZd	Z	d
Z
dd Zdd Zdd Zd	S )OpenStackKeystonezOpenStack KeystoneZopenstack_keystone)Z	openstackZopenstack_controllerZnopwTz!do not collect keystone passwords)defaultZdescz./var/lib/config-data/puppet-generated/keystoneN c                 C   s&  |  dddd| jd | jd | jd | jd | jd	 | jd
 | jd g | drn|  dd| j dg n|  dd| j dg | d}|d | _|d dks| | jsd| _|  | j dd dD }dd dD }t|rt|s| j	
d n| d | d | dd d! d S )"Nz'/etc/keystone/default_catalog.templatesz/etc/keystone/keystone.confz/etc/keystone/logging.confz/etc/keystone/policy.jsonz/etc/keystone/*.confz/etc/keystone/*.jsonz/etc/httpd/conf//etc/httpd/conf.d/z /etc/httpd/conf.modules.d/*.confz/var/spool/cron/z/etc/my.cnf.d/tripleo.cnfZall_logsz/var/log/keystone/z	/var/log/z*/keystone*z/var/log/keystone/*.logz*/keystone*.logzDcrudini --get /etc/keystone/keystone.conf identity domain_config_diroutputZstatusr   z/etc/keystone/domainsc                 S   s   g | ]}|t jkqS  osenviron.0pr   r   G/usr/lib/python3/dist-packages/sos/report/plugins/openstack_keystone.py
<listcomp>D   s     z+OpenStackKeystone.setup.<locals>.<listcomp>)ZOS_USERNAMEZOS_PASSWORDc                 S   s   g | ]}|t jkqS r   r   r   r   r   r   r   G   s     )ZOS_TENANT_NAMEZOS_PROJECT_NAMEz}Not all environment variables set. Source the environment file for the user intended to connect to the OpenStack environment.zopenstack endpoint listzopenstack catalog listZkeystone_confZkeystone_log)z.*/etc/keystone/keystone.confz/var/log/keystone/keystone.log)Zadd_copy_specvar_puppet_genZ
get_option	apachepkgZcollect_cmd_outputdomain_config_dirZ
path_isdirallanyZsoslogZwarningZadd_cmd_outputZadd_file_tags)selfZexec_outZvars_allZvars_anyr   r   r   setup   sR    




zOpenStackKeystone.setupc                 C   s:   |  d|| |  | jd || |  | jd || dS )z Apply regex substitution z/etc/keystone/*r
   N)do_path_regex_subr   )r   ZregexpZsubstr   r   r   apply_regex_subW   s      z!OpenStackKeystone.apply_regex_subc                 C   s|   ddddddddd	d
ddg}dg}d |}| dd | dd | d| dd | | jdd | dd d S )NZpasswordZqpid_passwordZrabbit_passwordZssl_key_passwordZldap_dns_passwordZneutron_admin_passwordZhost_passwordZadmin_passwordZadmin_tokenZca_passwordZtransport_urlZOIDCClientSecretZ
connection|z(^\s*(z)\s*(=\s*)?)(.*)z\1*********z!)\s*=\s*(.*)://(\w*):)(.*)(@(.*))z\1*********\6z)\s*=\s*)(.*)z
\1********)joinr   r   r   )r   Zprotect_keysZconnection_keysZjoin_con_keysr   r   r   postprocc   s8            

zOpenStackKeystone.postproc)__name__
__module____qualname__Z
short_descZplugin_nameZprofilesr   Zoption_listr   r   r   r   r   r    r   r   r   r   r      s   8r   c                   @   s   e Zd ZdZdZdS )DebianKeystoneZapache2)Zkeystonezpython-keystonezpython3-keystoneNr!   r"   r#   r   Zpackagesr   r   r   r   r$      s   r$   c                   @   s   e Zd ZdZdZdS )RedHatKeystoneZhttpd)zopenstack-selinuxNr%   r   r   r   r   r&      s   r&   )
r   Zsos.report.pluginsr   r   r   r   r   r   r$   r&   r   r   r   r   <module>   s   n
