o
    *b                     @   s*   d dl mZmZmZ G dd deeZdS )    )PluginUbuntuPlugin	PluginOptc                       s   e Zd ZdZdZdZdZdZedde	dd	ed
de	dd	edde	dd	gZ
dd Zdd Zdd Z fddZdd Zdd Z  ZS )MaaszUbuntu Metal-As-A-Servicemaas)Zsysmgmt)r   zmaas-common)z
maas-dhcpdzmaas-dhcpd6z	maas-httpz
maas-proxyz
maas-rackdzmaas-regiondzmaas-syslogzsnap.maas.supervisorprofile-name zName of the remote API)defaultZval_typeZdescurlzURL of the remote APIcredentialszCredentials, or the API keyc                 C   s   |  do|  do|  dS )Nr
   r   r   )
get_optionself r   9/usr/lib/python3/dist-packages/sos/report/plugins/maas.py_has_login_options,   s   zMaas._has_login_optionsc                 C   s2   |  d| d| d| df }|d dkS )Nzmaas login %s %s %sr   r
   r   statusr   )exec_cmdr   )r   retr   r   r   _remote_api_login0   s   zMaas._remote_api_loginc                 C   s   |  dd dkS )Nzsnap list maasr   r   )r   r   r   r   r   _is_snap_installed;   s   zMaas._is_snap_installedc                    s   t   rdS |  S )NT)supercheck_enabledr   r   	__class__r   r   r   >   s   
zMaas.check_enabledc                 C   s   |   | _| jr| ddg | d | g d n| g d | ddg | dr5| d	g |  rP|  rI| d
| d  d S | 	d d S d S )Nzsnap info maaszmaas statusz'/var/snap/maas/current/bind/session.key)	z/var/snap/maas/common/logz/var/snap/maas/common/snap_modez/var/snap/maas/current/*.confz/var/snap/maas/current/bindz/var/snap/maas/current/httpz"/var/snap/maas/current/supervisordz/var/snap/maas/current/preseedsz/var/snap/maas/current/proxyz/var/snap/maas/current/rsyslog)z/etc/squid-deb-proxyz	/etc/maasz/var/lib/maas/dhcp*z/var/log/apache2*z/var/log/maas*z/var/log/upstart/maas-*zapt-cache policy maas-*z apt-cache policy python-django-*zmaas-region-controllerzmaas-region dumpdataz"maas %s commissioning-results listr   z6Cannot login into MAAS remote API with provided creds.)
r   _is_snapZadd_cmd_outputZadd_forbidden_pathZadd_copy_specZis_installedr   r   r   Z
_log_errorr   r   r   r   setupE   s4   



z
Maas.setupc                 C   s"   | j rd}nd}| |dd d S )Nz(/var/snap/maas/current/maas/regiond.confz/etc/maas/regiond.confz(database_pass\s*:\s*)(.*)z
\1********)r   Zdo_file_sub)r   Zregiond_pathr   r   r   postproct   s   zMaas.postproc)__name__
__module____qualname__Z
short_descZplugin_nameZprofilesZpackagesservicesr   strZoption_listr   r   r   r   r   r   __classcell__r   r   r   r   r      s,    	/r   N)Zsos.report.pluginsr   r   r   r   r   r   r   r   <module>   s   
