Merge pull request #17262 from privateip/iosxr
add commit keyword arg to load_config method
This commit is contained in:
commit
66825f094d
1 changed files with 12 additions and 9 deletions
|
@ -64,7 +64,7 @@ class Cli(CliBase):
|
||||||
responses = self.execute(cmds)
|
responses = self.execute(cmds)
|
||||||
return responses
|
return responses
|
||||||
|
|
||||||
### immplementation of netcfg.Config ###
|
### implementation of netcfg.Config ###
|
||||||
|
|
||||||
def configure(self, commands, **kwargs):
|
def configure(self, commands, **kwargs):
|
||||||
cmds = ['configure terminal']
|
cmds = ['configure terminal']
|
||||||
|
@ -81,7 +81,7 @@ class Cli(CliBase):
|
||||||
cmd += ' %s' % flags
|
cmd += ' %s' % flags
|
||||||
return self.execute([cmd])[0]
|
return self.execute([cmd])[0]
|
||||||
|
|
||||||
def load_config(self, config, replace=False, commit=False, **kwargs):
|
def load_config(self, config, commit=False, replace=False, comment=None):
|
||||||
commands = ['configure terminal']
|
commands = ['configure terminal']
|
||||||
commands.extend(config)
|
commands.extend(config)
|
||||||
|
|
||||||
|
@ -94,19 +94,22 @@ class Cli(CliBase):
|
||||||
if commit:
|
if commit:
|
||||||
if replace:
|
if replace:
|
||||||
prompt = re.compile(r'\[no\]:\s$')
|
prompt = re.compile(r'\[no\]:\s$')
|
||||||
cmd = Command('commit replace', prompt=prompt,
|
commit = 'commit replace'
|
||||||
response='yes')
|
if comment:
|
||||||
|
commit += ' comment %s' % comment
|
||||||
|
cmd = Command(commit, prompt=prompt, response='yes')
|
||||||
self.execute([cmd, 'end'])
|
self.execute([cmd, 'end'])
|
||||||
else:
|
else:
|
||||||
self.execute(['commit', 'end'])
|
commit = 'commit'
|
||||||
|
if comment:
|
||||||
|
commit += ' comment %s' % comment
|
||||||
|
self.execute([commit, 'end'])
|
||||||
|
else:
|
||||||
|
self.execute(['abort'])
|
||||||
except NetworkError:
|
except NetworkError:
|
||||||
self.execute(['abort'])
|
self.execute(['abort'])
|
||||||
diff = None
|
diff = None
|
||||||
raise
|
raise
|
||||||
return diff[0]
|
return diff[0]
|
||||||
|
|
||||||
def save_config(self):
|
|
||||||
raise NotImplementedError
|
|
||||||
|
|
||||||
|
|
||||||
Cli = register_transport('cli', default=True)(Cli)
|
Cli = register_transport('cli', default=True)(Cli)
|
||||||
|
|
Loading…
Reference in a new issue