From 77e3dc9e6a916c39f65a3d56b8a57771e295f3fd Mon Sep 17 00:00:00 2001 From: Nathaniel Case Date: Wed, 6 Apr 2016 14:54:47 -0400 Subject: [PATCH] Fix network modules for ziploader changes --- lib/ansible/module_utils/eos.py | 13 ++++++------- lib/ansible/module_utils/ios.py | 8 ++++---- lib/ansible/module_utils/iosxr.py | 8 ++++---- lib/ansible/module_utils/junos.py | 8 ++++---- lib/ansible/module_utils/nxos.py | 9 ++++----- lib/ansible/module_utils/openswitch.py | 8 ++++---- 6 files changed, 26 insertions(+), 28 deletions(-) diff --git a/lib/ansible/module_utils/eos.py b/lib/ansible/module_utils/eos.py index 5d067b9ee10..33597a782c7 100644 --- a/lib/ansible/module_utils/eos.py +++ b/lib/ansible/module_utils/eos.py @@ -194,16 +194,15 @@ class NetworkModule(AnsibleModule): return self._config def _load_params(self): - params = super(NetworkModule, self)._load_params() - provider = params.get('provider') or dict() + super(NetworkModule, self)._load_params() + provider = self.params.get('provider') or dict() for key, value in provider.items(): if key in NET_COMMON_ARGS: - if params.get(key) is None and value is not None: - params[key] = value + if self.params.get(key) is None and value is not None: + self.params[key] = value for key, env_var in NET_ENV_ARGS.items(): - if params.get(key) is None and env_var in os.environ: - params[key] = os.environ[env_var] - return params + if self.params.get(key) is None and env_var in os.environ: + self.params[key] = os.environ[env_var] def connect(self): try: diff --git a/lib/ansible/module_utils/ios.py b/lib/ansible/module_utils/ios.py index a8a6345d589..acb2b352a5c 100644 --- a/lib/ansible/module_utils/ios.py +++ b/lib/ansible/module_utils/ios.py @@ -109,12 +109,12 @@ class NetworkModule(AnsibleModule): return self._config def _load_params(self): - params = super(NetworkModule, self)._load_params() - provider = params.get('provider') or dict() + super(NetworkModule, self)._load_params() + provider = self.params.get('provider') or dict() for key, value in provider.items(): if key in NET_COMMON_ARGS.keys(): - params[key] = value - return params + if self.params.get(key) is None and value is not None: + self.params[key] = value def connect(self): try: diff --git a/lib/ansible/module_utils/iosxr.py b/lib/ansible/module_utils/iosxr.py index 76c644f7834..94b16040354 100644 --- a/lib/ansible/module_utils/iosxr.py +++ b/lib/ansible/module_utils/iosxr.py @@ -99,12 +99,12 @@ class NetworkModule(AnsibleModule): return self._config def _load_params(self): - params = super(NetworkModule, self)._load_params() - provider = params.get('provider') or dict() + super(NetworkModule, self)._load_params() + provider = self.params.get('provider') or dict() for key, value in provider.items(): if key in NET_COMMON_ARGS.keys(): - params[key] = value - return params + if self.params.get(key) is None and value is not None: + self.params[key] = value def connect(self): try: diff --git a/lib/ansible/module_utils/junos.py b/lib/ansible/module_utils/junos.py index be1a9b8c23d..735f9a22dd3 100644 --- a/lib/ansible/module_utils/junos.py +++ b/lib/ansible/module_utils/junos.py @@ -76,12 +76,12 @@ class NetworkModule(AnsibleModule): return self._config def _load_params(self): - params = super(NetworkModule, self)._load_params() - provider = params.get('provider') or dict() + super(NetworkModule, self)._load_params() + provider = self.params.get('provider') or dict() for key, value in provider.items(): if key in NET_COMMON_ARGS.keys(): - params[key] = value - return params + if self.params.get(key) is None and value is not None: + self.params[key] = value def connect(self): self.connection = Cli(self) diff --git a/lib/ansible/module_utils/nxos.py b/lib/ansible/module_utils/nxos.py index 7b90ce8dd1f..9c38c13c056 100644 --- a/lib/ansible/module_utils/nxos.py +++ b/lib/ansible/module_utils/nxos.py @@ -197,13 +197,12 @@ class NetworkModule(AnsibleModule): return self._config def _load_params(self): - params = super(NetworkModule, self)._load_params() - provider = params.get('provider') or dict() + super(NetworkModule, self)._load_params() + provider = self.params.get('provider') or dict() for key, value in provider.items(): if key in NET_COMMON_ARGS.keys(): - if not params.get(key) and value is not None: - params[key] = value - return params + if self.params.get(key) is None and value is not None: + self.params[key] = value def connect(self): if self.params['transport'] == 'nxapi': diff --git a/lib/ansible/module_utils/openswitch.py b/lib/ansible/module_utils/openswitch.py index e4596712df8..fc9f8e988fe 100644 --- a/lib/ansible/module_utils/openswitch.py +++ b/lib/ansible/module_utils/openswitch.py @@ -176,12 +176,12 @@ class NetworkModule(AnsibleModule): return self._config def _load_params(self): - params = super(NetworkModule, self)._load_params() - provider = params.get('provider') or dict() + super(NetworkModule, self)._load_params() + provider = self.params.get('provider') or dict() for key, value in provider.items(): if key in NET_COMMON_ARGS.keys(): - params[key] = value - return params + if self.params.get(key) is None and value is not None: + self.params[key] = value def connect(self): if self.params['transport'] == 'rest':