�
oB�]c@s,dZddlZddlZddlmZddlmZddlmZeje �Z
dZdZdZ
ee
fZd �Zd
�Zddd�Zdd�Zdd
�Ze dkr(ddlZe�Zejdejd�Zeeedejjd��Zer(eje�q(ndS(s-Run the dhclient hook to record network info.i����N(t
atomic_helper(tlog(tstagess
dhclient-hooktuptdowncCs(tj�}tjj|jj�d�S(Nsdhclient.hooks(RtInittostpathtjointpathstget_runpath(ti((s;/usr/lib/python2.7/site-packages/cloudinit/dhclient_hook.pyt_get_hooks_dirscCsvi}xi|j�D][\}}|jd�s=|jd�r|jdd�jdd�j�}|||<qqW|S(srGiven info (os.environ), return a dictionary with
lower case keys for each entry starting with DHCP4_ or new_.tDHCP4_tnew_t(titemst
startswithtreplacetlower(tinfotnew_infotktvtkey((s;/usr/lib/python2.7/site-packages/cloudinit/dhclient_hook.pyt_filter_env_valss$cCs
|tkr%td|tf��n|dkr=t�}n|dkrUtj}ntjj||d�}|tkr�tjj |�s�tj
|�ntj|t
|��tjd|�nA|tkrtjj |�rtj|�tjd|�qndS(Ns*Unexpected event '%s'. Expected one of: %ss.jsonsWrote dhclient options in %ss Removed dhclient options file %s(tEVENTSt
ValueErrortNoneRRtenvironRRtUPtexiststmakedirsRt
write_jsonRtLOGtdebugtDOWNtremove(t interfaceteventtdata_dtenvt hook_file((s;/usr/lib/python2.7/site-packages/cloudinit/dhclient_hook.pytrun_hook$s"
cCsm|dkr'tjdtdt�}n|jddddt�|jddd�|jd ttf�|S(
NtprogtdescriptionR'thelpsevent taken on the interfacetchoicesR&s&the network interface being acted upontaction( RtargparsetArgumentParsertNAMEt__doc__tadd_argumentRtset_defaultsthandle_args(tparser((s;/usr/lib/python2.7/site-packages/cloudinit/dhclient_hook.pyt
get_parser9s
cCstd|jd|jd|�S(sXHandle the Namespace args.
Takes 'name' as passed by cloud-init main. not used here.R&R'R((R+R&R'(tnametargsR(((s;/usr/lib/python2.7/site-packages/cloudinit/dhclient_hook.pyR7Est__main__R;iR(t_CI_DHCP_HOOK_DATA_D(R4R1Rt cloudinitRRtloggingRt getLoggert__name__R"R3RR$RRRRR+R9R7tsysR8t
parse_argstargvR;Rtgettreturn_valuetexit(((s;/usr/lib/python2.7/site-packages/cloudinit/dhclient_hook.pyt<module>s. |