fabric: support arbitrary port breakouts
Not that we use anything but 1x and 4x. Mainly done so I can drop nonexistent (because they have been broken out) interfaces from NetBox.
This commit is contained in:
		
							parent
							
								
									16f34c4502
								
							
						
					
					
						commit
						0e9dac6985
					
				
					 1 changed files with 5 additions and 9 deletions
				
			
		| 
						 | 
				
			
			@ -1,11 +1,7 @@
 | 
			
		|||
# https://docs.nvidia.com/networking-ethernet-software/cumulus-linux/Layer-1-and-Switch-Ports/Interface-Configuration-and-Management/Switch-Port-Attributes/#breakout-ports
 | 
			
		||||
{% for interface in interfaces | selectattr('name', 'match', '^swp[0-9]+$') %}
 | 
			
		||||
{{ interface.name|regex_replace('^swp', '') }}=
 | 
			
		||||
{%- if interfaces|selectattr('name', 'match', '^'+interface.name+'s[0-9]+$') %}
 | 
			
		||||
4x
 | 
			
		||||
{% elif not interface.enabled %}
 | 
			
		||||
disabled
 | 
			
		||||
{% else %}
 | 
			
		||||
1x
 | 
			
		||||
{% endif %}
 | 
			
		||||
{% for interface in interfaces | selectattr('name', 'match', '^swp[0-9]+(s0)?$') %}
 | 
			
		||||
{# get '1' from 'swp1' and '2' from 'swp2s0' #}
 | 
			
		||||
{% set port = interface.name | regex_replace('^swp([0-9]+).*$', '\\1') %}
 | 
			
		||||
{% set count = interfaces | selectattr('name', 'match', '^swp'+port+'(s[0-9])*$') | length %}
 | 
			
		||||
{{ port }}={% if interface.enabled or count > 1 %}{{ count }}x{% else %}disabled{% endif +%}
 | 
			
		||||
{% endfor %}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue