napalm-automation / napalm

Network Automation and Programmability Abstraction Layer with Multivendor support
Apache License 2.0
2.26k stars 554 forks source link

Junos, configurations fails when there are no changes #1469

Open somebody78 opened 3 years ago

somebody78 commented 3 years ago

Description of Issue/Question

Hello,

I stumbled upon an issue and hope you can help me. I have a process where a configuration is either written to or deleted from a Juniper firewall using Nornir with Napalm. For a delete process it can happen that the config doesn't exist to begin with and there is no configuration change. After updating the Juniper firewall to version 18.4 this throws an exception, details at the bottom.

I found a note on the Juniper website saying that the behavior of the RPC reply changed starting from version 16.2 and I guess this is the root cause. However, I don't know how to fix that. I'd appreciate if you could take a look. Juniper Website

NOTE: Starting in Junos OS Release 16.2R2, when you compare the candidate and active configurations and display the differences in XML or JSON format, the device omits the <configuration> tag in the XML output and omits the configuration object in the JSON output if the comparison either returns no differences or if the comparison returns differences for only non-native configuration data, for example, configuration data associated with an OpenConfig data model.

Thanks Dirk

Did you follow the steps from https://github.com/napalm-automation/napalm#faq

(Place an x between the square brackets where applicable)

Setup

napalm version

(Paste verbatim output from pip freeze | grep napalm between quotes below)

napalm==3.2.0
nornir-napalm==0.1.1

Network operating system version

(Paste verbatim output from show version - or equivalent - between quotes below)

Model: srx1500
Junos: 18.4R3-S6.3

Steps to Reproduce the Issue

Apply a configuration to delete an object that doesn't exist using dry-run mode, e.g.

delete interfaces reth1 unit 499

Error Traceback

(Paste the complete traceback of the exception between quotes below)

Traceback (most recent call last):
  File "/home/users/nornir-user/nornir-3.0.0/nornir-venv/lib64/python3.6/site-packages/nornir/core/task.py", line 98, in start
    r = self.task(self, **self.params)
  File "/home/users/nornir-user/nornir-3.0.0/nornir-venv/lib64/python3.6/site-packages/nornir_napalm/plugins/tasks/napalm_configure.py", line 35, in napalm_configure
    diff = device.compare_config()
  File "/home/users/nornir-user/nornir-3.0.0/nornir-venv/lib64/python3.6/site-packages/napalm/junos/junos.py", line 273, in compare_config
    diff = self.device.cu.diff()
  File "/home/users/nornir-user/nornir-3.0.0/nornir-venv/lib64/python3.6/site-packages/jnpr/junos/utils/config.py", line 263, in diff
    diff_txt = rsp.find("configuration-output").text
AttributeError: 'bool' object has no attribute 'find'
mirceaulinic commented 3 years ago

Hi Dirk, that error message 'bool' object has no attribute 'find' is somewhat familiar to me, I think I've seen it myself too a couple of times - but didn't dig into it yet, as it seems to be raised extremely rarely. Do you see it every time you run, or very often? Regardless on the frequency, it must be investigated, but I'm just curious... Regarding the note you shared, I would imagine that modern junos-eznc releases would be updated to cope with that change. Does it still happen with napalm 3.3.1 and junos-eznc 2.6.1 ? Let me know.

somebody78 commented 3 years ago

Hi Mircea, Thanks for the quick reply. I see this happen everytime in this specific scenario, when I'm using a new configuration that doesn't really change the active config. I did the same test with newer versions for Napalm, junos-eznc and Nornir but unfortunately with the same result. Any help appreciated.

Dirk

hhopjh commented 3 years ago

I've got the same issue on JUNOS 18.4R3-S5.4

nornir-napalm         0.1.2
napalm                3.3.1
junos-eznc            2.6.2

I've also checked on JUNOS 19.4R3.11 - the issue isn't present.