1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Merge pull request #17386 from privateip/netcli

clean up method signatures in netcli
This commit is contained in:
Peter Sprygada 2016-09-04 09:21:17 -04:00 committed by GitHub
commit 1b1c1fe992

View file

@ -69,7 +69,7 @@ class Cli(object):
objects.append(self.to_command(cmd, output)) objects.append(self.to_command(cmd, output))
return self.connection.run_commands(objects) return self.connection.run_commands(objects)
def to_command(self, command, output=None, prompt=None, response=None): def to_command(self, command, output=None, prompt=None, response=None, **kwargs):
output = output or self.default_output output = output or self.default_output
if isinstance(command, Command): if isinstance(command, Command):
return command return command
@ -78,7 +78,7 @@ class Cli(object):
cmd = cmd['command'] cmd = cmd['command']
if isinstance(prompt, string_types): if isinstance(prompt, string_types):
prompt = re.compile(re.escape(prompt)) prompt = re.compile(re.escape(prompt))
return Command(command, output, prompt=prompt, response=response) return Command(command, output, prompt=prompt, response=response, **kwargs)
def add_commands(self, commands, output=None, **kwargs): def add_commands(self, commands, output=None, **kwargs):
for cmd in commands: for cmd in commands:
@ -97,8 +97,8 @@ class Cli(object):
class Command(object): class Command(object):
def __init__(self, command, output=None, prompt=None, is_reboot=False, def __init__(self, command, output=None, prompt=None, response=None,
response=None, delay=0): **kwargs):
self.command = command self.command = command
self.output = output self.output = output
@ -107,8 +107,7 @@ class Command(object):
self.prompt = prompt self.prompt = prompt
self.response = response self.response = response
self.is_reboot = is_reboot self.args = kwargs
self.delay = delay
def __str__(self): def __str__(self):
return self.command_string return self.command_string
@ -132,11 +131,12 @@ class CommandRunner(object):
self._default_output = module.connection.default_output self._default_output = module.connection.default_output
def add_command(self, command, output=None, prompt=None, response=None): def add_command(self, command, output=None, prompt=None, response=None,
**kwargs):
if command in [str(c) for c in self.commands]: if command in [str(c) for c in self.commands]:
raise AddCommandError('duplicated command detected', command=command) raise AddCommandError('duplicated command detected', command=command)
cmd = self.module.cli.to_command(command, output=output, prompt=prompt, cmd = self.module.cli.to_command(command, output=output, prompt=prompt,
response=response) response=response, **kwargs)
self.commands.append(cmd) self.commands.append(cmd)
def get_command(self, command, output=None): def get_command(self, command, output=None):