nornir-automation / nornir

Pluggable multi-threaded framework with inventory management to help operate collections of devices
https://nornir.readthedocs.io/
Apache License 2.0
1.4k stars 237 forks source link

Nornir write_file util not printing properly #620

Open hans-vvv opened 3 years ago

hans-vvv commented 3 years ago

Hi,

This is my first contribution on Github ever. Hopefully I didn't miss anything ;)

The write_file Nornir utility is not printing anything if default dry_run kwarg is not used when calling the function. In line 35 "None" is used as default, this evaluates in line 53 to "True". Changing line 35 to False resolves this issue.

Regards, Hans

https://github.com/nornir-automation/nornir_utils/blob/master/nornir_utils/plugins/tasks/files/write_file.py

hans-vvv commented 3 years ago

Sorry, to be more precise,

task.is_dry_run(dry_run) currently evaluates to True.

ktbyers commented 3 years ago

So you are saying task.is_dry_run(None) will evaluate to True?

Regards,

Kirk

On Sat, Dec 19, 2020 at 4:53 AM hans-vvv notifications@github.com wrote:

Sorry, to be more precise,

task.is_dry_run(dry_run) currently evaluates to True.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/nornir-automation/nornir/issues/620#issuecomment-748470695, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAG3VBALYOSIECPEQSQDSZDSVSO3RANCNFSM4VCIUTRQ .

-- Kirk Byers ktbyers@twb-tech.com ktbyers@twb-tech.com Simplify through Automation

ktbyers commented 3 years ago

Looking at the Nornir core code, if you don't pass any argument in then it looks like it uses self.global_dry_run which I assume will default to False (unless you are setting it somehow). Definite assumptions that I am making, however, as I only traced the source code so far.

Kirk

On Tue, Dec 22, 2020 at 9:43 AM Kirk Byers ktbyers@twb-tech.com wrote:

So you are saying task.is_dry_run(None) will evaluate to True?

Regards,

Kirk

On Sat, Dec 19, 2020 at 4:53 AM hans-vvv notifications@github.com wrote:

Sorry, to be more precise,

task.is_dry_run(dry_run) currently evaluates to True.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/nornir-automation/nornir/issues/620#issuecomment-748470695, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAG3VBALYOSIECPEQSQDSZDSVSO3RANCNFSM4VCIUTRQ .

-- Kirk Byers ktbyers@twb-tech.com ktbyers@twb-tech.com Simplify through Automation

-- Kirk Byers ktbyers@twb-tech.com ktbyers@twb-tech.com Simplify through Automation