From 062db03f99a8244b6c3878b6f5b750d3485538b8 Mon Sep 17 00:00:00 2001 From: Peter Sprygada Date: Mon, 4 Jul 2016 22:09:26 -0400 Subject: [PATCH] add get_config function to vyos shared module This adds a new shard function get_config to retrieve the device configuration either from module arguments or remotely from the device. --- lib/ansible/module_utils/vyos.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/ansible/module_utils/vyos.py b/lib/ansible/module_utils/vyos.py index 1ae74b0900e..5b8e11c5803 100644 --- a/lib/ansible/module_utils/vyos.py +++ b/lib/ansible/module_utils/vyos.py @@ -17,6 +17,7 @@ # along with Ansible. If not, see . # +import itertools import re from ansible.module_utils.network import NetworkError, get_module, get_exception @@ -34,7 +35,12 @@ def argument_spec(): ) vyos_argument_spec = argument_spec() -get_config = lambda x: x.params['config'] or x.config.get_config() +def get_config(module): + if module.params['config']: + return module.params['config'] + config = module.config.get_config() + module.params['config'] = config + return config def diff_config(candidate, config): updates = set() @@ -112,8 +118,7 @@ class Cli(NetCli): def run_commands(self, commands, **kwargs): commands = to_list(commands) - response = self.execute([str(c) for c in commands]) - return response + return self.execute([str(c) for c in commands]) ### Config methods ###