Merge pull request #5 from dgarros/pyez
Add options to get_config to accept format (text, set or xml)
This commit is contained in:
parent
2c90472609
commit
61baf41edc
1 changed files with 7 additions and 4 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue