�
�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_bysI
---
module: pn_cpu_class
author: "Pluribus Networks (@rajaspachipulusu17)"
version_added: "2.8"
short_description: CLI command to create/modify/delete cpu-class
description:
- This module can be used to create, modify and delete CPU class information.
options:
pn_cliswitch:
description:
- Target switch to run the CLI on.
required: False
type: str
state:
description:
- State the action to perform. Use C(present) to create cpu-class and
C(absent) to delete cpu-class C(update) to modify the cpu-class.
required: True
type: str
choices: ['present', 'absent', 'update']
pn_scope:
description:
- scope for CPU class.
required: false
choices: ['local', 'fabric']
pn_hog_protect:
description:
- enable host-based hog protection.
required: False
type: str
choices: ['disable', 'enable', 'enable-and-drop']
pn_rate_limit:
description:
- rate-limit for CPU class.
required: False
type: str
pn_name:
description:
- name for the CPU class.
required: False
type: str
s�
- name: create cpu class
pn_cpu_class:
pn_cliswitch: 'sw01'
state: 'present'
pn_name: 'icmp'
pn_rate_limit: '1000'
pn_scope: 'local'
- name: delete cpu class
pn_cpu_class:
pn_cliswitch: 'sw01'
state: 'absent'
pn_name: 'icmp'
- name: modify cpu class
pn_cpu_class:
pn_cliswitch: 'sw01'
state: 'update'
pn_name: 'icmp'
pn_rate_limit: '2000'
s�
command:
description: the CLI command run on the target node.
returned: always
type: str
stdout:
description: set of responses from the cpu-class command.
returned: always
type: list
stderr:
description: set of error responses from the cpu-class 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 } | } | d 7} t | | � d } | j � } d | k ra | j d t d d � n | } | d 7} t | | � d } | r� | j � } n | | k r� t St S( s�
This method checks for idempotency using the cpu-class-show command.
If a user with given name exists, return True else False.
:param module: The Ansible module to fetch input parameters
:param cli: The CLI string
t pn_names= system-settings-show format cpu-class-enable no-show-headersi t ont failedt msgs, Enable CPU class before creating or deletings+ cpu-class-show format name no-show-headers( t paramsR t splitt fail_jsont Truet False( t modulet clit namet clicopyt out( ( sQ /usr/lib/python2.7/site-packages/ansible/modules/network/netvisor/pn_cpu_class.pyt check_clij s
c C` s� t d d d d d d � } t d t d t d t d
d � d t d t d
d d
| j � � d t d t d
d d
d d g � d t d t d
d d
d d d g � d t d t d
d � d t d t d
d � � d d d d d d g g d d d g g d d d g g f � } | j d } | j d } | j d } | j d } | j d } | j d } | | } t | | � } t | | � }
| d | | f 7} | d k r�|
t k r�| j d t d d | � q�n | d k r|
t k r| j d t d d | � qn | d k rT|
t k r:| j d t d d | � n | rT| d | 7} qTn | d k r�| rw| d | 7} n | r�| d | 7} q�n t
| | | � d! S("