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

Adding module enos_config and its UT files #33081

Merged
merged 11 commits into from
Nov 29, 2017
Merged

Adding module enos_config and its UT files #33081

merged 11 commits into from
Nov 29, 2017

Conversation

amuraleedhar
Copy link
Contributor

SUMMARY

Creating the config module for enos from Lenovo.

ISSUE TYPE

New Module Pull Request

COMPONENT NAME

lib/ansible/modules/network/enos/enos_config.py
test/units/modules/network/enos/fixtures/enos_config_config.cfg
test/units/modules/network/enos/fixtures/enos_config_src.cfg
test/units/modules/network/enos/test_enos_config.py

ANSIBLE VERSION

ansible 2.5.0
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python2.7/dist-packages/ansible-2.5.0-py2.7.egg/ansible
executable location = /usr/local/bin/ansible
python version = 2.7.6 (default, Oct 26 2016, 20:30:19) [GCC 4.8.4]

ADDITIONAL INFORMATION

This is an effort to create modules for enos based switches from Lenovo.

@ansibot
Copy link
Contributor

ansibot commented Nov 20, 2017

The test ansible-test sanity --test pep8 [?] failed with the following errors:

lib/ansible/modules/network/enos/enos_config.py:316:1: W391 blank line at end of file
test/units/modules/network/enos/test_enos_config.py:131:1: W391 blank line at end of file

The test ansible-test sanity --test pylint [?] failed with the following errors:

lib/ansible/modules/network/enos/enos_config.py:316:0: trailing-newlines Trailing newlines
test/units/modules/network/enos/test_enos_config.py:131:0: trailing-newlines Trailing newlines

click here for bot help

@ansibot
Copy link
Contributor

ansibot commented Nov 20, 2017

@ansibot ansibot added affects_2.5 This issue/PR affects Ansible v2.5 module This issue/PR relates to a module. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. needs_triage Needs a first human triage before being processed. networking Network category new_module This PR includes a new module. new_plugin This PR includes a new plugin. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. test This PR relates to tests. labels Nov 20, 2017
@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Nov 20, 2017
@amuraleedhar
Copy link
Contributor Author

Please review these for merging

@bcoca bcoca removed the needs_triage Needs a first human triage before being processed. label Nov 20, 2017
required: false
default: line
choices: ['line', 'block', 'config']
force:
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove force: as the message says match: none is the correct way of doing this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes

match=dict(default='line', choices=['line', 'strict', 'exact', 'none']),
replace=dict(default='line', choices=['line', 'block', 'config']),

# this argument is deprecated in favor of setting match: none
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove force:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes


ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'network'}
Copy link
Member

Choose a reason for hiding this comment

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

This should be 'supported_by': 'community'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changing it, Thanks

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Nov 22, 2017
@ansibot
Copy link
Contributor

ansibot commented Nov 23, 2017

The test ansible-test sanity --test pep8 [?] failed with the following error:

lib/ansible/modules/network/enos/enos_config.py:186:1: E302 expected 2 blank lines, found 1

click here for bot help

@ansibot
Copy link
Contributor

ansibot commented Nov 23, 2017

The test ansible-test sanity --test pylint [?] failed with the following error:

lib/ansible/modules/network/enos/enos_config.py:186:0: trailing-whitespace Trailing whitespace

The test ansible-test sanity --test pep8 [?] failed with the following error:

lib/ansible/modules/network/enos/enos_config.py:186:1: W293 blank line contains whitespace

click here for bot help

@amuraleedhar
Copy link
Contributor Author

Please merge this now

required: false
default: no
choices: ['yes', 'no']
version_added: "2.5"
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this line.

As this is a new module the top-level version_added is the only one needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changing Now

not changed or committed, this argument is ignored.
required: false
default: 'configured by enos_config'
version_added: "2.5"
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this line.

As this is a new module the top-level version_added is the only one needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changing Now

required: false
default: false
choices: [ "yes", "no" ]
version_added: "2.5"
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this line.

As this is a new module the top-level version_added is the only one needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing now

mutually exclusive with I(lines).
required: false
default: null
version_added: "2.5"
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this line.

As this is a new module the top-level version_added is the only one needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changing Now

EXAMPLES = """
- name: configure top level configuration
enos_config:
lines: hostname {{ inventory_hostname }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be "lines: hostname {{ inventory_hostname }}"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changing

required: false
default: 'configured by enos_config'
version_added: "2.5"
admin:
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Is this the same as EOS & IOS's privilege mode?

  2. Would a password ever be needed

  3. In Ansible 2.5 we are moving to using the standard Ansible 'becomesystem to enter enable mode, though that requiresconnection: network_cli`, which I don't believe you are currently using.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For ENOS, to get into privilege mode, by default , u dont need a password. Soon after login using admin/admin u are in exec mode. To go to Privilege Mode u just have to type in enable. I have already made in the sample / test roles in my Github with connection: network_cli. But I am facing an issue in my module_util file enos.py that in load_config method its coming as exec mode (> prompt, not # prompt ) I am at the moment testing it with this code
def load_config(module, config):
try:
conn = get_connection(module)
conn.get('enable')
conn.edit_config(config)
except ConnectionError as exc:
module.fail_json(msg=to_text(exc))
May be this will change once I put become=true and become_method = enable.
But as of now its not working for me

@amuraleedhar
Copy link
Contributor Author

Please merge this now

@gundalow gundalow merged commit bada3af into ansible:devel Nov 29, 2017
@amuraleedhar amuraleedhar deleted the lenovo-module-config branch August 9, 2018 11:22
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.5 This issue/PR affects Ansible v2.5 module This issue/PR relates to a module. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. networking Network category new_module This PR includes a new module. new_plugin This PR includes a new plugin. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. test This PR relates to tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants