mpenning / ciscoconfparse

Parse, Audit, Query, Build, and Modify Arista / Cisco / Juniper / Palo Alto / F5 configurations.
http://www.pennington.net/py/ciscoconfparse/
GNU General Public License v3.0
793 stars 220 forks source link

[Bug]: CiscoConfParse.sync_diff returns "uncfg" line for childs and parents #226

Closed kornoa closed 2 years ago

kornoa commented 2 years ago

Contact Details

korte.noack@controlware.de

What happened?

loaded config: [ "interface GigabitEthernet1", " description Test1", "interface GigabitEthernet2", " description Test2" ]

reference_config = [ "interface GigabitEthernet1", " description Test1-New", "interface GigabitEthernet3", " description Test3" ]

calling sync_diff

--> output: interface GigabitEthernet1 no description Test1 no interface GigabitEthernet2 no description Test2 interface GigabitEthernet1 description Test1-New interface GigabitEthernet3 description Test3

--> expected: interface GigabitEthernet1 no description Test1 no interface GigabitEthernet2 interface GigabitEthernet1 description Test1-New interface GigabitEthernet3 description Test3

Deleting sub-command (child) "no description Test2" for "interface GigabitEthernet2", which is deleted one line above makes no sense and will lead to errors if deploying to a Cisco IOS device. If you accept this bug report, I can provide a fix and create a pull request.

CiscoConfParse Version

1.6.36

What Operating System are you using?

Microsoft Windows

What Python version(s) have this problem?

Python 3.9

Show us how to reproduce the problem. Please tell us if the problem is specific to certain inputs or situations.

import ciscoconfparse

config1 = [
    "interface GigabitEthernet1",
    " description Test1",
    "interface GigabitEthernet2",
    " description Test2"
]
cfg1 = ciscoconfparse.CiscoConfParse(config=config1)
reference_config  = [
    "interface GigabitEthernet1",
    " description Test1-New",
    "interface GigabitEthernet3",
    " description Test3"
]

diff = cfg1.sync_diff(cfgspec=reference_config, linespec='.*')
print("\n".join(diff))

Python tracebacks

no tracebacks

Relevant log output

No response

Code of Conduct

mpenning commented 2 years ago

Thank you for the reports... I'll fix these issues.

github-actions[bot] commented 2 years ago

This issue has automatically been marked stale due to inactivity. The issue will close unless further activity occurs. Please understand that the CiscoConfParse team is not obligated to comment on every issue. For more detailed information, please refer to our CONTRIBUTING guidance -> https://github.com/mpenning/ciscoconfparse/blob/main/.github/CONTRIBUTING.md

github-actions[bot] commented 2 years ago

This issue has automatically been marked stale due to inactivity. The issue will close unless further activity occurs. Please understand that the CiscoConfParse team is not obligated to comment on every issue. For more detailed information, please refer to our CONTRIBUTING guidance -> https://github.com/mpenning/ciscoconfparse/blob/main/.github/CONTRIBUTING.md

github-actions[bot] commented 2 years ago

Due to inactivity, CiscoConfParse's maintainers are closing this issue. Please refrain from further comments. In the future, CiscoConfParse's maintainers may reopen it solely at their own discretion. For more detailed information, please refer to our CONTRIBUTING guidance -> https://github.com/mpenning/ciscoconfparse/blob/main/.github/CONTRIBUTING.md