HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux ip-10-0-8-47 6.8.0-1021-aws #23~22.04.1-Ubuntu SMP Tue Dec 10 16:31:58 UTC 2024 aarch64
User: ubuntu (1000)
PHP: 8.1.2-1ubuntu2.22
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/cloudinit/config/__pycache__/cc_ubuntu_drivers.cpython-310.pyc
o

�Ad��@s8UdZddlZddlmZddlmZddlmZzddlZdZ	Wn
e
y.dZdZ	YnwddlmZdd	l
mZdd
l
mZmZmZmZddlmZddlmZmZdd
lmZe�e�ZdgZddded�eed�gedgd�Zeed<ee�ZdZ dZ!dZ"defdd�Z#de$deded ed!e%d"dfd#d$�Z&dS)%z<Ubuntu Drivers: Interact with third party drivers in Ubuntu.�N)�dedent)�Cloud)�DistroTF)�Logger)�log)�subp�
temp_utils�
type_utils�util)�Config)�
MetaSchema�get_meta_doc)�PER_INSTANCE�ubuntu�cc_ubuntu_driverszUbuntu Driversz,Interact with third party drivers in Ubuntu.zo        This module interacts with the 'ubuntu-drivers' command to install
        third party driver packages.zN        drivers:
          nvidia:
            license-accepted: true
        �drivers)�id�name�title�description�distros�examples�	frequency�activate_by_schema_keys�metazDubuntu-drivers: error: argument <command>: invalid choice: 'install'z�Template: linux/nvidia/latelink
Type: boolean
Default: true
Description: Late-link NVIDIA kernel modules?
 Enable this to link the NVIDIA kernel modules in cloud-init and
 make them available for use.
�X_LOADTEMPLATEFILE�distroc
Cs�t|t�stdt�|�|f��d}t�t�||��}|s&t�	d||�dSt
�d�s5t�	d�|dg�d}t�|d�}|rF|d	�|�7}t�	d
|||rO|nd�t
j|��dd
�}tj�|d�}zGz#t�|t�t�d��}	|	�t|�Wd�n1s�wYWnty�}
z
t�tdt|
���d}
~
wwWtj�|�r�t�|�n
tj�|�r�t�|�wwzt
�
ddd|g�WdSt
jy�}zt|j vr�t�!d��d|j"vr�t�!d��d}~ww)Nz.'drivers' config expected dict, found '%s': %sznvidia/license-acceptedz$Not installing NVIDIA drivers. %s=%szubuntu-driverszI'ubuntu-drivers' command not available.  Installing ubuntu-drivers-commonzubuntu-drivers-common�nvidiaznvidia/versionz:{}z<Installing and activating NVIDIA drivers (%s=%s, version=%s)�latestT)�dir�	needs_exeznvidia.templatez
cloud-initz.Failed to register NVIDIA debconf template: %s�installz--gpgpuz[the available version of ubuntu-drivers is too old to perform requested driver installationz"No drivers found for installation.z0ubuntu-drivers found no drivers for installation)#�
isinstance�dict�	TypeErrorr	�obj_namer
�translate_bool�get_cfg_by_path�LOG�debugr�which�formatr�mkdtemp�get_tmp_exec_path�os�path�join�
write_file�NVIDIA_DEBCONF_CONTENT�debconf�DebconfCommunicator�commandr�	Exception�logexc�str�isdir�del_dir�ProcessExecutionError� OLD_UBUNTU_DRIVERS_STDERR_NEEDLE�stderr�warning�stdout)�cfg�pkg_install_funcr�cfgpath�nv_acc�
driver_arg�version_cfg�tdir�debconf_file�dc�e�exc�rK�D/usr/lib/python3/dist-packages/cloudinit/config/cc_ubuntu_drivers.py�install_driversOsz
��
�

���
����
���
�
�
��rMrr@�cloudr�args�returncCsFd|vr|�d|�dSts|�d|�dSt|d|jj|j�dS)Nrz4Skipping module named %s, no 'drivers' key in configz<Skipping module named %s, 'python3-debconf' is not installed)r)�HAS_DEBCONFr>rMr�install_packages)rr@rNrrOrKrKrL�handle�s��rS)'�__doc__r.�textwrapr�cloudinit.cloudr�cloudinit.distrosrr3rQ�ImportError�loggingr�	cloudinitrrrr	r
�cloudinit.configr�cloudinit.config.schemarr
�cloudinit.settingsr�	getLogger�__name__r(rr�__annotations__r<r2rrMr8�listrSrKrKrKrL�<module>sj�
���	��

@������