�
�Udac @` s� d d l m Z m Z m Z e Z i d d 6d g d 6d d 6Z d Z d Z d
Z d d l
m Z d d l m
Z
m Z d d
l m Z d � Z d � Z e d k r� e � n d S( i ( t absolute_importt divisiont print_functions 1.1t metadata_versiont previewt statust communityt supported_bys
---
module: pn_vrouter_packet_relay
author: "Pluribus Networks (@rajaspachipulusu17)"
version_added: "2.9"
short_description: CLI command to add/remove vrouter-packet-relay
description:
- This module can be used to add packet relay configuration for DHCP on vrouter
and remove packet relay configuration for DHCP on vrouter.
options:
pn_cliswitch:
description:
- Target switch to run the CLI on.
required: false
type: str
state:
description:
- vrouter-packet-relay configuration command.
required: false
choices: ['present', 'absent']
type: str
default: 'present'
pn_forward_ip:
description:
- forwarding IP address.
required: true
type: str
pn_nic:
description:
- NIC.
required: true
type: str
pn_forward_proto:
description:
- protocol type to forward packets.
required: false
type: str
choices: ['dhcp']
default: 'dhcp'
pn_vrouter_name:
description:
- name of service config.
required: true
type: str
s
- name: vRouter packet relay add
pn_vrouter_packet_relay:
pn_cliswitch: "sw01"
pn_forward_ip: "192.168.10.1"
pn_nic: "eth0.4092"
pn_vrouter_name: "sw01-vrouter"
- name: vRouter packet relay remove
pn_vrouter_packet_relay:
pn_cliswitch: "sw01"
state: "absent"
pn_forward_ip: "192.168.10.1"
pn_nic: "eth0.4092"
pn_vrouter_name: "sw01-vrouter"
s�
command:
description: the CLI command run on the target node.
returned: always
type: str
stdout:
description: set of responses from the vrouter-packet-relay command.
returned: always
type: list
stderr:
description: set of error responses from the vrouter-packet-relay command.
returned: on error
type: list
changed:
description: indicates whether the CLI caused changes on the target.
returned: always
type: bool
( t
AnsibleModule( t pn_clit run_cli( t run_commandsc C` s� | j d } | j d } d } t | | � d } | rH | j � } n | | k rZ t n t } | r� d | } t | | � d } | r� | j � } n | | k r� t n t } n | | f 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 nic_str exists on the given vRouter, return NIC_EXISTS as True else
False.
:param module: The Ansible module to fetch input parameters
:param cli: The CLI string
:return Booleans: VROUTER_EXISTS, NIC_EXISTS
t pn_vrouter_namet pn_nics( vrouter-show format name no-show-headersi sA vrouter-interface-show vrouter-name %s format nic no-show-headers( t paramsR t splitt Truet False( t modulet clit vrouter_namet nic_strt
check_vroutert outt VROUTER_EXISTSt showt
NIC_EXISTS( ( s\ /usr/lib/python2.7/site-packages/ansible/modules/network/netvisor/pn_vrouter_packet_relay.pyt check_clie s
c
C` s5 t d d d d � } t d t d t d d � d t d t d d d
| j � d d � d t d t d d � d
t d t d d � d t d t d d d
d g d d � d t d t d d � � } t d | d d d d d d
d g g d d d d d
d g g f � } | j d } | j d } | j d } | j d
} | j d } | j d } | | } t | | � }
t | |
� \ } } | t k r�| j d t d d | � n | t k r�| j d t d d | � n | d k s�| d k r!|
d | 7}
|
d | | f 7}
|
d | | f 7}
n t | |
| � d S( s'