mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #15566 from privateip/junos
adds config_format to junos shared module
This commit is contained in:
commit
cea6d858bc
1 changed files with 10 additions and 4 deletions
|
@ -249,9 +249,16 @@ class Netconf(object):
|
|||
self.device.facts_refresh()
|
||||
return self.device.facts
|
||||
|
||||
def get_config(self):
|
||||
ele = self.rpc('get_configuration', format='text')
|
||||
return str(ele.text).strip()
|
||||
def get_config(self, config_format="text"):
|
||||
if config_format not in ['text', 'set', 'xml']:
|
||||
msg = 'invalid config format... must be one of xml, text, set'
|
||||
self._fail(msg=msg)
|
||||
|
||||
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
|
||||
|
||||
def rpc(self, name, format='xml', **kwargs):
|
||||
meth = getattr(self.device.rpc, name)
|
||||
|
@ -337,4 +344,3 @@ def get_module(**kwargs):
|
|||
|
||||
module.connect()
|
||||
return module
|
||||
|
||||
|
|
Loading…
Reference in a new issue