3 tjd|d|tjd}|dk r>|jdkr>|jdSdS)Nz^\s*z \s*=\s*(.*)$)flagsr)research MULTILINE lastindexgroup)rconfkeymorrr _get_keyval7s  zSystemdPlugin._get_keyvalc Cs~tjd|ddt||tjd\}}|dkrzy|ddkrF|d7}Wntk r\YnX||dt|d7}|S|S) Nz^(\s*z\s*=).*$z\g<1>)rr =)rsubnstrr IndexError)rr"r#valZconf_newZnsubsrrr _add_keyval?s(  zSystemdPlugin._add_keyvalcCstjd|dd|tjdS)Nz^\s*z\s*=.*\n)r)rsubr)rr"r#rrr_del_keyKszSystemdPlugin._del_keycCs,|jjtjdd}|dkr(tjddS|S)N)err_retz(error reading systemd configuration file)r read_filer r logerror)rZsystemd_system_confrrr_read_systemd_system_confNs  z'SystemdPlugin._read_systemd_system_confcCsptjtj}|jj||s8tjd|jj|dddS|jj|tjsltjdtj|jj|dddSdS)Nz(error writing systemd configuration fileT)no_errorFz/error replacing systemd configuration file '%s') r r ZTMP_FILE_SUFFIXr write_to_filer3r4unlinkrename)rr"Ztmpfilerrr_write_systemd_system_confUs  z(SystemdPlugin._write_systemd_system_confcCstjjtj|jS)N)rr joinr ZPERSISTENT_STORAGE_DIRname)rrrr_get_storage_filenamecsz#SystemdPlugin._get_storage_filenamecCsl|j}|dk rh|j}|jj|ddd}|jj||dkrN|j|tj}n|j|tj|}|j |dS)NT)r1r6) r5r=rr2r8r0r SYSTEMD_CPUAFFINITY_VARr-r:)rr"fnamecpu_affinity_savedrrr_remove_systemd_tuningfs z$SystemdPlugin._remove_systemd_tuningcCs0|tjkr,tjdtj|jtjddS)Nz6removing '%s' systemd tuning previously added by TuneDz[you may need to manualy run 'dracut -f' to update the systemd configuration in initrd image)r Z ROLLBACK_FULLr3infor>rAZconsole)rrZrollbackrrr_instance_unapply_staticrs z&SystemdPlugin._instance_unapply_staticc Cs<|dkr dSdjdd|jjtjddtjdd|DS)Nr. css|]}t|VqdS)N)r*).0vrrr |sz8SystemdPlugin._cpulist_convert_unpack..z\s+,z,\s+)r;rcpulist_unpackrr/)rZcpulistrrr_cpulist_convert_unpackysz%SystemdPlugin._cpulist_convert_unpackrF)Z per_devicec Csd}d}|jj|jj|jj|}djdd|jj|D}|j} | dk rh|j| t j }|j |}|r||j d|||S|r|j } |jj| ddd} |dk r| dkr||kr|jj| |ddtjdt j |t jf|j|j| t j |dS) NrDcss|]}t|VqdS)N)r*)rErFrrrrGsz)SystemdPlugin._cmdline..rT)r1r6)Zmakedirz setting '%s' to '%s' in the '%s')rZunescapeZ _variablesexpandZunquoter;rIr5r%r r>rJZ _verify_valuer=r2r7r3rBr r:r-) rZenablingvalueZverifyZignore_missingZ conf_affinityZconf_affinity_unpackedrFZ v_unpackedr"r?r@rrr_cmdline~s" zSystemdPlugin._cmdline)__name__ __module__ __qualname____doc__rrr classmethodrr%r-r0r5r:r=rAr Z ROLLBACK_SOFTrCrJZcommand_customrM __classcell__rr)rrr s    r)r.rZ decoratorsZ tuned.logsZtunedrZtuned.utils.commandsrZ tuned.constsr rrZlogsgetr3ZPluginrrrrrs