netdevops / hier_config

Hierarchical Configuration
MIT License
128 stars 24 forks source link

bgp route-map in place update #111

Closed kulpatel closed 10 months ago

kulpatel commented 1 year ago

I m new to hier_config, can someone suugest how can i achieve below by manipulating the options in yml file. I know that "sectional_overwrite_no_negate" will do the job.. Here my problem is currenlty its appearing as NO form of current command followed by actual command. I m looking for REPLACE/IN PLACE update. Now just startswith: neighbour will gneralize all commands starting with "neighbour keyword". What if i have directon OUT and different peer group (v4server is name of peer group).

Actual router bgp 1121 address-family ipv4 unicast no neighbor v4server route-map RM_SET_SRC in neighbor v4server route-map drain-community in exit

Expected router bgp 1121 address-family ipv4 unicast neighbor v4server route-map drain-community in exit

kulpatel commented 1 year ago

In above example there are three variable v4server = name of peer group, drain-community = route map name, in = direction. My problem is above can be achieved via below but it doesn't not give expected result if i change the direction to OUT in expected config (means "neighbor v4server route-map drain-community in" has to be converted to "no neighbor v4server route-map drain-community in" and "neighbor v4server route-map drain-community out" both statment should appear. Problem is after making it idempotent it consider that as always starting keyword can go inside multilevel to find its different command , anyway we can convey variable parts here?

idempotent_commands:
  - lineage:
      - startswith: vlan
      - startswith: name
  - lineage:
      - startswith: interface
      - startswith:
          - description
          - ip address
  - lineage:
      - startswith: router bgp
      - startswith: address-family
      - startswith: neighbor