%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/modules/debian_ip.pyo

�
���^c@@s�	dZddlmZmZmZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
mZddlmZddlZddlZddlZddlZddlZddlZeje�Zejdejejjejj j!d���Z"dZ#d	�Z$id
d6dd
6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd 6d!d"6d#d$6d%d&6d'd'6d(d(6d)d)6d*d*6d+d+6d,d,6d-d-6d.d.6Z%idd
6d
d6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6d d6d"d!6d&d%6d$d#6d'd'6d(d(6d)d)6d*d*6d+d+6d,d,6d-d-6d.d.6Z&id/d/6d0d06d1d16d2d26d3d36d4d46d5d56d6d66d7d76d8d86d9d96d:d:6d;d;6d<d<6d=d=6d>d>6d?d?6d@d@6Z'dAZ(dBZ)dCZ*dDZ+dEZ,dFZ-dGZ.dHZ/dIZ0dJZ1dKdLdMdNe2gZ3dOdPdQdRe4gZ5dSdTdUdVdWdXdYdZd[d\d]gZ6d^�Z7d_�Z8d`�Z9da�Z:db�Z;dc�Z<dd�Z=de�Z>df�Z?dg�Z@dh�ZAdi�ZBdj�ZCdk�ZDdl�ZEdm�ZFdn�ZGdo�ZHdp�ZIdq�ZJdr�ZKds�ZLddddt�ZNddddu�ZOdv�ZPidwdx6dydz6d{d|6d}d~6dd�6ZQeRd��ejSeQ�D��ZTd}eTd}<d{eTd{<d�d�d�d�d�d�gZUi"eOeUd�ejV�d�6eEd}6eHd6eKd�6eEd�6eId�6eEd�6eEd�6eGd{6eId>6eOd�d�d�gd�ejV�d�6eHd�6eId�6eId�6eHd�6eHd�6eHd�6eEd�6eGd|6eOd�d�d�d�d�gd�ejV�d�6eEd�6eEd�6eEd�6eId�6eHd�6eHd16eId�6eHd�6ePdw6ePdy6eHd�6eHd�6eHd�6eHd�6ZWd�d�d�d�d�d�d�gZXieOeX�d�6eFd}6eHd6eLd�6eFd�6eFd�6eGd{6eId>6eOd�d�d�d�gd�ejV�d�6eOdd�d�gd�eY�d�6eOdd�gd�eY�d�6eHd�6eOdd�gd�eY�d�6eOdd�gd�eY�d�6eId�6eId�6eJd�6eHd�6eOd�d�d�d�d�gd�ejV�d�6eEd�6eEd�6eId�6ePdw6ePdy6eHd�6eHd�6eHd�6ZZieHd�6eHd�6eOdd�d�gd�eY�d�6eHd�6eHd�6eHd�6eHd�6eHd�6eHd�6eHd�6eHd�6eHd�6Z[ieWe[gd�6eZe[gd�6Z\d�d��Z]d��Z^dd��Z_d��Z`d��Zad��Zbd��Zcd��Zdd��Zed��Zfd��Zgd��Zhd��Zid��Zjd��Zkd��Zld��Zmd��Znd��Zod��Zpe4d��Zqd��Zrd��Zsd��Ztd��Zud��Zvd��Zwd��Zxd��Zyd��Zzd��Z{d��Z|d��Z}d��Z~d��Zd��Z�dS(�u�
The networking module for Debian-based distros

References:

* http://www.debian.org/doc/manuals/debian-reference/ch05.en.html
i(tabsolute_importtprint_functiontunicode_literalsN(tsix(tStringIOtloaderu	debian_ipuipcC@stddkrtStdfS(u5
    Confine this module to Debian-based distros
    u	os_familyuDebianu?The debian_ip module could not be loaded: unsupported OS family(t
__grains__t__virtualname__tFalse(((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt__virtual__0su
link-speeduspeedulink-duplexuduplexuethernet-autoneguautonegu
ethernet-portuethernet-woluwoludriver-message-leveluethernet-pause-rxuethernet-pause-txuethernet-pause-autonegu
offload-rxurxu
offload-txutxu
offload-sgusguoffload-tsoutsouoffload-ufouufouoffload-gsougsouoffload-grougrouoffload-lroulrou!hardware-irq-coalesce-adaptive-rxu!hardware-irq-coalesce-adaptive-txuhardware-irq-coalesce-rx-usecsuhardware-irq-coalesce-rx-framesuhardware-dma-ring-rxuhardware-dma-ring-rx-miniuhardware-dma-ring-rx-jumbouhardware-dma-ring-txuuserupassworduproviderupppoe_ifaceunoipdefaultu
usepeerdnsudefaultrouteuholdoffumaxfailu
hide-passwordulcp-echo-intervalulcp-echo-failureuconnectunoauthupersistumtuunoaccompulinknameu/etc/network/routesu/etc/network/interfacesu/etc/network/interfaces.d/u/etc/network/if-up.d/u/etc/network/if-down.d/u/etc/modprobe.d/u/etc/default/networkingu
/etc/hostnameu/etc/resolv.confu/etc/ppp/peers/uyesuonutrueu1unouoffufalseu0uethubondualiasucloneuipsecudialupubridgeuslaveuvlanupppoeusourcecC@s"d}|j||dj|��S(uc
    Build an appropriate error message from a given option and
    a list of expected values.
    u>Invalid option -- Interface: {0}, Option: {1}, Expected: [{2}]u|(tformattjoin(tifacetoptiontexpectedtmsg((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt_error_msg_iface�scC@sd}|j|||�S(uc
    Build an appropriate error message from a given option and
    a list of expected values.
    uDInvalid option -- Route interface: {0}, Option: {1}, Expected: [{2}](R
(RR
RR((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt_error_msg_routes�scC@s&d}tj|j|||��dS(Nu=Using default option -- Interface: {0} Option: {1} Value: {2}(tlogtinfoR
(RtopttvalueR((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt_log_default_iface�scC@sd}|j|dj|��S(uc
    Build an appropriate error message from a given option and
    a list of expected values.
    u8Invalid network setting -- Setting: {0}, Expected: [{1}]u|(R
R(R
RR((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt_error_msg_network�scC@s#d}tj|j||��dS(Nu1Using existing setting -- Setting: {0} Value: {1}(RRR
(RRR((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt_log_default_network�scC@s/t|||�}tj|�t|��dS(uB
    Log and raise an error with a logical formatted message.
    N(RRterrortAttributeError(RR
RR((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt_raise_error_iface�s
cC@s,t||�}tj|�t|��dS(uB
    Log and raise an error with a logical formatted message.
    N(RRRR(R
RR((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt_raise_error_network�s
cC@s/t|||�}tj|�t|��dS(uB
    Log and raise an error with a logical formatted message.
    N(RRRR(RR
RR((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt_raise_error_routes�s
cC@spyQtjjj|d��3}g|j�D]}tjjj|�^q+SWdQXWnttfk
rkdSXdS(u7
    Reads and returns the contents of a text file
    urbNu(	tsalttutilstfilestflopent	readlineststringutilstto_strtOSErrortIOError(tpathtcontentstline((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt
_read_file�s
6cC@stjjjt�S(u 
    Parse /etc/resolv.conf
    (RRtdnstparse_resolvt_DEB_RESOLV_FILE(((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt_parse_resolve�scC@st�jdd�S(u6
    Parse /etc/resolv.conf and return domainname
    udomainu(R.tget(((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt_parse_domainname�scC@st�jdd�S(u8
    Parse /etc/resolv.conf and return searchdomain
    usearchu(R.R/(((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt_parse_searchdomain�scC@s/tt�}|r'|djd�dSdSdS(u1
    Parse /etc/hostname and return hostname
    iu
uN(R*t_DEB_HOSTNAME_FILEtsplit(R(((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt_parse_hostname�scC@s�tjjj�}d|d<tjjt�r�tjjj	t��r}xh|D]`}tjj
j|�|jd�r{qMqM|jd�rM|j
dd�dj�|d<qMqMWWdQXnt�}t�}t�}||d<||d	<||d
<|S(uH
    Parse /etc/default/networking and return current configuration
    uu
networkingu#uCONFIGURE_INTERFACESu=iNuhostnameu
domainnameusearchdomain(RRtodicttOrderedDicttosR'tisfilet_DEB_NETWORKING_FILER tfopenR#t
to_unicodet
startswithR3tstripR4R0R1(toptsR(R)thostnamet
domainnametsearchdomain((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt_parse_current_network_settingss"

0			


cC@stjjjj|�|dfS(uvalidate an IPv4 addressudotted IPv4 address(RRtvalidatetnett	ipv4_addr(R((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt__ipv4_quad$scC@stjjjj|�|dfS(uvalidate an IPv6 addressuIPv6 address(RRRCRDt	ipv6_addr(R((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt__ipv6*scC@stjjjj|�|dfS(uvalidate a mac addressuMAC address(RRRCRDtmac(R((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt__mac0scC@s
t|dfS(N(tTruetNone(R((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt
__anything6scC@sDt|}}yt|�}t}Wntk
r6nX||dfS(uvalidate an integeruinteger(RtintRKt
ValueError(Rtvalidt_value((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt__int:s


cC@sDt|}}yt|�}t}Wntk
r6nX||dfS(uvalidate a floatufloat(RtfloatRKRO(RRPRQ((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt__floatEs


cC@sltd}}t|�\}}}|oAd|ko?dkns_tjjjj|�}n|||fS(u4validate an IPv4 dotted quad or integer CIDR netmasku#dotted quad or integer CIDR (0->32)ii (RRRRRRCRDtnetmask(RRPterrmsgt_((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt__ipv4_netmaskPs

"cC@sQtd}}t|�\}}}|oAd|ko?dkn}|||fS(u validate an IPv6 integer netmaskuIPv6 netmask (0->128)ii�(RRR(RRPRVRW((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt__ipv6_netmaskYs
"cC@s�t|}}|rFy||�}||k}WqRtk
rBqRXn||k}|dkr�|r�t|dt|d�o�t|jd|��}dj||�}q�dj|�}n|||fS(uAvalidate that a value is in ``within`` and optionally a ``dtype``u__name__u	__class__unameu{0} within '{1}'uwithin '{0}'N(RRORLtgetattrthasattrt	__class__R
(RtwithinRVtdtypeRPRQttypename((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt	__within2as 

	cC@stjtd|d|d|�S(NR]RVR^(t	functoolstpartialR`(R]RVR^((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt__withinwscC@sit|tj�r'|j�j�}nt|d�rO|gkrOt|dfSt|dj|�fSdS(uAvalidate that a value contains one or more space-delimited valuesu__iter__uspace-delimited stringu*{0} is not a valid space-delimited value.
N(	t
isinstanceRtstring_typesR=R3R[RKRR
(R((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt__space_delimited_list|s

udns-nameserversudnsu
dns-searchusearchu	hwaddressuhwaddruaddressuipaddru	addressesuipaddrscc@s!|]\}}||fVqdS(N((t.0tktv((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pys	<genexpr>�subootpudhcpustaticumanualuloopbackupppR^uprotounetmasku	broadcastumetricugatewayupointopointuglobalulinkuhostuscopeuhostnameu
leasehoursu	leasetimeuvendoruclientubootfileuserverugreuGREuipipuIPIPu802.3adumodeuendpointudstaddrulocaluttluslavesuunituoptionsuvlan-raw-deviceunetworkutestuenable_ipv6uautouv4tunnelu6to4usiteiiuprivextumediau	accept_rauautoconfupreferred-lifetimeudad-attemptsudad-intervaluwireless-essidu
wireless-modeuwpa-ap-scanuwpa-confu
wpa-driveru	wpa-groupuwpa-key-mgmtuwpa-pairwiseuwpa-psku	wpa-protouwpa-roamuwpa-ssiduinetuinet6c	C@sst|d}}}tj|g�}x=|D]5}||kr-||}||�\}}}Pq-q-W|||fS(u�lookup the validation function for a [addrfam][attr] and
    return the results

    :param attr: attribute name
    :param value: raw setting value
    :param addrfam: address family (inet, inet6,
    uUnknown validator(RtATTRMAPSR/(	tattrRtaddrfamRPRQRVtattrmapstattrmapt
validate_func((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt_validate_interface_options

cC@s"|tkp!|tkp!|tkS(N(tWIRELESS_ATTR_MAPt
IPV4_ATTR_MAPt
IPV6_ATTR_MAP(Rk((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt_attrmaps_contain_attrscC@s�|d'kr�g}tjjt�rY|gtjt�D]}djt|�^q77}ntjjt�r�|j	dt�q�nt
jjj
�}d}xL|D]D}t
jjj|��'}i}x|D]}t
jjj|�}|j�jd�s�|j�r
q�n|jd�rC|j�}t|�dkrkd}	|	j|�}	tj|	�t|	��n|d}
|d	}|d
}|
|kr�t
jjj
�||
<nd||
kr�t
jjj
�||
d<n|||
dkrt
jjj
�||
d|<n||
d|}||d<||d
<||d<q�|dj�r�|j�}|j�jd'd�\}}
t|�rd|kr�|jdd�}n|}t||
|�\}}}|dkrd|krd|kr�g|d<n|dj|�q~|||<q�|tkr_d|krNt
jjj
�|d<n|
|d|<q�|jd�r�t jd|dd�d}d|kr�t
jjj
�|d<n|
|d|<q�|jd�r!t jd|dd�d}d|krt
jjj
�|d<n|
|d|<q�|d+kr�|
}d jt j!dd|��}||krjg||<n||j|�q�q�|jd!�r�xG|j�dD]9}||kr�t
jjj
�||<nt"||d"<q�Wq�|jd#�rAx�|j�dD]9}||kr,t
jjj
�||<nt"||d$<qWq�|jd%�r�d%|krut
jjj
�|d%<nd|d%kr�t
jjj
�|d%d<g|d%dd&<n|d%dd&j|j�d�q�q�WWd'QXq�Wx�|D]�}
|
d%krq�nd||
krFd(j|
�}	tj|	�|j#|
�q�nx�dddgD]t}d)||
dkrV|||
dd)kr�t$||
dd)|j%��}|||
dd)|d*<q�qVqVWq�W|S(,uP
    Parse /etc/network/interfaces and return current configured interfaces
    u{0}/{1}ii����u#uifaceiuInterface file malformed: {0}.iiiudatauaddrfamuprotoufilenameu-u_uaddressu	addressesuethtoolubondu[_-]tmaxsplitubondingubridgeubridginguupupre-upupost-upudownupre-downu	post-downu{0}_cmdsuautouenabledu
allow-hotpluguhotplugusourceusourcesNu,Interface file malformed for interface: {0}.uinetu_keys(uupupre-upupost-upudownupre-downu	post-down(&RLR7R'texistst_DEB_NETWORK_DIRtlistdirR
R8t_DEB_NETWORK_FILEtinsertRRR5R6R R:R#R;tlstripR<tisspaceR3tlenRRRtrstripRttreplaceRptappendt_REV_ETHTOOL_CONFIG_OPTStretsubRKtpoptsortedtkeys(tinterface_filestdirtadapterstmethodtinterface_filet
interfacest
iface_dictR)tslineRt
iface_nameRlRktvaluestrtattrnameRPRRVRtcmdtcmd_keytwordtopt_keys((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt_parse_interfaces!s�5

!



!




	
4


"(cC@s�i}d|krw|dtkr9|jidd6�qw|dtkr`|jidd6�qwt|dtt�nd|kr�ddg}|d|kr�|ji|dd6�q�t|d|�nd|kr6dd	d
dg}tj|d�|kr|ji|dd6�q6t||d|�ntt}x{dD]s}||krG||tkr�|jid|6�q�||tkr�|jid|6�q�t|||�qGqGW|S(u�
    Filters given options and outputs valid settings for ETHTOOLS_OPTS
    If an option has a value that is not expected, this
    function will log what the Interface, Setting and what it was
    expecting.
    uautoneguonuoffuduplexufulluhalfuspeedu10u100u1000u10000urxutxusgutsouufougsougroulro(urxutxusgutsouufougsougroulro(t_CONFIG_TRUEtupdatet
_CONFIG_FALSERRt	text_type(R>RtconfigRPR
((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt_parse_ethtool_opts�s4

cC@s�i}x+tD]#}||kr
||||<q
q
Wd|krb|drbt|dtt�ntt}x{dD]s}||krs||tkr�|jid	|6�q�||tkr�|jid
|6�q�t|||�qsqsW|S(u�
    Filters given options and outputs valid settings for ETHTOOLS_PPPOE_OPTS
    If an option has a value that is not expected, this
    function will log what the Interface, Setting and what it was
    expecting.
    uproviderunoipdefaultu
usepeerdnsudefaultrouteu
hide-passwordunoauthupersistunoaccompuTrueuFalse(unoipdefaultu
usepeerdnsudefaultrouteu
hide-passwordunoauthupersistunoaccomp(t_DEB_CONFIG_PPPOE_OPTSRR�R�R�(R>RR�RRPR
((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt_parse_ethtool_pppoe_opts�s


cC@s
i
dd6dd6dd6dd6d	d
6dd6dd
6dd6dd6dd6}|dd(kr�tjdj|��t|||�S|dd)kr�tjdj|��t|||�S|dd*kr�tjdj|��t|||�S|dd+kr$tjdj|��t|||�S|dd,krZtjd j|��t|||�S|dd-kr�tjd#j|��t|||�S|dd.kr�tjd&j|��t	|||�Sdddddd"d%dddddd!d$g}t
|d|�d'S(/u�
    Filters given options and outputs valid settings for requested
    operation. If an option has a value that is not expected, this
    function will log what the Interface, Setting and what it was
    expecting.
    u0u	ad_selectu16u	tx_queuesu100umiimonu250uarp_intervalu200u	downdelayu	lacp_rateu1u	max_bondsuupdelayuonuuse_carrierulayer2uxmit_hash_policyumodeu
balance-rru6Device: {0} Bonding Mode: load balancing (round-robin)u
active-backupu9Device: {0} Bonding Mode: fault-tolerance (active-backup)ubalance-xoru2u.Device: {0} Bonding Mode: load balancing (xor)u	broadcastu3u5Device: {0} Bonding Mode: fault-tolerance (broadcast)u802.3adu4u?Device: {0} Bonding Mode: IEEE 802.3ad Dynamic link aggregationubalance-tlbu5u1Device: {0} Bonding Mode: transmit load balancingubalance-albu6u1Device: {0} Bonding Mode: adaptive load balancingN(u
balance-rru0(u
active-backupu1(ubalance-xoru2(u	broadcastu3(u802.3adu4(ubalance-tlbu5(ubalance-albu6(RRR
t_parse_settings_bond_0t_parse_settings_bond_1t_parse_settings_bond_2t_parse_settings_bond_3t_parse_settings_bond_4t_parse_settings_bond_5t_parse_settings_bond_6R(R>Rtbond_defRP((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt_parse_settings_bond�s^




	cC@s�idd6}dg}d|kr�t|dt�r�dt|d�koVdknr�|jidd6�x^|dD]?}t|d�dkr�|dd	||d<qz||d<qzWq�t|d|�q�t|d|�nt|d|�d
|krVy*t|d
�|ji|d
d
6�Wq�tk
rRt|d
dg�q�Xn,t|d
|d
�|ji|d
d
6�|S(u�
    Filters given options and outputs valid settings for bond0.
    If an option has a value that is not expected, this
    function will log what the Interface, Setting and what it was
    expecting.
    u0umodeulist of ips (up to 16)u
arp_ip_targetiiuiu,uarp_intervaluinteger(RdtlistR}R�RRNROR(R>RR�tbondRPtip((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyR�Vs,
	&
cC@s�idd6}x�dddgD]�}||kr�y*t||�|ji|||6�Wq�tk
rt||dg�q�Xqt||||�|ji|||6�qWd|kr�|ji|dd6�ntdd	ko�td
ddks�d
|kru|d
tkr1|jidd
6�q�|d
tkrX|jidd
6�q�tt}t|d
|�q�t|d
|d
�|ji|d
d
6�n|S(u�
    Filters given options and outputs valid settings for bond1.
    If an option has a value that is not expected, this
    function will log what the Interface, Setting and what it was
    expecting.
    u1umodeumiimonu	downdelayuupdelayuintegeruprimaryuosuUbuntuuosrelease_infoiiuuse_carrieru0(RNR�RORRRR�R�(R>RR�R�tbindingRP((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyR�~s.

$
cC@s�idd6}dg}d|kr�t|dt�r�dt|d�koVdknr�|jidd6�x^|dD]?}t|d�dkr�|dd	||d<qz||d<qzWq�t|d|�q�t|d|�nt|d|�d
|krVy*t|d
�|ji|d
d
6�Wq�tk
rRt|d
dg�q�Xn,t|d
|d
�|ji|d
d
6�d|kr�d
ddg}|d|kr�|ji|dd6�q�t|d|�n|S(u�
    Filters given options and outputs valid settings for bond2.
    If an option has a value that is not expected, this
    function will log what the Interface, Setting and what it was
    expecting.
    u2umodeulist of ips (up to 16)u
arp_ip_targetiiuiu,uarp_intervaluintegeruhashing-algorithmulayer2ulayer2+3ulayer3+4uxmit_hash_policy(RdR�R}R�RRNROR(R>RR�R�RPR�((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyR��s6
	&
cC@sZidd6}x�dddgD]�}||kr�y*t||�|ji|||6�Wq�tk
rt||dg�q�Xqt||||�|ji|||6�qWd|kr*|dtkr�|jidd6�qV|dtkr
|jid	d6�qVtt}t|d|�n,t|d|d�|ji|dd6�|S(
u�
    Filters given options and outputs valid settings for bond3.
    If an option has a value that is not expected, this
    function will log what the Interface, Setting and what it was
    expecting.
    u3umodeumiimonu	downdelayuupdelayuintegeruuse_carrieru1u0(RNR�RORRR�R�(R>RR�R�R�RP((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyR��s(


cC@s.idd6}xdddddgD]}||kr�|dkr�||dkrh|jid	|6�n||d
kr�|jid|6�ndd	d
dg}n	dg}y*t||�|ji|||6�Wq*tk
r�t|||�q*Xq#t||||�|ji|||6�q#Wd
|kr�|d
tkra|jid	d
6�q�|d
tkr�|jidd
6�q�tt}t|d
|�n,t|d
|d
�|ji|d
d
6�d|kr*dddg}|d|kr|ji|dd6�q*t|d|�n|S(u�
    Filters given options and outputs valid settings for bond4.
    If an option has a value that is not expected, this
    function will log what the Interface, Setting and what it was
    expecting.
    u4umodeumiimonu	downdelayuupdelayu	lacp_rateu	ad_selectufastu1uslowu0uintegeruuse_carrieruhashing-algorithmulayer2ulayer2+3ulayer3+4uxmit_hash_policy(R�RNRORRR�R�(R>RR�R�R�RP((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyR��s@
	

cC@s�idd6}x�dddgD]�}||kr�y*t||�|ji|||6�Wq�tk
rt||dg�q�Xqt||||�|ji|||6�qWd|kr*|dtkr�|jidd6�qV|dtkr
|jid	d6�qVtt}t|d|�n,t|d|d�|ji|dd6�d
|kr}|ji|d
d
6�n|S(u�
    Filters given options and outputs valid settings for bond5.
    If an option has a value that is not expected, this
    function will log what the Interface, Setting and what it was
    expecting.
    u5umodeumiimonu	downdelayuupdelayuintegeruuse_carrieru1u0uprimary(RNR�RORRR�R�(R>RR�R�R�RP((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyR�,s,


cC@s�idd6}x�dddgD]�}||kr�y*t||�|ji|||6�Wq�tk
rt||dg�q�Xqt||||�|ji|||6�qWd|kr*|dtkr�|jidd6�qV|dtkr
|jid	d6�qVtt}t|d|�n,t|d|d�|ji|dd6�d
|kr}|ji|d
d
6�n|S(u�
    Filters given options and outputs valid settings for bond6.
    If an option has a value that is not expected, this
    function will log what the Interface, Setting and what it was
    expecting.
    u6umodeumiimonu	downdelayuupdelayuintegeruuse_carrieru1u0uprimary(RNR�RORRR�R�(R>RR�R�R�RP((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyR�Ss,


cC@sMi}d|krZt|dt�r?dj|d�|d<n|ji|dd6�nx}dddddgD]f}||krpy*t||�|ji|||6�Wq�tk
r�t||dg�q�XqpqpWxdd	d
gD]V}||kr�t||t�r'|ji|||6�q=t||dg�q�q�Wd|kr�tj	d
|dj
��r�|ji|dd6�q�t|ddg�nx�ddgD]�}||kr�yD||j�\}}t|�|jidj||�|6�Wq'tk
r#t||dg�q'Xq�q�Wd|kr�|dt
kr^|jidd6�q�|dtkr�|jidd6�q�t|dt
t�nd|krIt|dt�r�|ji|dd6�qI|dj�}|jd�}|j�r3|r3|jidj|dj|��d6�qIt||dg�n|S(u�
    Filters given options and outputs valid settings for BRIDGING_OPTS
    If an option has a value that is not expected, this
    function will log the Interface, Setting and what was expected.
    uportsu uageingufdugcintuhelloumaxageufloatu
bridgeprioumaxwaituintegeruhwu/[0-9a-f]{2}([-:])[0-9a-f]{2}(\1[0-9a-f]{2}){4}$uvalid MAC addressupathcostuportpriou{0} {1}uinterface integerustpuonuoffuwaitportiuinteger [interfaces](RdR�RR�RSRORRNR�tmatchtlowerR3R
R�R�R�tisdigit(R>RR�Rtporttcost_or_priotvaluest
waitport_time((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt_parse_bridge_optszs^
	
$
	cC@s�tjjj�}tjjj�||<|||d<tjjj�||d<||d}tjjj�|d<tjjj�|d<|r�t||d<n|jdt�r�t||d<nd}t}d|kr||dr|d|dd<d	|dd
<d}d|krD|ddkrDtjd
d|�|dd<nd|kr�d|kr�d|dd<d}t}q�nd|dd<|d/kr�t	||�}|r�i}	x |D]}
||
|	t
|
<q�W|	||d<t|	�||d<q�n|dkrct||�}|r�|j
dd0�|||d<t|�||d<|||d<q�nj|dkr�t||�}|r�|j
dd0�|||d<|d||dd<t|�||d<|||d<q�n�|dkr/|d||d<d|d<||d||d<|||d<n�|dkritjd
d|�||d<|||d<nd|d kr�t||�}|r�x/|D]$}
||
||d|t|
<q�Wn|||d<nx|D]}
|
jd!�r�|
d"}t}n|
}t}tj||�}t|�r�||
}|dkrQ|d#krQd$}n|r�t||d%d�\}}}|s�t|d&j|
|�|g�n|jd'd(�}||d|<q�|r�t}d0}x�ddgD]r}t||d%|�\}}}|r�t}|jd'd(�}|dks=||dkrQ||||<qQq�q�W|s�t|d&j|
|�|g�q�q�t||d%|�\}}}|s�t|d&j|
|�|g�n|jd'd(�}||||<q�q�WxAd)d*d+d,d-d.gD]'}
|
|kr||
|||
<qqWxHddgD]:}d||krk||d|krkq>|j
|�q>W|S(1uW
    Filters given options and outputs valid settings for a
    network interface.
    utypeudatauinetuinet6uenableduhotpluguenable_ipv6uaddrfamu64unetmasku
iface_typeuvlanu\.\d*uuvlan_raw_deviceuipaddru
ipv6ipaddrubridgeuethtooluethtool_keysumodeubridgingu
bridging_keysubondubondinguslavesubonding_keysuslaveumasterumanualuprotoupppoeuipv6iunoneustaticRlu'{0}' '{1}'u-u_uup_cmdsupre_up_cmdsupost_up_cmdsu	down_cmdsu
pre_down_cmdsupost_down_cmds(ubridgeN(RRR5R6RKR/RR�R�R�t_ETHTOOL_CONFIG_OPTSR�R�R�RLR�R�R�R<tSALT_ATTR_TO_DEBIAN_ATTR_MAPRtRpRR
R(R>t
iface_typetenabledRR�t
iface_datatdef_addrfamt
dual_stackttmp_ethtooltethtooltitemtbridgingtbondingRtoptnametv6onlyt_optnameR�RPRRVt
valid_onceRl((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt_parse_settings_eth�s� 


%

	
	"
$cC@sstjjj�}tjjj�||<|||d<tjjj�||d<||d}|dg|d<|S(uW
    Filters given options and outputs valid settings for a
    network interface.
    utypeudatausourceusources(RRR5R6(R>R�R�RR�R�((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt_parse_settings_sourceqscC@s�td�tj|�D��}td�tj|�D��}i}tt}d|kr�y#|d|d<td|d�Wq�tk
r�td|�q�Xn|d|d<|d|kr�|dtkr�d|d<q	|dtkr	d|d<q	n
td|�d|kr_y#|d|d<td|d�Wq_tk
r[tddg�q_Xn|drz|d|d<ntddg�d	|kr�|d	|d	<n|S(
ud
    Filters given options and outputs valid settings for
    the global network settings file.
    cs@s'|]\}}|j�|fVqdS(N(R�(RgRhRi((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pys	<genexpr>�scs@s'|]\}}|j�|fVqdS(N(R�(RgRhRi((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pys	<genexpr>�suenabledu
networkinguyesunouhostnameuserver1.example.comusearch(tdictRt	iteritemsR�R�RROR(R>tcurrenttresultRP((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt_parse_network_settings�s:





cC@sgtd�tj|�D��}i}d|krDt|dd�nx|D]}||||<qKW|S(u[
    Filters given options and outputs valid settings for
    the route settings file.
    cs@s'|]\}}|j�|fVqdS(N(R�(RgRhRi((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pys	<genexpr>�suroutesuList of routes(R�RR�R(RR>R�R((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt
_parse_routes�s
cC@s�tjj||j|��}tjj|�sdd}|j||�}tj|�t|��ntj	j
j|d��#}|jtj	j
j|��WdQX|S(u
    Writes a file to disk
    u){0} cannot be written. {1} does not existuwN(R7R'RR
RvRRRRRR R!twriteR#R$(RtdatatfoldertpatterntfilenameRtfout((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt_write_file�s
"cC@s�|jdd�}tjj||j|��}tjj|�svd}|j||�}tj|�t|��nt	j
jj|d��#}|j
t	j
jj|��WdQXtd|d�|S(u
    Writes a file to disk
    u.u_u){0} cannot be written. {1} does not existuwNu
file.set_modeu0755(RR7R'RR
RvRRRRRR R!R�R#R$t__salt__(RR�R�R�R�RR�((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt_write_file_routes�s
"cC@s�tjj|�rK|rKd}|j|�}tj|�t|��ntjj	j
|d��#}|jtjjj
|��WdQXdS(uf
    Writes a file to disk
    If file does not exist, only create if create
    argument is True
    uS{0} cannot be written. {0} does not exist                and create is set to FalseuwN(R7R'RvR
RRRRRR R!R�R#R$(R�R�tcreateRR�((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt_write_file_network�s
cC@s=t�}|j|�|jd�|j�}|j�|S(u.
    Return what would be written to disk
    i(RR�tseekR"tclose(R�ttouttoutput((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt
_read_temp�s	


cC@s|ytjd�}Wn%tjjk
r:tjd�dSX|ji|d6|d6�}g|jd�D]}|d^qhS(u=
    Return what would be written to disk for interfaces
    udebian_eth.jinjau(Could not load template debian_eth.jinjauunameudatau
(	tJINJAtget_templatetjinja2t
exceptionstTemplateNotFoundRRtrenderR3(RR�ttemplatetifcfgR�((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt_read_temp_ifacess
cK@sBy"tjd�}tjd�}Wn%tjjk
rItjd�dSXt�}|||<d}x�|D]�}d||kr�||ddkr�|ji|d6||d6�}n!|ji|d6||d6�}||}||krj|}	qjqjWt	}
d	|krM|d	j
d
�s:djt|d	�}n
|d	}t
}
n+d	||dkrr||d}nt}tjjtjj|��s�d}|jtjj|��}tj|�t|��ntjjj|d
��H}
|
r|
jtjjj|	��n|
jtjjj|��WdQX|	jd�S(u
    Writes a file to disk
    udebian_eth.jinjaudebian_source.jinjau(Could not load template debian_eth.jinjauutypeusourceunameudataufilenameu/u{0}/{1}u{0} cannot be written.uwNu
(R�R�R�R�R�RRR�R�RR<R
RwRKRyR7R'RvtdirnameRRRR R!R�R#R$R3(RR�tsettingsteth_templatetsource_templateR�R�tadapterttmptsaved_ifcfgt_SEPARATE_FILER�RR�((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt_write_file_ifacessF
	

$$!


	
"c	C@s2ytjd�}Wn%tjjk
r:tjd�dSXt�}|||<d}|ji||d6�}||}t	d||ddd}t
jjt
jj
|��s�d}|jt
jj
|��}tj|�t|��ntjjj|d	��#}|jtjjj|��Wd
QX|S(u
    Writes a file to disk
    udebian_ppp_eth.jinjau,Could not load template debian_ppp_eth.jinjauudatau/uinetuprovideru{0} cannot be written.uwN(R�R�R�R�R�RRR�R�t_DEB_PPP_DIRR7R'RvR�R
RRRR R:R�R#R$(	RR�R�R�R�R�R�RR�((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt_write_file_ppp_ifacesMs&
	


"c	K@s[tdd }t||�}ytjd�}Wn%tjjk
rWtjd�dSX|j	i|d6|d6�}d|kr�|dr�t
|�St||td	j
|��tjjtd	j
|��}|d
kr5xCdD];}d
dddj
||�dg}td|dt�q�Wtdd|�ntdd�tdd�t|�S(u�
    Create a bond script in /etc/modprobe.d with the passed settings
    and load the bonding kernel module.

    CLI Example:

    .. code-block:: bash

        salt '*' ip.build_bond bond0 mode=balance-alb
    u	osreleaseiu
conf.jinjau"Could not load template conf.jinjauunameubondingutestu{0}.confu5ualiasuoptionsusedu-iu-eu/^{0}\s{1}.*/du/etc/modprobe.confucmd.runtpython_shellufile.appendu	kmod.loadupkg.installu
ifenslave-2.6(ualiasuoptions(RR�R�R�R�R�R�RRR�R�R�t_DEB_NETWORK_CONF_FILESR
R7R'RR�RR*(	RR�t	deb_majorR>R�R�R't	line_typeR�((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt
build_bondks*


	c	K@s6|j�}|tkr+t||t�nd|krDd|d<n|dkr�d|d<d|krvd}tj|�t|��qvn�|dkr�d|d<tdd�n�|d	kr�d|d	<td
d�svtdd�}qvn�|dkr+d
|krvd}tj|�t|��qvnK|dkrvd|kred}tj|�t|��ntdd�n|dkr�t||||�}n|dkr�t||||�}nd|kr�|dr�t	|||�St
||||�}|d	krt|||�ng|D]}|d^q"S(u�
    Build an interface script for a network interface.

    CLI Example:

    .. code-block:: bash

        salt '*' ip.build_interface eth0 eth <settings>
    uprotoustaticuslaveuyesumasteru1master is a required setting for slave interfacesuvlanupkg.installupppoeupkg.versionupppubonduslavesu0slaves is a required setting for bond interfacesubridgeuportsuSports is a required setting for bridge interfaces on Debian or Ubuntu based systemsubridge-utilsuethusourceutestu
(uethubondubridgeuslaveuvlanupppoe(usource(R�t_IFACE_TYPESRRRRR�R�R�R�R�R�(	RR�R�R�RtinstR>R�R�((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pytbuild_interface�sN






cK@s�t||�}ytjd�}Wn%tjjk
rItjd�dSX|jddd|dd|�}|jdd	d|dd|�}d
|kr�|d
r�t	||�St
||td�}t|�}t
||t
d�}|t|�7}|S(u�
    Add route scripts for a network interface using up commands.

    CLI Example:

    .. code-block:: bash

        salt '*' ip.build_routes eth0 <settings>
    uroute_eth.jinjau'Could not load template route_eth.jinjaut
route_typeuaddtroutesuroutesRudelutestu	route-{0}(R�R�R�R�R�R�RRR�R�R�t_DEB_NETWORK_UP_DIRR*t_DEB_NETWORK_DOWN_DIR(RR�R>R�tadd_routecfgtdel_routecfgR�tresults((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pytbuild_routes�s2

	
			cC@s$|dkr tdd|g�SdS(uu
    Shutdown a network interface

    CLI Example:

    .. code-block:: bash

        salt '*' ip.down eth0 eth
    uslaveusourceucmd.runuifdown(uslaveusourceN(R�RL(RR�((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pytdownscC@s(tjjtdj|��}t|�S(u}
    Return the content of a bond script

    CLI Example:

    .. code-block:: bash

        salt '*' ip.get_bond bond0
    u{0}.conf(R7R'RR�R
R*(RR'((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pytget_bonds
cC@s�t�}||kr�y1|dkr6tjd�}ntjd�}Wn%tjjk
rmtjd�dSX|ji|d6||d6�}g|j	d�D]}|d^q�SgSd	S(
u�
    Return the contents of an interface script

    CLI Example:

    .. code-block:: bash

        salt '*' ip.get_interface eth0
    usourceudebian_source.jinjaudebian_eth.jinjau(Could not load template debian_eth.jinjauunameudatau
N(
R�R�R�R�R�R�RRR�R3(RR�R�R�R�((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt
get_interface%s	
!$cC@s$|dkr tdd|g�SdS(us
    Start up a network interface

    CLI Example:

    .. code-block:: bash

        salt '*' ip.up eth0 eth
    uslaveusourceucmd.runuifup(uslaveusourceN(R�RL(RR�((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pytupCscC@stddko0ttdjd�d�dk}|r�i}tdd�rytd	d�rld
|d<q�d|d<n
d|d<t�}t�}t�}||d<||d
<||d<n	t�}ytj	d�}Wn%t
jjk
rt
jd�dSX|j|�}t|�S(u�
    Return the contents of the global network script.

    CLI Example:

    .. code-block:: bash

        salt '*' ip.get_network_settings
    u
osfullnameuUbuntuu	osreleaseu.iiuservice.availableu
networkinguservice.statusuyesunouhostnameu
domainnameusearchdomainudisplay-network.jinjau-Could not load template display-network.jinjau(RRNR3R�R4R0R1RBR�R�R�R�R�RRR�R�(tskip_etc_default_networkingR�R?R@RAR�tnetwork((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pytget_network_settingsTs.#


			


	
cC@s\tjjtdj|��}t|�}tjjtdj|��}|t|�7}|S(u~
    Return the routes for the interface

    CLI Example:

    .. code-block:: bash

        salt '*' ip.get_routes eth0
    u	route-{0}(R7R'RR�R
R*R�(RR�R�((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt
get_routes�s
cK@s�d|krt|d<nd|kr2t|d<nt}|dtkr�d|krktd|d�}q�tjd�t}nt}|dtkr�tjd�t}n3tdd�}tjd	�|o�td
d�}|o�|S(u�
    Apply global network configuration.

    CLI Example:

    .. code-block:: bash

        salt '*' ip.apply_network_settings
    urequire_rebootuapply_hostnameuhostnameunetwork.mod_hostnameuUThe network state sls is trying to apply hostname changes but no hostname is defined.ubThe network state sls is requiring a reboot of the system to properly apply network configuration.uservice.stopu
networkingiu
service.start(RRKR�R�Rtwarningttimetsleep(R�thostname_restreststop((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pytapply_network_settings�s(


		
c	K@s�g}t�}t||�}tddkoNttdjd�d�dk}|r�|ddkrpd	}nd
}tdd�r�t|d�ntdd�r5t|d�q5nzytjd
�}Wn%tj	j
k
r�tjd�dSX|j
|�}d|kr%|dr%t|�St|tt�|djdd�}|d|d<|d}	|d}
t}t|�dkr�|d}||	kr�|}
||d<t}q�|	}
|
|d<n|	}
|
|d<t}d|kr+|d}||
kr|}||d<t}q;|
}||d<n|
}||d<|sG|rht�}tjd�}tjd�}g}xctt�D]U}|j|�r�dj|
�}n!|j|�r�dj|�}n|j|�q�Wd|kr|jddj|
��nd|kr0|jd|kdj|��ndj|�}d|koR|dsht|t�qhnytjd�}Wn%tj	j
k
r�tjd�dSX|j
|�}|jt|��|S(u�
    Build the global network script.

    CLI Example:

    .. code-block:: bash

        salt '*' ip.build_network_settings <settings>
    u
osfullnameuUbuntuu	osreleaseu.iiu
networkinguyesuservice.enableuservice.disableuservice.availableuNetworkManageru
network.jinjau%Could not load template network.jinjauutestuhostnameiu
domainnameusearchdomainusearchu	domain\s+u	search\s+u
domain {0}u
search {0}udomainu
udisplay-network.jinjau-Could not load template display-network.jinja(RBR�RRNR3R�R�R�R�R�R�RRR�R�R�R9RKRR}R.R�tcompileR*R-R�R
R�RzRtextend(R�tchangestcurrent_network_settingsR>Rtservice_cmdR�RR�tcurrent_domainnametcurrent_searchdomaint
new_domaintnew_domainnameR@t
new_searchtnew_searchdomainRAtresolvetdomain_progtsearch_progtnew_contentsR�t
new_resolv((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pytbuild_network_settings�s�
	#	





	



	

	"
(�t__doc__t
__future__RRRRatloggingtos.pathR7R�R	R�tjinja2.exceptionstsalt.extRtsalt.ext.six.movesRtsalt.utils.dnsRtsalt.utils.filestsalt.utils.odicttsalt.utils.stringutilstsalt.utils.templatestsalt.utils.validate.nett	getLoggert__name__RtEnvironmenttFileSystemLoaderR'RRt	templatestTEMPLATE_DIRNAMER�RR	R�R�R�t_DEB_ROUTES_FILERyRwR�R�R�R9R2R-R�RKR�RR�R�RRRRRRRRR*R.R0R1R4RBRFRHRJRMRRRTRXRYRLR`RcRfR�R�R�tDEBIAN_ATTR_TO_SALT_ATTR_MAPtIPV4_VALID_PROTOR�RrtIPV6_VALID_PROTORNRsRqRjRpRtR�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�RRRRRRRR(((s:/usr/lib/python2.7/site-packages/salt/modules/debian_ip.pyt<module>s	$	



																														


%

"%


	�	,		Z	(	(	/	$	3	'	'	G	�		.				
		6		*	E	,					-		*

Zerion Mini Shell 1.0