-
Notifications
You must be signed in to change notification settings - Fork 13
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
format and remove vlan ranging fixing issue #30
Open
GuyFoetz
wants to merge
1
commit into
ansible-collections:main
Choose a base branch
from
GOVCERT-LU:os6_vlan_trunk_issue
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GuyFoetz
commented
Apr 23, 2021
Comment on lines
23
to
100
{% if ports.state is defined and ports.state == "absent" -%} | ||
interface {{ ports.port }} | ||
no switchport access vlan | ||
{% else -%} | ||
interface {{ ports.port }} | ||
switchport access vlan {{ vlan_id[1] }} | ||
{% endif -%} | ||
{% endif -%} | ||
exit | ||
{% endfor -%} | ||
{% endif -%} | ||
exit | ||
{% endfor -%} | ||
{% endif -%} | ||
{% endif -%} | ||
{% endif -%} | ||
{% endif -%} | ||
{% endfor -%} | ||
{%- set cmd_dict = {} -%} | ||
{%- for key in os6_vlan.keys() -%} | ||
{% if 'vlan' in key %} | ||
{%- set vlan_id = key.split(" ") -%} | ||
{%- set vlan_vars = os6_vlan[key] -%} | ||
{%- set tagged_vlans = [] -%} | ||
{%- set tagged_members_present = [] -%} | ||
{%- set tagged_members_absent= [] -%} | ||
{% if vlan_vars.tagged_members is defined and vlan_vars.tagged_members -%} | ||
{%- for ports in vlan_vars.tagged_members -%} | ||
{% if ports.port is defined and ports.port -%} | ||
{%- set port = ports.port -%} | ||
{% if ports.state is defined and ports.state == 'absent' -%} | ||
{% if port in cmd_dict and 'absent' in cmd_dict[port] -%} | ||
{%- set tmp_vlan_list=cmd_dict[port]['absent'] -%} | ||
{%- set x=tmp_vlan_list.extend([vlan_id[1]]) -%} | ||
{%- set x=cmd_dict[port].update({'absent': tmp_vlan_list}) -%} | ||
{%- elif port in cmd_dict and 'absent' not in cmd_dict[port] -%} | ||
{%- set x=cmd_dict[port].update({'absent': [vlan_id[1]]}) -%} | ||
{%- else -%} | ||
{%- set x=cmd_dict.update({port: {'absent': [vlan_id[1]]}}) -%} | ||
{% endif -%} | ||
{%- else -%} | ||
{% if port in cmd_dict and 'present' in cmd_dict[port] -%} | ||
{%- set tmp_vlan_list=cmd_dict[port]['present'] -%} | ||
{%- set x=tmp_vlan_list.extend([vlan_id[1]]) -%} | ||
{%- set x=cmd_dict[port].update({'present': tmp_vlan_list}) -%} | ||
{%- elif port in cmd_dict and 'present' not in cmd_dict[port] -%} | ||
{%- set x=cmd_dict[port].update({'present': [vlan_id[1]]}) -%} | ||
{%- else -%} | ||
{%- set x=cmd_dict.update({port: {'present': [vlan_id[1]]}}) -%} | ||
{% endif -%} | ||
{% endif -%} | ||
{% endif -%} | ||
{% endfor -%} | ||
{% endif -%} | ||
{% endif -%} | ||
{% endfor -%} | ||
{%- for cmd in cmd_dict -%} | ||
{%- set cmd_dict = {} -%} | ||
{%- for key in os6_vlan.keys() -%} | ||
{% if 'vlan' in key %} | ||
{%- set vlan_id = key.split(" ") -%} | ||
{%- set vlan_vars = os6_vlan[key] -%} | ||
{%- set tagged_vlans = [] -%} | ||
{%- set tagged_members_present = [] -%} | ||
{%- set tagged_members_absent= [] -%} | ||
{% if vlan_vars.tagged_members is defined and vlan_vars.tagged_members -%} | ||
{%- for ports in vlan_vars.tagged_members -%} | ||
{% if ports.port is defined and ports.port -%} | ||
{%- set port = ports.port -%} | ||
{% if ports.state is defined and ports.state == 'absent' -%} | ||
{% if port in cmd_dict and 'absent' in cmd_dict[port] -%} | ||
{%- set tmp_vlan_list=cmd_dict[port]['absent'] -%} | ||
{%- set x=tmp_vlan_list.extend([vlan_id[1]]) -%} | ||
{%- set x=cmd_dict[port].update({'absent': tmp_vlan_list}) -%} | ||
{%- elif port in cmd_dict and 'absent' not in cmd_dict[port] -%} | ||
{%- set x=cmd_dict[port].update({'absent': [vlan_id[1]]}) -%} | ||
{%- else -%} | ||
{%- set x=cmd_dict.update({port: {'absent': [vlan_id[1]]}}) -%} | ||
{% endif -%} | ||
{%- else -%} | ||
{% if port in cmd_dict and 'present' in cmd_dict[port] -%} | ||
{%- set tmp_vlan_list=cmd_dict[port]['present'] -%} | ||
{%- set x=tmp_vlan_list.extend([vlan_id[1]]) -%} | ||
{%- set x=cmd_dict[port].update({'present': tmp_vlan_list}) -%} | ||
{%- elif port in cmd_dict and 'present' not in cmd_dict[port] -%} | ||
{%- set x=cmd_dict[port].update({'present': [vlan_id[1]]}) -%} | ||
{%- else -%} | ||
{%- set x=cmd_dict.update({port: {'present': [vlan_id[1]]}}) -%} | ||
{% endif -%} | ||
{% endif -%} | ||
{% endif -%} | ||
{% endfor -%} | ||
{% endif -%} | ||
{% endif -%} | ||
{% endfor -%} | ||
{%- for cmd in cmd_dict -%} | ||
interface {{cmd}} | ||
{% if 'tagged_members_state' in os6_vlan and os6_vlan['tagged_members_state']=='absent' %} | ||
{% if 'tagged_members_state' in os6_vlan and os6_vlan['tagged_members_state']=='absent' %} | ||
no switchport trunk allowed vlan |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just formatting it
GuyFoetz
commented
Apr 23, 2021
Comment on lines
-102
to
-121
{% for cmd_item in cmd_dict[cmd] %} | ||
{% if 'present' == cmd_item -%} | ||
{% set sort_list = cmd_dict[cmd]['present']| sort %} | ||
{% elif 'absent' in cmd_item -%} | ||
{% set sort_list = cmd_dict[cmd]['absent']| sort %} | ||
{% endif %} | ||
{% set range_list = [] %} | ||
{% set temp = {'temp': []} %} | ||
{% for i in range(sort_list|length) %} | ||
{% set x=temp['temp'].extend([sort_list[i]]) %} | ||
{% if (i != sort_list|length -1 and sort_list[i+1]|int - sort_list[i]|int > 1) or (i == sort_list|length -1) %} | ||
{% if temp['temp']|first != temp['temp']|last %} | ||
{% set x=range_list.extend([temp['temp']|first|string+'-'+temp['temp']|last|string]) %} | ||
{% set x=temp.update({'temp': []}) %} | ||
{% else %} | ||
{% set x=range_list.extend([temp['temp']|last|string]) %} | ||
{% set x=temp.update({'temp': []}) %} | ||
{% endif %} | ||
{% endif %} | ||
{% endfor %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this part got removed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
SUMMARY
Fixes #22
I removed the vlan ranging as the sort function used to do this cannot sort numerically correct
ISSUE TYPE
COMPONENT NAME
os6_vlan
ADDITIONAL INFORMATION