관리-도구
편집 파일: cc_grub_dpkg.cpython-39.pyc
a ����'�Dg�����������������������@���s����U�d�Z�ddlZddlZddlmZmZ�ddlmZ�ddlm Z �ddl mZ�ddlm Z �ddlmZ�d d dge dd gd�Zeed<�e�e�Zdd��Zed�dd�Zee eedd�dd�Ze ed�dd�ZdS�)z5Grub Dpkg: Configure grub debconf installation device�����N)�subp�util)�Cloud)�Config)� MetaSchema)�PER_INSTANCE)�ProcessExecutionErrorZcc_grub_dpkgZubuntuZdebian� grub_dpkg� grub-dpkg)�idZdistrosZ frequencyZactivate_by_schema_keys�metac��������������� ���C���sf��d}�g�}d}d}t���rd}d}z tjdd||gdd �j���}�W�np�ty��}�z<t|jt�rft� d ��nd|j v�r|t� d��n��W�Y�d }~n&d }~0��ty����t� td��Y�n0�|�r�tj�|��s�dS�z&tjdddd|�gdd �j������}W�n"�t�y���t� td|���Y�n0�t� dd�|���dd��|D��}t� dd�|���|�rRt|�d�n|�}t� d|��|S�)z� Fetches the /dev/disk/by-id device grub is installed to. Falls back to plain disk name if no by-id entry is present. ���diskz/bootZdevicez /boot/efiz grub-probez-tT)Zcapturez'grub-probe' not found in $PATHzfailed to get canonical pathz)grub-probe 'failed to get canonical path'Nz*grub-probe failed to execute for grub_dpkgZudevadm�infoz--rootz--query=symlinkz3udevadm DEVLINKS symlink query failed for disk='%s'z%considering these device symlinks: %s�,c�����������������S���s���g�|�]}d�|v�r|�qS�)z disk/by-id��)�.0�devr���r����A/usr/lib/python3.9/site-packages/cloudinit/config/cc_grub_dpkg.py� <listcomp>Z��������zfetch_idevs.<locals>.<listcomp>z)filtered to these disk/by-id symlinks: %sr���zselected %s)� is_efi_bootedr����stdout�stripr���� isinstance�reason�FileNotFoundError�LOG�debug�stderr� Exceptionr����logexc�os�path�exists�split�join�sorted)r���ZdevicesZprobe_targetZprobe_mount�e�idevsr���r���r����fetch_idevs���sJ����� ��� r*���)�returnc��������������� ���C���sF���zt�j�d�W�S��ty@�}��zt�d|���W�Y�d}�~�dS�d}�~�0�0�dS�)z4 Check if the system is booted in EFI mode. z/sys/firmware/efiz7Failed to determine if system is booted in EFI mode: %sNF)r"���r#���r$����OSErrorr����error)r(���r���r���r���r���c���s ����r���)�name�cfg�cloud�argsr+���c�������������� ���C���s����|��d|��di���}|si�}|��dd�}t�|�rDt�d|�|��d�S�t|�}t�d|��ztjdg|d��W�n2�ty��}�zt�td |��W�Y�d�}~n d�}~0�0�d�S�) Nr ���r ����enabledFz*%s disabled by config grub_dpkg/enabled=%sz-Setting grub debconf-set-selections with '%s'zdebconf-set-selections)�dataz6Failed to run debconf-set-selections for grub_dpkg: %s) �getr���Zis_falser���r����get_debconf_configr���r ���r!���)r.���r/���r0���r1����mycfgr2���Z dconf_selr(���r���r���r����handleo���s���� �r7���)r6���r+���c�����������������C���s����t���r*t�|�dd�}|du�r"t��}d|�S�t�|�dd�}|du�rFt��}|��d�}|du�r`|�}nt|t�stt�|�}t|�� ��}d||f�S�dS�)zd Returns the debconf config for grub-pc or grub-efi depending on the systems boot mode. zgrub-efi/install_devicesNz+grub-pc grub-efi/install_devices string %s zgrub-pc/install_deviceszgrub-pc/install_devices_emptyz[grub-pc grub-pc/install_devices string %s grub-pc grub-pc/install_devices_empty boolean %s ) r���r���Zget_cfg_option_strr*���r4���r����boolZtranslate_bool�str�lower)r6���r)���Zidevs_emptyr���r���r���r5�������s(����� ��r5���)�__doc__Zloggingr"���Z cloudinitr���r���Zcloudinit.cloudr���Zcloudinit.configr���Zcloudinit.config.schemar���Zcloudinit.settingsr���Zcloudinit.subpr���r����__annotations__Z getLogger�__name__r���r*���r8���r���r9����listr7���r5���r���r���r���r����<module> ���s$���� D