�
�Udac @ s� i d d 6d g d 6d d 6Z d Z d Z d Z d d
l Z d d l m Z d d l m Z d d
l m
Z
m Z m Z d Z
d Z d Z d e f d � � YZ d � Z e d k r� e � n d
S( s 1.1t metadata_versiont previewt statust communityt supported_bysu
---
module: ce_bfd_view
version_added: "2.4"
short_description: Manages BFD session view configuration on HUAWEI CloudEngine devices.
description:
- Manages BFD session view configuration on HUAWEI CloudEngine devices.
author: QijunPan (@QijunPan)
notes:
- This module requires the netconf system service be enabled on the remote device being managed.
- Recommended connection is C(netconf).
- This module also works with C(local) connections for legacy playbooks.
options:
session_name:
description:
- Specifies the name of a BFD session.
The value is a string of 1 to 15 case-sensitive characters without spaces.
required: true
local_discr:
description:
- Specifies the local discriminator of a BFD session.
The value is an integer that ranges from 1 to 16384.
remote_discr:
description:
- Specifies the remote discriminator of a BFD session.
The value is an integer that ranges from 1 to 4294967295.
min_tx_interval:
description:
- Specifies the minimum interval for receiving BFD packets.
The value is an integer that ranges from 50 to 1000, in milliseconds.
min_rx_interval:
description:
- Specifies the minimum interval for sending BFD packets.
The value is an integer that ranges from 50 to 1000, in milliseconds.
detect_multi:
description:
- Specifies the local detection multiplier of a BFD session.
The value is an integer that ranges from 3 to 50.
wtr_interval:
description:
- Specifies the WTR time of a BFD session.
The value is an integer that ranges from 1 to 60, in minutes.
The default value is 0.
tos_exp:
description:
- Specifies a priority for BFD control packets.
The value is an integer ranging from 0 to 7.
The default value is 7, which is the highest priority.
admin_down:
description:
- Enables the BFD session to enter the AdminDown state.
By default, a BFD session is enabled.
The default value is bool type.
type: bool
default: 'no'
description:
description:
- Specifies the description of a BFD session.
The value is a string of 1 to 51 case-sensitive characters with spaces.
state:
description:
- Determines whether the config should be present or not on the device.
default: present
choices: ['present', 'absent']
extends_documentation_fragment: ce
s�
- name: bfd view module test
hosts: cloudengine
connection: local
gather_facts: no
vars:
cli:
host: "{{ inventory_hostname }}"
port: "{{ ansible_ssh_port }}"
username: "{{ username }}"
password: "{{ password }}"
transport: cli
tasks:
- name: Set the local discriminator of a BFD session to 80 and the remote discriminator to 800
ce_bfd_view:
session_name: atob
local_discr: 80
remote_discr: 800
state: present
provider: '{{ cli }}'
- name: Set the minimum interval for receiving BFD packets to 500 ms
ce_bfd_view:
session_name: atob
min_rx_interval: 500
state: present
provider: '{{ cli }}'
s
proposed:
description: k/v pairs of parameters passed into module
returned: always
type: dict
sample: {
"admin_down": false,
"description": null,
"detect_multi": null,
"local_discr": 80,
"min_rx_interval": null,
"min_tx_interval": null,
"remote_discr": 800,
"session_name": "atob",
"state": "present",
"tos_exp": null,
"wtr_interval": null
}
existing:
description: k/v pairs of existing configuration
returned: always
type: dict
sample: {
"session": {
"adminDown": "false",
"createType": "SESS_STATIC",
"description": null,
"detectMulti": "3",
"localDiscr": null,
"minRxInt": null,
"minTxInt": null,
"remoteDiscr": null,
"sessName": "atob",
"tosExp": null,
"wtrTimerInt": null
}
}
end_state:
description: k/v pairs of configuration after module execution
returned: always
type: dict
sample: {
"session": {
"adminDown": "false",
"createType": "SESS_STATIC",
"description": null,
"detectMulti": "3",
"localDiscr": "80",
"minRxInt": null,
"minTxInt": null,
"remoteDiscr": "800",
"sessName": "atob",
"tosExp": null,
"wtrTimerInt": null
}
}
updates:
description: commands sent to the device
returned: always
type: list
sample: [
"bfd atob",
"discriminator local 80",
"discriminator remote 800"
]
changed:
description: check to see if a change was made on the device
returned: always
type: bool
sample: true
i����N( t ElementTree( t
AnsibleModule( t
get_nc_configt
set_nc_configt ce_argument_specs�
<filter type="subtree">
<bfd xmlns="http://www.huawei.com/netconf/vrp" content-version="1.0" format-version="1.0">
%s
</bfd>
</filter>
sR
<bfdSchGlobal>
<bfdEnable></bfdEnable>
</bfdSchGlobal>
s�
<bfdCfgSessions>
<bfdCfgSession>
<sessName>%s</sessName>
<createType></createType>
<localDiscr></localDiscr>
<remoteDiscr></remoteDiscr>
<minTxInt></minTxInt>
<minRxInt></minRxInt>
<detectMulti></detectMulti>
<wtrTimerInt></wtrTimerInt>
<tosExp></tosExp>
<adminDown></adminDown>
<description></description>
</bfdCfgSession>
</bfdCfgSessions>
t BfdViewc B sh e Z d Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z
d � Z d
� Z RS( s Manages BFD Viewc C s� | | _ d | _ | j � | j j d | _ | j j d | _ | j j d | _ | j j d | _ | j j d | _ | j j d | _
| j j d | _ | j j d | _ | j j d | _
| j j d
| _ | j j d | _ | j j d | _ | j j d
| _ | j j d | _ t | _ t � | _ t � | _ t � | _ t � | _ t � | _ t � | _ t � | _ d S( Nt session_namet local_discrt remote_discrt min_tx_intervalt min_rx_intervalt detect_multit wtr_intervalt tos_expt
admin_downt descriptiont statet hostt usernamet port( t spect Nonet modulet __init_module__t paramsR R R
R R R R R R R R R R R t Falset changedt dictt bfd_dictt listt updates_cmdt commandst resultst proposedt existingt end_state( t selft
argument_spec( ( sS /usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_bfd_view.pyt __init__� s2
c C s t d | j d t � | _ d S( s init moduleR* t supports_check_modeN( R R t TrueR ( R) ( ( sS /usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_bfd_view.pyR s c C s t � } t � | d <t � | d <t t t | j } t | j | � } d | k rZ | S| j d d � j d d � j d d � j d d � } t j | � } | j
d � } | r� x% | D] } | j | d | j <q� Wn | j
d
� } | rx% | D] } | j | d | j <q� Wn | S( s bfd config dictt globalt sessions <data/>s
t s
s/ xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"s) xmlns="http://www.huawei.com/netconf/vrp"s bfd/bfdSchGlobals bfd/bfdCfgSessions/bfdCfgSession(
R t
CE_NC_GET_BFDt CE_NC_GET_BFD_GLBt CE_NC_GET_BFD_SESSIONR R R t replaceR t
fromstringt findt textt tag( R) R! t conf_strt xml_strt roott glbt attrt sess( ( sS /usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_bfd_view.pyt get_bfd_dict s(
c C s� d } t � } d } | j s"