3 ܓir$@s2ddlZddlmZmZmZGdddeeZdS)N)Plugin RedHatPlugin PluginOptc@s`eZdZdZdZdZdZdZedde d d ed de d d gZ d dZ ddZ ddZ ddZdS)AAPContainerizedzPCollects details about AAP Containerized setup under a user's home directoryzAAP Containerized SetupZaap_containerizedsysmgmtansiblepodmanusernamez>Username that was used to setup AAP containerized installation)defaultZval_typeZdesc directoryzhAbsolute path to AAP containers volume directory. Defaults to 'aap' under provided user's home directorycs`jd}jd_|sjdjd}|ddkrt}x>|djD].}d|krNd |krN|jd d \}}|j|qNWt|d kr|j }jd |d nj ddSjst j j d|}j|d_jjrfdddHD}j|jjnj d%jd&d'|d(d)fd'|d*d+fg} x | D]\} } j| | d,qNWj|} xP| D]H} jd'|d-| d | d.d/d0jd'|d1| d | d2d0qzWd3d4gd5d6d7d8d9d:d;gdd3d?gd@dAgdBdCgdD}x^|jD]R\}}|| krx<|D]4}j|}jd'|dE|dF|dG||d0qWqWdS)INr r zMAAP username is missing, use '-k aap_containerized.username=' to set itzps auxstatusroutputz/usr/bin/podmanz!/.local/share/containers/storage/)maxsplitzAAP username detected as ''z5Unable to determine AAP username, terminating plugin.~Zaapcsg|]}jj|qS) path_joinaap_directory_name).0path)selfr'/usr/lib/python3.6/aap_containerized.py Isz*AAPContainerized.setup.. containerstlscontroller/etc/*.certcontroller/etc/*.keyeda/etc/*.cert eda/etc/*.keygateway/etc/*.certgateway/etc/*.keyhub/etc/*.cert hub/etc/*.keyhub/etc/keys/*.pempostgresql/*.crtpostgresql/*.keyreceptor/etc/*.crtreceptor/etc/*.keyreceptor/etc/*.pem redis/*.crt redis/*.keyz Directory z2 does not exist or invalid absolute path provided.zsu - z -c 'podman info --debug'Z podman_infoz -c 'podman ps -a --format json'Zpodman_ps_all_json)suggest_filenamez -c 'podman logs z.logZaap_container_logs)r-Zsubdirz -c 'podman inspect Zpodman_inspect_logszawx-manage check_license --datazawx-manage list_instancesz!automation-gateway-service statusz!aap-gateway-manage print_settingsz!aap-gateway-manage authenticatorsz!aap-gateway-manage showmigrationsz aap-gateway-manage list_servicesz'aap-gateway-manage feature_flags --listzaap-gateway-manage --versionzawx-manage showmigrationsz"awx-manage run_dispatcher --statusz)awx-manage run_callback_receiver --statuszawx-manage run_wsrelay --statuszaap-eda-manage --versionzaap-eda-manage showmigrationszreceptorctl statuszreceptorclt work list)zautomation-controller-taskzautomation-gatewayzautomation-controller-webzautomation-eda-apiZreceptorz -c 'podman exec -it z bash -c "z"')rrrrrr r!r"r#r$r%r&r'r(r)r*r+r,)Z get_optionrZ _log_warnexec_cmdset splitlinessplitaddlenpop _log_errorosr expanduserrZ path_existsZadd_forbidden_pathZ add_copy_specZadd_cmd_output_get_aap_container_namesitemsZ_mangle_command)rr ZpsZ podman_userslineuser_Zuser_home_directoryZforbidden_pathsZpodman_commandsZcommandfilenameZaap_containersZ containerZpod_cmdsZpodZcmdscmdZfnamer)rrsetup)s                zAAPContainerized.setupc Cs\y8d|d}|j|}|ddkr6|djjdSgStk rV|jdgSXdS)Nzsu - z& -c 'podman ps -a --format {{.Names}}'r rr z"Error retrieving Podman containers)r.stripr1 Exceptionr5)rr r>Zcmd_outrrrr8s    z)AAPContainerized._get_aap_container_namescCsHddddddg}|jd}|dd krDx|D]}||d kr,d Sq,Wd S) Nzdumb-init -- /usr/bin/envoyz!dumb-init -- /usr/bin/supervisordz'dumb-init -- /usr/bin/launch_awx_web.shz(dumb-init -- /usr/bin/launch_awx_task.shzdumb-init -- aap-eda-managez5pulpcore-content --name pulp-content --bind 127.0.0.1zps --noheaders -eo argsr rrTF)r.)rZ aap_processesZ ps_outputZprocessrrr check_enableds    zAAPContainerized.check_enabledcCs|jd}d}d}|j||||jd}d}d}|j||||jd}d}d}|j|||d }|jd |d d }|jd |d dS)Nz/controller/etc/settings.pyz$(EMAIL_HOST_PASSWORD\s*=\s*)\'(.+)\'z \1********z/gateway/etc/settings.pyz(\s*'PASSWORD'\s*:\s*)('.*')z/eda/etc/settings.yamlz6(\s*)(PASSWORD|MQ_USER_PASSWORD|SECRET_KEY)(:\s*)(.*$)z\1\2\3********z8((["\']?PASSWORD["\']?\s*[:=]\s*)[rb]?["\'])(.*?)(["\'])z!aap-gateway-manage print_settingsz\1**********\4z-((SECRET_KEY\s*=\s*)([rb]?["\']))(.*?)(["\'])z\1**********\5)rZdo_path_regex_subZdo_cmd_output_sub)rZ file_pathZjregreplZregexZ replacementrrrpostprocs,   zAAPContainerized.postprocN)rr)r)__name__ __module__ __qualname____doc__Z short_descZ plugin_nameZprofilesZpackagesrstrZ option_listr?r8rCrErrrrrs(  r)r6Zsos.report.pluginsrrrrrrrr s