�
�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
d d
l m Z d e f d � � YZ 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_bysV
---
module: onyx_buffer_pool
version_added: "2.8"
author: "Anas Badaha (@anasb)"
short_description: Configures Buffer Pool
description:
- This module provides declarative management of Onyx Buffer Pool configuration
on Mellanox ONYX network devices.
notes:
- Tested on ONYX 3.6.8130
options:
name:
description:
- pool name.
required: true
pool_type:
description:
- pool type.
choices: ['lossless', 'lossy']
default: lossy
memory_percent:
description:
- memory percent.
switch_priority:
description:
- switch priority, range 1-7.
s�
- name: configure buffer pool
onyx_buffer_pool:
name: roce
pool_type: lossless
memory_percent: 50.00
switch_priority: 3
s
commands:
description: The list of configuration mode commands to send to the device.
returned: always
type: list
sample:
- traffic pool roce type lossless
- traffic pool roce memory percent 50.00
- traffic pool roce map switch-priority 3
( t
AnsibleModule( t show_cmd( t BaseOnyxModulet OnyxBufferPoolModulec B` sP e Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z RS( c C` s� t d t d d d t � d t d d d g d d � d
t d d � d t d d
� � } t � } | j | � t d | d t � | _ d S( s initialize module
t namet typet strt requiredt pool_typet choicest losslesst lossyt defaultt memory_percentt floatt switch_priorityt intt
argument_spect supports_check_modeN( t dictt Truet updateR t _module( t selft element_specR ( ( sQ /usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_buffer_pool.pyt init_moduleF s
c C` s/ | j j } t | � | _ | j | j � d S( N( R t paramsR t _required_configt validate_param_values( R t
module_params( ( sQ /usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_buffer_pool.pyt get_required_configU s c C` sC | r? d t | � k o# d k n r? | j j d d � n d S( Ni i t msgs- switch_priority value must be between 0 and 7( R R t fail_json( R t value( ( sQ /usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_buffer_pool.pyt validate_switch_priorityZ s )c C` s� | d k r d S| j | j j d � � } | d j d � | j d <t | d j d � � | j d <t | d j d � � | j d <d S( NR i t TypeR s Switch PrioritiesR s
Memory [%]R ( t Nonet getR# t _current_configR R ( R t traffic_pool_config( ( sQ /usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_buffer_pool.pyt _set_traffic_pool_config^ s c C` s7 d j | j j d � � } t | j | d t d t �S( Ns show traffic pool {0}R t json_fmtt
fail_on_error( t formatR# R- R R R t False( R t cmd( ( sQ /usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_buffer_pool.pyt _show_traffic_poolf s c C` s) t � | _ | j � } | j | � d S( N( R R. R6 R0 ( R R/ ( ( sQ /usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_buffer_pool.pyt load_current_configj s c C` sO | j j d � } | j j d � } | j d k rF | j | | � n1 | j j d � } | | k rw | j | | � n | j j d � } | d k r� | j j d � } | d k s� | | k r� | j j d j | | � � q� n | j j d � } | d k rK| j j d � } | d k s)| | k rK| j j d j | | � � qKn d S( NR R R s# traffic pool {0} memory percent {1}R s( traffic pool {0} map switch-priority {1}( R# R- R. R, t _add_add_traffic_pool_cmdst _commandst appendR3 ( R R R t current_pool_typeR t curr_memory_percentR t curr_switch_priority( ( sQ /usr/lib/python2.7/site-packages/ansible/modules/network/onyx/onyx_buffer_pool.pyt generate_commandso s"