mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
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.
This commit is contained in:
parent
54db1df244
commit
062db03f99
1 changed files with 8 additions and 3 deletions
|
@ -17,6 +17,7 @@
|
|||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
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 ###
|
||||
|
||||
|
|
Loading…
Reference in a new issue