From dc42b43cd1ed019a847add4b6ce35eab1a40413d Mon Sep 17 00:00:00 2001 From: Barry Peddycord III Date: Fri, 20 Jul 2018 11:38:29 -0400 Subject: [PATCH] NCLU Module: Improve performance by not operating on empty lines (#43024) * Update nclu.py Stop module from running `net` on empty commands. * Update nclu.py Updated the copyright date * Update nclu.py Returned metadata version to 1.1 * Update nclu.py Fix indentation to be a multiple of 4. * Create changelog fragment --- changelogs/fragments/43024-nclu-empty-net-commands.yaml | 2 ++ lib/ansible/modules/network/cumulus/nclu.py | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/43024-nclu-empty-net-commands.yaml diff --git a/changelogs/fragments/43024-nclu-empty-net-commands.yaml b/changelogs/fragments/43024-nclu-empty-net-commands.yaml new file mode 100644 index 00000000000..50a95620be6 --- /dev/null +++ b/changelogs/fragments/43024-nclu-empty-net-commands.yaml @@ -0,0 +1,2 @@ +bugfixes: +- nclu - no longer runs net on empty lines in templates (https://github.com/ansible/ansible/pull/43024) diff --git a/lib/ansible/modules/network/cumulus/nclu.py b/lib/ansible/modules/network/cumulus/nclu.py index 764e9b2435f..0aa5f0d92c4 100644 --- a/lib/ansible/modules/network/cumulus/nclu.py +++ b/lib/ansible/modules/network/cumulus/nclu.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# (c) 2016-2017, Cumulus Networks +# (c) 2016-2018, Cumulus Networks # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function @@ -185,7 +185,8 @@ def run_nclu(module, command_list, command_string, commit, atomic, abort, descri # Run all of the net commands output_lines = [] for line in commands: - output_lines += [command_helper(module, line.strip(), "Failed on line %s" % line)] + if line.strip(): + output_lines += [command_helper(module, line.strip(), "Failed on line %s" % line)] output = "\n".join(output_lines) # If pending changes changed, report a change.