ó æ ”\c@s¥ddlmZddlTddlZddlmZddlmZddlj Z ddl Z ddl Z ddl Z ej jƒZdejfd„ƒYZdS( i(tbase(t*iÿÿÿÿN(t exceptions(tcommandstBootloaderPlugincBseZdZd„Zd„Zd„Zed„ƒZd„Zd„Z d„Z d„Z e d „Z d „Zd „Zd „Zd „Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zedƒd„ƒZedƒd„ƒZedƒd„ƒZedde ddƒd „ƒZed!de ddƒd"„ƒZed#de ddƒd$„ƒZ d%„Z!RS(&sÁ Plugin for tuning bootloader options. Currently only grub2 is supported and reboot is required to apply the tunings. These tunings are unloaded only on profile change followed by reboot. cOsPtjjtjƒs'tjdƒ‚ntt|ƒj ||Žt ƒ|_ dS(Ns4Required GRUB2 template not found, disabling plugin.( tostpathtisfiletconststGRUB2_TUNED_TEMPLATE_PATHRtNotSupportedPluginExceptiontsuperRt__init__Rt_cmd(tselftargstkwargs((sC/usr/lib/python2.7/site-packages/tuned/plugins/plugin_bootloader.pyR scCsRt|_t|_t|_t|_d|_d|_d|_ |j ƒ|_ dS(Nt( tFalset_has_dynamic_tuningtTruet_has_static_tuningtupdate_grub2_cfgt_initrd_remove_dirtNonet_initrd_dst_img_valt _cmdline_valt _initrd_valt_get_grub2_cfg_filest_grub2_cfg_file_names(Rtinstance((sC/usr/lib/python2.7/site-packages/tuned/plugins/plugin_bootloader.pyt_instance_inits       cCsdS(N((RR((sC/usr/lib/python2.7/site-packages/tuned/plugins/plugin_bootloader.pyt_instance_cleanup'scCs.idd6dd6dd6dd6dd6dd6S(Ntgrub2_cfg_filetinitrd_dst_imgtinitrd_add_imgtinitrd_add_dirtinitrd_remove_dirtcmdline(R(tcls((sC/usr/lib/python2.7/site-packages/tuned/plugins/plugin_bootloader.pyt_get_config_options*sc Cs©|jƒjƒ}g}xm|D]e}t|ƒjdƒrJ|j|ƒq||krg||||tS|jddkrutjjtj|jƒ|_qundS(NRiR’( RR-RRRRRŠRR‹(RRšRR›Rœ((sC/usr/lib/python2.7/site-packages/tuned/plugins/plugin_bootloader.pyt_initrd_dst_imgÿsR%cCs>|r dS|r:|dk r:|jj|ƒdk|_ndS(Nt1(RR tget_boolR(RRšRR›Rœ((sC/usr/lib/python2.7/site-packages/tuned/plugins/plugin_bootloader.pyR sR#t per_devicetpriorityi cCs_|r dS|r[|dk r[t|ƒ}|j|ƒ|dkrEtS|j|ƒs[tSndS(NR(RR-RŽRR™(RRšRR›Rœtsrc_img((sC/usr/lib/python2.7/site-packages/tuned/plugins/plugin_bootloader.pyt_initrd_add_imgs   R$c Csv|r dS|rr|dk rrt|ƒ}|j|ƒ|dkrEtStjj|ƒsltjd|ƒtStj d|ƒt j ddddƒ\}}tj d|ƒtj |ƒ|jjd |d |d tƒ\}} tj d | ƒ|d kr%tjdƒ|jj|dtƒtS|j|ƒ|jj|ƒ|jrrtj d|ƒ|jj|ƒqrndS(NRsFerror: cannot create initrd image, source directory '%s' doesn't exists+generating initrd image from directory '%s'tprefixstuned-bootloader-tsuffixs.tmps+writing initrd image to temporary file '%s'sfind . | cpio -co > %stcwdtshells cpio log: %siserror generating initrd imagetno_errorsremoving directory '%s'(RR-RŽRRRRR0terrorRMttempfiletmkstempRZtcloseR R}RRRR™Rtrmtree( RRšRR›Rœtsrc_dirtfdttmpfileRR‚((sC/usr/lib/python2.7/site-packages/tuned/plugins/plugin_bootloader.pyt_initrd_add_dir s2    (    R&c Cs|jj|jj|ƒƒ}|rß|jjdƒ}t|ƒdkrLdSt|jƒƒ}t|jƒƒ}|j |ƒ} | |kr¯t j t j dt|ƒfƒtSt jt jdt| ƒt|ƒfƒtSn|r|dk rt j dƒt|_||_ndS(Ns /proc/cmdlineiR&s;installing additional boot command line parameters to grub2(t _variablestexpandR tunquoteRjRlRR{R6t intersectionR0RMRtSTR_VERIFY_PROFILE_VALUE_OKR-RRªtSTR_VERIFY_PROFILE_VALUE_FAILRRR( RRšRR›RœtvR&t cmdline_sett value_settcmdline_intersect((sC/usr/lib/python2.7/site-packages/tuned/plugins/plugin_bootloader.pyt_cmdline>s"  )  cCs3|r/|jr/|jƒ|jƒt|_ndS(N(RRxR‰R(RRRš((sC/usr/lib/python2.7/site-packages/tuned/plugins/plugin_bootloader.pyt_instance_post_staticSs  ("R3t __module__t__doc__R RR t classmethodR(RCRRKRSRRXR`RgRqRwRxRzRVRˆR‰RŽR‘R™tcommand_customRRžRR¤R²R½R¾(((sC/usr/lib/python2.7/site-packages/tuned/plugins/plugin_bootloader.pyRs:               ! !!(RRt decoratorst tuned.logsttunedRttuned.utils.commandsRt tuned.constsRRR7R«tlogstgetR0tPluginR(((sC/usr/lib/python2.7/site-packages/tuned/plugins/plugin_bootloader.pyts