roll up of fixes and updates for junos modules (#22543)

* removes cli functions
* adds comment and confirm to arguments
* implements zeroize argument
* fixes get_diff function in junos shared lib to return diff
* lots of minor bug fixes in junos_config
* minor syntax fixes in junos_netconf
* updates netconf integration tests
This commit is contained in:
Peter Sprygada 2017-03-12 11:45:00 -05:00 committed by GitHub
commit 2b2072a8c9
6 changed files with 86 additions and 92 deletions

View file

@ -80,6 +80,7 @@ import re
from ansible.module_utils.junos import junos_argument_spec, check_args
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.connection import exec_command
from ansible.module_utils.network_common import to_list
from ansible.module_utils.six import iteritems
USE_PERSISTENT_CONNECTION = True
@ -97,10 +98,11 @@ def map_obj_to_commands(updates, module):
elif want['state'] == 'absent' and have['state'] == 'present':
commands.append('delete system services netconf')
elif want['netconf_port'] != have.get('netconf_port'):
commands.append(
'set system services netconf ssh port %s' % want['netconf_port']
)
elif want['state'] == 'present':
if want['netconf_port'] != have.get('netconf_port'):
commands.append(
'set system services netconf ssh port %s' % want['netconf_port']
)
return commands
@ -110,7 +112,12 @@ def parse_port(config):
return int(match.group(1))
def map_config_to_obj(module):
config = get_config(module, ['system services netconf'])
cmd = 'show configuration system services netconf'
rc, out, err = exec_command(module, cmd)
if rc != 0:
module.fail_json(msg='unable to retrieve current config', stderr=err)
config = str(out).strip()
obj = {'state': 'absent'}
if config:
obj.update({
@ -138,12 +145,6 @@ def map_params_to_obj(module):
return obj
def get_config(module, flags=[]):
rc, out, err = exec_command(module, cmd)
if rc != 0:
module.fail_json(msg='unable to retrieve current config', stderr=err)
return str(out).strip()
def load_config(module, config, commit=False):
exec_command(module, 'configure')