summaryrefslogtreecommitdiff
path: root/lib/ansible/modules/network/dellos9/dellos9_config.py
diff options
context:
space:
mode:
authorSenthil Kumar Ganesan <skg.net.dev@gmail.com>2017-03-27 11:32:57 -0700
committerJohn R Barker <john@johnrbarker.com>2017-03-27 19:32:57 +0100
commitdd63dfcf1ec50bade4eaf8925330d7c96e475cc5 (patch)
tree22cd8095ae65744bf8ef4db11f6b42f5c4b96a82 /lib/ansible/modules/network/dellos9/dellos9_config.py
parentf9b75d44e8718830e3e641f7b4f7a0ffa4c9f324 (diff)
downloadansible-dd63dfcf1ec50bade4eaf8925330d7c96e475cc5.tar.gz
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
Diffstat (limited to 'lib/ansible/modules/network/dellos9/dellos9_config.py')
-rw-r--r--lib/ansible/modules/network/dellos9/dellos9_config.py27
1 files changed, 19 insertions, 8 deletions
diff --git a/lib/ansible/modules/network/dellos9/dellos9_config.py b/lib/ansible/modules/network/dellos9/dellos9_config.py
index 95d68a0705..6820d7c7fb 100644
--- a/lib/ansible/modules/network/dellos9/dellos9_config.py
+++ b/lib/ansible/modules/network/dellos9/dellos9_config.py
@@ -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