mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-02 14:40:19 -07:00
Network module code cleanup (#5061)
* Fix imports in junos_template * Python 3 compatibility in eos_command * Python 3 compatibility for ios_command * Clean up issues with ios_facts * Python 3 compatibility for ios_facts * Import shuffle in ios_template * Python 3 compatibility for iosxr_command * Clean up iosxr_facts.py * Python 3 compatibility for iosxr_facts * Python 3 compatibility for junos_command * Python 3 compatibility for ops_command * Cleanup issues with ops_facts * Python 3 compatibility for ops_facts * Cleanup issues with ops_template * Python 3 compatibility for vyos_command * Cleanup issues with vyos_facts * Python 3 compatibility for vyos_facts
This commit is contained in:
parent
6ae0342a0a
commit
aa82f48dc8
12 changed files with 74 additions and 48 deletions
|
@ -100,8 +100,11 @@ ansible_net_gather_subset:
|
|||
"""
|
||||
import re
|
||||
|
||||
from ansible.module_utils.netcmd import CommandRunner
|
||||
from ansible.module_utils.vyos import NetworkModule
|
||||
import ansible.module_utils.vyos
|
||||
from ansible.module_utils.pycompat24 import get_exception
|
||||
from ansible.module_utils.netcli import CommandRunner
|
||||
from ansible.module_utils.network import NetworkModule
|
||||
from ansible.module_utils.six import iteritems
|
||||
|
||||
|
||||
class FactsBase(object):
|
||||
|
@ -112,6 +115,9 @@ class FactsBase(object):
|
|||
|
||||
self.commands()
|
||||
|
||||
def commands(self):
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class Default(FactsBase):
|
||||
|
||||
|
@ -160,7 +166,7 @@ class Config(FactsBase):
|
|||
entry = None
|
||||
|
||||
for line in commits.split('\n'):
|
||||
match = re.match('(\d+)\s+(.+)by(.+)via(.+)', line)
|
||||
match = re.match(r'(\d+)\s+(.+)by(.+)via(.+)', line)
|
||||
if match:
|
||||
if entry:
|
||||
entries.append(entry)
|
||||
|
@ -288,7 +294,7 @@ def main():
|
|||
for key in runable_subsets:
|
||||
instances.append(FACT_SUBSETS[key](runner))
|
||||
|
||||
runner.run_commands()
|
||||
runner.run()
|
||||
|
||||
try:
|
||||
for inst in instances:
|
||||
|
@ -299,7 +305,7 @@ def main():
|
|||
module.fail_json(msg='unknown failure', output=runner.items, exc=str(exc))
|
||||
|
||||
ansible_facts = dict()
|
||||
for key, value in facts.iteritems():
|
||||
for key, value in iteritems(facts):
|
||||
key = 'ansible_net_%s' % key
|
||||
ansible_facts[key] = value
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue