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

�
�Udac@s�dZidd6dgd6dd6ZdZdZd	Zd
dlZd
dlmZda	d
Z
dZd�Zd�Z
d�Zd�Zd�Zedkr�e�ndS(s  PN CLI vlan-create/vlan-delete s1.1tmetadata_versiont
deprecatedtstatust	communitytsupported_bys�
---
module: pn_vlan
author: "Pluribus Networks (@amitsi)"
version_added: "2.2"
short_description: CLI command to create/delete a VLAN.
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 vlan-create or vlan-delete command.
  - VLANs are used to isolate network traffic at Layer 2.The VLAN identifiers
    0 and 4095 are reserved and cannot be used per the IEEE 802.1Q standard.
    The range of configurable VLAN identifiers is 2 through 4092.
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(es) to run the cli on.
    required: False
    default: 'local'
  state:
    description:
      - State the action to perform. Use 'present' to create vlan and
        'absent' to delete vlan.
    required: True
    choices: ['present', 'absent']
  pn_vlanid:
    description:
      - Specify a VLAN identifier for the VLAN. This is a value between
        2 and 4092.
    required: True
  pn_scope:
    description:
      - Specify a scope for the VLAN.
      - Required for vlan-create.
    choices: ['fabric', 'local']
  pn_description:
    description:
      - Specify a description for the VLAN.
  pn_stats:
    description:
      - Specify if you want to collect statistics for a VLAN. Statistic
        collection is enabled by default.
    type: bool
  pn_ports:
    description:
      - Specifies the switch network data port number, list of ports, or range
        of ports. Port numbers must ne in the range of 1 to 64.
  pn_untagged_ports:
    description:
      - Specifies the ports that should have untagged packets mapped to the
        VLAN. Untagged packets are packets that do not contain IEEE 802.1Q VLAN
        tags.
s�
- name: create a VLAN
  pn_vlan:
    state: 'present'
    pn_vlanid: 1854
    pn_scope: fabric

- name: delete VLANs
  pn_vlan:
    state: 'absent'
    pn_vlanid: 1854
s�
command:
  description: The CLI command run on the target node(s).
  returned: always
  type: str
stdout:
  description: The set of responses from the vlan command.
  returned: always
  type: list
stderr:
  description: The set of error responses from the vlan command.
  returned: on error
  type: list
changed:
  description: Indicates whether the CLI caused changes on the target.
  returned: always
  type: bool
i����N(t
AnsibleModulei�icCsw|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((sM/usr/lib/python2.7/site-packages/ansible/modules/network/netvisor/_pn_vlan.pytpn_cli�s



cCst|jd}|dt|�}tj|�}|j|�d}|j�}t|�|krjtantadS(s!
    This method checks for idempotency using the vlan-show command.
    If a vlan with given vlan id exists, return VLAN_EXISTS as True else False.
    :param module: The Ansible module to fetch input parameters
    :param cli: The CLI string
    :return Global Booleans: VLAN_EXISTS
    t	pn_vlanids0 vlan-show id %s format id,scope no-show-headersiN(R
tstrtshlextsplittrun_commandtTruetVLAN_EXISTStFalse(RRtvlanidtshowtout((sM/usr/lib/python2.7/site-packages/ansible/modules/network/netvisor/_pn_vlan.pyt	check_cli�s
	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(
RRRRRtcmdtresultRterrt	print_cli((sM/usr/lib/python2.7/site-packages/ansible/modules/network/netvisor/_pn_vlan.pytrun_cli�s,

	

	

	
cCs4d}|dkrd}n|dkr0d}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.
    tpresentsvlan-createtabsentsvlan-deleteN(tNone(RR((sM/usr/lib/python2.7/site-packages/ansible/modules/network/netvisor/_pn_vlan.pyR#�s		c
Cstdtdtdtdd�dtdtdddt�dtdtddd	d
�dtdtdddd
dg�dtdtdd�dtddddd
g�dtdd�dtdd�dtdd�dtdd��
ddd
ddggdddggf�}|jd}|jd}|jd}|jd}|jd}|jd}|jd}t|�}t|�}	t|ko�tkns�|j	dddt�n|dkr�t
||	�ttkr|j	dtddt|��n|	d|t|�|f7}	|r5|	d |7}	n|tkrN|	d!7}	n|tkrg|	d"7}	n|r~|	d#|7}	n|r�|	d$|7}	q�n|d%kr�t
||	�ttkr�|j	dtdd&t|��n|	d'|t|�f7}	nt
||	�d(S()s' This section is for arguments parsing t
argument_specRtrequiredttypeRRtno_logRtdefaultR	RtchoicesR+R,Rtinttpn_scopetfabrictpn_descriptiontpn_statstbooltpn_portstpn_untagged_portstrequired_ifR s"VLAN id must be between 2 and 4092R!svlan-createtskippedsVLAN with id %s already existss %s id %s scope %s s
 description s stats s
 no-stats s ports s untagged-ports svlan-deletesVLAN with id %s does not exists
 %s id %s N(RtdictRRR
R#RtMIN_VLAN_IDtMAX_VLAN_IDR$RRRR*(
RRRtscopetdescriptiontstatstportstuntagged_portsRR((sM/usr/lib/python2.7/site-packages/ansible/modules/network/netvisor/_pn_vlan.pytmain�sj






	

	


	t__main__(t__doc__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNRtansible.module_utils.basicRR-RR@R?RRR*R#RFt__name__(((sM/usr/lib/python2.7/site-packages/ansible/modules/network/netvisor/_pn_vlan.pyt<module>s$


A
			,		Q

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