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 nxos_vrf issues #37092

Merged
merged 2 commits into from Mar 13, 2018
Merged

Fix nxos_vrf issues #37092

merged 2 commits into from Mar 13, 2018

Conversation

saichint
Copy link
Contributor

@saichint saichint commented Mar 6, 2018

SUMMARY

Fixes #37091

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

nxos_vrf

ANSIBLE VERSION
ansible 2.6.0 (devel fed20b825f) last updated 2018/02/15 12:51:12 (GMT -400)
  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 = /root/agents-ci/ansible/lib/ansible
  executable location = /root/agents-ci/ansible/bin/ansible
  python version = 2.7.6 (default, Oct 26 2016, 20:30:19) [GCC 4.8.4]
ADDITIONAL INFORMATION
  • This PR fixes issues in nxos_vrf issues #37091
  • Integration test cases are enhanced for nxos_vrf module to include all parameters and for testing defaults and also takes care of platform differences.
  • Tested on all possible platforms and versions.

* NOTE: 'interfaces' parameter is added in 2.5 to nxos_vrf module. This does the same functionality as nxos_vrf_interface module. Actually nxos_vrf module is accepting 'list' for 'interfaces' which is more accurate than nxos_vrf_interface which takes only interface per task. Given these restrictions and redundancy, it is RECOMMENDED to deprecate nxos_vrf_interface module. If not, at least properly document this behavior in nxos_vrf_interface module.

@ansibot
Copy link
Contributor

ansibot commented Mar 6, 2018

@ansibot ansibot added bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. networking Network category nxos Cisco NXOS community support:network This issue/PR relates to code supported by the Ansible Network Team. test This PR relates to tests. labels Mar 6, 2018
@gundalow gundalow removed the needs_triage Needs a first human triage before being processed. label Mar 7, 2018
@trishnaguha trishnaguha self-assigned this Mar 7, 2018
@trishnaguha trishnaguha added this to the 2.6.0 milestone Mar 7, 2018
@@ -266,7 +266,7 @@ def map_obj_to_commands(updates, module):
commands.append('shutdown')
commands.append('exit')

if interfaces:
if interfaces and interfaces[0] != 'default':
Copy link
Member

Choose a reason for hiding this comment

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

Why check only the first item of the list not to be default?

Copy link
Contributor Author

@saichint saichint Mar 9, 2018

Choose a reason for hiding this comment

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

interfaces is a list parameter. It allows either an array of interfaces or 'default' keyword (to remove all the existing interfaces on the device). Since it is list, I am checking the first element to see if it is 'default' or not.
I followed this example:

If there is some other better way, let me know.

@@ -293,7 +297,7 @@ def map_obj_to_commands(updates, module):
commands.insert(0, 'vrf context {0}'.format(name))
commands.append('exit')

if interfaces:
if interfaces and interfaces[0] != 'default':
Copy link
Member

Choose a reason for hiding this comment

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

same question for this like the above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See my reply above

@@ -318,6 +322,14 @@ def map_obj_to_commands(updates, module):
commands.append('interface {0}'.format(i))
commands.append('no switchport')
commands.append('no vrf member {0}'.format(name))
elif interfaces and interfaces[0] == 'default':
Copy link
Member

Choose a reason for hiding this comment

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

why check only the first item of the list to be default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See my reply above

@@ -318,6 +322,14 @@ def map_obj_to_commands(updates, module):
commands.append('interface {0}'.format(i))
commands.append('no switchport')
commands.append('no vrf member {0}'.format(name))
elif interfaces and interfaces[0] == 'default':
if obj_in_have['interfaces']:
Copy link
Member

Choose a reason for hiding this comment

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

what if there is no obj_in_have['interfaces']? there should be an else part in this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Basically, if interfaces is 'default' and the current object has some interfaces, this code removes them by doing 'no' cmd on each of them. There is no need for 'else' here because if the current object has no interfaces and user wants 'default', we are already in that state so no new commands need to be generated and impotence is maintained.

@saichint
Copy link
Contributor Author

saichint commented Mar 9, 2018

@trishnaguha Thanks for review comments, I put explanations for your remarks. Let me know if that is ok. Also please check my Note in the "Additional Information" section about the nxos_vrf_interface and decide whether we need to deprecate it.

@trishnaguha
Copy link
Member

@saichint Thanks for the explanation. The PR looks good to me.
I agree with your though of deprecating nxos_vrf_interface module. We can have that on 2.6 roadmap. Thanks.

@trishnaguha trishnaguha merged commit dc61f4c into ansible:devel Mar 13, 2018
@saichint saichint deleted the vrf branch March 13, 2018 16:12
@trishnaguha trishnaguha modified the milestones: 2.6.0, 2.5.0 Mar 15, 2018
@trishnaguha trishnaguha added this to Need CP into 2.5.1 in zzz NOT USED: Networking Bugs Mar 15, 2018
@trishnaguha
Copy link
Member

cherry-picked to 2.5

@trishnaguha trishnaguha moved this from Need CP into 2.5.1 to Done in zzz NOT USED: Networking Bugs Mar 29, 2018
trishnaguha pushed a commit to trishnaguha/ansible that referenced this pull request Mar 29, 2018
* fix nxos_vrf issues

* fix doc

(cherry picked from commit dc61f4c)
trishnaguha added a commit that referenced this pull request Mar 29, 2018
* Fix nxos_switchport (#37328)

(cherry picked from commit ff57fd0)

* Fix nxos_l2_interface and test typo (#37336)

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

* fix ios_l2_interface (#37389)

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

* fix required args for nxos_snapshot and docs improvement (#37232)

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

* add nxos_snapshot test for missing required param (#37248)

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

* Ensure network_cli nxos test is run only once - remove unnecessary files (#37462)

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

* Integration Tests only: nxos_user (#37852)

* add new integration file to nxos_user

* fix shippable error

* change nxapi to connection

* review comments

(cherry picked from commit 63da50e)

* fix UnboundLocalError nxos_bgp_af module (#37610)

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

* Fix nxos_vrf issues (#37092)

* fix nxos_vrf issues

* fix doc

(cherry picked from commit dc61f4c)

* fix nxos_vrf_af issues (#37211)

(cherry picked from commit 74e79d9)

* fix nxos_udld issues (#37418)

(cherry picked from commit 05b266c)

* fix nxos_vlan issues (#38008)

(cherry picked from commit 6f2cb28)

* add changelog

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
@dagwieers dagwieers added the cisco Cisco technologies label Feb 23, 2019
@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. cisco Cisco technologies core_review In order to be merged, this PR must follow the core review workflow. module This issue/PR relates to a module. networking Network category nxos Cisco NXOS community support:network This issue/PR relates to code supported by the Ansible Network Team. test This PR relates to tests.
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

nxos_vrf issues
5 participants