netdevops / hier_config

Hierarchical Configuration
MIT License
126 stars 24 forks source link

Omited lines with nxos os #104

Closed Zulzig closed 2 years ago

Zulzig commented 2 years ago
ISSUE TYPE
SOFTWARE VERSIONS
python:

Python 3.8.13 (default, Mar 17 2022, 00:00:00)

hier_config:

hier-config==2.0.1 nornir-hier-config==0.1.0

SUMMARY

I would like to generate a remediation file for a Cisco Nexus device. I found that some lines seem to be omited when you choose nxos os.

STEPS TO REPRODUCE

Create two files: running-config.txt:

tacacs-server deadtime 3
tacacs-server host 192.168.1.99 key 7 "Test12345"

template.txt:

tacacs-server host 192.168.1.98 key 0 Test135 timeout 3
tacacs-server host 192.168.100.98 key 0 test135 timeout 3

the script when i set nxos from a host.

from hier_config.host import Host
from hier_config import HConfig
host = Host(hostname='test', os='nxos')
running = HConfig(host=host)
running.load_from_file('running-config.txt')
compiled = HConfig(host=host)
compiled.load_from_file('template.txt')
rem = running.config_to_get_to(compiled)
for line in rem.all_children():
    print(line.cisco_style_text())
EXPECTED RESULTS
no tacacs-server deadtime 3
no tacacs-server host 192.168.1.99 key 7 "Test12345"
tacacs-server host 192.168.1.98 key 0 Test135 timeout 3
tacacs-server host 192.168.100.98 key 0 test135 timeout 3
ACTUAL RESULTS
tacacs-server host 192.168.1.98 key 0 Test135 timeout 3
tacacs-server host 192.168.100.98 key 0 test135 timeout 3

When I set host = Host(hostname='test', os='nxos') to host = Host(hostname='test', os='ios')

EXPECTED RESULTS
no tacacs-server deadtime 3
no tacacs-server host 192.168.1.99 key 7 "Test12345"
tacacs-server host 192.168.1.98 key 0 Test135 timeout 3
tacacs-server host 192.168.100.98 key 0 test135 timeout 3
ACTUAL RESULTS
no tacacs-server deadtime 3
no tacacs-server host 192.168.1.99 key 7 "Test12345"
tacacs-server host 192.168.1.98 key 0 Test135 timeout 3
tacacs-server host 192.168.100.98 key 0 test135 timeout 3
Zulzig commented 2 years ago

I don't know if it is best way to fixe it. Use uppercase instead of lowercase seems to be resolve the issue.