Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os10_bgp Network statement Bug #162

Open
bas-1988 opened this issue Feb 14, 2024 · 1 comment
Open

os10_bgp Network statement Bug #162

bas-1988 opened this issue Feb 14, 2024 · 1 comment

Comments

@bas-1988
Copy link

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?

@prasadapr
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants