|
| 1 | +{# Default values which will be used if no actual configuration available #} |
| 2 | +{% set default_cable = '40m' %} |
| 3 | + |
| 4 | +{# Port configuration to cable length look-up table #} |
| 5 | +{# Each record describes mapping of DUT (DUT port) role and neighbor role to cable length #} |
| 6 | +{# Roles described in the minigraph #} |
| 7 | +{% set ports2cable = { |
| 8 | + 'torrouter_server' : '5m', |
| 9 | + 'leafrouter_torrouter' : '40m', |
| 10 | + 'spinerouter_leafrouter' : '300m' |
| 11 | + } |
| 12 | +%} |
| 13 | + |
| 14 | +{%- macro cable_length(port_name) %} |
| 15 | + {%- set cable_len = [] %} |
| 16 | + {%- for local_port in DEVICE_NEIGHBOR %} |
| 17 | + {%- if local_port == port_name %} |
| 18 | + {%- if DEVICE_NEIGHBOR_METADATA is defined and DEVICE_NEIGHBOR_METADATA[DEVICE_NEIGHBOR[local_port].name] %} |
| 19 | + {%- set neighbor = DEVICE_NEIGHBOR_METADATA[DEVICE_NEIGHBOR[local_port].name] %} |
| 20 | + {%- set neighbor_role = neighbor.type %} |
| 21 | + {%- set roles1 = switch_role + '_' + neighbor_role %} |
| 22 | + {%- set roles2 = neighbor_role + '_' + switch_role %} |
| 23 | + {%- set roles1 = roles1 | lower %} |
| 24 | + {%- set roles2 = roles2 | lower %} |
| 25 | + {%- if roles1 in ports2cable %} |
| 26 | + {%- if cable_len.append(ports2cable[roles1]) %}{% endif %} |
| 27 | + {%- elif roles2 in ports2cable %} |
| 28 | + {%- if cable_len.append(ports2cable[roles2]) %}{% endif %} |
| 29 | + {%- endif %} |
| 30 | + {%- endif %} |
| 31 | + {%- endif %} |
| 32 | + {%- endfor %} |
| 33 | + {%- if cable_len -%} |
| 34 | + {{ cable_len.0 }} |
| 35 | + {%- else %} |
| 36 | + {%- if switch_role.lower() == 'torrouter' %} |
| 37 | + {%- for local_port in VLAN_MEMBER %} |
| 38 | + {%- if local_port[1] == port_name %} |
| 39 | + {%- set roles3 = switch_role + '_' + 'server' %} |
| 40 | + {%- set roles3 = roles3 | lower %} |
| 41 | + {%- if roles3 in ports2cable %} |
| 42 | + {%- if cable_len.append(ports2cable[roles3]) %}{% endif %} |
| 43 | + {%- endif %} |
| 44 | + {%- endif %} |
| 45 | + {%- endfor %} |
| 46 | + {%- if cable_len -%} |
| 47 | + {{ cable_len.0 }} |
| 48 | + {%- else -%} |
| 49 | + {{ default_cable }} |
| 50 | + {%- endif %} |
| 51 | + {%- else -%} |
| 52 | + {{ default_cable }} |
| 53 | + {%- endif %} |
| 54 | + {%- endif %} |
| 55 | +{%- endmacro %} |
| 56 | + |
| 57 | +{%- if DEVICE_METADATA is defined %} |
| 58 | +{%- set switch_role = DEVICE_METADATA['localhost']['type'] %} |
| 59 | +{%- endif -%} |
| 60 | + |
| 61 | +{% set port_names_list = [] %} |
| 62 | +{% for port in PORT %} |
| 63 | + {%- if port_names_list.append(port) %}{% endif %} |
| 64 | +{% endfor %} |
| 65 | +{% set port_names = port_names_list | join(',') -%} |
| 66 | + |
| 67 | +{ |
| 68 | + "CABLE_LENGTH": { |
| 69 | + "AZURE": { |
| 70 | + {% for port in PORT %} |
| 71 | + {% set cable = cable_length(port) -%} |
| 72 | + "{{ port }}": "{{ cable }}"{%- if not loop.last -%},{% endif %} |
| 73 | + |
| 74 | + {% endfor %} |
| 75 | + } |
| 76 | + }, |
| 77 | + "BUFFER_POOL": { |
| 78 | + "ingress_lossless_pool": { |
| 79 | + "size": "158630302", |
| 80 | + "type": "ingress", |
| 81 | + "mode": "dynamic", |
| 82 | + "xoff": "71577600" |
| 83 | + }, |
| 84 | + "lossy_pool": { |
| 85 | + "size": "56012386", |
| 86 | + "type": "egress", |
| 87 | + "mode": "dynamic", |
| 88 | + "xoff": "0" |
| 89 | + }, |
| 90 | + "egress_lossless_pool": { |
| 91 | + "size": "214642688", |
| 92 | + "type": "egress", |
| 93 | + "mode": "static" |
| 94 | + } |
| 95 | + }, |
| 96 | + "BUFFER_PROFILE": { |
| 97 | + "ingress_lossless_profile": { |
| 98 | + "pool":"ingress_lossless_pool", |
| 99 | + "xoff":"135520", |
| 100 | + "size":"1518", |
| 101 | + "dynamic_th":"1", |
| 102 | + "xon_offset":"9408" |
| 103 | + }, |
| 104 | + "egress_lossless_profile": { |
| 105 | + "pool":"ingress_lossless_pool", |
| 106 | + "size":"0", |
| 107 | + "static_th":"22798336" |
| 108 | + }, |
| 109 | + "ingress_lossy_profile": { |
| 110 | + "pool":"lossy_pool", |
| 111 | + "size":"0", |
| 112 | + "static_th":"22798336" |
| 113 | + }, |
| 114 | + "egress_lossy_profile": { |
| 115 | + "pool":"lossy_pool", |
| 116 | + "size":"1518", |
| 117 | + "dynamic_th":"2" |
| 118 | + } |
| 119 | + }, |
| 120 | + "BUFFER_PG": { |
| 121 | +{% for port in port_names_list %} |
| 122 | + "{{ port }}|3-4": { |
| 123 | + "profile" : "ingress_lossless_profile" |
| 124 | + }, |
| 125 | +{% endfor %} |
| 126 | +{% for port in port_names_list %} |
| 127 | + "{{ port }}|0": { |
| 128 | + "profile" : "ingress_lossy_profile" |
| 129 | + }, |
| 130 | +{% endfor %} |
| 131 | +{% for port in port_names_list %} |
| 132 | + "{{ port }}|1-2": { |
| 133 | + "profile" : "ingress_lossy_profile" |
| 134 | + }, |
| 135 | +{% endfor %} |
| 136 | +{% for port in port_names_list %} |
| 137 | + "{{ port }}|5-7": { |
| 138 | + "profile" : "ingress_lossy_profile" |
| 139 | + }{% if not loop.last %},{% endif %} |
| 140 | + |
| 141 | +{% endfor %} |
| 142 | + }, |
| 143 | + |
| 144 | + "BUFFER_QUEUE": { |
| 145 | +{% for port in port_names_list %} |
| 146 | + "{{ port }}|3-4": { |
| 147 | + "profile" : "egress_lossless_profile" |
| 148 | + }, |
| 149 | +{% endfor %} |
| 150 | +{% for port in port_names_list %} |
| 151 | + "{{ port }}|0-2": { |
| 152 | + "profile" : "egress_lossy_profile" |
| 153 | + }, |
| 154 | +{% endfor %} |
| 155 | +{% for port in port_names_list %} |
| 156 | + "{{ port }}|5-7": { |
| 157 | + "profile" : "egress_lossy_profile" |
| 158 | + }{% if not loop.last %},{% endif %} |
| 159 | + |
| 160 | +{% endfor %} |
| 161 | + } |
| 162 | +} |
0 commit comments