
    Vh                         d dl mZmZmZ eZ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 d	d
dZd Zd Zd Zd Zedk(  r e        yy)    )absolute_importdivisionprint_functiona  
module: nxos_pim
extends_documentation_fragment:
- cisco.nxos.nxos
short_description: Manages configuration of a PIM instance.
description:
- Manages configuration of a Protocol Independent Multicast (PIM) instance.
notes:
- Unsupported for Cisco MDS
version_added: 1.0.0
author: Gabriele Gerbino (@GGabriele)
options:
  bfd:
    description:
    - Enables BFD on all PIM interfaces.
    - "Dependency: ''feature bfd''"
    type: str
    choices:
    - enable
    - disable
  ssm_range:
    description:
    - Configure group ranges for Source Specific Multicast (SSM). Valid values are
      multicast addresses or the keyword C(none) or keyword C(default). C(none) removes
      all SSM group ranges. C(default) will set ssm_range to the default multicast
      address. If you set multicast address, please ensure that it is not the same
      as the C(default), otherwise use the C(default) option.
    type: list
    default: []
    elements: str
a  
- name: Configure ssm_range, enable bfd
  cisco.nxos.nxos_pim:
    bfd: enable
    ssm_range: 224.0.0.0/8

- name: Set to default
  cisco.nxos.nxos_pim:
    ssm_range: default

- name: Remove all ssm group ranges
  cisco.nxos.nxos_pim:
    ssm_range: none
z
commands:
    description: commands sent to the device
    returned: always
    type: list
    sample:
      - ip pim bfd
      - ip pim ssm range 224.0.0.0/8
N)AnsibleModule)CustomNetworkConfig)
get_configload_config
ip pim bfdip pim ssm rangebfd	ssm_rangec                     i }t        t        |             }|D ]r  }d|v r]t        j                  d|t        j                        }|s/|j                  d      j                  dd      }|j                         ||<   dd|v sid|v snd||<   t |S )	Nr   z2ssm range (?P<value>(?:[\s\d.\/]+|none|default))?$valuez232.0.0.0/8 r   r
   enable)strr   researchMgroupreplacesplit)moduleargsexistingconfigargmr   s          g/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/cisco/nxos/plugins/modules/nxos_pim.pyget_existingr!   d   s    HF#$F %#		EA
 (00C %c\lf4$HSM%  O    c                 l    i }|j                         D ]  \  }}| j                  |      }||||<     |S N)itemsget)key_maptablenew_dictkeyr   new_keys         r    apply_key_mapr,   {   sE    Hkkm &
U++c" %HW& Or"   c                 8   t               }t        t        |      }|j                         D ]W  \  }}d}|dk(  r$|dk(  rd}n/|dk(  rd}n'|r%dj	                  |      }n|dk(  r|d	k(  rd
nd}	|	|z   }|sG|j                  |       Y |r|j                  |g        y y )Nr   r   defaultzno ip pim ssm range nonenonezip pim ssm range nonezip pim ssm range {0}r
   disablezno )parents)listr,   PARAM_TO_COMMAND_KEYMAPr%   formatappendadd)
r   r   proposed	candidatecommandsproposed_commandsr*   r   commandno_cmds
             r    get_commandsr=      s    vH%&=xH'--/ %
U$$	!4&1077>L #y0UbFslGOOG$%" h+ r"   c                     t        t        ddddg      t        ddg d            } t        | d	
      }t               }dg |d}|j                  }t        j                         D cg c]
  }||   	| c}dv rR|d   D ]J  }t        j                  d|      r n2t        |j                  d            dk7  s9|j                  d       L t        |      }t        fd|j                         D              }i }	|j                         D ]  \  }
}|
dk(  r|r |d   dk(  r|j                  |
      s'd|	|
<   -t        t        |D cg c]  }t!        |       c}            }t        t        |j                  |
g       D cg c]  }t!        |       c}            }||k7  sdj#                  d |D              |	|
<   |
dk(  r||j                  dd      k7  s||	|
<   ||j                  |
      k7  s||	|
<    t%        d      }t'        |||	|       |r&|j)                         }||d<   d	|d<   t+        ||        |j,                  di | y c c}w c c}w c c}w )NFr   r   r0   )requiredtypechoicesr2   )r?   r@   r.   elementsr   T)argument_specsupports_check_mode)changedr9   warningsr   znone|default.   z^Valid ssm_range values are multicast addresses or the keyword 'none' or the keyword 'default'.)msgc              3   6   K   | ]  \  }}|v s||f  y wr$    ).0kvr   s      r    	<genexpr>zmain.<locals>.<genexpr>   s     HDAqa4i!QHs   	r   r.    c              3   2   K   | ]  }t        |        y wr$   )r   )rL   ss     r    rO   zmain.<locals>.<genexpr>   s     ,?SV,?s   r      )indentr9   rE   rK   )dictr   r2   paramsr3   keysr   r   lenr   	fail_jsonr!   r%   r&   sortedsetr   joinr   r=   
items_textr	   	exit_json)rC   r   rF   resultrV   rM   itemr   proposed_argsr7   r*   r   irN   exr8   r   s                   @r    mainrd      sS   %eh	5JKFBOM
 DQFvHBHEF]]F.335O!9NAOD d;' 	Dyy.4::c?#q(  F ! 		 FD)HHFLLNHHMH#))+ "
U+qY.<<$$-HSM361A678Cc21F GAQ GHI7$'HH,?Q,?$?HSME\UI66 %hll3''!HSM!"$ $1-I8Y7((*	&z yFI&FvY P.  7 Gs   )
I4III"__main__)
__future__r   r   r   r@   __metaclass__DOCUMENTATIONEXAMPLESRETURNr   ansible.module_utils.basicr   Pansible_collections.ansible.netcommon.plugins.module_utils.network.common.configr   Eansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxosr   r	   r3   r!   r,   r=   rd   __name__rK   r"   r    <module>ro      su   $ A @ >
 
 4 # .,27t zF r"   