Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix misuse of 'self' in lib/ansible/module_utils/network/eos/eos.py. … #39074

Merged
merged 2 commits into from
Apr 23, 2018
Merged

Fix misuse of 'self' in lib/ansible/module_utils/network/eos/eos.py. … #39074

merged 2 commits into from
Apr 23, 2018

Conversation

eakman
Copy link
Contributor

@eakman eakman commented Apr 20, 2018

Fixes #27630

SUMMARY

There seems to be a slight error in ansible/lib/ansible/module_utils/network/eos/eos.py in the method load_config.

As you can see from the snippet below in the old code, when configure is called (an instance method of CLI), self is given as an argument. This is causing an error (see issue number #27630) because configure only takes two arguments. This commit removes self from the arguments of load_config.

Old code:

def load_config(self, commands, commit=False, replace=False):
        ...
        if not all((bool(use_session), self.supports_sessions)):
            if commit:
                return self.configure(self, commands)
            else:
                self._module.warn("EOS can not check config without config session")
                result = {'changed': True}
                return result
        ....

New code:

def load_config(self, commands, commit=False, replace=False):
        ...
        if not all((bool(use_session), self.supports_sessions)):
            if commit:
                return self.configure(commands)
            else:
                self._module.warn("EOS can not check config without config session")
                result = {'changed': True}
                return result
        ....
ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

ansible/lib/ansible/module_utils/network/eos/eos.py

ANSIBLE VERSION
ansible 2.4.2.0
  config file = /Users/xbbnllu/.ansible.cfg
  configured module search path = [u'/Users/xbbnllu/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ansible
  executable location = ./bin/ansible
  python version = 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 12:39:47) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
ADDITIONAL INFORMATION
[bugfix/misuse_of_self_in_eos_module_util 2a22085b2b] Fix misuse of 'self' in lib/ansible/module_utils/network/eos/eos.py. Method load_config
 1 file changed, 1 insertion(+), 1 deletion(-)

@ansibot
Copy link
Contributor

ansibot commented Apr 20, 2018

@ansibot ansibot added bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. networking Network category new_contributor This PR is the first contribution by a new community member. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Apr 20, 2018
@@ -232,7 +232,7 @@ def load_config(self, commands, commit=False, replace=False):

if not all((bool(use_session), self.supports_sessions)):
if commit:
return self.configure(self, commands)
return self.configure(commands)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is another place where this function is called. Would you mind fixing that also? https://github.com/eakman/ansible/blob/2a22085b2b4af6aa9de4b82311e9586d75611bb9/lib/ansible/module_utils/network/eos/eos.py#L423
Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'll take a look!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I made the requested changes.

@trishnaguha trishnaguha removed the needs_triage Needs a first human triage before being processed. label Apr 20, 2018
@trishnaguha trishnaguha merged commit 80d7e22 into ansible:devel Apr 23, 2018
@trishnaguha trishnaguha added this to Need CP into 2.5.2 in zzz NOT USED: Networking Bugs Apr 23, 2018
@eakman eakman deleted the bugfix/misuse_of_self_in_eos_module_util branch April 23, 2018 12:09
@trishnaguha trishnaguha self-assigned this Apr 25, 2018
@trishnaguha trishnaguha added this to Nice to have in 2.4.x Blocker List Apr 26, 2018
@trishnaguha trishnaguha moved this from Need CP into 2.5.3 to Done in zzz NOT USED: Networking Bugs May 4, 2018
@trishnaguha
Copy link
Member

cherry-picked to 2.5

trishnaguha pushed a commit to trishnaguha/ansible that referenced this pull request May 4, 2018
ansible#39074)

* Fix misuse of 'self' in lib/ansible/module_utils/network/eos/eos.py. Method load_config

* Fix all instances of self.config(self,...

(cherry picked from commit 80d7e22)
trishnaguha added a commit that referenced this pull request May 4, 2018
* Handle nxos_feature issue where json isn't supported (#39150)

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
(cherry picked from commit 9eff1f1)

* Integration Tests only: nxos_snmp_contact (#39318)

* add integration test cases for snmp_contact

* removing unnecessary files

(cherry picked from commit bdb75cd)

* fix nxos_ntp issues (#39178)

* fix nxos_ntp issues

* review comments

* fix idempotent fail case

(cherry picked from commit 2f99a17)

* nxos_interface: AttributeError: 'NoneType' object has no attribute 'group' (#38544)

This fixes an issue we recently encounteredi with nxos_interface:

```
Traceback (most recent call last):
  File "/tmp/ansible_JmLoba/ansible_module_nxos_interface.py", line 777, in main
    have = map_config_to_obj(want, module)
  File "/tmp/ansible_JmLoba/ansible_module_nxos_interface.py", line 606, in map_config_to_obj
    obj['speed'] = re.search(r'speed (\d+)', body).group(1)
AttributeError: 'NoneType' object has no attribute 'group'
```

(cherry picked from commit dca6e2d)

* fix nxos_snmp_community issues (#39258)

(cherry picked from commit 1afec5a)

* Add aggregate example in nxos_l2_interface module doc (#39275)

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
(cherry picked from commit 86817cd)

* Fix misuse of 'self' in lib/ansible/module_utils/network/eos/eos.py. … (#39074)

* Fix misuse of 'self' in lib/ansible/module_utils/network/eos/eos.py. Method load_config

* Fix all instances of self.config(self,...

(cherry picked from commit 80d7e22)

* Fix for nxos_snmp_host issues (#39642)

* fix snmp_host issues

* source files

* fix shippable

* remove defaults to match arg spec

(cherry picked from commit f99bae1)

* fix nxos_snmp_traps issues (#39444)

* fix snmp_traps code

* add IT cases

* fix shippable

* fix shippable without ignore

(cherry picked from commit 99748cb)

* changelog

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
oolongbrothers pushed a commit to oolongbrothers/ansible that referenced this pull request May 14, 2018
ansible#39074)

* Fix misuse of 'self' in lib/ansible/module_utils/network/eos/eos.py. Method load_config

* Fix all instances of self.config(self,...
oolongbrothers pushed a commit to oolongbrothers/ansible that referenced this pull request May 15, 2018
ansible#39074)

* Fix misuse of 'self' in lib/ansible/module_utils/network/eos/eos.py. Method load_config

* Fix all instances of self.config(self,...
ilicmilan pushed a commit to ilicmilan/ansible that referenced this pull request Nov 7, 2018
ansible#39074)

* Fix misuse of 'self' in lib/ansible/module_utils/network/eos/eos.py. Method load_config

* Fix all instances of self.config(self,...
@ansible ansible locked and limited conversation to collaborators Apr 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue/PR relates to a bug. networking Network category new_contributor This PR is the first contribution by a new community member. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

eos_config - TypeError: configure() takes exactly 2 arguments (3 given)
3 participants