Skip to content

Collapsed VLAN lines can produce a destructive "no vlan x,y" remediation in Cisco IOS #264

Description

@nopg

Describe the bug
On Cisco IOS, unnamed VLANs can be rendered collapsed onto a single comma/range line (e.g. vlan 69,381). When such a collapsed line is present in the running config, hier_config treats that whole line as one config object. If the intended config lists those VLANs as separate blocks, the literal line vlan 69,381 is absent from the intended config, so hier_config negates the entire line — emitting a destructive no vlan 69,381 that removes both VLANs (and any config under them), then re-adds them. A simple rename of an already-named VLAN works fine; the bug is specific to collapsed, unnamed VLAN lines.

To Reproduce
Steps to reproduce the behavior:

  1. Running config contains a collapsed VLAN line: vlan 69,381
  2. Intended config lists them as separate blocks, e.g. vlan 69 / name newname and vlan 381
  3. Build a remediation with WorkflowRemediation (or config_to_get_to)
  4. See no vlan 69,381 in the remediation output

i.e.:

from hier_config import get_hconfig, WorkflowRemediation, Platform

running  = get_hconfig(Platform.CISCO_IOS, "vlan 69,381\n")
intended = get_hconfig(Platform.CISCO_IOS, "vlan 69\n name newname\nvlan 381\n")
print(WorkflowRemediation(running, intended).remediation_config_filtered_text(include_tags={}, exclude_tags={}))

will print:

no vlan 69,381   <--- the bug
vlan 69
  name newname
vlan 381

Expected behavior
The above example should ONLY produce the below, as no vlans are actually getting removed.

vlan 69
  name newname

Desktop (please complete the following information):

  • Driver: CISCO_IOS (also affects IOS-XE via the same driver)
  • Hier Config Version: 3.6.0

Additional context
The HP ProCurve driver already handles the analogous case (it splits comma-separated VLAN lists at load time). The Cisco IOS driver has no equivalent. Fix: a post-load callback that splits collapsed comma/range VLAN id lists (vlan 69,381, vlan 10-12) into one vlan <id> block each, so they diff block-to-block.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions