
    Vhe                     z    d dl mZmZmZ eZddgddZdZdZdZ	d d	l
mZ d d
lmZmZmZmZ d Zedk(  r e        yy)    )absolute_importdivisionprint_functionz1.1preview	certified)metadata_versionstatussupported_bya"  
---
module: aci_bd
short_description: Manage Bridge Domains (BD) objects (fv:BD)
description:
- Manages Bridge Domains (BD) on Cisco ACI fabrics.
options:
  arp_flooding:
    description:
    - Determines if the Bridge Domain should flood ARP traffic.
    - The APIC defaults to C(false) when unset during creation.
    type: bool
  bd:
    description:
    - The name of the Bridge Domain.
    type: str
    aliases: [ bd_name, name ]
  bd_type:
    description:
    - The type of traffic on the Bridge Domain.
    - The APIC defaults to C(ethernet) when unset during creation.
    type: str
    choices: [ ethernet, fc ]
  description:
    description:
    - Description for the Bridge Domain.
    type: str
  enable_multicast:
    description:
    - Determines if PIM is enabled.
    - The APIC defaults to C(false) when unset during creation.
    type: bool
  enable_routing:
    description:
    - Determines if IP forwarding should be allowed.
    - The APIC defaults to C(true) when unset during creation.
    type: bool
  endpoint_clear:
    description:
    - Clears all End Points in all Leaves when C(true).
    - The value is not reset to disabled once End Points have been cleared; that requires a second task.
    - The APIC defaults to C(false) when unset during creation.
    type: bool
  endpoint_move_detect:
    description:
    - Determines if GARP should be enabled to detect when End Points move.
    type: str
    choices: [ default, garp ]
  endpoint_retention_action:
    description:
    - Determines if the Bridge Domain should inherit or resolve the End Point Retention Policy.
    - The APIC defaults to C(resolve) when unset during creation.
    type: str
    choices: [ inherit, resolve ]
  endpoint_retention_policy:
    description:
    - The name of the End Point Retention Policy the Bridge Domain should use when
      overriding the default End Point Retention Policy.
    type: str
  igmp_snoop_policy:
    description:
    - The name of the IGMP Snooping Policy the Bridge Domain should use when
      overriding the default IGMP Snooping Policy.
    type: str
  ip_learning:
    description:
    - Determines if the Bridge Domain should learn End Point IPs.
    - The APIC defaults to C(true) when unset during creation.
    type: bool
  ipv6_nd_policy:
    description:
    - The name of the IPv6 Neighbor Discovery Policy the Bridge Domain should use when
      overridding the default IPV6 ND Policy.
    type: str
  l2_unknown_unicast:
    description:
    - Determines what forwarding method to use for unknown l2 destinations.
    - The APIC defaults to C(proxy) when unset during creation.
    type: str
    choices: [ proxy, flood ]
  l3_unknown_multicast:
    description:
    - Determines the forwarding method to use for unknown multicast destinations.
    - The APIC defaults to C(flood) when unset during creation.
    type: str
    choices: [ flood, opt-flood ]
  ipv6_l3_unknown_multicast:
    description:
    - Determines the forwarding method to use for IPv6 unknown multicast destinations.
    - The APIC defaults to C(flood) when unset during creation.
    type: str
    choices: [ flood, opt-flood ]
  limit_ip_learn:
    description:
    - Determines if the BD should limit IP learning to only subnets owned by the Bridge Domain.
    - The APIC defaults to C(true) when unset during creation.
    type: bool
  mac_address:
    description:
    - The MAC Address to assign to the C(bd) instead of using the default.
    - The APIC defaults to C(00:22:BD:F8:19:FF) when unset during creation.
    type: str
    aliases: [ mac ]
  multi_dest:
    description:
    - Determines the forwarding method for L2 multicast, broadcast, and link layer traffic.
    - The APIC defaults to C(bd-flood) when unset during creation.
    type: str
    choices: [ bd-flood, drop, encap-flood ]
  state:
    description:
    - Use C(present) or C(absent) for adding or removing.
    - Use C(query) for listing an object or multiple objects.
    type: str
    choices: [ absent, present, query ]
    default: present
  name_alias:
    description:
    - The alias for the current object. This relates to the nameAlias field in ACI.
    type: str
  tenant:
    description:
    - The name of the Tenant.
    type: str
    aliases: [ tenant_name ]
  vrf:
    description:
    - The name of the VRF.
    type: str
    aliases: [ vrf_name ]
  route_profile:
    description:
    - The Route Profile to associate with the Bridge Domain.
    type: str
  route_profile_l3out:
    description:
    - The L3 Out that contains the associated Route Profile.
    type: str
  host_based_routing:
    description:
    - Enables advertising host routes (/32 prefixes) out of the L3OUT(s) that are associated to this BD.
    - The APIC defaults to C(false) when unset during creation.
    type: bool
    aliases: [ advertise_host_routes ]
  enable_rogue_except_mac:
    description:
    - Rogue exception MAC wildcard support for Bridge Domains.
    - Only available in APIC version 6.0 or later.
    - The APIC defaults to C(false) when unset during creation.
    type: bool
  allow_intersite_bum_traffic:
    description:
    - Control whether BUM traffic is allowed between sites.
    - The APIC defaults to C(false) when unset during creation.
    type: bool
    aliases: [allow_bum_traffic]
  allow_intersite_l2_stretch:
    description:
    - Allow L2 Stretch between sites.
    - The APIC defaults to C(false) when unset during creation.
    type: bool
    aliases: [allow_l2_stretch]
  allow_ipv6_multicast:
    description:
    - Flag to indicate if ipv6 multicast is enabled.
    - The APIC defaults to C(false) when unset during creation.
    type: bool
    aliases: [ ipv6_multicast, ipv6_mcast, allow_ipv6_mcast]
  link_local_address:
    description:
    - The override of the system generated IPv6 link-local address.
    type: str
    aliases: [ ll_addr_ipv6, ll_addr, link_local]
  multicast_arp_drop:
    description:
    - Enable BD rogue multicast ARP packet drop.
    - Only available in APIC version 6.0 or later.
    - The APIC defaults to C(true) when unset during creation.
    type: bool
    aliases: [ mcast_arp_drop ]
  vmac:
    description:
    - Virtual MAC address of the BD/SVI. This is used when the BD is extended to multiple sites using L2 Outside.
    type: str
  optimize_wan_bandwidth:
    description:
    - Optimize WAN Bandwidth improves the network application experience at the branch and makes better use of limited network resources.
    - The APIC defaults to C(false) when unset during creation.
    type: bool
    aliases: [wan_optimization, opt_bandwidth]
  mld_snoop_policy:
    description:
    - The name of the Multicast Listener Discovery (MLD) Snooping Policy the Bridge Domain should use when overriding the default MLD Snooping Policy.
    - To delete this attribute, pass an empty string.
    type: str
    aliases: [mld_snoop, mld_policy]
  igmp_policy:
    description:
    - The name of the IGMP Interface Policy the Bridge Domain should use when overriding the default IGMP Interface Policy.
    - To delete this attribute, pass an empty string.
    type: str
    aliases: [igmp]
  vlan:
    description:
    - The selected VLAN for bridge domain access port encapsulation.
    - To delete this attribute, pass an empty string.
    type: str
    aliases: [encap]
  monitoring_policy:
    description:
    - The name of the Monitoring Policy to apply to the Bridge Domain.
    - To delete this attribute, pass an empty string.
    type: str
    aliases: [mon_pol, monitoring_pol]
  first_hop_security_policy:
    description:
    - The name of the First Hop Security Policy to apply to the Bridge Domain.
    - To delete this attribute, pass an empty string.
    type: str
    aliases: [fhsp, fhs_pol, fhsp_name]
  pim_source_filter:
    description:
    - The name of the PIM Source Filter to apply to the Bridge Domain.
    - To delete this attribute, pass an empty string.
    - Only available in APIC version 5.2 or later.
    type: str
    aliases: [pim_source]
  pim_destination_filter:
    description:
    - The name of the PIM Destination Filter to apply to the Bridge Domain.
    - To delete this attribute, pass an empty string.
    - Only available in APIC version 5.2 or later.
    type: str
    aliases: [pim_dest, pim_destination]

extends_documentation_fragment:
- cisco.aci.aci
- cisco.aci.annotation
- cisco.aci.owner

notes:
- The C(tenant) used must exist before using this module in your playbook.
  The M(cisco.aci.aci_tenant) module can be used for this.
seealso:
- module: cisco.aci.aci_tenant
- name: APIC Management Information Model reference
  description: More information about the internal APIC class B(fv:BD).
  link: https://developer.cisco.com/docs/apic-mim-ref/
author:
- Jacob McGill (@jmcgill298)
- Samita Bhattacharjee (@samitab)
a6
  
- name: Add Bridge Domain
  cisco.aci.aci_bd:
    host: "{{ inventory_hostname }}"
    username: "{{ username }}"
    password: "{{ password }}"
    validate_certs: false
    tenant: prod
    bd: web_servers
    mac_address: 00:22:BD:F8:19:FE
    vrf: prod_vrf
    host_based_routing: true
    allow_intersite_bum_traffic: true
    allow_intersite_l2_stretch: true
    allow_ipv6_mcast: true
    ll_addr: "fe80::1322:33ff:fe44:5566"
    vmac: "00:AA:BB:CC:DD:03"
    optimize_wan_bandwidth: true
    vlan: vlan-101
    igmp_policy: web_servers_igmp_pol
    monitoring_policy: web_servers_monitoring_pol
    igmp_snoop_policy: web_servers_igmp_snoop
    mld_snoop_policy: web_servers_mld_snoop
    first_hop_security_policy: web_servers_fhs
    state: present
  delegate_to: localhost

- name: Add an FC Bridge Domain
  cisco.aci.aci_bd:
    host: "{{ inventory_hostname }}"
    username: "{{ username }}"
    password: "{{ password }}"
    validate_certs: false
    tenant: prod
    bd: storage
    bd_type: fc
    vrf: fc_vrf
    enable_routing: false
    state: present
  delegate_to: localhost

- name: Modify a Bridge Domain
  cisco.aci.aci_bd:
    host: "{{ inventory_hostname }}"
    username: "{{ username }}"
    password: "{{ password }}"
    validate_certs: true
    tenant: prod
    bd: web_servers
    arp_flooding: true
    l2_unknown_unicast: flood
    state: present
  delegate_to: localhost

- name: Modify a Bridge Domain to remove mld_snoop_policy and first_hop_security_policy
  cisco.aci.aci_bd:
    host: "{{ inventory_hostname }}"
    username: "{{ username }}"
    password: "{{ password }}"
    validate_certs: true
    tenant: prod
    bd: web_servers
    arp_flooding: true
    l2_unknown_unicast: flood
    mld_snoop_policy: ""
    first_hop_security_policy: ""
    state: present
  delegate_to: localhost

- name: Query All Bridge Domains
  cisco.aci.aci_bd:
    host: "{{ inventory_hostname }}"
    username: "{{ username }}"
    password: "{{ password }}"
    validate_certs: true
    state: query
  delegate_to: localhost
  register: query_result

- name: Query a Bridge Domain
  cisco.aci.aci_bd:
    host: "{{ inventory_hostname }}"
    username: "{{ username }}"
    password: "{{ password }}"
    validate_certs: true
    tenant: prod
    bd: web_servers
    state: query
  delegate_to: localhost
  register: query_result

- name: Delete a Bridge Domain
  cisco.aci.aci_bd:
    host: "{{ inventory_hostname }}"
    username: "{{ username }}"
    password: "{{ password }}"
    validate_certs: true
    tenant: prod
    bd: web_servers
    state: absent
  delegate_to: localhost
a
  
current:
  description: The existing configuration from the APIC after the module has finished
  returned: success
  type: list
  sample:
    [
        {
            "fvTenant": {
                "attributes": {
                    "descr": "Production environment",
                    "dn": "uni/tn-production",
                    "name": "production",
                    "nameAlias": "",
                    "ownerKey": "",
                    "ownerTag": ""
                }
            }
        }
    ]
error:
  description: The error information as returned from the APIC
  returned: failure
  type: dict
  sample:
    {
        "code": "122",
        "text": "unknown managed object class foo"
    }
raw:
  description: The raw output returned by the APIC REST API (xml or json)
  returned: parse error
  type: str
  sample: '<?xml version="1.0" encoding="UTF-8"?><imdata totalCount="1"><error code="122" text="unknown managed object class foo"/></imdata>'
sent:
  description: The actual/minimal configuration pushed to the APIC
  returned: info
  type: list
  sample:
    {
        "fvTenant": {
            "attributes": {
                "descr": "Production environment"
            }
        }
    }
previous:
  description: The original configuration from the APIC before the module has started
  returned: info
  type: list
  sample:
    [
        {
            "fvTenant": {
                "attributes": {
                    "descr": "Production",
                    "dn": "uni/tn-production",
                    "name": "production",
                    "nameAlias": "",
                    "ownerKey": "",
                    "ownerTag": ""
                }
            }
        }
    ]
proposed:
  description: The assembled configuration from the user-provided parameters
  returned: info
  type: dict
  sample:
    {
        "fvTenant": {
            "attributes": {
                "descr": "Production environment",
                "name": "production"
            }
        }
    }
filter_string:
  description: The filter string used for the request
  returned: failure or debug
  type: str
  sample: ?rsp-prop-include=config-only
method:
  description: The HTTP method used for the request to the APIC
  returned: failure or debug
  type: str
  sample: POST
response:
  description: The HTTP response from the APIC
  returned: failure or debug
  type: str
  sample: OK (30 bytes)
status:
  description: The HTTP status from the APIC
  returned: failure or debug
  type: int
  sample: 200
url:
  description: The HTTP url used for the request to the APIC
  returned: failure or debug
  type: str
  sample: https://10.11.12.13/api/mo/uni/tn-production.json
)AnsibleModule)	ACIModuleaci_argument_specaci_annotation_specaci_owner_specc                     t               } | j                  t                      | j                  t                       | j                  di dt	        d      dt	        dddg      d	t	        dd
dg      dt	        d      dt	        d      dt	        d      dt	        d      dt	        dddg      dt	        dddg      dt	        d      dt	        d      dt	        d      dt	        d      dt	        dddg      dt	        dddg      d t	        dddg      d!t	        d      d"t	        dd#g      d$t	        dg d%      d&t	        dd'g d()      d*t	        dd+g      d,t	        dd-g      d.t	        d      d/t	        d      d0t	        d      d1t	        dd2g      d3t	        d      d4t	        dd5g      d6t	        dd7g      d8t	        dg d9      d:t	        dg d;      d<t	        dd=g      d>t	        d      d?t	        dd@dAg      dBt	        ddCdDg      dEt	        ddFg      dGt	        ddHg      dIt	        ddJdKg      dLt	        dg dM      dNt	        ddOg      dPt	        ddQdRg       t        | dSd&dTdd*ggd&d'dd*gggU      }t        |      }|j                  |j                  j                  d            }|j                  j                  d      }|j                  j                  d	      }|d
k(  rdV}|j                  j                  d      }|j                  |j                  j                  d            }|j                  |j                  j                  d            }|j                  |j                  j                  d            }	|j                  j                  d      }
|
dk(  rdW}
|j                  j                  d      }|j                  j                  d      }|j                  j                  d      }|j                  |j                  j                  d            }|j                  j                  d      }|j                  j                  d      }|j                  j                  d      }|j                  j                  d       }|j                  |j                  j                  d!            }|j                  j                  d"      }|j                  j                  d$      }|j                  j                  d&      }|j                  j                  d*      }|j                  j                  d,      }|j                  j                  d.      }|j                  j                  d/      }|j                  j                  d0      }|j                  |j                  j                  d1            }|j                  |j                  j                  d3            }|j                  |j                  j                  d4            }|j                  |j                  j                  d6            }|j                  |j                  j                  d8            } |j                  j                  d:      }!|j                  |j                  j                  d<            }"|j                  j                  d>      }#|j                  |j                  j                  d?            }$|j                  j                  dB      }%|j                  j                  dE      }&|j                  j                  dG      }'|j                  j                  dI      }(|j                  j                  dL      })|j                  j                  dN      }*|j                  j                  dP      }+g dX},|*|+|,j                  g dY       |j                  t	        dZd[j                  |      |d|i\      t	        d]d^j                  |      |d|i\      |,_       |j                          |d'k(  rt	        di d`|da|db|	dc|
dd|de|d#|df|dg|d|dh|di|dj|dk|dl|dm|dn|do|dp|dq| dr|!ds|"d>|#dt|$}-|||-du<   dvdwdx|iiidydwdz|iiid{dwd||%iiid}dwd~|iiiddw||diiddw||diiddwd|)iiiddwdH|'iiiddwd|(iiig	}.|&6|&dWk(  rdWndj                  ||&      }/|.j                  di ddwd|/iiigdi       |*|+di g di}0di g di}1|*<|*dWk(  rdWndj                  ||*      }2|1d   d   j                  di ddwd|2iiigdi       |+<|+dWk(  rdWndj                  ||+      }3|1d   d   j                  di ddwd|3iiigdi       |0d   d   j                  |1       |.j                  |0       |j                  d]|-|.       |j!                  d]       |j#                          n|dTk(  r|j%                          |j'                          y )Narp_floodingbool)typebdstrbd_namename)r   aliasesbd_typeethernetfc)r   choicesdescriptionenable_multicastenable_routingendpoint_clearendpoint_move_detectdefaultgarpendpoint_retention_actioninheritresolveendpoint_retention_policyigmp_snoop_policyip_learningipv6_nd_policyl2_unknown_unicastproxyfloodl3_unknown_multicastz	opt-floodipv6_l3_unknown_multicastlimit_ip_learnmac_addressmac
multi_dest)zbd-flooddropzencap-floodstatepresent)absentr6   query)r   r"   r   tenanttenant_namevrfvrf_nameroute_profileroute_profile_l3out
name_aliashost_based_routingadvertise_host_routesenable_rogue_except_macallow_intersite_bum_trafficallow_bum_trafficallow_intersite_l2_stretchallow_l2_stretchallow_ipv6_multicast)ipv6_multicast
ipv6_mcastallow_ipv6_mcastlink_local_address)ll_addr_ipv6ll_addr
link_localmulticast_arp_dropmcast_arp_dropvmacoptimize_wan_bandwidthwan_optimizationopt_bandwidthmld_snoop_policy	mld_snoop
mld_policyigmp_policyigmpvlanencapmonitoring_policymon_polmonitoring_polfirst_hop_security_policy)fhspfhs_pol	fhsp_namepim_source_filter
pim_sourcepim_destination_filterpim_destpim_destinationTr7   )argument_specsupports_check_moderequired_ifregular )fvRsCtx
fvRsIgmpsnfvRsBDToNdPfvRsBdToEpRetfvRsBDToProfile	fvRsMldsnigmpIfPigmpRsIfPolfvAccPfvRsABDPolMonPolfvRsBDToFhs)pimBDPpimBDFilterPolpimBDSrcFilterPolpimBDDestFilterPolrtdmcRsFilterToRtMapPolfvTenantztn-{0})	aci_classaci_rnmodule_objecttarget_filterfvBDzBD-{0})
root_class
subclass_1child_classesarpFlooddescrepClearepMoveDetectMode
ipLearninglimitIpLearnToSubnets
mcastAllowmultiDstPktActr   unicastRouteunkMacUcastActunkMcastAct	nameAliasenableRogueExceptMachostBasedRoutingintersiteBumTrafficAllowintersiteL2Stretchipv6McastAllowllAddrmcastARPDropOptimizeWanBandwidthv6unkMcastActrm   
attributestnFvCtxNamern   tnIgmpSnoopPolNamerr   tnMldSnoopPolNamero   tnNdIfPolNamerp   )
resolveActtnFvEpRetPolNamerq   )tnL3extOutNametnRtctrlProfileNamerw   tnFhsBDPolNameru   rv   tnMonEPGPolNamezuni/tn-{0}/igmpIfPol-{1}rs   rt   tDn)r   childrenrx   ry   zuni/tn-{0}/rtmap-{1}r   rz   r|   r{   )r~   class_configchild_configs)r~    )r   updater   r   dictr   r   booleanparamsgetextendconstruct_urlformatget_existingappendpayloadget_diffpost_configdelete_config	exit_json)4rh   moduleacir   r   r   r   r   r   r    r!   r$   r'   r(   r)   r*   r+   r.   r/   r0   r1   r3   r5   r9   r;   r=   r>   r?   r@   rB   rC   rE   rG   rK   rO   rQ   rR   rU   rX   rZ   r\   r_   rc   re   r   r   r   igmp_policy_tdnpim_bdpim_filter_polpim_source_filter_tdnpim_destination_filter_tdns4                                                       d/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/cisco/aci/plugins/modules/aci_bd.pymainr     s   %'M,./)*M *v&*UY$78* %*d);<* e$	*
 6** (* (* "uy&6IJ* #'EIy;Q"R* #'E"2* E** f%* '*  UWg4FG* "uw6LM*  #'EG[;Q"R!*" (#*$ eeW5%*& U,OP'*( y:XY)** 8+*, ej\2-*. &/*0 !e,1*2 U#3*4  V6M5NO5*6 !%& 17*8 %)f?R>S$T9*: $(V>P=Q#R;*< "v7kl=*>  U4]^?*@  V6F5GHA*B uC*D  $:Lo9^_E*F 5;2MNG*H efX6I*J uwi0K*L EI?O3PQM*N #'E;["\O*P EL>BQ*R  $EV8WXS*X # hx 01i$!12
F F
C;;v}}00@AL			4	 Bmm	*G*--##M2K{{6==#4#45G#HI[[!2!23C!DEN[[!2!23C!DEN!==,,-CDy(! & 1 12M N & 1 12M N))*=>++fmm//>?K]]&&'78N**+?@!==,,-CD & 1 12M N[[!2!23C!DEN--##M2K""<0JMMg&E]]x(F
--

E
"CMM%%o6M --++,AB""<0JV]]%6%67K%LM!kk&--*;*;<U*VW"%++fmm.?.?@].^"_!$V]]->->?[-\!];;v}}'8'89O'PQ**+?@V]]%6%67K%LM==V$D [[):):;S)TU}}(();<--##M2K==V$D))*=> & 1 12M N))*=>#]]../GHM $(>(J	
  ??6* !6*	
 ??2&!2,	
 $    	 
!

 #
 2	

 #
 #1
 
 (
 &
 
 
 (
 .
 -
 !
  "9!
" 0#
$ &A%
&  :'
( 0)
* &+
, ,-
. /
0 "81
6 %0,EL) s';<=L+?AR*STU<*=?O)PQR\O^+LMN|<U  lE  .F  G  HBUn{/| }~\,<>W+XYZwo67,1BDU0V!WX

 "$/2$5b;U;\;\]cep;qO  )Bm^jmr  uD  mE  ^F  NG  MH  .I  "J  K(,B,Nrr BCF.rr0RSN ,.?2.EKaKhKhio  rC  LD%/0<CC(Kdgsv{  ~S  vT  gU  KV  JW  +X  Y &13IR3ORUkUrUrsy  |R  VS*/0<CC)"Lehtw|  Y  wZ  h[  L\  K]  ,^  _ 8Z(//?  (f<}]v&	(	MMO    __main__N)
__future__r   r   r   r   __metaclass__ANSIBLE_METADATADOCUMENTATIONEXAMPLESRETURNansible.module_utils.basicr   6ansible_collections.cisco.aci.plugins.module_utils.acir   r   r   r   r   __name__r   r   r   <module>r      sj    A @(-)Vab {zeNg
R 5 E  E\~ zF r   