mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #16572 from privateip/netcmd
adds new method to return specific response from command to netcmd
This commit is contained in:
commit
d9546d6367
1 changed files with 14 additions and 0 deletions
|
@ -163,9 +163,23 @@ class CommandRunner(object):
|
|||
self.retries = 10
|
||||
self.interval = 1
|
||||
|
||||
self._cache = dict()
|
||||
|
||||
def add_command(self, command, output=None):
|
||||
self.module.cli.add_commands(command, output=output)
|
||||
|
||||
def get_command(self, command):
|
||||
try:
|
||||
cmdobj = self._cache[command]
|
||||
return cmdobj.response
|
||||
except KeyError:
|
||||
for cmd in self.module.cli.commands:
|
||||
if str(cmd) == command:
|
||||
self._cache[command] = cmd
|
||||
return cmd.response
|
||||
raise ValueError("command '%s' not found" % command)
|
||||
|
||||
|
||||
def add_conditional(self, condition):
|
||||
self.conditionals.add(Conditional(condition))
|
||||
|
||||
|
|
Loading…
Reference in a new issue