Merge pull request #5 from dgarros/pyez

Add options to get_config to accept format (text, set or xml)
This commit is contained in:
Peter Sprygada 2016-04-24 07:43:21 -04:00 committed by Peter Sprygada
parent 2c90472609
commit 61baf41edc

View file

@ -249,9 +249,13 @@ class Netconf(object):
self.device.facts_refresh()
return self.device.facts
def get_config(self):
ele = self.rpc('get_configuration', format='text')
def get_config(self, config_format="text"):
ele = self.rpc('get_configuration', format=config_format)
if config_format == "text" or config_format == "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 +341,3 @@ def get_module(**kwargs):
module.connect()
return module