Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/network/onyx/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_interface.pyc

�
�Udac@`sddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
mZddlZdd
l
mZddlmZddlmZddlmZddlmZddlmZddlmZdefd��YZd�Zedkre�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys�
---
module: onyx_interface
version_added: "2.5"
author: "Samer Deeb (@samerd)"
short_description: Manage Interfaces on Mellanox ONYX network devices
description:
  - This module provides declarative management of Interfaces
    on Mellanox ONYX network devices.
notes:
options:
  name:
    description:
      - Name of the Interface.
    required: true
  description:
    description:
      - Description of Interface.
  enabled:
    description:
      - Interface link status.
    type: bool
  speed:
    description:
      - Interface link speed.
    choices: ['1G', '10G', '25G', '40G', '50G', '56G', '100G']
  mtu:
    description:
      - Maximum size of transmit packet.
  aggregate:
    description: List of Interfaces definitions.
  duplex:
    description:
      - Interface link status
    default: auto
    choices: ['full', 'half', 'auto']
  tx_rate:
    description:
      - Transmit rate in bits per second (bps).
      - This is state check parameter only.
      - Supports conditionals, see L(Conditionals in Networking Modules,../network/user_guide/network_working_with_command_output.html)
  rx_rate:
    description:
      - Receiver rate in bits per second (bps).
      - This is state check parameter only.
      - Supports conditionals, see L(Conditionals in Networking Modules,../network/user_guide/network_working_with_command_output.html)
  delay:
    description:
      - Time in seconds to wait before checking for the operational state on
        remote device. This wait is applicable for operational state argument
        which are I(state) with values C(up)/C(down).
    default: 10
  purge:
    description:
      - Purge Interfaces not defined in the aggregate parameter.
        This applies only for logical interface.
    default: false
    type: bool
  state:
    description:
      - State of the Interface configuration, C(up) means present and
        operationally up and C(down) means present and operationally C(down)
    default: present
    choices: ['present', 'absent', 'up', 'down']
s�
- name: configure interface
  onyx_interface:
      name: Eth1/2
      description: test-interface
      speed: 100G
      mtu: 512

- name: make interface up
  onyx_interface:
    name: Eth1/2
    enabled: True

- name: make interface down
  onyx_interface:
    name: Eth1/2
    enabled: False

- name: Check intent arguments
  onyx_interface:
    name: Eth1/2
    state: up

- name: Config + intent
  onyx_interface:
    name: Eth1/2
    enabled: False
    state: down
s�
commands:
  description: The list of configuration mode commands to send to the device.
  returned: always
  type: list
  sample:
    - interface ethernet 1/2
    - description test-interface
    - mtu 512
    - exit
(tdeepcopyN(tsleep(t
AnsibleModule(t	iteritems(tconditional(tremove_default_spec(tBaseOnyxModule(tget_interfaces_configtOnyxInterfaceModulecB`s�eZejd�Zejd�Zejd�Zejd�ZdZdZ	dZ
dZiee6ee
6ee	6ee6Zid)e6d*e
6d+e	6d,e6Z
id-e6d.e
6d/e	6de6Zd0Zd1Zed��Zed��Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zed��Zed��Zed��Zed��Z d�Z!d�Z"d �Z#d!�Z$d"�Z%d#�Z&d$�Z'd%�Z(d&�Z)d'�Z*d(�Z+RS(2s^Eth(\d+\/\d+|\d+\/\d+\/\d+)$s^Vlan (\d+)$s^Loopback (\d+)$s	^Po(\d+)$tethernettloopbacktvlansport-channeltspeedtrx_ratettx_ratetmtutabsenttuptdowntdescriptioncC`s�tdtdd�dt�dtdddd	d
ddd
g�dtdd�dtdd�dtdddd�dtdddddddg�dt�dt��	S(NtnamettypetstrRRtchoicest1Gt10Gt25Gt40Gt50Gt56Gt100GRtinttenabledtbooltdelaytdefaulti
tstatetpresentRRRRR(tdict(tcls((sO/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_interface.pyt_get_element_spec�s	$	cC`s-t|�}tdt�|d<t|�|S(NtrequiredR(RR.tTrueR
(R/telement_spectaggregate_spec((sO/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_interface.pyt_get_aggregate_spec�s
c	C`s�|j�}|j|�}tdtddddd|�dtdtdd	��}|j|�d
dgg}d
dgg}td|d|d
|dt�|_dS(s module initialization
        t	aggregateRtlisttelementsR.toptionstpurgeR+R)Rt
argument_spectrequired_one_oftmutually_exclusivetsupports_check_modeN(R0R5R.tFalsetupdateR
R2t_module(tselfR3R4R;R<R=((sO/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_interface.pytinit_module�s	
cC`s |r|jjdd�ndS(NtmsgsPurge is not supported!(RAt	fail_json(RBtvalue((sO/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_interface.pytvalidate_purge�scC`s&|dkr"|jjdd�ndS(NtautoRDsDuplex is not supported!(RARE(RBRF((sO/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_interface.pytvalidate_duplex�scC`sdd}d}xKt|j�D]:\}}|j|�}|r|}|jd�}PqqW||fS(Ni(tNoneRtIF_TYPE_MAPtmatchtgroup(RBtif_nametif_typetif_idtinterface_typetinterface_regexRL((sO/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_interface.pyt_get_interface_type�scC`sW|d}|j|�\}}|s?|jjdd|�n||d<||d<dS(NRRDsunsupported interface: %sRORP(RSRARE(RBtparamsRNRORP((sO/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_interface.pyt_set_if_type�s

cC`s�|j|j}xG|D]?}||}|dk	r|jjdd||jf�qqW|d}|j|j}||kr�|jjdd||jf�ndS(NRDs.attribute %s is not supported for %s interfaceR,s*%s state is not supported for %s interface(tUNSUPPORTED_ATTRSt_interface_typeRJRAREtUNSUPPORTED_STATES(RBtif_objtunsupported_attrstattrtvalt	req_statetunsupported_states((sO/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_interface.pyt_check_supported_attrs�s


cC`sixb|jD]W}|d}|js/||_n%|j|krT|jjdd�n|j|�q
WdS(NRORDs0Cannot aggregate interfaces from different types(t_required_configRWRARER_(RBRYRO((sO/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_interface.pyt_validate_interface_type�s
	
cC`sRt�|_|jj}|jd�}|r�x|D]v}x4|D],}|j|�dkrA||||<qAqAW|j||�|j�}|j|�|jj	|�q4Wn�i	|dd6|dd6|dd6|dd6|dd6|dd6|dd6|d	d	6|d
d
6}|j|�|j|�|jj	|�|j
�dS(NR6RRRRR,R*R(RR(R7R`RARTtgetRJtvalidate_param_valuestcopyRUtappendRa(RBt
module_paramsR6titemtkeytreq_itemRT((sO/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_interface.pytget_required_config	s4




cC`s|j|d�S(Ntheader(tget_config_attr(R/Rg((sO/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_interface.pytget_if_name)scC`s(|j|d�}t|�j�dkS(NsAdmin stateR((RlRtlower(R/Rgtadmin_state((sO/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_interface.pytget_admin_state-scC`s=|j|d�}|s-|j|d�}nt|�j�S(NsOperational statetState(RlRRn(R/Rgt
oper_state((sO/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_interface.pytget_oper_state2scC`sW|j|d�}|sdSy"t|j�d�}d|SWntk
rRdSXdS(NsActual speedis%dG(RlR'tsplitt
ValueErrorRJ(R/RgR((sO/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_interface.pyt	get_speed9s
cC`s�|j|j}d}|j|�}|r=|jd�}ntd|d|j|d�d|j|�d|j|�d|j|�d	|j	|�d
|�S(NtiRRtDescriptionRRR(R,RP(
RKRWRLRMR.RlRvtget_mtuRpRs(RBRRgtregexRPRL((sO/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_interface.pyt_create_if_dataDscC`st|j|j�S(N(RRARW(RB((sO/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_interface.pyt_get_interfaces_configSscC`s|j�|_t�|_|j�}|s1dS|j|jkrx�|D].}|j|�}|j||�|j|<qJWn�t�}x||D]t}xkt|�D]]\}}x5|D]-}x$t|�D]\}}|||<q�Wq�W|j||�|j|<q�Wq�WdS(N(	t_get_os_versiont_os_versionR.t_current_configR|tONYX_API_VERSIONRmR{R(RBtconfigtif_dataRNt	if_configtif_attrRhRF((sO/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_interface.pytload_current_configVs$
	

cC`su|j|jkr6|d}|jjdd|�n|s@dS|d}|sTdS|jjd|j|f�dS(NRRDs#cannot remove ethernet interface %sRPsno interface %s %s(RWtIF_TYPE_ETHRAREt	_commandsRe(RBtreq_iftcurr_ifRRP((sO/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_interface.pyt_generate_no_if_commandsks

	cC`s_|s
dS|d}|sdS|jjd|j|f�|jj|�|jjd�dS(NRPsinterface %s %stexit(R�ReRWtextend(RBR�tcmd_listRP((sO/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_interface.pyt_add_commands_to_interfacexs
	c
C`s|d}g}x�|jD]�}|j|�}|j|�}||kr|r�|dt|�}|j|jkr�|dkr�|dd}n|j|�q�qqW|jdt�}	|dk	r�||	kr�d}|r�d|}n|j|�n|r|j||�ndS(	NR(t RRtforcetshutdownsno %s(smtusspeed(	tIF_MODIFIABLE_ATTRSRbRRWR�ReR?RJR�(
RBR�R�R(R�t	attr_namet	candidatetrunningtcmdtcurr_enabled((sO/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_interface.pyt_generate_if_commands�s(

cC`s�x�|jD]�}|d}|jj|i�}|re|j|jkre|jjdd|�q
n|d}|dkr�|j||�q
|j||�q
WdS(NRRDs$could not find ethernet interface %sR,R(	R`RRbRWR�RARER�R�(RBR�RR�R]((sO/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_interface.pytgenerate_commands�s

cC`st|j|jd�S(Ntrates(RRARW(RB((sO/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_interface.pyt_get_interfaces_rates�scC`st|j|jd�S(NR(RRARW(RB((sO/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_interface.pyt_get_interfaces_status�scC`sb|j|i�}|r^|d}|j|�j�}|dksSt||�r^d|SndS(Nisstate eq(%s)(RbRststripRJR(RBRt
want_statetstatusesR�t
curr_state((sO/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_interface.pyt_check_state�s
c
C`scg}t}d}d}xD|jD]9}|jd�}|jd�}|jd�}	|d}
|dkr|r|	rq"n|r�|dr�t}|d}|d	kr�t|�q�n|dkr|dkr�|j�p�i}n|j|
||�}|r|j|�qnd}
|s)|	rc|s>|j	�}n|j|
�}
|
rc|
d	}
qcn|r�d}|
r�|
jd
�}|r�|j
�d	}q�n|dks�t||j�dt
�r�|jd|�q�n|	r"d}|
r|
jd
�}|r|j
�d	}qn|dksDt|	|j�dt
�r[|jd|	�q[q"q"W|S(NR,RRRRRtchangedR*isegress ratetcaststx_rate singress ratesrx_rate (supsdown(supsdown(R?RJR`RbR2R	R�R�ReR�RtRR�R'(RBtresulttfailed_conditionstdelay_calledR�R�R�R�twant_tx_ratetwant_rx_rateRR*tcondtif_ratesthave_tx_ratethave_rx_rate((sO/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_interface.pytcheck_declarative_intent_params�sf



((sspeedsrx_ratestx_rate(sspeedsmtusrx_ratestx_rate(sspeedsrx_ratestx_rate(sabsent((supsdown(sspeedsdescriptionsmtuN(,t__name__t
__module__tretcompiletIF_ETH_REGEXt
IF_VLAN_REGEXtIF_LOOPBACK_REGEXtIF_PO_REGEXR�tIF_TYPE_LOOPBACKtIF_TYPE_VLANt
IF_TYPE_PORKRVRXR�RJRWtclassmethodR0R5RCRGRIRSRUR_RaRjRmRpRsRvR{R|R�R�R�R�R�R�R�R�R�(((sO/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_interface.pyR�sd


									
	 				
						cC`stj�dS(s+ main entry point for module execution
    N(Rtmain(((sO/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_interface.pyR��st__main__(t
__future__RRRRt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNRdRR�ttimeR	tansible.module_utils.basicR
tansible.module_utils.sixRt)ansible.module_utils.network.common.utilsRR
t&ansible.module_utils.network.onyx.onyxRRRR�R�(((sO/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_interface.pyt<module>s*


B�j	

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]