Refactor IOS libs to use cliconf (#34136)

* Refactor IOS libs to use cliconf

* Fix pep8

* Remove bytstrings from edit_config and additional end on load_config

* Fix pep8
This commit is contained in:
Ricardo Carrillo Cruz 2018-01-11 11:50:01 +01:00 committed by GitHub
parent 2b3b689616
commit 477cd3f775
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 70 additions and 39 deletions

View file

@ -65,10 +65,21 @@ class Cliconf(CliconfBase):
@enable_mode
def edit_config(self, command):
for cmd in chain(['configure terminal'], to_list(command), ['end']):
self.send_command(to_bytes(cmd))
try:
cmd = json.loads(cmd)
command = cmd['command']
prompt = cmd['prompt']
answer = cmd['answer']
except:
command = cmd
prompt = None
answer = None
self.send_command(to_bytes(command), to_bytes(prompt), to_bytes(answer))
def get(self, command, prompt=None, answer=None, sendonly=False):
return self.send_command(command, prompt=prompt, answer=answer, sendonly=sendonly)
return self.send_command(to_bytes(command), prompt=to_bytes(prompt),
answer=to_bytes(answer), sendonly=sendonly)
def get_capabilities(self):
result = {}