def to_commands(module, commands): if not isinstance(commands, list): raise AssertionError('argument must be of type <list>') transform = EntityCollection(module, _COMMAND_SPEC) commands = transform(commands) return commands
def run_commands(module, commands, check_rc=True): connection = get_connection(module) transform = EntityCollection(module, command_spec) commands = transform(commands) responses = list() for cmd in commands: out = connection.get(**cmd) responses.append(to_text(out, errors='surrogate_then_replace')) return responses
def to_commands(module, commands): if not isinstance(commands, list): raise AssertionError('argument must be of type <list>') transform = EntityCollection(module, command_spec) commands = transform(commands) for index, item in enumerate(commands): if module.check_mode and not item['command'].startswith('show'): module.warn('only show commands are supported when using check ' 'mode, not executing `%s`' % item['command']) return commands