Current File : //lib/python2.7/site-packages/cloudinit/net/__init__.pyo
�
�jbc@s�ddlZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZmZej
e�ZdZdZejd�d	�Zd
�Zdd�Zddddd
�Zdd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zdd�Z d�Z!d�Z"dd�Z#dd�Z$dd�Z%d�Z&d�Z'd�Z(d�Z)d �Z*d!�Z+d"�Z,d#�Z-d$e.fd%��YZ/d&�Z0dd'�Z1ddd(�Z2d)�Z3e4d*�Z5e4e4d+�Z6e7d,�Z8e4d-�Z9e4e4dd.�Z:d/�Z;d0�Z<d1�Z=d2�Z>d3�Z?d4�Z@d5eAfd6��YZBd7eCfd8��YZDdS(9i����N(tpartial(tmask_to_net_prefix(tutil(tUrlErrortreadurls/sys/class/net/teth0s([0-9]+)cCsAgtj||�D]*}|j�r1t|�n	|j�^qS(sDSorting for Humans: natural sort order. Can be use as the key to sort
    functions.
    This will sort ['eth0', 'ens3', 'ens10', 'ens12', 'ens8', 'ens0'] as
    ['ens0', 'ens3', 'ens8', 'ens10', 'ens12', 'eth0'] instead of the simple
    python way which will produce ['ens0', 'ens10', 'ens12', 'ens3', 'ens8',
    'eth0'].(tretsplittisdigittinttlower(tst_nsrettext((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pytnatural_sort_keyscCstS(s3Simple function to return the global SYS_CLASS_NET.(t
SYS_CLASS_NET(((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pytget_sys_class_path"stcCst�|d|S(Nt/(R(tdevnametpath((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pytsys_dev_path'sc
Cst||�}ytj|�}Wn�ttfk
r�}t|dd�}	|	tjtj	fkr}|dk	r}||�Sn|	tj
fkr�|dk	r�||�Sn�nX|j�}|dkr�|Sy||SWn?tk
r}|dk	r�||�St
jd||��nXdS(Nterrnos5Found unexpected (not translatable) value '%s' in '%s(RRt	load_filetOSErrortIOErrortgetattrtNoneRtENOENTtENOTDIRtEINVALtstriptKeyErrortLOGtdebug(
RRt	translatet	on_enoentton_keyerrort	on_einvaltdev_pathtcontentstete_errno((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pytread_sys_net+s.


	
cCs.d�}t||d|d|d|d|�S(NcSstS(N(tFalse(R)((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pyt
on_excp_falseIsR%R$R&R#(R+(tifacetfieldR#R-((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pytread_sys_net_safeHs	cCsFt||�}|tkrdSyt|�SWntk
rAdSXdS(N(R0R,RR	t
ValueError(R.R/tval((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pytread_sys_net_intRs
cCs.itd6td6td6}t|dd|�S(Ntuptunknowntdownt	operstateR#(tTrueR,R0(RR#((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pytis_up\scCstjjt|d��S(Ntwireless(tosRtexistsR(R((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pytis_wirelessdscCstjjt|d��S(Ntbridge(R;RR<R(R((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pyt	is_bridgehscCstjjt|d��S(Ntbonding(R;RR<R(R((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pytis_bondlscCs,t|dd�}tjj|�r(|SdS(s8Return the master path for devname, or None if no masterRtmasterN(RR;RR<R(RR((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pyt
get_masterpscCsht|�}|dkrtStjj|d�}tjj|d�}tjj|�pgtjj|�S(s@Return a bool indicating if devname's master is a bridge or bondR@R>N(RCRR,R;RtjoinR<(Rtmaster_pathtbonding_pathtbridge_path((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pytmaster_is_bridge_or_bondxscCsA|dkrt|�}nt||�s9t||�r=tStS(s� netfailover driver uses 3 nics, master, primary and standby.
        this returns True if the device is either the primary or standby
        as these devices are to be ignored.
    N(Rt
device_drivertis_netfail_primarytis_netfail_standbyR8R,(Rtdriver((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pytis_netfailover�s	cCs1d}yt|d�}Wntk
r,nX|S(sE Returns a str from reading /sys/class/net/<devname>/device/features.Rsdevice/features(R+t	Exception(Rtfeatures((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pytget_dev_features�s
cCs7t|�}|s%t|�dkr)tS|ddkS(s� Return True if VIRTIO_NET_F_STANDBY bit (62) is set.

    https://github.com/torvalds/linux/blob/         089cf7f6ecb266b6a4164919a2e69bd2f938374a/         include/uapi/linux/virtio_net.h#L60
    i@i>t1(RPtlenR,(RRO((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pythas_netfail_standby_feature�scCsUt|�dk	rtS|dkr1t|�}n|dkrAtSt|�sQtStS(s A device is a "netfail master" device if:

        - The device does NOT have the 'master' sysfs attribute
        - The device driver is 'virtio_net'
        - The device has the standby feature bit set

        Return True if all of the above is True.
    t
virtio_netN(RCRR,RIRSR8(RRL((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pytis_netfail_master�s	cCs�t|dd�}tjj|�s(tS|dkrCt|�}n|dkrStStjjtjj|��}t|�}|dkr�tSt	|�}|s�tSt
S(sL A device is a "netfail primary" device if:

        - the device has a 'master' sysfs file
        - the device driver is not 'virtio_net'
        - the 'master' sysfs file points to device with virtio_net driver
        - the 'master' device has the 'standby' feature bit set

        Return True if all of the above is True.
    RRBRTN(RR;RR<R,RRItbasenametrealpathRSR8(RRLtmaster_sysfs_pathtmaster_devnamet
master_drivertmaster_has_standby((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pyRJ�scCsUt|�dkrtS|dkr1t|�}n|dkrAtSt|�sQtStS(s� A device is a "netfail standby" device if:

        - The device has a 'master' sysfs attribute
        - The device driver is 'virtio_net'
        - The device has the standby feature bit set

        Return True if all of the above is True.
    RTN(RCRR,RIRSR8(RRL((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pyRK�s	cCs)t|d�}|r%|dkr%tStS(s�
    /* interface name assignment types (sysfs name_assign_type attribute) */
    #define NET_NAME_UNKNOWN	0	/* unknown origin (not exposed to user) */
    #define NET_NAME_ENUM		1	/* enumerated by kernel */
    #define NET_NAME_PREDICTABLE	2	/* predictably named by the kernel */
    #define NET_NAME_USER		3	/* provided by user-space */
    #define NET_NAME_RENAMED	4	/* renamed by user-space */
    tname_assign_typet3t4(R]R^(R0R8R,(RR\((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pyt
is_renamed�s	cCs%tt|d��}d|j�kS(NtueventsDEVTYPE=vlan(tstrR0t
splitlines(RR`((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pytis_vlanscCs`t|d�}|dkrtSt|�s/tStjd|�t|dditd6td6�S(Ntiflinkt2s/'%s' is wireless, basing 'connected' on carriertcarrierR#t0RQ(R0R8R=R,R!R"(RRd((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pytis_connectedscCstjjt|d��S(Ntdevice(R;RR<R(R((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pytis_physicalscCstjjt|��S(N(R;RR<R(R((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pyt
is_presentscCsId}t|d�}tjj|�rEtjjtj|��}n|S(s8Return the device driver for net device named 'devname'.s
device/driverN(RRR;RtislinkRVtreadlink(RRLtdriver_path((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pyRI!s
cCs#t|d�}|tkrdS|S(s;Return the device id string for net device named 'devname'.s
device/deviceN(R0R,R(Rtdev_id((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pytdevice_devid,scCsNytjt��}Wn1tk
rI}|jtjkrCg}qJ�nX|S(N(R;tlistdirRRRR(tdevsR)((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pytget_devicelist5s	tParserErrorcBseZdZRS(s6Raised when a parser has issue parsing a file/content.(t__name__t
__module__t__doc__(((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pyRt@scCs.|st|t�rtS|jd�dkS(Ntconfigtdisabled(t
isinstancetdictR,tget(tcfg((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pytis_disabled_cfgDscCs`|sg}ndtj�kr1tjd�nvgt�D]%}|dkr;t|�r;|^q;}t|�r�tjd|�d}tjtj|dtj�nt	dg�}t	gt�D]}t
|�|kr�|^q��}|j|�}g}g}x�|D]�}|jd�r'qnt
|�r9qnt|�rKqnt|�r]qnt|d�}	|	r�|j|�qnt|d	�}
|
r�|j|�qnt|d
�}|dkr|j|�qqqW|r�|}n|}tt|dt��}t|kr8|jt�|jdt�nx!|D]}
t|
d�r?|
Sq?WdS(s1Return the name of the 'fallback' network device.s
net.ifnames=0s9Stable ifnames disabled by net.ifnames=0 in /proc/cmdlinetlos4Found unstable nic names: %s; calling udevadm settles!Waiting for udev events to settletfunctvethRftdormantR7R6tlowerlayerdownR5tkeyitaddress(sdormantsdownR�sunknownN(Rtget_cmdlineR!R"RsR_RRtlog_timetudevadm_settletsetRIt
differencet
startswithR?RARMR3tappendR0tlisttsortedRtDEFAULT_PRIMARY_INTERFACEtremovetinsertR(tblacklist_driversRitunstabletmsgtinvalid_interfacestpotential_interfacest	connectedtpossibly_connectedt	interfaceRfR�R7tnamestname((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pytfind_fallback_nicJsd	%		




	

cCs�|st}ntd|�}|s(dSt|�rDi|d6}nit|d�j�d6}itd6|d6|d6}|r�t|�}|r�||dd<q�nii||6d	6d
d6}|S(
sBGenerate network cfg v2 for dhcp on the NIC most likely connected.R�R�R�t
macaddresstdhcp4sset-nametmatchRLt	ethernetsitversionN(R,R�RRUR0R
R8RI(R�t
config_driverttarget_nameR�R}RLtnconf((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pytgenerate_fallback_config�s 	cCsad�}d�}|jd�}|dkr7||�S|dkrM||�Std|��dS(NcSs�g}x�|jdi�D]�}|jd�dkr:qn|jd�}|sUqn|jd�}|jdi�jd�}|jdi�jd�}|s�t|�}n|s�t|�}n|j||||g�qW|S(	NRxttypetphysicaltmac_addressR�tparamsRLt	device_id(R|RIRpR�(tnetcfgtphysdevstenttmacR�RLR�((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pyt
_version_1�s cSs�g}x�|jdi�j�D]�}|jd�}|s@qn|jdi�jd�}|sgqn|jdi�jd�}|jdi�jd�}|s�t|�}n|s�t|�}n|j||||g�qW|S(NR�sset-nameR�R�RLR�(R|tvaluesRIRpR�(R�R�R�R�R�RLR�((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pyt
_version_2�s R�iis"Unknown network config version: %s(R|tRuntimeError(R�R�R�R�((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pytextract_physdevs�s		

c
CsKt|�}tg|D]}|d|df^q�}t|j��}t�j�}x�tdd�D]�}|j|�r�tjd�dS|j	|�}tjd|�xV|D]N}	t
||	�}
ttj
d|
�}d|
}tjtj|d|�q�Wt�j�}qjWd	|}tj|�|rGt|��ndS(
Niiis*net: all expected physical devices presents)net: waiting for expected net devices: %sR<s.Waiting for udev events to settle or %s existsR�s-Not all expected physical devices present: %s(R�R{R�tkeystget_interfaces_by_mactrangetissubsetR!R"R�RRRR�R�twarningR�(
R�tstrictR�R.texpected_ifacest
expected_macstpresent_macst_tmissingR�tsyspathtsettleR�((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pytwait_for_physdevs�s(-




cCs>ytt|��Wn#tk
r9}td|��nXdS(s�read the network config and rename devices accordingly.
    if strict_present is false, then do not raise exception if no devices
    match.  if strict_busy is false, then do not raise exception if the
    device cannot be renamed because it is currently configured.

    renames are only attempted for interfaces of type 'physical'.  It is
    expected that the network system will create other devices with the
    correct name in place.s(Failed to apply network config names: %sN(t_rename_interfacesR�R�(R�tstrict_presenttstrict_busyR)((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pytapply_network_config_namess
cCs>t|d�}|dkr4|r0td��ntS|dkS(s�return True if the provided interface has its own address.

    Based on addr_assign_type in /sys.  Return true for any interface
    that does not have a 'stolen' address. Examples of such devices
    are bonds or vlans that inherit their mac from another device.
    Possible values are:
      0: permanent address    2: stolen from another device
      1: randomly generated   3: set using dev_set_mac_addresstaddr_assign_types%s had no addr_assign_type.iiiN(iii(R3RR1R8(tifnameR�tassign_type((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pytinterface_has_own_macs
c
CsJi}x]t�D]R\}}}}idd6|d6|d6|j�d6|d6t|�d6||<qW|rFtjd�}tjdd	d
ddd
dgdt�\}}tjddd
dgdt�\}	}t	�}
x*||	fD]}|
j
|j|��q�Wx;|j�D]*}|dt
kp8|d|
k|d<qWn|S(s�Collect information necessary for rename_interfaces.

    returns a dictionary by mac address like:
       {name:
         {
          'downable': None or boolean indicating that the
                      device has only automatically assigned ip addrs.
          'device_id': Device id value (if it has one)
          'driver': Device driver (if it has one)
          'mac': mac address (in lower case)
          'name': name
          'up': boolean: is_up(name)
         }}
    tdownableR�RLR�R�R4s[0-9]+:\s+(\w+)[@:]tips-6taddrtshowt	permanenttscopetglobaltcaptures-4N(tget_interfacesRR
R9RtcompileRtsubpR8R�tupdatetfindallR�R,(
tcheck_downabletcur_infoR�R�RLR�tnmatchtipv6t_errtipv4tnics_with_addressest	bytes_outtd((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pyt_get_current_rename_info(s*
'	cs�t|�stjd�dS|dkr5t�}ni�x`|j�D]R\}}|j�}|jd�r�|dj�|d<n||d<|�|<qHW�fd�}d�}d�}	d�}
g}g}g}
|��}d}d	}d
����fd�}x�|D]�\}}}}|r;|j�}ng}||||�}|s|r|j	d||f�qqn|jd�}||kr�qn|s�|r|j	d||f�qqn|d
rTd}|ds|r|j	||||f�qqnt
|d
<|j	d|||ff�|
j	d
|||ff�n||krf||}|d
r�d}|ds�|r|j	||||f�qqq�|j	d|||ff�nd}x0|dks�||kr|d7}||}q�W|j	d||||ff�||d<|��}|d
rf|
j	d
|||ff�qfn|j	d|||d|ff�||d<|��}||7}qWi|d6|	d6|
d
6}t|�t|
�dkrt|�rtjd|�q�tjd|�n�tjd|||
�xk||
D]_\}}}}y|j|�|�Wq8tk
r�}|j	d|||||f�q8Xq8Wt|�r�tdj|���ndS(Nsno interfaces to renameR�R�cstd��j�D��S(Ncss|]}|d|fVqdS(R�N((t.0tdata((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pys	<genexpr>fs(R{R�(tbymac(R�(s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pyt
update_bynamees	cSs)tjddd|d|gdt�dS(NR�tlinkR�R�R�(RR�R8(tcurtnew((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pytrenameiscSs&tjddd|dgdt�dS(NR�R�R�R6R�(RR�R8(R�((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pyR6lscSs&tjddd|dgdt�dS(NR�R�R�R4R�(RR�R8(R�((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pyR4oss
cirename%di����cSs�|r@|r@|r@|d|ko?|d|ko?|d|kS|rj|rj|d|koi|d|kS|r~|d|kStS(smatch if set and in dataR�RLR�(R,(R�R�RLR�((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pytentry_matchyscs�g�j�D]!}�||||�r
|^q
}t|�rt|�dkrwd||||f}t|��n|dSdS(NisjFailed to match a single device. Matched devices "%s" with search values "(mac:%s driver:%s device_id:%s)"i(R�RRR1R(R�RLR�R�R�R�(R�R�(s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pyt
find_entry�s!s<[nic not present] Cannot rename mac=%s to %s, not available.R4s*[busy] Error renaming mac=%s from %s to %sR�R6s2[busy-target] Error renaming mac=%s from %s to %s.iR�is(unable to do any work for renaming of %ss$no work necessary for renaming of %ss$achieving renaming of %s with ops %ss.[unknown] Error performing %s%s for %s, %s: %ss
(
RRR!R"RR�titemstcopyR|R
R�R,RNRD(trenamesR�R�tcurrent_infoR�R�R�R�R�R6R4topsterrorstupst
cur_bynamettmpname_fmtttmpiR�R�tnew_nameRLR�tcur_opstcur_nameR�ttargetttmp_nametopmaptopR�R)((R�R�s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pyR�Ss�

				









"#
cCs7d}tjjt|d��r*d}nt||�S(s6Returns the string value of an interface's MAC AddressR�t
bonding_slavesbonding_slave/perm_hwaddr(R;RtisdirRR0(R�R((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pytget_interface_mac�s	cCsMt|d�dkrIt|�}|rE|rE|dd!|d}n|SdS(s�Returns the string value of an Infiniband interface's hardware
    address. If ethernet_format is True, an Ethernet MAC-style 6 byte
    representation of the address will be returned.
    R�t32i$i�i3N(R0R�(R�tethernet_formatR�((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pytget_ib_interface_hwaddr�s
cCs�i}x�t�D]�\}}}}||krNtd||||f��n|||<t|t�}|r||kr�td||||f��n|||<qqW|S(smBuild a dictionary of tuples {mac: name}.

    Bridges and any devices that have a 'stolen' mac are excluded.s5duplicate mac found! both '%s' and '%s' have mac '%s'(R�R�RR8(tretR�R�t_drivert_devidtib_mac((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pyR��s
c	Csg}t�}djd�}x�|D]�}t|�s=q%nt|�rOq%nt|�raq%nt|�rsq%nt|�dk	r�t|�r�q%nt	|�r�q%nt
|�}|s�q%n|dkr�||t|� kr�q%n|j||t
|�t|�f�q%W|S(s�Return list of interface tuples (name, mac, driver, device_id)

    Bridges and any devices that have a 'stolen' mac are excluded.t:t00iR(R(RRRRRRRRRRRRRRRRN(RsRDR�R?RcRARCRRHRMR�RRR�RIRp(RRrtzero_macR�R�((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pyR�s.	
")cCsxi}xkt�D]`\}}}}t|t�}|r||krctd||||f��n|||<qqW|S(sTBuild a dictionary mapping Infiniband interface names to their hardware
    address.s5duplicate mac found! both '%s' and '%s' have mac '%s'(R�RR,R�(RR�R�R((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pytget_ib_hwaddrs_by_interface6scCset|jd�|jd�g�s8tjd|�tSyt|dd�Wntk
r`tSXtS(sxReturn true when the instance has access to the provided URL

    Logs a warning if url is not the expected format.
    shttp://shttps://sOIgnoring connectivity check. Expected URL beginning with http*:// received '%s'ttimeouti(tanyR�R!R�R,RRR8(turl((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pythas_url_connectivityEs$
tEphemeralIPv4NetworkcBsVeZdZdddd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
RS(	s�Context manager which sets up temporary static network configuration.

    No operations are performed if the provided interface already has the
    specified configuration.
    This can be verified with the connectivity_url.
    If unconnected, bring up the interface with valid ip, prefix and broadcast.
    If router is provided setup a default route for that interface. Upon
    context exit, clean up the interface leaving no configuration behind.
    c	Cs�t||||g�s9tdj||||���nyt|�|_Wn(tk
rv}tdj|���nX||_||_||_||_||_	||_
g|_dS(sSSetup context manager and validate call signature.

        @param interface: Name of the network interface to bring up.
        @param ip: IP address to assign to the interface.
        @param prefix_or_mask: Either netmask of the format X.X.X.X or an int
            prefix.
        @param broadcast: Broadcast address for the IPv4 network.
        @param router: Optionally the default gateway IP.
        @param connectivity_url: Optionally, a URL to verify if a usable
           connection already exists.
        @param static_routes: Optionally a list of static routes from DHCP
        s5Cannot init network on {0} with {1}/{2} and bcast {3}sCannot setup network: {0}N(tallR1tformatRtprefixtconnectivity_urlR�R�t	broadcasttroutert
static_routestcleanup_cmds(	tselfR�R�tprefix_or_maskRRRRR)((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pyt__init__as 						cCsl|jr2t|j�r2tjd|j�dSn|j�|jrR|j�n|jrh|j�ndS(s>Perform ephemeral network setup if interface is not connected.s=Skip ephemeral network setup, instance has connectivity to %sN(	RR
R!R"t_bringup_deviceRt_bringup_static_routesRt_bringup_router(R((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pyt	__enter__�s	


	
	cCs+x$|jD]}tj|dt�q
WdS(sTeardown anything we set up.R�N(RRR�R8(Rt	excp_typet
excp_valuetexcp_tracebacktcmd((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pyt__exit__�sc	Cs<tjdddddd||fd|jgdt�d	S(
s7Perform the ip command to remove the specified address.R�s-familytinetR�tdels%s/%stdevR�N(RR�R�R8(RR�R((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pyt_delete_address�scCsKdj|j|j�}tjd|j||j�yHtjddddd|d|jd	|jg
d
t	didd
6�WnDtj
k
r�}d|jkr��ntjd|j|j�n�Xtjdddddd	|jdgd
t	�|jj
dddddd	|jdg�|jj
ddddd|d	|jg�dS(s1Perform the ip comands to fully setup the device.s{0}/{1}s:Attempting setup of ephemeral network on %s with %s brd %sR�s-familyR#R�taddRR%R�t
update_envtCtLANGsFile existss7Skip ephemeral network setup, %s already has address %sR�R�R4R6R$N(RR�RR!R"R�RRR�R8tProcessExecutionErrortstderrRR�(RtcidrR)((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pyR�s0	
	cCs�x�|jD]�\}}g}|dkr7d|g}ntjdddd|g|d|jgdt�|jjd	dddd
|g|d|jg�q
WdS(Ns	0.0.0.0/0tviaR�s-4trouteR�R%R�iR$(RRR�R�R8RR�(Rtnet_addresstgatewaytvia_arg((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pyR�s	cCs$tjddddgdt�\}}d|krStjd|j|j��dStjdd	dd
|jd|jd|jg	dt�|j	j
d
dd	dd|jd|jd|jg	�tjdd	dd
dd|jd|jg	dt�|j	j
d
dd	dddd|jg�dS(s<Perform the ip commands to fully setup the router if needed.R�R/R�s	0.0.0.0/0R�tdefaults<Skip ephemeral route setup. %s already has default route: %sNs-4R'R%tsrciR$R.(RR�R8R!R"R�RRR�RR�(RtoutR�((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pyR�s$'		N(RuRvRwRRRR"R&RRR(((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pyRVs						tRendererNotFoundErrorcBseZRS((RuRv(((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pyR6�s(ERtloggingR;Rt	functoolsRtcloudinit.net.network_stateRt	cloudinitRtcloudinit.url_helperRRt	getLoggerRuR!RR�R�RRRRR+R0R3R9R=R?RARCRHRMRPRSRURJRKR_RcRhRjRkRIRpRsRNRtR~R�R�R�R8R�R�R,R�R�R�R�RR�R�R	R
tobjectRR�R6(((s:/usr/lib/python2.7/site-packages/cloudinit/net/__init__.pyt<module>sr	
	
						

	
	
!										K	1%+�	
			 		�