{# ####### CMD: Set command variables on a per-os_type basis ####### #}
{% if 'ios' in os_type |string %}
{% set intf_cmd = "show interfaces status" %}
{% set switchport_cmd = "show interfaces switchport" %}
{% set ip_brief_cmd = "show ip interface brief" %}
{% elif 'nxos' in os_type |string %}
{% set intf_cmd = "show interface status" %}
{% set switchport_cmd = "show interface switchport" %}
{% set ip_brief_cmd = "show ip  interface brief vrf all | json" %}
{% elif 'asa' in os_type |string %}
{% set intf_cmd = "show interface" %}
{% set ip_brief_cmd = "show interface ip brief" %}
{% elif 'wlc' in os_type |string %}
{% set intf_cmd = "show port summary" %}
{% set ip_brief_cmd = "show interface summary" %}
{% elif 'panos' in os_type |string %}
{% set intf_cmd = "show interface hardware" %}
{% set ip_brief_cmd = "show interface logical" %}
{% endif %}


{# ##### VAL_CMDS/DESIRED_STATE: Build a dict of validation commands or desired state of each sub-feature ##### #}
- {{ feature }}:
{% set generate_val_file = sub_features.__class__.__name__ == 'list' %}
{% set desired_state = sub_features.__class__.__name__ == 'dict' %}
{% for sub_feat in (sub_features if generate_val_file else sub_features.items()) %}
{% set input_vars = None if generate_val_file else sub_feat[1] %}
{% set sub_feat = sub_feat if generate_val_file else sub_feat[0] %}
{# ### INTF: {cmd: {intf: {duplex: x, speed: x, type:x, connected }} ### #}
{% if sub_feat == 'intf' and intf_cmd is defined %}
    intf: 
      {{ intf_cmd }}:
{% if generate_val_file %}
        VALIDATE
{% elif desired_state %}
{% for each_intf, intf_info in input_vars.items() %}
        {{ each_intf }}:
          duplex: {{ intf_info.duplex | default('') }}
          speed: {{ intf_info.speed | default('') }}
          type: {{ intf_info.type | default('') }}
          status: connected
{% endfor %}{% endif %}
{# ### SWITCHPORT: {cmd: {intf: {mode: access or trunk, vlan: x or [x,y]}} ### #}
{% elif sub_feat == 'switchport' and switchport_cmd is defined %}
    switchport: 
      {{ switchport_cmd }}:
{% if generate_val_file %}
        VALIDATE
{% elif desired_state %}
{% for each_intf, intf_info in input_vars.items() %}
        {{ each_intf }}: 
          mode: {{ intf_info.mode }}
{% if intf_info.vlan.__class__.__name__ != 'list' %}
          vlan: {{ intf_info.vlan }}
{% elif intf_info.vlan.__class__.__name__ == 'list' %}
          vlan: 
            _mode: strict
            list: {{ intf_info.vlan }}
{% endif %}{% endfor %}{% endif %}
{# ### IP_BRIEF: {cmd: {intf: {ip:x, status: x}}} ### #}
{% elif sub_feat == 'ip_brief' and ip_brief_cmd is defined %}
    ip_brief: 
{# Needed as panos in_brief doesnt have intf status #}
{% if 'panos' in os_type |string %}
      {{ intf_cmd }}: SUB_FEATURE_COMBINED_CMD
{% endif %}
      {{ ip_brief_cmd }}:
{% if generate_val_file %}
        VALIDATE
{% elif desired_state %}
{% for each_intf, each_ip in input_vars.items() %}
        {{ each_intf }}:
          ip: {{ each_ip }}
          status: up
{% endfor %}{% endif %}

{# ##### End statements: for sub_feature and sub_feature conditional  ##### #}
{% endif %}{% endfor %}
