mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
adds check on config_format kwarg in junos
This adds a check to validate the arugment for config_format kwarg in get_config. If the specified format is not a valid option, the shared module will call fail_json
This commit is contained in:
parent
61baf41edc
commit
c87300f9e7
1 changed files with 5 additions and 2 deletions
|
@ -250,9 +250,12 @@ class Netconf(object):
|
|||
return self.device.facts
|
||||
|
||||
def get_config(self, config_format="text"):
|
||||
ele = self.rpc('get_configuration', format=config_format)
|
||||
if config_format not in ['text', 'set', 'xml']:
|
||||
msg = 'invalid config format... must be one of xml, text, set'
|
||||
self._fail(msg=msg)
|
||||
|
||||
if config_format == "text" or config_format == "set":
|
||||
ele = self.rpc('get_configuration', format=config_format)
|
||||
if config_format in ['text', 'set']:
|
||||
return str(ele.text).strip()
|
||||
elif config_format == "xml":
|
||||
return ele
|
||||
|
|
Loading…
Reference in a new issue