dellemc.os10 icon indicating copy to clipboard operation
dellemc.os10 copied to clipboard

os10_bgp Network statement Bug

Open bas-1988 opened this issue 1 year ago • 1 comments

The following yaml Configuration,

os10_bgp:
  asn: xxx
  vrfs:
    - name: "xxx"
      address_family_ipv4:
      ipv4_network:
        - address: 1.1.1.0/24
          state: present

results in:

router bgp xxx
  !
 vrf xxx
  !
  address-family ipv4 unicast
   network 1.1.1.0/24

Because the logic places the network statement under address-family:

{% macro render_ipv4_network_configs(ipv4_network_vars) %}
      {% for net in ipv4_network_vars %}
        {% if net.address is defined and net.address %}
          {% if net.state is defined and net.state == "absent"%}
  no network {{ net.address }}
          {% else %}
  network {{ net.address }}
          {% endif %}
        {% endif %}
      {% endfor %}
{% endmacro %}

    {% if vrf.ipv4_network is defined and vrf.ipv4_network %}
      {% set ipv4_network_vars = vrf.ipv4_network %}
  address-family ipv4 unicast
 {{ render_ipv4_network_configs(ipv4_network_vars) }}
    {% endif %}

The issue here is that, when placing the configuration under absent:

os10_bgp:
  asn: xxx
  vrfs:
    - name: "xxx"
      address_family_ipv4:
      ipv4_network:
        - address: 1.1.1.0/24
          state: absent

You will get the following error message: fatal: [xxx]: FAILED! => {"changed": false, "command": "no network 1.1.1.0/24", "msg": "no network 1.1.1.0/24\r\n% Error: Unrecognized command.\r\n\u0007xxx(config-router-bgp-xxx-vrf)# ", "rc": -32603}

This is because it's not deleting it under the address family. but under the vrf.

If you compare this with aggregate address it is working because that's actually placed under the correct spot allready:

os10_bgp:
  asn: xxx
  vrfs:
    - name: "xxx"
      address_family_ipv4:
        aggregate_address:
          - ip_and_mask: 1.1.1.1/24
            state: present

results in:

router bgp xxx
  !
 vrf xxx
  !
  address-family ipv4 unicast
    aggregate-address 1.1.1.0/24

and:

os10_bgp:
  asn: xxx
  vrfs:
    - name: "xxx"
      address_family_ipv4:
        aggregate_address:
          - ip_and_mask: 1.1.1.1/16
            state: absent

results in:

router bgp xxx
  !
 vrf xxx
  !
  address-family ipv4 unicast
  !
{% macro render_af_configs(af_vars) %}
    {% if af_vars is defined and af_vars %}
      {% if af_vars.aggregate_address is defined and af_vars.aggregate_address %}
        {% for addr in af_vars.aggregate_address %}
          {% if addr.ip_and_mask is defined and addr.ip_and_mask %}
            {% if addr.state is defined and addr.state == "absent" %}
  no aggregate-address {{ addr.ip_and_mask }}
            {% else %}
              {% set aggr_str = addr.ip_and_mask %}
              {% if addr.adv_map is defined and addr.adv_map %}
                {% set aggr_str = aggr_str ~ " advertise-map " ~ addr.adv_map %}
              {% endif %}
              {% if addr.as_set is defined and addr.as_set %}
                {% set aggr_str = aggr_str ~ " as-set " %}
              {% endif %}
              {% if addr.attr_map is defined and addr.attr_map %}
                {% set aggr_str = aggr_str ~ " attribute-map " ~ addr.attr_map %}
              {% endif %}
              {% if addr.summary is defined and addr.summary %}
                {% set aggr_str = aggr_str ~ " summary-only" %}
              {% endif %}
              {% if addr.suppress_map is defined and addr.suppress_map %}
                {% set aggr_str = aggr_str ~ " suppress-map " ~ addr.suppress_map %}
              {% endif %}
  aggregate-address {{ aggr_str }}
            {% endif %}
          {% endif %}
        {% endfor %}
      {% endif %}
    {% endif %}
{% endmacro %}

Can you guys please fix this?

bas-1988 avatar Feb 14 '24 12:02 bas-1988

Hi @bas-1988, sure we will verify and update on this.

prasadapr avatar Feb 14 '24 17:02 prasadapr