�
�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 m Z m Z m Z m Z y* d d
l m Z d d l m Z e Z Wn e k
r� Z e Z n Xd � Z d � Z d � Z d � Z e d k re � n d S( i ( t absolute_importt divisiont print_functions 1.1t metadata_versiont previewt statust communityt supported_bys�
---
module: netscaler_cs_policy
short_description: Manage content switching policy
description:
- Manage content switching policy.
- "This module is intended to run either on the ansible control node or a bastion (jumpserver) with access to the actual netscaler instance."
version_added: "2.4"
author: George Nikolopoulos (@giorgos-nikolopoulos)
options:
policyname:
description:
- >-
Name for the content switching policy. Must begin with an ASCII alphanumeric or underscore C(_)
character, and must contain only ASCII alphanumeric, underscore, hash C(#), period C(.), space C( ), colon
C(:), at sign C(@), equal sign C(=), and hyphen C(-) characters. Cannot be changed after a policy is
created.
- "The following requirement applies only to the NetScaler CLI:"
- >-
If the name includes one or more spaces, enclose the name in double or single quotation marks (for
example, my policy or my policy).
- "Minimum length = 1"
url:
description:
- >-
URL string that is matched with the URL of a request. Can contain a wildcard character. Specify the
string value in the following format: C([[prefix] [*]] [.suffix]).
- "Minimum length = 1"
- "Maximum length = 208"
rule:
description:
- >-
Expression, or name of a named expression, against which traffic is evaluated. Written in the classic
or default syntax.
- "Note:"
- >-
Maximum length of a string literal in the expression is 255 characters. A longer string can be split
into smaller strings of up to 255 characters each, and the smaller strings concatenated with the +
operator. For example, you can create a 500-character string as follows: '"<string of 255
characters>" + "<string of 245 characters>"'
domain:
description:
- "The domain name. The string value can range to 63 characters."
- "Minimum length = 1"
action:
description:
- >-
Content switching action that names the target load balancing virtual server to which the traffic is
switched.
extends_documentation_fragment: netscaler
requirements:
- nitro python sdk
s�
- name: Create url cs policy
delegate_to: localhost
netscaler_cs_policy:
nsip: 172.18.0.2
nitro_user: nsroot
nitro_pass: nsroot
validate_certs: no
state: present
policyname: policy_1
url: /example/
s
loglines:
description: list of logged messages by the module
returned: always
type: list
sample: ['message 1', 'message 2']
msg:
description: Message detailing the failure reason
returned: failure
type: str
sample: "Could not load nitro python sdk"
diff:
description: List of differences between the actual configured object and the configuration specified in the module
returned: failure
type: dict
sample: { 'url': 'difference. ours: (str) example1 other: (str) /example1' }
( t
AnsibleModule( t ConfigProxyt get_nitro_clientt netscaler_common_argumentst logt loglinest ensure_feature_is_enabled( t cspolicy( t nitro_exceptionc C` s9 t d � t j | d | j d � d k r1 t St Sd S( Ns Checking if policy existss
policyname:%st
policynamei ( R R t count_filteredt paramst Truet False( t clientt module( ( sY /usr/lib/python2.7/site-packages/ansible/modules/network/netscaler/netscaler_cs_policy.pyt
policy_exists| s
#c C` s� t d � t j | d | j d � d k r1 t St j | d | j d � } | j | d � } d | k rw | d =n t | � d k r� t St Sd S( Ns5 Checking if defined policy is identical to configureds
policyname:%sR i t ip( R R R R R t get_filteredt diff_objectt lenR ( R R t cspolicy_proxyt policy_listt diff_dict( ( sY /usr/lib/python2.7/site-packages/ansible/modules/network/netscaler/netscaler_cs_policy.pyt policy_identical� s
#
c C` s. t j | d | j d � } | j | d � S( Ns
policyname:%sR i ( R R R R ( R R R R ( ( sY /usr/lib/python2.7/site-packages/ansible/modules/network/netscaler/netscaler_cs_policy.pyt diff_list� s c
C` s� t d t d d � d t d d � d t d d � d t d d � d t d d � � } t � } t � } | j t � | j | � | j | � t d | d t � } t d
t d t d t � } t s� | j d
d � n t | � } y | j
� Wn� t k
r1} d t | j
� | j f } | j d
| � n� t k
r�} t t | � � d k ru| j d
d t | � � q�t t | � � d k r�| j d
d t | � � q�| j d
d t | � � n Xd d d d d g } d d d d d d d d g } i }
t d t � d | d | j d | d! | d"