mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
Ansible 2.3 feature support for dellos9 and dellos10 (#22856)
* Ansible 2.3 feature support for dellos9 and dellos10 * Use Persistent Connection Manager * Fix CI issue, revert the doc and metadata changes * Reverted the meta_info (supported_by) to community from core * Fixed the CI issues, use module_utisl.six and updated legacy-files
This commit is contained in:
parent
f9b75d44e8
commit
dd63dfcf1e
17 changed files with 1083 additions and 416 deletions
|
@ -201,9 +201,12 @@ saved:
|
|||
sample: True
|
||||
|
||||
"""
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.netcfg import NetworkConfig, dumps
|
||||
from ansible.module_utils.network import NetworkModule
|
||||
from ansible.module_utils.dellos9 import get_config, get_sublevel_config
|
||||
from ansible.module_utils.dellos9 import dellos9_argument_spec, check_args
|
||||
from ansible.module_utils.dellos9 import load_config, run_commands
|
||||
from ansible.module_utils.dellos9 import WARNING_PROMPTS_RE
|
||||
|
||||
|
||||
def get_candidate(module):
|
||||
|
@ -237,10 +240,11 @@ def main():
|
|||
backup=dict(type='bool', default=False)
|
||||
)
|
||||
|
||||
argument_spec.update(dellos9_argument_spec)
|
||||
|
||||
mutually_exclusive = [('lines', 'src')]
|
||||
|
||||
module = NetworkModule(argument_spec=argument_spec,
|
||||
connect_on_load=False,
|
||||
module = AnsibleModule(argument_spec=argument_spec,
|
||||
mutually_exclusive=mutually_exclusive,
|
||||
supports_check_mode=True)
|
||||
|
||||
|
@ -248,7 +252,11 @@ def main():
|
|||
|
||||
match = module.params['match']
|
||||
replace = module.params['replace']
|
||||
result = dict(changed=False, saved=False)
|
||||
|
||||
warnings = list()
|
||||
check_args(module, warnings)
|
||||
|
||||
result = dict(changed=False, saved=False, warnings=warnings)
|
||||
|
||||
candidate = get_candidate(module)
|
||||
|
||||
|
@ -257,15 +265,18 @@ def main():
|
|||
if parents:
|
||||
contents = get_sublevel_config(config, module)
|
||||
config = NetworkConfig(contents=contents, indent=1)
|
||||
else:
|
||||
config = NetworkConfig(contents=config, indent=1)
|
||||
configobjs = candidate.difference(config, match=match, replace=replace)
|
||||
|
||||
else:
|
||||
configobjs = candidate.items
|
||||
|
||||
if module.params['backup']:
|
||||
result['__backup__'] = module.cli('show running-config')[0]
|
||||
result['__backup__'] = get_config(module)
|
||||
|
||||
commands = list()
|
||||
|
||||
if configobjs:
|
||||
commands = dumps(configobjs, 'commands')
|
||||
commands = commands.split('\n')
|
||||
|
@ -277,11 +288,11 @@ def main():
|
|||
commands.extend(module.params['after'])
|
||||
|
||||
if not module.check_mode and module.params['update'] == 'merge':
|
||||
response = module.config.load_config(commands)
|
||||
result['responses'] = response
|
||||
load_config(module, commands)
|
||||
|
||||
if module.params['save']:
|
||||
module.config.save_config()
|
||||
cmd = {'command': 'copy runing-config startup-config', 'prompt': WARNING_PROMPTS_RE, 'answer': 'yes'}
|
||||
run_commands(module, [cmd])
|
||||
result['saved'] = True
|
||||
|
||||
result['changed'] = True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue