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_magp.pyo

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlmZdd
l
mZddlmZddlmZdefd��YZd�Zedkr�e�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys�
---
module: onyx_magp
version_added: "2.5"
author: "Samer Deeb (@samerd)"
short_description: Manage MAGP protocol on Mellanox ONYX network devices
description:
  - This module provides declarative management of MAGP protocol on vlan
    interface of Mellanox ONYX network devices.
notes:
  - Tested on ONYX 3.6.4000
options:
  magp_id:
    description:
      - "MAGP instance number 1-255"
    required: true
  interface:
    description:
      - VLAN Interface name.
    required: true
  state:
    description:
      - MAGP state.
    default: present
    choices: ['present', 'absent', 'enabled', 'disabled']
  router_ip:
    description:
      - MAGP router IP address.
  router_mac:
    description:
      - MAGP router MAC address.
s�
- name: run add vlan interface with magp
  onyx_magp:
    magp_id: 103
    router_ip: 192.168.8.2
    router_mac: AA:1B:2C:3D:4E:5F
    interface: Vlan 1002
s�
commands:
  description: The list of configuration mode commands to send to the device.
  returned: always
  type: list
  sample:
    - interface vlan 234 magp 103
    - exit
    - interface vlan 234 magp 103 ip virtual-router address 1.2.3.4
N(t
AnsibleModule(t	iteritems(tBaseOnyxModule(tshow_cmdtOnyxMagpModulecB`s�eZejd�Zed��Zd�Zd�Zd�Z	ed��Z
d�Zd�Zd�Z
d	�Zd
�Zd�Zd�ZRS(
s^Vlan (\d+)$cC`s^tdtdddt�dtddddd	d
dg�dtdt�d
t�dt��S(Ntmagp_idttypetinttrequiredtstatetdefaulttpresenttchoicestabsenttenabledtdisabledt	interfacet	router_ipt
router_mac(tdicttTrue(tcls((sJ/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_magp.pyt_get_element_specMs	cC`s>|j�}t�}|j|�td|dt�|_dS(s' Ansible module initialization
        t
argument_spectsupports_check_modeN(RRtupdateRRt_module(tselftelement_specR((sJ/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_magp.pytinit_moduleXs	
cC`sC|r?dt|�ko#dknr?|jjdd�ndS(Nii�tmsgs!magp id must be between 1 and 255(RR"t	fail_json(R#tvalue((sJ/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_magp.pytvalidate_magp_idbs)cC`s�|jj}|d}|jj|�}d}|rLt|jd��}n|jjdd�td|dd|dd|d	|d	d
|d
�|_|j	|j�dS(NRiiR&s2Invalid interface name: should be "Vlan <vlan_id>"R
Rtvlan_idRR(
R"tparamst
IF_VLAN_REGEXtmatchRtgroupR'Rt_required_configtvalidate_param_values(R#t
module_paramsRR-R*((sJ/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_magp.pytget_required_configfs



cC`s&|j|d�}t|j�d�S(Ntheaderi(tget_config_attrRtsplit(RtitemR3((sJ/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_magp.pytget_magp_idysc
C`smt|j|d��}|j|d�j�}td|d|d|d|j|d�d|j|d	��S(
NsInterface vlansAdmin stateR
RR*Rs
Virtual IPRsVirtual MAC(RR4tlowerR(R#R
R6R*R((sJ/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_magp.pyt_create_magp_instance_data~scC`s�|j|jkrxx�|D]X}xOt|�D]A\}}t|jdd��}|j||d�|j|<q,WqWn?x<|D]4}|j|�}|j||�}||j|<qWdS(NsMAGP ti(t_os_versiontONYX_API_VERSIONR	RtreplaceR9t_current_configR7(R#t	magp_datatmagp_configt	magp_nametdataR
t	magp_itemt	inst_data((sJ/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_magp.pyt_update_magp_data�s
(
cC`s"d}t|j|dtdt�S(Ns	show magptjson_fmtt
fail_on_error(RR"RtFalse(R#tcmd((sJ/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_magp.pyt_get_magp_config�scC`sA|j�|_t�|_|j�}|r=|j|�ndS(N(t_get_os_versionR;RR>RJRE(R#R?((sJ/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_magp.pytload_current_config�s
cC`sx|jd}|jd}|jj|�}|s6dS|j|�}||krtd||f}|jj|�ndS(NR*R
sinterface vlan %s no magp %s(R/R>tgett	_commandstappend(R#treq_vlan_idtreq_magp_idtcurr_magp_datatcurr_vlan_idRI((sJ/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_magp.pyt_generate_no_magp_commands�s

cC`sW|jd}|jd}|jj|t��}|jd�}d||f}t}||kr�|r�d||f}|jj|�t}n|jj|�|jjd�n|jd}	|jd�}
|	r|
|	ks�|r>d||	f}|jj|�q>n/|
r>|
dkr>d	|}|jj|�n|jd
}|jd
�}|ro|j�}n|r�|j�}||ks�|r�d||f}|jj|�q�n/|r�|dkr�d
|}|jj|�n|dkrS|jdd�}
|
|krS|dkr'd}nd}d||f}|jj|�qSndS(NR*R
sinterface vlan %s magp %ssinterface vlan %s no magp %stexitRs%s ip virtual-router address %ss0.0.0.0s%s no ip virtual-router addressRs#%s ip virtual-router mac-address %ss00:00:00:00:00:00s#%s no ip virtual-router mac-addressRRRsno shutdowntshutdowns%s %s(senabledsdisabled(	R/R>RMRRHRNRORR8(R#t	req_stateRPRQRRRStmagp_prefixtcreate_new_magpRIt
req_router_iptcurr_router_iptreq_router_mactcurr_router_mact
curr_statetsuffix((sJ/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_magp.pyt_generate_magp_commands�sZ


	





	cC`s0|jd}|dkr#|j�S|j|�S(NRR(R/RTR`(R#RW((sJ/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_magp.pytgenerate_commands�s

(t__name__t
__module__tretcompileR,tclassmethodRR%R)R2R7R9RERJRLRTR`Ra(((sJ/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_magp.pyRJs	
			
	
				2cC`stj�dS(s+ main entry point for module execution
    N(Rtmain(((sJ/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_magp.pyRg�st__main__(t
__future__RRRRt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNRdtansible.module_utils.basicRtansible.module_utils.sixR	t&ansible.module_utils.network.onyx.onyxR
RRRgRb(((sJ/usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_magp.pyt<module>s 


!	�	

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