3 YÉj ã@sTdZddgZddlZddlZddlmZddlmZddlm Z dd„Z d d„Z dS) z.Functions to search for and change ifcfg filesÚsearch_ifcfg_of_interfaceÚifcfg_set_zone_of_interfaceéN)Úconfig)Úlog)ÚifcfgcCsºtjjtjƒsdSxtttjtjƒƒD]`}|jdƒs4q$xd D]}|j|ƒr:q:q:Wd |krXq$t d tj|fƒ}|j ƒ|j d ƒ|kr$|Sq$Wd tj|f}tjj|ƒr¶t |ƒ}|j ƒ|SdS)z6search ifcfg file for the interface in config.IFCFGDIRNzifcfg-ú.bakú.origú.rpmnewú.rpmorigú.rpmsaveú-rangeÚ.z%s/%sZDEVICEz %s/ifcfg-%s)rrr r r r ) ÚosÚpathÚexistsrZIFCFGDIRÚsortedÚlistdirÚ startswithÚendswithrÚreadÚget)Ú interfaceÚfilenameZignoredÚ ifcfg_file©rú/usr/lib/python3.6/fw_ifcfg.pyr!s*   cCsn|dkr d}t|ƒ}|dk rj|jdƒ|krj|jdƒdko>|dk rjtjd||jfƒ|jd|ƒ|jƒdS)zYSet zone (ZONE=) in the ifcfg file that uses the interface (DEVICE=)NÚZZONEzSetting ZONE=%s in '%s')rrrZdebug1rÚsetÚwrite)Zzonerrrrrr?s ) Ú__doc__Ú__all__rZos.pathZfirewallrZfirewall.core.loggerrZfirewall.core.io.ifcfgrrrrrrrÚs