%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@sdZddlmZmZmZddlZddlZddlZddlZddl	Z
ddlZ
ddlZ
ddl
mZmZmZddlmZyddlZWnek
r�dZnXyddlZWnek
r�dZnXyddlZWnek
rdZnXyddlmZWnek
rMdZnXeje�ZdZdZd	Zd
Z dZ!dd
dde"gZ#dZ$dZ%dZ&d�Z'd�Z(d�Z)d�Z*d�Z+d�Z,d�Z-d�Z.d�Z/d�Z0d�Z1d�Z2de!d �Z3d!�Z4d"�Z5d#�Z6d$�Z7d%�Z8d&�Z9d'�Z:d(�Z;d)�Z<dd*�Z=d+�Z>dd,�Z?d-�Z@d.�ZAd/�ZBd0�ZCd1�ZDd2�ZEd3�ZFd4�ZGd5�ZHd6�ZId7�ZJd8�ZKd9�ZLd:�ZMdS(;u6
The networking module for NI Linux Real-Time distro

i(tabsolute_importtprint_functiontunicode_literalsN(tmaptrangetconfigparser(tsix(tCaseInsensitiveDictuipu/net/connman/service/u"/var/lib/connman/interfaces.configu/usr/local/natinst/bin/nirtcfgu/etc/natinst/share/ni-rt.iniuyesuonutrueu1ii@uEtherCATcC@s|st|��ndS(u6
    Raise an exception if the condition is false
    N(tRuntimeError(t	conditionterr((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pyt_assume_condition<scC@s�y~d}ttddk|�ttd�ttd�tddkr}ttd�ttd	�tt�d
kd�nWn tk
r�}tt	|�fSXt
S(uA
    Confine this module to NI Linux Real-Time based distros
    u>The nilrt_ip module could not be loaded: unsupported OS familyu	os_familyu	NILinuxRTu+The python package request is not installedu+The python pyiface package is not installedulsb_distrib_idunilrtu-The python package pyconnman is not installedu(The python DBus package is not installeduofflineuConnman is not running(Rt
__grains__Rtpyifacet	pyconnmantdbust
_get_stateRtFalsetstrt__virtualname__(tmsgtexc((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pyt__virtual__Ds



cC@s`ytj�jd�SWnBtk
r+dStjk
r[}tjjdj	|���nXdS(u&
    Returns the state of connman
    uStateuofflineuConnman daemon error: {0}N(
RtConnManagertget_propertytKeyErrorRt
DBusExceptiontsaltt
exceptionstCommandExecutionErrortformat(R((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pyRVs
c	C@snd}tj�j�}xO|D]G\}}|dj||d|d|ddk|ddk�7}qW|S(u-
    Returns the technologies of connman
    uu<{0}
	Name = {1}
	Type = {2}
	Powered = {3}
	Connected = {4}
uNameuTypeuPowerediu	Connected(RRtget_technologiesR(ttechttechnologiestpathtparams((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pyt_get_technologiesbs	6cC@sSg}tj�j�}x4|D],\}}|jtj|tt���qW|S(u2
    Returns a list with all connman services
    (RRtget_servicestappendRt	text_typetlentSERVICE_PATH(tservtservicesR"t_((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pyt
_get_servicesns
$cC@s=tjtjjt|��jd�}|dkp<|dkS(u2
    Verify if a connman service is connected
    uStateuonlineuready(RtConnServicetosR"tjoinR)R(tservicetstate((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pyt
_connectedys'cC@sut|t�r3|jd�}|o-t|�}nt|d�oK|gk}|r^tdfStdj|�fSdS(uK
    validate that a value contains one or more space-delimited values
    u u__iter__uspace-delimited stringu{0} is not a valid list.
N(t
isinstanceRtsplittallthasattrtTrueRR(tvaluetitemstvalid((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pyt_space_delimited_list�s
cC@s�t|�dkr�tjjjj|dj��sKtdj|d�fStjjjj	|dj��s�tdj|d�fStjjjj|dj��s�tdj|d�fSntdj|�fSt
d	fS(
u
    validate ipv4 values
    iiu'Invalid ip address: {0} for ipv4 optioniu$Invalid netmask: {0} for ipv4 optioniu$Invalid gateway: {0} for ipv4 optionu"Invalid value: {0} for ipv4 optionu(R(Rtutilstvalidatetnett	ipv4_addrtstripRRtnetmaskR8(R9((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pyt_validate_ipv4�s"""cC@sSxLt�D]A}tjtjjt|��}|jd�d|kr
|Sq
WdS(u^
    returns the coresponding service to given interface if exists, otherwise return None
    uEthernetu	InterfaceN(	R-RR.R/R"R0R)RtNone(tifacet_servicetservice_info((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pyt_interface_to_service�s
cC@s�tjtjjt|��}i|d6|jd�dkd6tj|jd�d�d6tj|jd�d�d	6}|jd
�}|dks�|dkrit	|d
<idd6|d<d}|jd�ddkr�|d7}n|j|�}x�ddddgD]�}|j
|�}|d$krEtj
d||�qn|dkr�d}|dkrld}q�|d%kr�d}q�ntj|�|d|j�<qW|jd�}xkdddgD]Z}|j
|�}|d$kr�tj
d||�q�ntj|�g|d |j�<q�Wg}	x-|jd!�D]}
|	jtj|
��q8W|	|dd"<n
t|d
<d|kr�ddg|dd#<n|S(&u4
    return details about given connman service
    ulabeluTypeuwifiuwirelessuEthernetu	InterfaceuconnectioniduAddressuhwaddruStateureadyuonlineuupu0.0.0.0ugatewayuipv4uIPv4uMethodumanualu.ConfigurationuNetmaskuGatewayu%Unable to get IPv4 %s for service %s
urequestmodeudhcpudhcp_linklocalufixedustaticuIPv6uPrefixu%Unable to get IPv6 %s for service %s
uipv6uNameserversudnsusupportedrequestmodesN(umanualufixed(RR.R/R"R0R)RRR'R8tgetRDtlogtwarningtlowerR&R(R1RGtdataR2tipv4t	ipv4_infotinfoR9t	ipv6_infotnameserverstnameserver_prop((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pyt_get_service_info�sV 

	!$
cC@s�g}y�tjjjdd��e}|j�}xO|D]G}d|kr7|j�dj�}||kr~|j|�q~q7q7WWdQXWntk
r�t	j
d�nX|S(u
    return dns list
    u/etc/resolv.confur+u
nameserveriNuCould not get domain
(RR=tfilestfopent	readlinesR5RAR&tIOErrorRJRK(tdns_listtdns_infotlinestlinetdns((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pyt
_get_dns_info�s
!
cC@sJt|�dkrF|d|dko1dknrF|dd!}n|S(uB
    Remove leading and trailing double quotes if they exist.
    iii����u"(R((R9((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pyt_remove_quotes�s6ucC@s�i}|s|Stjjj|d���}tjdt�}|j|�xp|D]h}tj	r�|j
||�r�t|j||��n|||<qQt|j||d|��||<qQWWdQX|S(u;
    Get values for some options and a given section from a config file.

    :param section: Section Name
    :param options: List of options
    :param default_value: Default value if an option doesn't have a value. Default is empty string.
    :param filename: config file. Default is INI_FILE.
    :return:
    urt	dict_typetfallbackN(
RR=RURVRtRawConfigParserRtreadfpRtPY2t
has_optionR_RI(tsectiontoptionst
default_valuetfilenametresultstconfig_filet
config_parsertoption((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pyt_load_configs


	7,cC@s|t|ddgd�}t|d�}t|d�}|dkrX|dkrTdSdS|dkrhdS|dkrxd	SdS(
u0
    return requestmode for given interface
    ulinklocalenabledudhcpenabledi����iudhcp_linklocalu	dhcp_onlyulinklocal_onlyiustatic(Rntint(t	interfacetsettingstlink_local_enabledtdhcp_enabled((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pyt_get_request_mode_infoscC@s0t|dg�dj�}|dkr,|SdS(u0
    return adaptermode for given interface
    umodeudisableduethercatutcpip(udisableduethercat(RnRL(Rptmode((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pyt_get_adapter_mode_info2sc	@sQg}tddg�dj�}tjdj|���tjjjdj|���}|j	�}WdQXd�x:|D]2}|j
d�rz|jd�d	j��PqzqzWx��D]�}|d
kr�q�n�j
|i�}|j
d�r||krq�n||dkr�t���fd
�|dD��r�||g7}q�q�W|S(u�
    Return possible adapter modes for a given interface using a blacklist.

    :param interface: interface name
    :param blacklist: given blacklist
    :return: list of possible adapter modes
    ulvrtuAdditionalNetworkProtocolsu/sys/class/net/{0}u/sys/class/net/{0}/ueventNuuDEVTYPE=u=iu_uadditional_protocolunamec3@sO|]E}�d|dkr)|�kpF�d|dkoF|�kVqdS(u_usysuueventN((t.0t
iface_type(t	blacklisttsys_interface_pathtuevent_devtype(s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pys	<genexpr>Usutype(RnRLR/treadlinkRRR=RURVRWt
startswithR5RARItany(	RpRyt
adapter_modest	protocolstuevent_filetuevent_linesR\tadapter_modeR9((RyRzR{s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pyt_get_possible_adapter_modes:s*!

cC@si|jd6|jd6|jd d6td6iddgd6dd	6d
6td6}dj|djd
��}tjjt�rt	|ddgdt�}|ddkr|djd�}|d|d
d<|djd�|d
d<|d|d
d<|d|d
d<qn|S(uh
    Return information about an interface from config file.

    :param interface: interface label
    uconnectionidulabeli����uhwaddruupustaticudhcp_linklocalusupportedrequestmodesurequestmodeuipv4uwirelessuu:uIPv4uNameserversRiu/iuaddressu,udnsiunetmaskiugateway(
tnamethwaddrRR0R5R/R"texiststINTERFACES_CONFIGRn(RpRMthwaddr_section_numbertinformationtipv4_information((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pyt_get_static_info\s&



c
C@sPiigd6gd6td6d6idgd6dgd6td6d6idgd6ddd	gd6td6d
6idd6dd6dd	6d
6}i|jd6|jd6t|j|�d6t|j�d6td6iddddgd6t|j�d6d6|jd d6}g}|dddkr7|ddddg7}n|dd
krW|d g7}nt|j|�}|jt	@d!kr�t|d<|j
|j�|dd"<|j
|j�|dd#<d$|dd%<t
�|dd&<nb|dddkr>|d|dd"<|d|dd#<|d|dd%<|dg|dd&<ntjjjd'd(��[}tjd)jd*|j�tj�}|j|j��}|s�d,n|jd+�}Wd,QX|d,k	r$t|�d-kr$d.jgtd/dd0�D]&}	tt||	|	d1!d2��^q��|dd%<n|dd
krLi|d d36|d
<n|S(4u.
    return details about given interface
    unameutypeuadditional_protocolutcpipueth0ugadgetudisableduusbuwlanuethercatusysuueventu_ulabeluconnectionidusupported_adapter_modesuadapter_modeuupudhcp_linklocalu	dhcp_onlyulinklocal_onlyustaticusupportedrequestmodesurequestmodeuipv4i����uhwaddru
IP_AddressuSubnet_MaskuGatewayuDNS_AddressuMasterIDiuaddressunetmasku0.0.0.0ugatewayudnsu/proc/net/routeuru'^{interface}\t[0]{{8}}\t([0-9A-Z]{{8}})RpiNiu.ii����iiumasterid(RR8R�R�RvRtR�RntflagstIFF_RUNNINGt
sockaddrToStrtaddrRBR^RR=RURVtretcompileRt	MULTILINEtsearchtreadRDtgroupR(R0RRRo(
RpRyRMtneeded_settingsRqt
route_filetpatterntmatchtiface_gateway_hexti((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pyt_get_interface_infoysl





$!ScC@s�d}x�t|j��D]�\}}t|t�rmx�t|�D]%}|tj|�d|d7}qAWqt|t�r�djg|D]}tj|�^q��}|tj|�d|d7}q|tj|�dtj|�d7}qW|j	�S(u=
    converts a dictionary object into a list of strings
    uu-u
u u: (
tsortedR:R4tdictt_dict_to_stringRR'tlistR0t
splitlines(t
dictionarytrettkeytvalR\titemttext((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pyR��s&+",cC@s/t|j�}|dk	r%t|�St|�S(u�
    Return information about an interface even if it's not associated with a service.

    :param interface: interface label
    N(RHR�RDRTR�(RpR1((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pyt	_get_info�s
cC@svgtj�D]}|jt@dkr
|^q
}tddkr\ittt|��d6Sittt|��d6S(u�
    Get details about all the interfaces on the minion

    :return: information about all interfaces omitting loopback
    :rtype: dictionary

    CLI Example:

    .. code-block:: bash

        salt '*' ip.get_interfaces_details
    iulsb_distrib_idunilrtu
interfaces(	R
t	getIfacesR�tIFF_LOOPBACKRR�RR�R�(Rpt_interfaces((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pytget_interfaces_details�s
2cC@s�tddkr�t|�}t|dd�|dkrFtd�nltddj||��}|d	d
kr�dj|dkr�d
nd||d�}tjj|��ntSt	|�}|s�tjjdj|���nt
|�s�tjt
jjt|��}y2|dkr+|j�n	|j�}|dkSWq�tk
r�tjjdj|dkrsd
nd|���q�XntS(u>
    Enable or disable an interface

    Change adapter mode to TCP/IP. If previous adapter mode was EtherCAT, the target will need reboot.

    :param interface: interface label
    :param new_state: up or down
    :return: True if the service was enabled, otherwise an exception will be thrown.
    :rtype: bool
    ulsb_distrib_idunilrtuModeuTCPIPuethercatu$system.set_reboot_required_witnesseducmd.run_alluip link set {0} {1}uretcodeiu&Couldn't {0} interface {1}. Error: {2}uupuenableudisableustderruInvalid interface name: {0}uCouldn't {0} service: {1}
N(RRvt_save_configt__salt__RRRRR8RHR3RR.R/R"R0R)tconnectt
disconnectRDt	Exception(Rpt	new_statetinitial_modetoutRR1R2((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pyt
_change_state�s.$
(cC@s
t|d�S(uu
    Enable the specified interface

    Change adapter mode to TCP/IP. If previous adapter mode was EtherCAT, the target will need reboot.

    :param str interface: interface label
    :return: True if the service was enabled, otherwise an exception will be thrown.
    :rtype: bool

    CLI Example:

    .. code-block:: bash

        salt '*' ip.up interface-label
    uup(R�(RpRx((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pytupscC@s
t|�S(uy
    Enable the specified interface

    Change adapter mode to TCP/IP. If previous adapter mode was EtherCAT, the target will need reboot.

    :param str interface: interface label
    :return: True if the service was enabled, otherwise an exception will be thrown.
    :rtype: bool

    CLI Example:

    .. code-block:: bash

        salt '*' ip.enable interface-label
    (R�(Rp((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pytenable&scC@s
t|d�S(u{
    Disable the specified interface

    Change adapter mode to Disabled. If previous adapter mode was EtherCAT, the target will need reboot.

    :param str interface: interface label
    :return: True if the service was disabled, otherwise an exception will be thrown.
    :rtype: bool

    CLI Example:

    .. code-block:: bash

        salt '*' ip.down interface-label
    udown(R�(RpRx((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pytdown9scC@s
t|�S(u~
    Disable the specified interface

    Change adapter mode to Disabled. If previous adapter mode was EtherCAT, the target will need reboot.

    :param str interface: interface label
    :return: True if the service was disabled, otherwise an exception will be thrown.
    :rtype: bool

    CLI Example:

    .. code-block:: bash

        salt '*' ip.disable interface-label
    (R�(Rp((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pytdisableLscC@sgt}|dj|||�7}td|�ddkrcdj|||�}tjj|��ndS(uD
    Helper function to persist a configuration in the ini file
    u* --set section={0},token='{1}',value='{2}'ucmd.run_alluretcodeiu%Error: could not set {} to {} for {}
N(tNIRTCFG_PATHRR�RRR(RfttokenR9tcmdtexc_msg((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pyR�_s
cC@sptddkrZt|�}t|dt�t|d|�|dkrVtd�ntStjjd��dS(	u�
    Configure specified adapter to use EtherCAT adapter mode. If successful, the target will need reboot if it doesn't
    already use EtherCAT adapter mode, otherwise will return true.

    :param interface: interface label
    :param master_id: EtherCAT Master ID
    :return: True if the settings were applied, otherwise an exception will be thrown.

    CLI Example:

    .. code-block:: bash

        salt '*' ip.set_ethercat interface-label master-id
    ulsb_distrib_idunilrtuModeuMasterIDuethercatu$system.set_reboot_required_witnesseduEtherCAT is not supportedN(	RRvR�tNIRTCFG_ETHERCATR�R8RRR(Rpt	master_idR�((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pytset_ethercatjscC@st|�t|�dS(u)
    Disable and enable an interface
    N(R�R�(Rp((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pyt_restart�s
cC@s�tddkrtt|�}t|dd�t|dd�t|dd�|dkrftd	�n
t|�tSt|�}|s�tjj	d
j
|���ntjt
jjt|��}|jd�}tjdd
d�|d<tjdd
d�|d<tjdd
d�|d<tjdd
d�|d<y'|jd|�|jddg�Wn7tk
r�}dj
||�}tjj	|��nXtS(u�
    Configure specified adapter to use DHCP with linklocal fallback

    Change adapter mode to TCP/IP. If previous adapter mode was EtherCAT, the target will need reboot.

    :param str interface: interface label
    :return: True if the settings were applied, otherwise an exception will be thrown.
    :rtype: bool

    CLI Example:

    .. code-block:: bash

        salt '*' ip.set_dhcp_linklocal_all interface-label
    ulsb_distrib_idunilrtuModeuTCPIPudhcpenabledu1ulinklocalenableduethercatu$system.set_reboot_required_witnesseduInvalid interface name: {0}uIPv4.Configurationudhcpt
variant_leveliuMethoduuAddressuNetmaskuGatewayuNameservers.Configurationu8Couldn't set dhcp linklocal for service: {0}
Error: {1}
(RRvR�R�R�R8RHRRRRRR.R/R"R0R)RRtStringtset_propertyR�(RpR�R1RNRR�((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pytset_dhcp_linklocal_all�s2
cC@s�tddks%tjjd��nt|�}t|dd�t|dd�t|dd	�|d
kr{td�n
t|�tS(u�
    Configure specified adapter to use DHCP only

    Change adapter mode to TCP/IP. If previous adapter mode was EtherCAT, the target will need reboot.

    :param str interface: interface label
    :return: True if the settings were applied, otherwise an exception will be thrown.
    :rtype: bool

    CLI Example:

    .. code-block:: bash

        salt '*' ip.dhcp_only_all interface-label
    ulsb_distrib_idunilrtuNot supported in this versionuModeuTCPIPudhcpenabledu1ulinklocalenabledu0uethercatu$system.set_reboot_required_witnessed(	RRRRRvR�R�R�R8(RpR�((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pytset_dhcp_only_all�s
cC@s�tddks%tjjd��nt|�}t|dd�t|dd�t|dd	�|d
kr{td�n
t|�tS(u�
    Configure specified adapter to use linklocal only

    Change adapter mode to TCP/IP. If previous adapter mode was EtherCAT, the target will need reboot.

    :param str interface: interface label
    :return: True if the settings were applied, otherwise an exception will be thrown.
    :rtype: bool

    CLI Example:

    .. code-block:: bash

        salt '*' ip.linklocal_only_all interface-label
    ulsb_distrib_idunilrtuNot supported in this versionuModeuTCPIPudhcpenabledu0ulinklocalenabledu1uethercatu$system.set_reboot_required_witnessed(	RRRRRvR�R�R�R8(RpR�((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pytset_linklocal_only_all�s
cK@stjd|�}tj�}tjjt�r|y2tj	j
jtd��}|j|�WdQXWq|tj
k
rxq|Xn|jd }dj|jd��}|jdj|��s�|jdj|��n|jdd	�}|jd
d	�}|jdd	�}|jdd�}	|jd
dj|��}
|jdj|�ddj|||��|jdj|�d|	�|jdj|�d|
�|jdj|�d|�|jdj|�dd�tj	j
jtd��}|j|�WdQXtS(uI
    Configure an interface that is not detected as a service by Connman (i.e. link is down)

    :param interface: interface label
    :param settings:
            - ip
            - netmask
            - gateway
            - dns
            - name
    :return: True if settings were applied successfully.
    :rtype: bool
    R�urNi����uu:u
interface_{0}uipu0.0.0.0unetmaskugatewayudnsunameuethernet_cable_{0}uIPv4u{0}/{1}/{2}uNameserversuNameuMACuTypeuethernetuw(R
t	InterfaceRtConfigParserR/R"R�R�RR=RURVRctMissingSectionHeaderErrorR�R0R5thas_sectionRtadd_sectionRItsettwriteR8(RpRqtparserRkR�R�t
ip_addressRBtgatewaytdns_serversR�((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pyt_configure_static_interface�s4
c
C@s�t|||g�\}}|s6tjj|��nt|�\}}|sctjj|��nt|t�s�|jd�}ntddkrEt	|�}t
|dd�t
|dd�t
|dd�t
|d	|�t
|d
|�t
|d|�|rt
|d|d
�n|dkr7td�n
t|�t
St|�}|s�|tj�kr�t|i|d6dj|�d6|d6|d6�Stjjdj|���ntjtjjt|��}|jd�}	tjddd�|	d<tjdj|�dd�|	d<tjdj|�dd�|	d<tjdj|�dd�|	d<yI|jd|	�|jdg|D]}
tjdj|
��^q��Wn7tk
r�}dj||�}tjj|��nXt
S( u{
    Configure specified adapter to use ipv4 manual settings

    Change adapter mode to TCP/IP. If previous adapter mode was EtherCAT, the target will need reboot.

    :param str interface: interface label
    :param str address: ipv4 address
    :param str netmask: ipv4 netmask
    :param str gateway: ipv4 gateway
    :param str nameservers: list of nameservers servers separated by spaces
    :return: True if the settings were applied, otherwise an exception will be thrown.
    :rtype: bool

    CLI Example:

    .. code-block:: bash

        salt '*' ip.set_static_all interface-label address netmask gateway nameservers
    u ulsb_distrib_idunilrtuModeuTCPIPudhcpenabledu0ulinklocalenabledu
IP_AddressuSubnet_MaskuGatewayuDNS_Addressiuethercatu$system.set_reboot_required_witnesseduipu,udnsunetmaskugatewayuInvalid interface name: {0}uIPv4.ConfigurationumanualR�iuMethodu{0}uAddressuNetmaskuNameservers.Configurationu9Couldn't set manual settings for service: {0}
Error: {1}
(RCRRRR<R4R�R5RRvR�R�R�R8RHR
R�R�R0RRR.R/R"R)RRR�R�R�(
RptaddressRBR�RRR>RR�R1RNtdRR�((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pytset_static_allsR
 """9cC@s<t�}x,|dD] }|d|krt|�SqWdS(u�
    Returns details about given interface.

    CLI Example:

    .. code-block:: bash

        salt '*' ip.get_interface eth0
    u
interfacesuconnectionidN(R�R�RD(RER�t
_interface((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pyt
get_interface[s

	cK@sLtddkr%tjjd��n|dkrOtjjdj|���nd|ksk|ddkrxt|�n�|ddkr�d	j|d�}tjj|��n|d
}|d}|d}g}xBtj|�D]1\}	}
d
|	ksd|	kr�||
7}q�q�Wt|||||�|rBt	|�nt
|�S(u�
    Build an interface script for a network interface.

    CLI Example:

    .. code-block:: bash

        salt '*' ip.build_interface eth0 eth <settings>
    ulsb_distrib_idunilrtuNot supported in this version.uethu"Interface type not supported: {0}:uprotoudhcpustaticu#Protocol type: {0} is not supporteduipaddrunetmaskugatewayudnsudomain(RRRRRR�Rt	iteritemsR�R�R�(RERxtenabledRqR�R�RBR�R]R�R�((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pytbuild_interfacels(





cK@s�tddkr%tjjd��ng}d|kri|dtkrXtdd�qitdd�nd|kr�|djd	d
�d}||d<td}||kr�td
|�|jdj|��q�n|S(u�
    Build the global network script.

    CLI Example:

    .. code-block:: bash

        salt '*' ip.build_network_settings <settings>
    ulsb_distrib_idunilrtuNot supported in this version.u
networkinguservice.enableuconnmanuservice.disableuhostnameu.iiunetwork.get_hostnameunetwork.mod_hostnameuhostname={0}(	RRRRt_CONFIG_TRUER�R5R&R(Rqtchangestnew_hostnametold_hostname((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pytbuild_network_settings�s


cC@s�tddkr%tjjd��ng}t�dkr@dnd}|jdj|��td}|jd	j|��|S(
u�
    Return the contents of the global network script.

    CLI Example:

    .. code-block:: bash

        salt '*' ip.get_network_settings
    ulsb_distrib_idunilrtuNot supported in this version.uofflineunouyesunetworking={0}unetwork.get_hostnameuhostname={0}(RRRRRR&RR�(Rqt
networkingthostname((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pytget_network_settings�s

cK@stddkr%tjjd��nd|kr>t|d<nd|krWt|d<nt}|dtkr�d|kr�td|d�}q�tj	d�t}nt}|dtkr�tj	d	�t}n3td
d�}t
jd�|otd
d�}|o|S(u�
    Apply global network configuration.

    CLI Example:

    .. code-block:: bash

        salt '*' ip.apply_network_settings
    ulsb_distrib_idunilrtuNot supported in this version.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.stopuconnmaniu
service.start(RRRRRR8R�R�RJRKttimetsleep(Rqthostname_restreststop((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pytapply_network_settings�s,


		
(Nt__doc__t
__future__RRRtloggingR�R/R�tsalt.exceptionsRtsalt.utils.filestsalt.utils.validate.nettsalt.ext.six.movesRRRtsalt.extRRtImportErrorRDRR
trequests.structuresRt	getLoggert__name__RJRR)R�R�tINI_FILER8R�R�R�R�RRRR$R-R3R<RCRHRTR^R_RnRtRvR�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�(((s9/usr/lib/python2.7/site-packages/salt/modules/nilrt_ip.pyt<module>s�







										:		
			"		E				%						,			*	@		$		

Zerion Mini Shell 1.0