* Check for provider values inside check_args of respective network code

* Partial revert of b9ee5aa

The no_log change is okay, but take out the action result munging
This commit is contained in:
Nathaniel Case 2017-04-07 19:22:17 -04:00 committed by GitHub
parent 6314169afd
commit 86c714548f
20 changed files with 60 additions and 72 deletions

View file

@ -31,7 +31,7 @@
#
import re
from ansible.module_utils.basic import env_fallback
from ansible.module_utils.basic import env_fallback, return_values
from ansible.module_utils.network_common import to_list, ComplexList
from ansible.module_utils.connection import exec_command
from ansible.module_utils.netcfg import NetworkConfig,ConfigLine
@ -63,6 +63,11 @@ def check_args(module, warnings):
warnings.append('argument %s has been deprecated and will be '
'removed in a future version' % key)
if provider:
for param in ('auth_pass', 'password'):
if provider.get(param):
module.no_log_values.update(return_values(provider[param]))
def get_config(module, flags=[]):
cmd = 'show running-config '

View file

@ -30,7 +30,7 @@
#
import re
from ansible.module_utils.basic import env_fallback
from ansible.module_utils.basic import env_fallback, return_values
from ansible.module_utils.network_common import to_list, ComplexList
from ansible.module_utils.connection import exec_command
from ansible.module_utils.netcfg import NetworkConfig, ConfigLine, ignore_line, DEFAULT_COMMENT_TOKENS
@ -63,6 +63,11 @@ def check_args(module, warnings):
warnings.append('argument %s has been deprecated and will be '
'removed in a future version' % key)
if provider:
for param in ('auth_pass', 'password'):
if provider.get(param):
module.no_log_values.update(return_values(provider[param]))
def get_config(module, flags=[]):
cmd = 'show running-config '

View file

@ -31,7 +31,7 @@
#
import re
from ansible.module_utils.basic import env_fallback
from ansible.module_utils.basic import env_fallback, return_values
from ansible.module_utils.network_common import to_list, ComplexList
from ansible.module_utils.connection import exec_command
from ansible.module_utils.netcfg import NetworkConfig,ConfigLine
@ -63,6 +63,11 @@ def check_args(module, warnings):
warnings.append('argument %s has been deprecated and will be '
'removed in a future version' % key)
if provider:
for param in ('auth_pass', 'password'):
if provider.get(param):
module.no_log_values.update(return_values(provider[param]))
def get_config(module, flags=[]):
cmd = 'show running-config '

View file

@ -30,7 +30,7 @@
import os
import time
from ansible.module_utils.basic import env_fallback
from ansible.module_utils.basic import env_fallback, return_values
from ansible.module_utils.connection import exec_command
from ansible.module_utils.network_common import to_list, ComplexList
from ansible.module_utils.six import iteritems
@ -64,6 +64,11 @@ def check_args(module, warnings):
warnings.append('argument %s has been deprecated and will be '
'removed in a future version' % key)
if provider:
for param in ('auth_pass', 'password'):
if provider.get(param):
module.no_log_values.update(return_values(provider[param]))
def load_params(module):
provider = module.params.get('provider') or dict()
for key, value in iteritems(provider):

View file

@ -25,7 +25,7 @@
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# 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.basic import env_fallback, return_values
from ansible.module_utils.network_common import to_list, ComplexList
from ansible.module_utils.connection import exec_command
@ -50,6 +50,11 @@ def check_args(module, warnings):
warnings.append('argument %s has been deprecated and will be '
'removed in a future version' % key)
if provider:
for param in ('auth_pass', 'password'):
if provider.get(param):
module.no_log_values.update(return_values(provider[param]))
def get_defaults_flag(module):
rc, out, err = exec_command(module, 'show running-config ?')

View file

@ -26,7 +26,7 @@
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# 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.basic import env_fallback, return_values
from ansible.module_utils.network_common import to_list, ComplexList
from ansible.module_utils.connection import exec_command
@ -49,6 +49,11 @@ def check_args(module, warnings):
warnings.append('argument %s has been deprecated and will be '
'removed in a future version' % key)
if provider:
for param in ('password',):
if provider.get(param):
module.no_log_values.update(return_values(provider[param]))
def get_config(module, flags=[]):
cmd = 'show running-config '
cmd += ' '.join(flags)

View file

@ -20,7 +20,7 @@ from contextlib import contextmanager
from xml.etree.ElementTree import Element, SubElement
from ansible.module_utils.basic import env_fallback
from ansible.module_utils.basic import env_fallback, return_values
from ansible.module_utils.netconf import send_request, children
from ansible.module_utils.netconf import discard_changes, validate
from ansible.module_utils.six import string_types
@ -48,6 +48,11 @@ def check_args(module, warnings):
warnings.append('argument %s has been deprecated and will be '
'removed in a future version' % key)
if provider:
for param in ('password',):
if provider.get(param):
module.no_log_values.update(return_values(provider[param]))
def _validate_rollback_id(module, value):
try:
if not 0 <= int(value) <= 49:

View file

@ -30,7 +30,7 @@
import re
import collections
from ansible.module_utils.basic import env_fallback
from ansible.module_utils.basic import env_fallback, return_values
from ansible.module_utils.network_common import to_list, ComplexList
from ansible.module_utils.connection import exec_command
from ansible.module_utils.six import iteritems
@ -61,6 +61,11 @@ def check_args(module, warnings):
warnings.append('argument %s has been deprecated and will be '
'removed in a future version' % key)
if provider:
for param in ('password',):
if provider.get(param):
module.no_log_values.update(return_values(provider[param]))
def load_params(module):
provider = module.params.get('provider') or dict()
for key, value in iteritems(provider):

View file

@ -28,7 +28,7 @@
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# 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.basic import env_fallback, return_values
from ansible.module_utils.network_common import to_list, ComplexList
from ansible.module_utils.connection import exec_command
@ -51,6 +51,11 @@ def check_args(module, warnings):
warnings.append('argument %s has been deprecated and will be '
'removed in a future version' % key)
if provider:
for param in ('password',):
if provider.get(param):
module.no_log_values.update(return_values(provider[param]))
def get_config(module, flags=[]):
cmd = 'admin display-config '
cmd += ' '.join(flags)

View file

@ -25,7 +25,7 @@
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# 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.basic import env_fallback, return_values
from ansible.module_utils.network_common import to_list
from ansible.module_utils.connection import exec_command
@ -50,6 +50,11 @@ def check_args(module, warnings):
warnings.append('argument %s has been deprecated and will be '
'removed in a future version' % key)
if provider:
for param in ('password',):
if provider.get(param):
module.no_log_values.update(return_values(provider[param]))
def get_config(module, target='commands'):
cmd = ' '.join(['show configuration', target])

View file

@ -93,12 +93,6 @@ class ActionModule(_ActionModule):
self._play_context.become_method = None
result = super(ActionModule, self).run(tmp, task_vars)
try:
del result['invocation']['module_args']['provider']
except KeyError:
pass
return result
def _get_socket_path(self, play_context):

View file

@ -89,12 +89,6 @@ class ActionModule(_ActionModule):
self._play_context.become_method = None
result = super(ActionModule, self).run(tmp, task_vars)
try:
del result['invocation']['module_args']['provider']
except KeyError:
pass
return result
def _get_socket_path(self, play_context):

View file

@ -93,12 +93,6 @@ class ActionModule(_ActionModule):
self._play_context.become_method = None
result = super(ActionModule, self).run(tmp, task_vars)
try:
del result['invocation']['module_args']['provider']
except KeyError:
pass
return result
def _get_socket_path(self, play_context):

View file

@ -118,12 +118,6 @@ class ActionModule(_ActionModule):
self._task.args['provider'] = provider
result = super(ActionModule, self).run(tmp, task_vars)
try:
del result['invocation']['module_args']['provider']
except KeyError:
pass
return result
def _get_socket_path(self, play_context):

View file

@ -88,12 +88,6 @@ class ActionModule(_ActionModule):
self._play_context.become_method = None
result = super(ActionModule, self).run(tmp, task_vars)
try:
del result['invocation']['module_args']['provider']
except KeyError:
pass
return result
def _get_socket_path(self, play_context):

View file

@ -83,12 +83,6 @@ class ActionModule(_ActionModule):
task_vars['ansible_socket'] = socket_path
result = super(ActionModule, self).run(tmp, task_vars)
try:
del result['invocation']['module_args']['provider']
except KeyError:
pass
return result
def _get_socket_path(self, play_context):

View file

@ -103,12 +103,6 @@ class ActionModule(_ActionModule):
task_vars['ansible_socket'] = socket_path
result = super(ActionModule, self).run(tmp, task_vars)
try:
del result['invocation']['module_args']['provider']
except KeyError:
pass
return result
def _get_socket_path(self, play_context):

View file

@ -120,12 +120,6 @@ class ActionModule(_ActionModule):
self._task.args['transport'] = transport
result = super(ActionModule, self).run(tmp, task_vars)
try:
del result['invocation']['module_args']['provider']
except KeyError:
pass
return result
def _get_socket_path(self, play_context):
@ -160,5 +154,3 @@ class ActionModule(_ActionModule):
return strategy(*args, **kwargs)
except AnsibleFallbackNotFound:
pass

View file

@ -79,12 +79,6 @@ class ActionModule(_ActionModule):
task_vars['ansible_socket'] = socket_path
result = super(ActionModule, self).run(tmp, task_vars)
try:
del result['invocation']['module_args']['provider']
except KeyError:
pass
return result
def _get_socket_path(self, play_context):

View file

@ -81,12 +81,6 @@ class ActionModule(_ActionModule):
task_vars['ansible_socket'] = socket_path
result = super(ActionModule, self).run(tmp, task_vars)
try:
del result['invocation']['module_args']['provider']
except KeyError:
pass
return result
def _get_socket_path(self, play_context):