Anons79 Mini Shell

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

�
�Udac@s�dZidd6dgd6dd6ZdZdZd	Zd
dlZd
dlmZda	da
dadad
�Z
d�Zd�Zd�Zd�Zd�Zedkr�e�ndS(s, PN-CLI vrouter-interface-add/remove/modify s1.1tmetadata_versiont
deprecatedtstatust	communitytsupported_bys.
---
module: pn_vrouterif
author: "Pluribus Networks (@amitsi)"
version_added: "2.2"
short_description: CLI command to add/remove/modify vrouter-interface.
deprecated:
  removed_in: '2.12'
  why: Doesn't support latest Pluribus Networks netvisor
  alternative: Latest modules will be pushed in Ansible future versions.
description:
  - Execute vrouter-interface-add, vrouter-interface-remove,
    vrouter-interface-modify command.
  - You configure interfaces to vRouter services on a fabric, cluster,
    standalone switch or virtual network(VNET).
options:
  pn_cliusername:
    description:
      - Provide login username if user is not root.
    required: False
  pn_clipassword:
    description:
      - Provide login password if user is not root.
    required: False
  pn_cliswitch:
    description:
      - Target switch to run the cli on.
    required: False
    default: 'local'
  state:
    description:
      - State the action to perform. Use 'present' to add vrouter interface,
        'absent' to remove vrouter interface and 'update' to modify vrouter
        interface.
    required: True
    choices: ['present', 'absent', 'update']
  pn_vrouter_name:
    description:
      - Specify the name of the vRouter interface.
    required: True
  pn_vlan:
    description:
      - Specify the VLAN identifier. This is a value between 1 and 4092.
  pn_interface_ip:
    description:
      - Specify the IP address of the interface in x.x.x.x/n format.
  pn_assignment:
    description:
      - Specify the DHCP method for IP address assignment.
    choices: ['none', 'dhcp', 'dhcpv6', 'autov6']
  pn_vxlan:
    description:
      - Specify the VXLAN identifier. This is a value between 1 and 16777215.
  pn_interface:
    description:
      - Specify if the interface is management, data or span interface.
    choices: ['mgmt', 'data', 'span']
  pn_alias:
    description:
      - Specify an alias for the interface.
  pn_exclusive:
    description:
      - Specify if the interface is exclusive to the configuration. Exclusive
        means that other configurations cannot use the interface. Exclusive is
        specified when you configure the interface as span interface and allows
        higher throughput through the interface.
    type: bool
    required: False
  pn_nic_enable:
    description:
      - Specify if the NIC is enabled or not
    type: bool
  pn_vrrp_id:
    description:
      - Specify the ID for the VRRP interface. The IDs on both vRouters must be
        the same IS number.
  pn_vrrp_priority:
    description:
      - Specify the priority for the VRRP interface. This is a value between
         1 (lowest) and 255 (highest).
  pn_vrrp_adv_int:
    description:
      - Specify a VRRP advertisement interval in milliseconds. The range is
        from 30 to 40950 with a default value of 1000.
  pn_l3port:
    description:
      - Specify a Layer 3 port for the interface.
  pn_secondary_macs:
    description:
      - Specify a secondary MAC address for the interface.
  pn_nic_str:
    description:
      - Specify the type of NIC. Used for vrouter-interface remove/modify.
s�
- name: Add vrouter-interface
  pn_vrouterif:
    pn_cliusername: admin
    pn_clipassword: admin
    state: 'present'
    pn_vrouter_name: 'ansible-vrouter'
    pn_interface_ip: 101.101.101.2/24
    pn_vlan: 101

- name: Add VRRP..
  pn_vrouterif:
    pn_cliusername: admin
    pn_clipassword: admin
    state: 'present'
    pn_vrouter_name: 'ansible-vrouter'
    pn_interface_ip: 101.101.101.2/24
    pn_vrrp_ip: 101.101.101.1/24
    pn_vrrp_priority: 100
    pn_vlan: 101

- name: Remove vrouter-interface
  pn_vrouterif:
    pn_cliusername: admin
    pn_clipassword: admin
    state: 'absent'
    pn_vrouter_name: 'ansible-vrouter'
    pn_interface_ip: 101.101.101.2/24
s�
command:
  description: The CLI command run on the target node(s).
  returned: always
  type: str
stdout:
  description: The set of responses from the vrouterif command.
  returned: on success
  type: list
stderr:
  description: The set of error responses from the vrouterif command.
  returned: on error
  type: str
changed:
  description: Indicates whether the CLI caused changes on the target.
  returned: always
  type: bool
i����N(t
AnsibleModulecCsw|jd}|jd}|jd}|rF|rFd||f}nd}|dkre|d7}n|d|7}|S(	s
    This method is to generate the cli portion to launch the Netvisor cli.
    It parses the username, password, switch parameters from module.
    :param module: The Ansible module to fetch username, password and switch
    :return: returns the cli string for further processing
    tpn_cliusernametpn_clipasswordtpn_cliswitchs"/usr/bin/cli --quiet --user %s:%s s/usr/bin/cli --quiet tlocals switch-local s switch (tparams(tmoduletusernametpasswordt	cliswitchtcli((sR/usr/lib/python2.7/site-packages/ansible/modules/network/netvisor/_pn_vrouterif.pytpn_cli�s



cCs8|jd}|jd}|jd}|d}tj|�}|j|�d}|j�}||krttanta|r�|d|}|d|7}tj|�}|j|�d}|r�taq�tan|r4|d|}|d7}tj|�}|j|�d}||kr+taq4tand	S(
s�
    This method checks if vRouter exists on the target node.
    This method also checks for idempotency using the vrouter-interface-show
    command.
    If the given vRouter exists, return VROUTER_EXISTS as True else False.

    If an interface with the given ip exists on the given vRouter,
    return INTERFACE_EXISTS as True else False. This is required for
    vrouter-interface-add.

    If nic_str exists on the given vRouter, return NIC_EXISTS as True else
    False. This is required for vrouter-interface-remove.

    :param module: The Ansible module to fetch input parameters
    :param cli: The CLI string
    :return Global Booleans: VROUTER_EXISTS, INTERFACE_EXISTS, NIC_EXISTS
    tpn_vrouter_nametpn_interface_ipt
pn_nic_strs* vrouter-show format name no-show-headers is( vrouter-interface-show vrouter-name %s s#ip %s format ip,nic no-show-headerss format nic no-show-headersN(	R
tshlextsplittrun_commandtTruetVROUTER_EXISTStFalsetINTERFACE_EXISTSt
NIC_EXISTS(RRtvrouter_nametinterface_iptnic_strt
check_vroutertouttshow((sR/usr/lib/python2.7/site-packages/ansible/modules/network/netvisor/_pn_vrouterif.pyt	check_cli�s4



			
	cCs�|jd}|jd}|d|}|d|7}tj|�}|j|�d}|j�}t|�dkr�tadS|d}ta|SdS(	s
    This module checks if VRRP interface can be added. If No, return VRRP_EXISTS
    as True.
    If Yes, fetch the nic string from the primary interface and return nic and
    VRRP_EXISTS as False.
    :param module:
    :param cli:
    :return: nic, Global Boolean: VRRP_EXISTS
    RRs( vrouter-interface-show vrouter-name %s s#ip %s format ip,nic no-show-headersiiiN(	R
RRRtlenRtVRRP_EXISTStNoneR(RRRRR!R tnic((sR/usr/lib/python2.7/site-packages/ansible/modules/network/netvisor/_pn_vrouterif.pytget_nics



c
	Cs�|jd}|jd}t|�}tj|�}|j|�\}}}|j|�d}	|dkr�|jd|	d|j�dd|d	t�n|r�|jd|	d
|j�dd|d	t�n |jd|	dd|d	t�dS(
s
    This method executes the cli command on the target node(s) and returns the
    output. The module then exits based on the output.
    :param cli: the complete cli string to be executed on the target node(s).
    :param module: The Ansible module to fetch command
    Rtstateiitcommandtstderrtmsgs%s operation failedtchangedtstdouts%s operation completedN(	R
tget_command_from_stateRRRt	exit_jsontstripRR(
RRRR(R)tcmdtresultR terrt	print_cli((sR/usr/lib/python2.7/site-packages/ansible/modules/network/netvisor/_pn_vrouterif.pytrun_cli&s,

	

	

	
cCsId}|dkrd}n|dkr0d}n|dkrEd}n|S(s�
    This method gets appropriate command name for the state specified. It
    returns the command name for the specified state.
    :param state: The state for which the respective command name is required.
    tpresentsvrouter-interface-addtabsentsvrouter-interface-removetupdatesvrouter-interface-modifyN(R%(R(R)((sR/usr/lib/python2.7/site-packages/ansible/modules/network/netvisor/_pn_vrouterif.pyR.Rs			c+Csqtdtdtdtdd�dtdtdddt�dtdtddd	d
�dtdtdddd
ddg�dtdtdd�dtdd�dtdtdd�dtdddddddg�dtdd�dtddddddg�dtdd�dtdd �d!tdd �d"tdd�d#tdd�d$tdd�d%tdd�d&tdd�d'tdd��d(dd
ddggdddd'ggf�}|jd}|jd}|jd}|jd}|jd}|jd}|jd}|jd}|jd}	|jd!}
|jd"}|jd#}|jd$}
|jd%}|jd&}|jd'}t|�}t|�}t||�|d)kr�ttkr�|j	d*td+d,|�n|r�t
||�}ttkr!|j	d*td+d-|�n|d.||f7}|d/||t|�f7}|ro|d0t|�7}n|
r�|d1|
7}q�nKt
tkr�|j	d*td+d2|�n|d.||f7}|d3|7}|r�|d4t|�7}n|r|d5|7}n|r|d6|7}n|r<|d7t|�7}n|rS|d8|7}n|rj|d9|7}n|	tkr�|d:7}n|	tkr�|d;7}n|
tkr�|d<7}n|
tkr�|d=7}n|r�|d>|7}q�n|d?kr`ttkr|j	d*td+d,|�nttkrF|j	d*td+d@|�n|dA|||f7}nt||�dBS(Cs' This portion is for arguments parsing t
argument_specRtrequiredttypetstrRtno_logRtdefaultR	R(tchoicesR6R7R8Rtpn_vlantintRt
pn_assignmenttnonetdhcptdhcpv6tautov6tpn_vxlantpn_interfacetmgmttdatatspantpn_aliastpn_exclusivetboolt
pn_nic_enablet
pn_vrrp_idtpn_vrrp_prioritytpn_vrrp_adv_intt	pn_l3porttpn_secondary_macsRtrequired_ifsvrouter-interface-addtskippedR+svRouter %s does not exists;VRRP interface on %s already exists. Check the IP addressess %s vrouter-name %s s" ip %s vrrp-primary %s vrrp-id %s s vrrp-priority %s s vrrp-adv-int %s s>vRouter interface on %s already exists. Check the IP addressess ip %s s vlan s	 l3-port s assignment s vxlan s if s
 alias-on s exclusive s no-exclusive s nic-enable s
 nic-disable s secondary-macs svrouter-interface-removes,vRouter interface with nic %s does not exists %s vrouter-name %s nic %s N(RtdictRRR
R.RR"RR/R'R$R<RRR5(RR(RtvlanRt
assignmenttvxlant	interfacetaliast	exclusivet
nic_enabletvrrp_idt
vrrp_prioritytvrrp_adv_inttl3porttsecondary_macsRR)Rtvrrp_primary((sR/usr/lib/python2.7/site-packages/ansible/modules/network/netvisor/_pn_vrouterif.pytmainbs�
















			



		t__main__(t__doc__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNRtansible.module_utils.basicRR%RRRR$RR"R'R5R.Ret__name__(((sR/usr/lib/python2.7/site-packages/ansible/modules/network/netvisor/_pn_vrouterif.pyt<module>s(


`		;		,		�

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