a 'Dg@sUdZddlZddlZddlmZmZddlmZddlm Z ddl m Z ddl m Z ddlmZd d d ge d d gdZe ed<eeZddZedddZee eeddddZe edddZdS)z5Grub Dpkg: Configure grub debconf installation deviceN)subputil)Cloud)Config) MetaSchema) PER_INSTANCE)ProcessExecutionErrorZ cc_grub_dpkgZubuntuZdebian grub_dpkg grub-dpkg)idZdistrosZ frequencyZactivate_by_schema_keysmetac Csfd}g}d}d}trd}d}z tjdd||gdd j}Wnpty}zZzfetch_idevs..z)filtered to these disk/by-id symlinks: %srz selected %s) is_efi_bootedrstdoutstripr isinstancereasonFileNotFoundErrorLOGdebugstderr Exceptionrlogexcospathexistssplitjoinsorted)rZdevicesZ probe_targetZ probe_mounteidevsrrr fetch_idevssJ         r*)returnc CsFztjdWSty@}ztd|WYd}~dSd}~00dS)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$OSErrorrerror)r(rrrrcs  r)namecfgcloudargsr+c Cs|d|di}|si}|dd}t|rDtd||dSt|}td|ztjdg|dWn2ty}zttd |WYd}~n d}~00dS) 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) getrZis_falserrget_debconf_configrr r!)r.r/r0r1mycfgr2Z dconf_selr(rrrhandleos   r7)r6r+cCstr*t|dd}|dur"t}d|St|dd}|durFt}|d}|dur`| }nt|tstt|}t| }d||fSdS)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 ) rrZget_cfg_option_strr*r4rboolZtranslate_boolstrlower)r6r)Z idevs_emptyrrrr5s(    r5)__doc__Zloggingr"Z cloudinitrrZcloudinit.cloudrZcloudinit.configrZcloudinit.config.schemarZcloudinit.settingsrZcloudinit.subprr __annotations__Z getLogger__name__rr*r8rr9listr7r5rrrr s$      D