fixes ios_facts that was returning no values (#21357)

* adds conversion to command dict into ios shared lib
* fixes hardware commands in ios_facts
* adds network_os value to play_context in ios action plugin

fixes #21190
pull/21387/head
Peter Sprygada 8 years ago committed by GitHub
parent bf836850a4
commit 9937e604f5

@ -26,7 +26,7 @@
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
from ansible.module_utils.basic import env_fallback
from ansible.module_utils.network_common import to_list
from ansible.module_utils.network_common import to_list, ComplexList
from ansible.module_utils.connection import exec_command
_DEVICE_CONFIGS = {}
@ -65,9 +65,19 @@ def get_config(module, flags=[]):
_DEVICE_CONFIGS[cmd] = cfg
return cfg
def to_commands(commands):
transform = ComplexList(dict(
command=dict(key=True),
prompt=dict(),
response=dict()
))
return transform(commands)
def run_commands(module, commands, check_rc=True):
responses = list()
for cmd in to_list(commands):
commands = to_commands(to_list(commands))
for cmd in commands:
cmd = module.jsonify(cmd)
rc, out, err = exec_command(module, cmd)
if check_rc and rc != 0:

@ -208,8 +208,8 @@ class Default(FactsBase):
class Hardware(FactsBase):
COMMANDS = [
'dir | include Directory',
'show memory statistics | include Processor'
'dir',
'show memory statistics'
]
def populate(self):

@ -41,7 +41,8 @@ class ActionModule(_ActionModule):
pc = copy.deepcopy(self._play_context)
pc.connection = 'network_cli'
pc.port = provider['port'] or self._play_context.port
pc.network_os = 'ios'
pc.port = provider['port'] or self._play_context.port or 22
pc.remote_user = provider['username'] or self._play_context.connection_user
pc.password = provider['password'] or self._play_context.password
pc.become = provider['authorize'] or False

Loading…
Cancel
Save