Merge pull request #15566 from privateip/junos

adds config_format to junos shared module
This commit is contained in:
Peter Sprygada 2016-04-24 08:57:08 -04:00
commit cea6d858bc

View file

@ -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