
    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
Z
d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZmZ d Zd ZddddddZd Zd Zd Zd Zd Zd Z d Z!d(dZ"d Z#d Z$d Z%d Z&d  Z'd! Z(d" Z)d# Z*d$ Z+d% Z,d& Z-e.d'k(  r e-        yy))    )absolute_importdivisionprint_functiona  
module: ios_vrf
author: Peter Sprygada (@privateip)
short_description: Module to configure VRF definitions.
description:
  - This module provides declarative management of VRF definitions on Cisco IOS devices.  It
    allows playbooks to manage individual or the entire VRF collection.  It also supports
    purging VRF definitions from the configuration that are not explicitly defined.
version_added: 1.0.0
extends_documentation_fragment:
  - cisco.ios.ios
notes:
  - Tested against Cisco IOSXE Version 17.3 on CML.
  - This module works with connection C(network_cli).
    See U(https://docs.ansible.com/ansible/latest/network/user_guide/platform_ios.html)
options:
  vrfs:
    description:
      - The set of VRF definition objects to be configured on the remote IOS device.  Ths
        list entries can either be the VRF name or a hash of VRF definitions and attributes.  This
        argument is mutually exclusive with the C(name) argument.
    type: list
    elements: raw
  name:
    description:
      - The name of the VRF definition to be managed on the remote IOS device.  The
        VRF definition name is an ASCII string name used to uniquely identify the VRF.  This
        argument is mutually exclusive with the C(vrfs) argument
    type: str
  description:
    description:
      - Provides a short description of the VRF definition in the current active configuration.  The
        VRF definition value accepts alphanumeric characters used to provide additional
        information about the VRF.
    type: str
  address_family:
    description:
      - The list of address families with MDT parameters to be configured on the remote IOS device.
    type: list
    suboptions:
      afi:
        description: Address family identifier.
        type: str
        choices:
          ["ipv4", "ipv6"]
      mdt:
        description: MDT parameters.
        type: dict
        suboptions:
          auto_discovery:
            description: Auto-discovery parameters.
            type: dict
            suboptions:
              vxlan:
                description: Vxlan parameters.
                type: dict
                suboptions:
                  enable:
                    description: Enable VXLAN.
                    type: bool
                  inter_as:
                    description: Enable inter-as.
                    type: bool
          default:
            description: Parameters for default option.
            type: dict
            suboptions:
              vxlan_mcast_group:
                description: VXLAN multicast group value.
                type: str
          data:
            description: Parameters for data option.
            type: dict
            suboptions:
              vxlan_mcast_group:
                description: VXLAN multicast group value.
                type: str
              threshold:
                description: Threshold value.
                type: int
          overlay:
            description: Parameters for overlay option.
            type: dict
            suboptions:
              use_bgp:
                description: parameters for BGP option.
                type: dict
                suboptions:
                  enable:
                    description: Enable use BGP.
                    type: bool
                  spt_only:
                    description: Enable SPT only.
                    type: bool
    elements: dict
  rd:
    description:
      - The router-distinguisher value uniquely identifies the VRF to routing processes
        on the remote IOS system.  The RD value takes the form of C(A:B) where C(A)
        and C(B) are both numeric values.
    type: str
  interfaces:
    description:
      - Identifies the set of interfaces that should be configured in the VRF.  Interfaces
        must be routed interfaces in order to be placed into a VRF.
    type: list
    elements: str
  associated_interfaces:
    description:
      - This is a intent option and checks the operational state of the for given vrf
        C(name) for associated interfaces. If the value in the C(associated_interfaces)
        does not match with the operational state of vrf interfaces on device it will
        result in failure.
    type: list
    elements: str
  delay:
    description:
      - Time in seconds to wait before checking for the operational state on remote
        device.
    default: 10
    type: int
  purge:
    description:
      - Instructs the module to consider the VRF definition absolute.  It will remove
        any previously configured VRFs on the device.
    default: false
    type: bool
  state:
    description:
      - Configures the state of the VRF definition as it relates to the device operational
        configuration.  When set to I(present), the VRF should be configured in the
        device active configuration and when set to I(absent) the VRF should not be
        in the device active configuration
    default: present
    choices:
      - present
      - absent
    type: str
  route_both:
    description:
      - Adds an export and import list of extended route target communities to the VRF.
    type: list
    elements: str
  route_export:
    description:
      - Adds an export list of extended route target communities to the VRF.
    type: list
    elements: str
  route_import:
    description:
      - Adds an import list of extended route target communities to the VRF.
    type: list
    elements: str
  route_both_ipv4:
    description:
      - Adds an export and import list of extended route target communities in address-family
        configuration submode to the VRF.
    type: list
    elements: str
  route_export_ipv4:
    description:
      - Adds an export list of extended route target communities in address-family configuration
        submode to the VRF.
    type: list
    elements: str
  route_import_ipv4:
    description:
      - Adds an import list of extended route target communities in address-family configuration
        submode to the VRF.
    type: list
    elements: str
  route_both_ipv6:
    description:
      - Adds an export and import list of extended route target communities in address-family
        configuration submode to the VRF.
    type: list
    elements: str
  route_export_ipv6:
    description:
      - Adds an export list of extended route target communities in address-family configuration
        submode to the VRF.
    type: list
    elements: str
  route_import_ipv6:
    description:
      - Adds an import list of extended route target communities in address-family configuration
        submode to the VRF.
    type: list
    elements: str
aP	  
- name: Configure a vrf named management
  cisco.ios.ios_vrf:
    name: management
    description: oob mgmt vrf
    interfaces:
      - Management1

- name: Remove a vrf named test
  cisco.ios.ios_vrf:
    name: test
    state: absent

- name: Configure set of VRFs and purge any others
  cisco.ios.ios_vrf:
    vrfs:
      - red
      - blue
      - green
    purge: true

- name: Creates a list of import RTs for the VRF with the same parameters
  cisco.ios.ios_vrf:
    name: test_import
    rd: 1:100
    route_import:
      - 1:100
      - 3:100

- name:
    Creates a list of import RTs in address-family configuration submode for the
    VRF with the same parameters
  cisco.ios.ios_vrf:
    name: test_import_ipv4
    rd: 1:100
    route_import_ipv4:
      - 1:100
      - 3:100

- name:
    Creates a list of import RTs in address-family configuration submode for the
    VRF with the same parameters
  cisco.ios.ios_vrf:
    name: test_import_ipv6
    rd: 1:100
    route_import_ipv6:
      - 1:100
      - 3:100

- name: Creates a list of export RTs for the VRF with the same parameters
  cisco.ios.ios_vrf:
    name: test_export
    rd: 1:100
    route_export:
      - 1:100
      - 3:100

- name:
    Creates a list of export RTs in address-family configuration submode for the
    VRF with the same parameters
  cisco.ios.ios_vrf:
    name: test_export_ipv4
    rd: 1:100
    route_export_ipv4:
      - 1:100
      - 3:100

- name:
    Creates a list of export RTs in address-family configuration submode for the
    VRF with the same parameters
  cisco.ios.ios_vrf:
    name: test_export_ipv6
    rd: 1:100
    route_export_ipv6:
      - 1:100
      - 3:100

- name:
    Creates a list of import and export route targets for the VRF with the same
    parameters
  cisco.ios.ios_vrf:
    name: test_both
    rd: 1:100
    route_both:
      - 1:100
      - 3:100

- name:
    Creates a list of import and export route targets in address-family configuration
    submode for the VRF with the same parameters
  cisco.ios.ios_vrf:
    name: test_both_ipv4
    rd: 1:100
    route_both_ipv4:
      - 1:100
      - 3:100

- name:
    Creates a list of import and export route targets in address-family configuration
    submode for the VRF with the same parameters
  cisco.ios.ios_vrf:
    name: test_both_ipv6
    rd: 1:100
    route_both_ipv6:
      - 1:100
      - 3:100
a1  
commands:
  description: The list of configuration mode commands to send to the device
  returned: always
  type: list
  sample:
    - vrf definition ansible
    - description management vrf
    - rd: 1:100
start:
  description: The time the job started
  returned: always
  type: str
  sample: "2016-11-16 10:38:15.126146"
end:
  description: The time the job ended
  returned: always
  type: str
  sample: "2016-11-16 10:38:25.595612"
delta:
  description: The time elapsed to perform all operations
  returned: always
  type: str
  sample: "0:00:10.469466"
N)partial)AnsibleModule)exec_command)	iteritems)NetworkConfig)
get_configload_configc                    | j                         j                  d      ry| j                         j                  d      ry| j                         j                  d      ry| j                         j                  d      ry| j                         j                  d	      ry| j                         j                  d
      ry| j                         j                  d      ryy)NETethernetVLsviLOloopbackMG
managementMAPOportchannelNVnveunknown)upper
startswith)	interfaces    e/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/cisco/ios/plugins/modules/ios_vrf.pyget_interface_typer    l  s    ##D)			%	%d	+			%	%d	+			%	%d	+			%	%d	+			%	%d	+			%	%d	+    c                 ^    d| z  |vr|j                  d| z  g       |j                  |       y )Nvrf definition %s)extendappend)namecmdcommandss      r   add_command_to_vrfr)     s0    T!1,t345OOCr!   zmdt auto-discovery zmdt default vxlan zmdt data vxlan zmdt data threshold zmdt overlay )auto_discoverydefault
data_mcastdata_thresholdoverlayc                    | d   j                         D ]  \  }}t        |   }|dv r||d   z   }t        |||       )|dk(  r|t        |      z   }t        |||       J|dk(  r7|d   d   r|dz   }|d   j	                  d      r|d	z   d
z   }t        |||       |dk(  s|d   d   r|dz   }|d   j	                  d      r|d	z   dz   }t        |||        y )Nmdt)r+   r,   vxlan_mcast_groupr-   r*   vxlanenableinter_as zinter-asr.   use_bgpzuse-bgpspt_onlyzspt-only)itemsKEY_TO_COMMAND_MAPr)   strget)afi_dictvrf_namer(   keyvaluer'   s         r   add_mdt_commandsr@     s	   uo++- 8
U %++122Cxh7$$E
"Cxh7$$W~h'GmW~!!*-Ci*,xh7IY)IoY##J/Ci*,xh7)8r!   c           
      
   t               }| D ]-  }|\  }}d }|d   dk(  r|j                  d|d   z         ,|j                  d      s|j                  d|d   z  g       t	        |j
                  j                         D cg c]+  \  }}|j                  d      s|j                  d      r|r|- c}}      d	k7  }	t	        |j
                  j                         D cg c]+  \  }}|j                  d
      s|j                  d      r|r|- c}}      d	k7  }
|
r|j                  ddg       |	r|j                  ddg        |||d      rd|d   z  }t        |d   ||        |||d      rd|d   z  }t        |d   ||        |||d      r|d   D ]  }d|z  }t        |d   ||         |||d      r|d   D ]  }d|z  }t        |d   ||         |||d      rCd}t        |d   ||       |d   D ]  }d|z  }t        |d   ||        d}t        |d   ||        |||d      rCd}t        |d   ||       |d   D ]  }d|z  }t        |d   ||        d}t        |d   ||        |||d      rCd}t        |d   ||       |d   D ]  }d|z  }t        |d   ||        d}t        |d   ||        |||d      rCd}t        |d   ||       |d   D ]  }d|z  }t        |d   ||        d}t        |d   ||        |||d      r|d   D ]  }|d   i }|d   j                  di       }|r d|v rd|d   i|d   d <   d!|v r|d!   |d   d"<   |d   j                         D ][  \  }}t        fd#|j                  di       D        i       } ||d   |j                  di       |      sI|j                  ||i       ] |sd$t              z   }t        |d   ||       t        d|i|d   |       t        |d   d|        |d%   t        |j                  d%g             j                  |d%         D ]  }|j                  d&|z  d'|d   z  g         t        |d%         j                  |j                  d%g             D ]  }t!        |      }t#        d(|)      }|d&|z     j$                  }d*j'                  |      }|j                  d&|z  d+|d   z  g       t)        j*                  d,|t(        j,                        }|s|j                  |j/                                 0 |S c c}}w c c}}w )-Nc                    t        | j                        t              r|t        j                        t              r]| j                        xrJ | j                        j                        k7  xr% t        fd| j                        D               S | j                        xr# | j                        j                        k7  S )Nc              3   D   K   | ]  }|j                        v   y w)N)r;   ).0elemhavexs     r   	<genexpr>z<map_obj_to_commands.<locals>.needs_update.<locals>.<genexpr>  s     L 3Ls    )
isinstancer;   listall)wantrF   rG   s    ``r   needs_updatez)map_obj_to_commands.<locals>.needs_update  s    $((1+t,DHHQK1NHHQK Mtxx{2MLLLL
 88A;=488A;$((1+#==r!   stateabsentno vrf definition %sr&   r#   _ipv6_bothr   _ipv4address-family ipv4exitaddress-family ipv6descriptionzdescription %srdzrd %sroute_importzroute-target import %sroute_exportzroute-target export %sroute_import_ipv4zexit-address-familyroute_export_ipv4route_import_ipv6route_export_ipv6address_familyafir0   datar1   r,   	thresholdr-   c              3   4   K   | ]  }|d    k(  s|  yw)r`   N )rD   ir`   s     r   rH   z&map_obj_to_commands.<locals>.<genexpr>  s     VqahRUoVs   address-family 
interfaceszinterface %szno vrf forwarding %s   indentcontents
zvrf forwarding %szip address .+)rJ   r%   r;   r$   lenparamsr8   endswithr)   popnextupdater:   r@   set
differencer   r
   childrenjoinresearchMgroup)updatesmoduler(   rr   rL   rF   rM   kvipv6ipv4r'   routewant_mdtaf_dict	data_dictkey_invalue_inhave_mdtintfcfg	configobjru   intf_configmatchr`   s                            @r   map_obj_to_commandsr     s=   vH }3
d	> =H$OO2T&\ABxx OO04<?@A %+MM$7$7$9 AqJJw/1::g3FA     %+MM$7$7$9 AqJJw/1::g3FA    !6 ?@!6 ?@dM2"T-%88CtF|S(;dD)DJ&CtF|S(;dN3n- @.6"4<h?@ dN3n- @.6"4<h?@ d$78'CtF|S(;12 @.6"4<h?@ (CtF|S(;d$78'CtF|S(;12 @.6"4<h?@ (CtF|S(;d$78'CtF|S(;12 @.6"4<h?@ (CtF|S(;d$78'CtF|S(;12 @.6"4<h?@ (CtF|S(;d$45 !12 Vuo$UO//;	*i7/;N1O95 #i/<Ek<R(89(0(=(=(? ;$FH#VDHH-=r$BV H
 $HUOX\\%5LfU'9:; 03s8;C&tF|S(C$eW%5tF|XN&tF|5JHU1V4 )DHH\267BB4CUV `$!68NQUV\Q]8] ^_`D./::488LRT;UV 3 ()SA	$^d%:;DD"ii1$!68KdSYl8Z [\		/;EOOEKKM23k}3| OWs   0U"0Uc                     | d|z     }dj                  |j                        }t        j                  d|t        j                        }|r|j                  d      S y )Nr#   rl   zdescription (.+)$rh   rv   ru   rw   rx   ry   rz   r   r&   r   r   s       r   parse_descriptionr   )  sQ    
'$.
/C
))CLL
!CII)35E{{1~ r!   c                     | d|z     }dj                  |j                        }t        j                  d|t        j                        }|r|j                  d      S y )Nr#   rl   zrd (.+)$rh   r   r   s       r   parse_rdr   1  sP    
'$.
/C
))CLL
!CIIj#rtt,E{{1~ r!   c                    d}t               }t        t        j                  dt	        |       t        j
                              D ]S  }| |   j                  D ]?  }||v s	 ||j                         d      j                  |j                  d      d          A U |S # t        $ r, |j                  d      d   g||j                         d   <   Y zw xY w)Nzvrf forwardingz^interface .+r5   rh   )
dictrs   rw   findallr:   ry   ru   splitr%   KeyError)r   vrf_cfgrg   r   lines        r   parse_interfacesr   9  s    GJBJJIEF HdO,, 	HD$Htzz|B/077

38JK	HH    H48JJsOA4F3GJtzz|B/0Hs   7B2CCc                     | d|z     }dj                  |j                        }t        j                  d|t        j                        }|S )Nr#   rl   route-target\s+import\s+(.+)rv   ru   rw   r   ry   r   r&   r   matchess       r   parse_importr   F  @    
'$.
/C
))CLL
!Cjj93EGNr!   c                     | d|z     }dj                  |j                        }t        j                  d|t        j                        }|S )Nr#   rl   route-target\s+export\s+(.+)r   r   s       r   parse_exportr   M  r   r!   c                 N   t        j                  d      }t               }d }d }|dk(  rt        | |      }t	        | |      }n;|dk(  rt        | |      }t        | |      }n|dk(  rt        | |      }t        | |      }|r|r|D ]  }|j                  |      }|j                         j                  d      }|D ]h  }	|j                  |	      }
|
j                         j                  d      }
||
k(  s9||vr|j                  |g      nd  |
|vr|j                  |
g      nd  j  |S )Nz(?P<rd>.+:.+)globalr   r   rX   )rw   compilerJ   r   r   parse_export_ipv4parse_import_ipv4parse_export_ipv6parse_import_ipv6rx   	groupdictr;   r$   )r   r&   r_   
rd_patternr   export_matchimport_matchexexrdimimrds              r   
parse_bothr   T  s4   O,JfGLL!#It4#It4	6	!(D9(D9	6	!(D9(D9 	LB$$R(D>>#''-D" L!((,~~'++D14<.2'.AGNND6*t.2'.AGNND6*tL	L Nr!   c                     | d|z     }	 |d   }dj                  |j                        }t        j                  d|t        j                        }|S # t
        $ r Y y w xY w)Nr#   rT   rl   r   rv   ru   rw   r   ry   r   r   r&   r   subcfgr   s        r   r   r   o  b    
'$.
/C*+6??+**=vrttL    AA 	AAc                     | d|z     }	 |d   }dj                  |j                        }t        j                  d|t        j                        }|S # t
        $ r Y y w xY w)Nr#   rT   rl   r   r   r   s        r   r   r   z  r   r   c                     | d|z     }	 |d   }dj                  |j                        }t        j                  d|t        j                        }|S # t
        $ r Y y w xY w)Nr#   rV   rl   r   r   r   s        r   r   r     r   r   c                     | d|z     }	 |d   }dj                  |j                        }t        j                  d|t        j                        }|S # t
        $ r Y y w xY w)Nr#   rV   rl   r   r   r   s        r   r   r     r   r   c           	         | d|z     }g }dD ]  }i }	 |d|z      }dj                  |j                        }t        j                  d      }t        j                  d      }t        j                  d      }	t        j                  d	      }
t        j                  d
      }|j                         D ]
  }|j                         }|j                  |      }|r|j                         }|j                  di       j                  |d   i       j                  dd       |d   r5|j                  di       j                  |d   i       j                  dd       |j                  |      }|r6|j                         }|j                  di       j                  d|d          |	j                  |      }|r7|j                         }|j                  di       j                  d|d          :|
j                  |      }|r.|j                         }|j                  dt        |d                |j                  |      }|s|j                         }|j                  di       j                  di       j                  dd       |d   s|j                  di       j                  di       j                  dd        |j                  ||d        |S # t        $ r d}Y w xY w)Nr#   )r   r   rf   rl    zD^mdt +auto\-discovery +(?P<option>\S+)(\s+(?P<inter_as>inter\-as))?$z+^mdt +default +vxlan +(?P<mcast_group>\S+)$z'^mdt +data +vxlan +(?P<mcast_group>.+)$z0^mdt +data +threshold +(?P<threshold_value>\d+)$z@^mdt +overlay +(?P<use_bgp>use-bgp)(\s+(?P<spt_only>spt-only))?$r*   optionr3   Tr4   r+   r1   mcast_groupr,   r-   threshold_valuer.   r6   r7   r`   r0   )rv   ru   r   rw   r   
splitlinesstripr   r   
setdefaultintr%   )r   r&   r   mdt_listipret_dictr   re1re2re3re4re5r   mrz   s                  r   	parse_mdtr     s   
'$.
/CH C6	*R/0FYYv/F
 jj`ajjGHjjCDjjLMjj\]%%' 2	3D::<D		$A##$4b9DD(O *Xt,$''(8"=HHh !jT2		$A##Ir2=='-( 		$A##L"5@@'-( 		$A##$4c%@Q:R6ST		$A##Ir2== *Xt,$''	26AA! !jT2e2	3h 	845GC6H O  	F	s   #KK&%K&c                 @   t        |       }t        d|      }t        j                  d|t        j                        }|s
t               S t               }t        |      }t        |      D ]  }|dt        ||      t        ||      |j                  |g       t        ||      t        ||      t        ||      t        ||      t        ||      t        ||d      t!        ||      t#        ||      t        ||d      t%        ||      d}|j'                  |        |S )	Nrh   ri   z^vrf definition (\S+)presentr   )r_   r   )r&   rN   rW   rX   rg   rY   rZ   
route_bothr[   r\   route_both_ipv4r]   r^   route_both_ipv6r_   )r   r
   rw   r   ry   rJ   r   rs   r   r   r;   r   r   r   r   r   r   r   r   r%   )r|   configr   r   	instancesrg   itemobjs           r   map_config_to_objr     s   FQ8IJJ/>EvI!),JE
 ,Y=9d+$..r2(D9(D9$Y5!29d!C!29d!C))T&Q!29d!C!29d!C))T&Q'	48
" 	%& r!   c                    |j                  |       s|j                  |    }n>|j                  |    j                  dd      }|j                  |   } |||           ||    }t	               j                  d| z        }|r	 |||       |S )Ntyper:   zvalidate_%s)r;   rn   argument_spec _CHECK_ARGUMENT_TYPES_DISPATCHERglobals)r>   r   r|   r?   
value_typetype_checker	validators          r   get_param_valuer     s    88C=c" ))#.2265A
>>zJT#YS		mc12I% Lr!   c                 p   | j                   j                  d      }|s\| j                   d   s| j                   d   r
t               S | j                   d   s| j                  d       d| j                   d   ig}n]t               }|D ]N  }t	        |t
              s|j                  d|i       'd|vr| j                  d       >|j                  |       P t               }|D ]O  }t        t        ||       } |d      |d<    |d      |d<    |d	      |d	<    |d
      |d
<    |d      |d<    |d      |d<    |d      |d<    |d      |d<    |d      |d<    |d      |d<    |d      |d<    |d      |d<    |d      |d<    |d      |d<   g d}|D ]{  }|d|z     s|d|z     st               |d|z  <   |d|z     st               |d|z  <   |d|z     j                   |d|z               |d|z     j                   |d|z               }  |d      |d<   |j                  |       R |S )Nvrfsr&   purgezname is requiredmsg)r   r|   rW   rX   rg   rN   rY   rZ   r   r[   r\   r   r]   r^   r   r_   )r   rQ   rS   zroute_both%szroute_export%szroute_import%sassociated_interfaces)
rn   r;   rJ   	fail_jsonrI   r   r%   r   r   r$   )r|   r   
collectionr   objects	get_valueboth_addresses_familyr_   s           r   map_params_to_objr     s   ==V$D}}V$w)?6Mv&!34v}}V456
V
 	(DdD)!!64.1t#  %7 8!!$'	( fG O$vF	'6]t_T
&|4\!'*W(8^(8^&|4\$-.A$B !$-.A$B !"+,=">$-.A$B !$-.A$B !"+,=">!*+;!< 63 	NN^34,~=>>BfD)N:;,~=>>BfD)N:;%67>>n~=> %67>>n~=>	 )22I(J$%t=> Nr!   c                    t               }| D ]  t        fd|D        d       }t        |d u d   dk(  f      r|j                  i f       At	              D ]p  \  }}|s	t        |t               r5	 t        |      t        ||         k7  r|f|vr|j                  |f       N|||   k7  sW|f|vs^|j                  |f       r  |S # t        $ r |||   k7  r|j                  |f       Y w xY w)Nc              3   :   K   | ]  }|d    d    k(  s|  yw)r&   Nrd   )rD   re   entrys     r   rH   z!update_objects.<locals>.<genexpr>L  s      C1&	U6](BQCs   rN   r   )rJ   rq   rK   r%   r	   rI   sorted	TypeError)rL   rF   r{   r   r>   r?   r   s         @r   update_objectsr   I  s   fG :CCTJeGn	9:;NNE2;''. :
U!%.!%e}tCy0AA$)4=#?$+NNE4=$A
 $s)+!4=7#NNE4=9::& N  ) !$S	1 't} = !s   43C$C87C8c                    |j                   d   r|d   r"t        j                  |j                   d          |j                   d   }t        |dj	                  |            \  }}}|dk(  r|j                         j                         }|sy |d   }|d   }	| D ]V  }
|
d   |k(  s|
j                  d      |
d   D ]1  }t        |      t        |	      us|j                  d|	d	|
       3 X y y y )Nr   changeddelayr&   zshow vrf | include {0}r   r   z
Interface z not configured on vrf r   )
rn   timesleepr   formatr   r   r;   r    r   )rL   r|   resultr&   rcouterrra   vrfr   wre   s               r   check_declarative_intent_paramsr  a  s   }},-)JJv}}W-.}}V$#F,D,K,KD,QRC799;$$&Dq'CRI V9#uu45= 67 -a08J98UU",,OXZ^$_ - 	  .r!   c                  0   t        t        dddg      t        dt        t        dt        t        dt        t        d      t        d            	      
      	      t        dt        t        dt        t        d      t        d            	            	      t        dt        t        d            	      t        dt        t        d      t        d            	            	            } t        d8i dt        dd      dt        d      dt        d      dt        dd|       dt        d      dt        dd      dt        dd      dt        dd      dt        dd      dt        dd      d t        dd      d!t        dd      d"t        dd      d#t        dd      d$t        dd      d%t        dd      d&t        d'd(      d)t        dd*+      d,t        d-d-d.g/      }d0g}t        ||d12      }d3d*i}t               }||d4<   t        |      }t	        |      }t        t        ||      |      }|j                  d)   r^|D 	cg c]  }	|	d   	 }
}	|D 	cg c]  }	|	d   	 }}	t        |      j                  |
      D ]  }d5|z  }||vs|j                  |        ||d6<   |r|j                  st        ||       d1|d3<   t        |||        |j                  d8i | y7c c}	w c c}	w )9z%main entry point for module executionr:   r   r   )r   choicesr   bool)r   )r3   r7   )r   options)r6   )r3   r4   )r2   )r1   r   )r1   rb   )r.   r*   r+   ra   r   r   rJ   raw)r   elementsr&   rW   r_   )r   r  r	  rX   rZ   rY   r   r\   r[   r   r^   r]   r   rg   r   r   
   )r+   r   r   F)r   r+   rN   r   rO   )r+   r  )r&   r   T)r   mutually_exclusivesupports_check_moder   warningsrP   r(   Nrd   )r   r   rJ   r   r   r   r   rn   rs   rt   r%   
check_moder   r  	exit_json)address_family_specr   r  r|   r   r  rL   rF   r(   rG   	want_vrfs	have_vrfsr   r'   s                 r   mainr  x  sX   eff%56  $!'$('+'8)-6):%!  $ "!'$('+'8)-6):%   *.E*:  *.E*:"&E"2?&)
,\  v.u e$ &BUV	
 U v6 v6 Ve4 FU; FU; &59 FU; FU; &59 Ve4  #?!" 2E*#$ .%& 9y(.CD'M* ++#- F
 FvH!F:V$DV$D">$#=vFH}}W(,-1QvY-	-(,-1QvY-	-	N--i8 	%D(4/C("$	% "F:  ) y#D&&9Fv .-s   0LL__main__)r   )/
__future__r   r   r   r   __metaclass__DOCUMENTATIONEXAMPLESRETURNrw   r   	functoolsr   ansible.module_utils.basicr   ansible.module_utils.connectionr   ansible.module_utils.sixr	   Pansible_collections.ansible.netcommon.plugins.module_utils.network.common.configr
   Bansible_collections.cisco.ios.plugins.module_utils.network.ios.iosr   r   r    r)   r9   r@   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  __name__rd   r!   r   <module>r#     s   $ A @ }~jX
2 
   4 8 .& ,##+ 80@F
6HV<"1h0._D zF r!   