Skip to content

Commit

Permalink
Merge pull request #17386 from privateip/netcli
Browse files Browse the repository at this point in the history
clean up method signatures in netcli
  • Loading branch information
privateip committed Sep 4, 2016
2 parents 5859d35 + a839acf commit 1b1c1fe
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/ansible/module_utils/netcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def __call__(self, commands, output=None):
objects.append(self.to_command(cmd, output))
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
if isinstance(command, Command):
return command
Expand All @@ -78,7 +78,7 @@ def to_command(self, command, output=None, prompt=None, response=None):
cmd = cmd['command']
if isinstance(prompt, string_types):
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):
for cmd in commands:
Expand All @@ -97,8 +97,8 @@ def run_commands(self):

class Command(object):

def __init__(self, command, output=None, prompt=None, is_reboot=False,
response=None, delay=0):
def __init__(self, command, output=None, prompt=None, response=None,
**kwargs):

self.command = command
self.output = output
Expand All @@ -107,8 +107,7 @@ def __init__(self, command, output=None, prompt=None, is_reboot=False,
self.prompt = prompt
self.response = response

self.is_reboot = is_reboot
self.delay = delay
self.args = kwargs

def __str__(self):
return self.command_string
Expand All @@ -132,11 +131,12 @@ def __init__(self, module):
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]:
raise AddCommandError('duplicated command detected', command=command)
cmd = self.module.cli.to_command(command, output=output, prompt=prompt,
response=response)
response=response, **kwargs)
self.commands.append(cmd)

def get_command(self, command, output=None):
Expand Down

0 comments on commit 1b1c1fe

Please sign in to comment.