Skip to content

Instantly share code, notes, and snippets.

@mrlesmithjr
Created December 5, 2017 21:05
Show Gist options
  • Select an option

  • Save mrlesmithjr/cbd5f18393af06a3ffd3053e174719d5 to your computer and use it in GitHub Desktop.

Select an option

Save mrlesmithjr/cbd5f18393af06a3ffd3053e174719d5 to your computer and use it in GitHub Desktop.
---
tenants:
{% for tenant in aci_discovered_tenants %}
{{ tenant }}:
{% for _ap_tenants in _aci_discovered_aps['results'] %}
{% for _ap_tenant in _ap_tenants['existing'] %}
{% if _ap_tenant['fvTenant']['attributes']['name'] == tenant %}
{% if _ap_tenant['fvTenant']['children'] is defined %}
app_profiles:
{% for ap in _ap_tenant['fvTenant']['children'] %}
{% set _ap = ap['fvAp']['attributes'] %}
{{ _ap['name'] }}:
description: {% if _ap['descr'] %}{{ _ap['descr'] }}{% else %}[]{% endif %}
{% if ap['fvAp']['children'] is defined %}
epgs:
{% for _ap_epg in ap['fvAp']['children'] %}
{% if _ap_epg['fvAEPg'] is defined %}
{% set _epg = _ap_epg['fvAEPg']['attributes'] %}
{{ _epg['name'] }}:
{% if _ap_epg['fvAEPg']['children'] is defined %}
{% for _ap_epg_attr in _ap_epg['fvAEPg']['children'] %}
{% if _ap_epg_attr['fvRsBd'] is defined %}
bridge_domain: {{ _ap_epg_attr['fvRsBd']['attributes']['tnFvBDName'] }}
{% endif %}
{% endfor %}
{% endif %}
fwd_control: {% if _epg['fwdCtrl'] %}{{ _epg['fwdCtrl'] }}{% else %}[]{% endif %}
intra_epg_isolation: {{ _epg['pcEnfPref'] }}
priority: {{ _epg['prio'] }}
state: {{ aci_discovery_default_epg_state }}
{% endif %}
{% endfor %}
{% endif %}
state: {{ aci_discovery_default_ap_state }}
{% endfor %}
{% elif _ap_tenant['fvTenant']['children'] is not defined %}
app_profiles: []
{% endif %}
{% endif %}
{% endfor %}
{% endfor %}
{% for _bd_tenants in _aci_discovered_bds['results'] %}
{% for _bd_tenant in _bd_tenants['existing'] %}
{% if _bd_tenant['fvTenant']['attributes']['name'] == tenant %}
{% if _bd_tenant['fvTenant']['children'] is defined %}
bridge_domains:
{% for bd in _bd_tenant['fvTenant']['children'] %}
{% set _bd = bd['fvBD']['attributes'] %}
{{ _bd['name'] }}:
arp_flooding: {{ _bd['arpFlood'] }}
bd_type: {% if _bd['type']|lower == "regular" %}ethernet{% else %}{{ _bd['type'] }}{% endif %}
description: {% if _bd['descr'] %}{{ _bd['descr'] }}{% else %}[]{% endif %}
enable_multicast: {{ _bd['mcastAllow'] }}
enable_routing: {{ _bd['unicastRoute'] }}
endpoint_clear: {{ _bd['epClear'] }}
endpoint_move_detect: {% if _bd['epMoveDetectMode'] %}{{ _bd['epMoveDetectMode'] }}{% else %}[]{% endif %}
ip_learning: {{ _bd['ipLearning'] }}
l2_unknown_unicast: {{ _bd['unkMacUcastAct'] }}
l3_unknown_multicast: {{ _bd['unkMcastAct'] }}
limit_ip_learn: {{ _bd['limitIpLearnToSubnets'] }}
multi_dest: {{ _bd['multiDstPktAct'] }}
state: {{ aci_discovery_default_bd_state }}
subnets:
{% for _bd_tenant_subnets in _aci_discovered_bd_subnets['results'] %}
{% for _bd_tenant_subnet in _bd_tenant_subnets['existing'] %}
{% if _bd_tenant_subnet['fvTenant']['attributes']['name'] == tenant %}
{% if _bd_tenant_subnet['fvTenant']['children'] is defined %}
{% for _bd_subnet in _bd_tenant_subnet['fvTenant']['children'] %}
{% if _bd_subnet['fvBD'] is defined %}
{% if _bd_subnet['fvBD']['attributes']['name'] == _bd['name'] %}
{% if _bd_subnet['fvBD']['children'] is defined %}
{% for bd_subnet in _bd_subnet['fvBD']['children'] %}
{% if bd_subnet['fvSubnet'] is defined %}
{% set __bd_subnet = bd_subnet['fvSubnet']['attributes'] %}
{{ __bd_subnet['ip']|ipaddr('network') }}:
gateway: {{ __bd_subnet['ip']|ipaddr('address') }}
description: {% if __bd_subnet['descr'] %}{{ __bd_subnet['descr'] }}{% else %}[]{% endif %}
mask: {{ __bd_subnet['ip']|ipaddr('prefix') }}
preferred: {{ __bd_subnet['preferred'] }}
scope: {{ __bd_subnet['scope'] }}
state: {{ aci_discovery_default_bd_subnet_scope_state }}
subnet_name: {% if __bd_subnet['name'] %}{{ __bd_subnet['name'] }}{% else %}[]{% endif %}
{% endif %}
{% endfor %}
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
{% endif %}
{% endfor %}
{% endfor %}
{% endfor %}
{% elif _bd_tenant['fvTenant']['children'] is not defined %}
bridge_domains: []
{% endif %}
{% endif %}
{% endfor %}
{% endfor %}
{% for _contract_tenants in _aci_discovered_contracts['results'] %}
{% for _contract_tenant in _contract_tenants['existing'] %}
{% if _contract_tenant['fvTenant']['attributes']['name'] == tenant %}
{% if _contract_tenant['fvTenant']['children'] is defined %}
contracts:
{% for contract in _contract_tenant['fvTenant']['children'] %}
{% set _contract = contract['vzBrCP']['attributes'] %}
{{ _contract['name'] }}:
description: {% if _contract['descr'] %}{{ _contract['descr'] }}{% else %}[]{% endif %}
dscp: {{ _contract['targetDscp'] }}
priority: {{ _contract['prio'] }}
scope: {{ _contract['scope'] }}
state: {{ aci_discovery_default_contract_state }}
{% if contract['vzBrCP']['children'] is defined %}
subjects:
{% for contract_subject in contract['vzBrCP']['children'] %}
{% if contract_subject['vzSubj'] is defined %}
{% set _contract_subject = contract_subject['vzSubj']['attributes'] %}
{{ _contract_subject['name'] }}:
consumer_match: {{ _contract_subject['consMatchT'] }}
description: {% if _contract_subject['descr'] %}{{ _contract_subject['descr'] }}{% else %}[]{% endif %}
dscp: {{ _contract_subject['targetDscp'] }}
priority: {{ _contract_subject['prio'] }}
provider_match: {{ _contract_subject['provMatchT'] }}
reverse_filter: {{ _contract_subject['revFltPorts'] }}
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}
{% endif %}
{% endfor %}
{% endfor %}
{% for _filter_tenants in _aci_discovered_filters['results'] %}
{% for _filter_tenant in _filter_tenants['existing'] %}
{% if _filter_tenant['fvTenant']['attributes']['name'] == tenant %}
{% if _filter_tenant['fvTenant']['children'] is defined %}
filters:
{% for filter in _filter_tenant['fvTenant']['children'] %}
{% set _filter = filter['vzFilter']['attributes'] %}
{{ _filter['name'] }}:
description: {% if _filter['descr'] %}{{ _filter['descr'] }}{% else %}[]{% endif %}
{% if filter['vzFilter']['children'] is defined %}
{% for _filter_entry in filter['vzFilter']['children'] %}
{% if _filter_entry['vzEntry'] is defined %}
{% set __filter_entry = _filter_entry['vzEntry']['attributes'] %}
entries:
{{ __filter_entry['name'] }}:
arp_flag: {{ __filter_entry['arpOpc'] }}
description: {% if __filter_entry['descr'] %}{{ __filter_entry['descr'] }}{% else %}[]{% endif %}
dst_to_port: {{ __filter_entry['dToPort'] }}
dst_from_port: {{ __filter_entry['dFromPort'] }}
ether_type: {{ __filter_entry['etherT'] }}
icmp_msg_type: {{ __filter_entry['icmpv4T'] }}
icmp6_msg_type: {{ __filter_entry['icmpv6T'] }}
ip_protocol: {{ __filter_entry['prot'] }}
src_to_port: {{ __filter_entry['sToPort'] }}
src_from_port: {{ __filter_entry['sFromPort'] }}
stateful: {{ __filter_entry['stateful'] }}
{% endif %}
{% endfor %}
{% endif %}
state: {{ aci_discovery_default_filter_state }}
{% endfor %}
{% endif %}
{% endif %}
{% endfor %}
{% endfor %}
state: {{ aci_discovery_default_tenant_state }}
{% for _vrf_tenants in _aci_discovered_vrfs['results'] %}
{% for _vrf_tenant in _vrf_tenants['existing'] %}
{% if _vrf_tenant['fvTenant']['attributes']['name'] == tenant %}
{% if _vrf_tenant['fvTenant']['children'] is defined %}
vrfs:
{% for vrf in _vrf_tenant['fvTenant']['children'] %}
{% set _vrf = vrf['fvCtx']['attributes'] %}
{{ _vrf['name'] }}:
description: {% if _vrf['descr'] %}{{ _vrf['descr'] }}{% else %}[]{% endif %}
policy_control_direction: {{ _vrf['pcEnfDir'] }}
policy_control_preference: {{ _vrf['pcEnfPref'] }}
state: {{ aci_discovery_default_vrf_state }}
{% endfor %}
{% elif _vrf_tenant['fvTenant']['children'] is not defined %}
vrfs: []
{% endif %}
{% endif %}
{% endfor %}
{% endfor %}
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment