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_vrouter.pyc

�
�Udac@s�dZidd6dgd6dd6ZdZdZd	Zd
dlZd
dlmZda	da
d
�Zd�Zd�Z
d�Zd�Zedkr�e�ndS(s5 PN CLI vrouter-create/vrouter-delete/vrouter-modify s1.1tmetadata_versiont
deprecatedtstatust	communitytsupported_bys�
---
module: pn_vrouter
author: "Pluribus Networks (@amitsi)"
version_added: "2.2"
short_description: CLI command to create/delete/modify a vrouter.
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-create, vrouter-delete, vrouter-modify command.
  - Each fabric, cluster, standalone switch, or virtual network (VNET) can
    provide its tenants with a virtual router (vRouter) service that forwards
    traffic between networks and implements Layer 3 protocols.
  - C(vrouter-create) creates a new vRouter service.
  - C(vrouter-delete) deletes a vRouter service.
  - C(vrouter-modify) modifies a vRouter service.
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 vrouter,
        'absent' to delete vrouter and 'update' to modify vrouter.
    required: True
    choices: ['present', 'absent', 'update']
  pn_name:
    description:
      - Specify the name of the vRouter.
    required: true
  pn_vnet:
    description:
      - Specify the name of the VNET.
      - Required for vrouter-create.
  pn_service_type:
    description:
      - Specify if the vRouter is a dedicated or shared VNET service.
    choices: ['dedicated', 'shared']
  pn_service_state:
    description:
      -  Specify to enable or disable vRouter service.
    choices: ['enable', 'disable']
  pn_router_type:
    description:
      - Specify if the vRouter uses software or hardware.
      - Note that if you specify hardware as router type, you cannot assign IP
        addresses using DHCP. You must specify a static IP address.
    choices: ['hardware', 'software']
  pn_hw_vrrp_id:
    description:
      - Specifies the VRRP ID for a hardware vrouter.
  pn_router_id:
    description:
      - Specify the vRouter IP address.
  pn_bgp_as:
    description:
      - Specify the Autonomous System Number(ASN) if the vRouter runs Border
        Gateway Protocol(BGP).
  pn_bgp_redistribute:
    description:
      - Specify how BGP routes are redistributed.
    choices: ['static', 'connected', 'rip', 'ospf']
  pn_bgp_max_paths:
    description:
      - Specify the maximum number of paths for BGP. This is a number between
        1 and 255 or 0 to unset.
  pn_bgp_options:
    description:
      - Specify other BGP options as a whitespaces separated string within
        single quotes ''.
  pn_rip_redistribute:
    description:
      - Specify how RIP routes are redistributed.
    choices: ['static', 'connected', 'ospf', 'bgp']
  pn_ospf_redistribute:
    description:
      - Specify how OSPF routes are redistributed.
    choices: ['static', 'connected', 'bgp', 'rip']
  pn_ospf_options:
    description:
      - Specify other OSPF options as a whitespaces separated string within
        single quotes ''.
  pn_vrrp_track_port:
    description:
      - Specify list of ports and port ranges.
s�
- name: create vrouter
  pn_vrouter:
    state: 'present'
    pn_name: 'ansible-vrouter'
    pn_vnet: 'ansible-fab-global'
    pn_router_id: 208.74.182.1

- name: delete vrouter
  pn_vrouter:
    state: 'absent'
    pn_name: 'ansible-vrouter'
s�
command:
  description: The CLI command run on the target node(s).
  returned: always
  type: str
stdout:
  description: The set of responses from the vrouter command.
  returned: always
  type: list
stderr:
  description: The set of error responses from the vrouter command.
  returned: on error
  type: list
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((sP/usr/lib/python2.7/site-packages/ansible/modules/network/netvisor/_pn_vrouter.pytpn_cli�s



cCs�|jd}|d}tj|�}|j|�d}|j�d}|d|}|d7}tj|�}|j|�d}|r�tanta|d}tj|�}|j|�d}|j�}||kr�tantadS(s�
    This method checks for idempotency using the vlan-show command.
    A switch can have only one vRouter configuration.
    If a vRouter already exists on the given switch, return VROUTER_EXISTS as
    True else False.
    If a vRouter with the given name exists(on a different switch), return
    VROUTER_NAME_EXISTS as True else False.

    :param module: The Ansible module to fetch input parameters
    :param cli: The CLI string
    :return Global Booleans: VROUTER_EXISTS, VROUTER_NAME_EXISTS
    tpn_names% switch-setup-show format switch-nameis vrouter-show location %s sformat name no-show-headerss* vrouter-show format name no-show-headers N(R
tshlextsplittrun_commandtTruetVROUTER_EXISTStFalsetVROUTER_NAME_EXISTS(RRtnametlocationtoutt
check_vroutertshow((sP/usr/lib/python2.7/site-packages/ansible/modules/network/netvisor/_pn_vrouter.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(
RRRRR tcmdtresultRterrt	print_cli((sP/usr/lib/python2.7/site-packages/ansible/modules/network/netvisor/_pn_vrouter.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-createtabsentsvrouter-deletetupdatesvrouter-modifyN(tNone(RR ((sP/usr/lib/python2.7/site-packages/ansible/modules/network/netvisor/_pn_vrouter.pyR%s			c,Cstdtdtdtdd�dtdtdddt�dtdtddd	d
�dtdtdddd
ddg�dtdtdd�dtdd�dtdddddg�dtdddddg�dtdddddg�dtdd�dtdd�dtdd�dtdddd d!d"d#g�d$tdd�d%tdd�d&tdddd d!d'd#g�d(tdddd d!d'd"g�d)tdd�d*tdd��d+dd
ddggdddggdddggf�}|jd}|jd}|jd}|jd}|jd}|jd}|jd}|jd}|jd}	|jd}
|jd$}|jd%}|jd&}
|jd(}|jd)}|jd*}t|�}t|�}|d,kr9t||�ttkr"|j	d-td.d/|�n|d0||f7}n�|d1kr�t||�t
tkrw|j	d-td.d2�nttkr�|j	d-td.d3|�q�n|d0||f7}|r�|d4|7}n|r�|d5|7}n|r�|d6|7}n|r|d7|7}n|r0|d8t|�7}n|rG|d9|7}n|	rd|d:t|	�7}n|
r{|d;|
7}n|r�|d<t|�7}n|r�|d=|7}n|
r�|d>|
7}n|r�|d?|7}n|r�|d=|7}n|r|d@|7}nt||�dAS(Bs' This section is for arguments parsing t
argument_specRtrequiredttypetstrRtno_logRtdefaultR	RtchoicesR-R.R/Rtpn_vnettpn_service_typet	dedicatedtsharedtpn_service_statetenabletdisabletpn_router_typethardwaretsoftwaret
pn_hw_vrrp_idtinttpn_router_idt	pn_bgp_astpn_bgp_redistributetstatict	connectedtriptospftpn_bgp_max_pathstpn_bgp_optionstpn_rip_redistributetbgptpn_ospf_redistributetpn_ospf_optionstpn_vrrp_track_porttrequired_ifsvrouter-deletetskippedR"s#vRouter with name %s does not exists %s name %s svrouter-creates:Maximum number of vRouters has been reached on this switchs#vRouter with name %s already existss vnet s %s-vnet-service t s
 router-type s hw-vrrp-id s router-id s bgp-as s bgp-redistribute s bgp-max-paths s %s s rip-redistribute s ospf-redistribute s vrrp-track-port N(
RtdictRRR
R%RRRR&RR4R,(RRRtvnettservice_typet
service_statetrouter_typet
hw_vrrp_idt	router_idtbgp_astbgp_redistributet
bgp_max_pathstbgp_optionstrip_redistributetospf_redistributetospf_optionstvrrp_track_portR R((sP/usr/lib/python2.7/site-packages/ansible/modules/network/netvisor/_pn_vrouter.pytmain(s�
















	
	
	t__main__(t__doc__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNRtansible.module_utils.basicRR0RRRRR,R%Rdt__name__(((sP/usr/lib/python2.7/site-packages/ansible/modules/network/netvisor/_pn_vrouter.pyt<module>s"


d		.	,		�

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