Skip to content

Commit 99da2fc

Browse files
authored
[isolated-topo] make ipv4 and ipv4 BGP sessions optional, make ipv6 only topology deployable (sonic-net#106)
<!-- Please make sure you've read and understood our contributing guidelines; https://github.com/sonic-net/SONiC/blob/gh-pages/CONTRIBUTING.md Please provide following information to help code review process a bit easier: --> ### Description of PR <!-- - Please include a summary of the change and which issue is fixed. - Please also include relevant motivation and context. Where should reviewer start? background context? - List any dependencies that are required for this change. --> Summary: Fixes # (issue) We have ipv6 address only topology which only establish ipv6 BGP sessions. So we raise this PR to make ipv4 BGP sessions optional and make ipv6 only topology deployable. ### Type of change <!-- - Fill x for your type of change. - e.g. - [x] Bug fix --> - [ ] Bug fix - [x] Testbed and Framework(new/improvement) - [ ] Test case(new/improvement) ### Back port request - [ ] 202012 - [ ] 202205 - [ ] 202305 - [ ] 202311 - [ ] 202405 ### Approach #### What is the motivation for this PR? We have ipv6 address only topology which only establish ipv6 BGP sessions. #### How did you do it? Make ipv4 BGP sessions optional and make ipv6 only topology deployable #### How did you verify/test it? Deploy in lab #### Any platform specific information? #### Supported testbed topology if it's a new test case? ### Documentation <!-- (If it's a new feature, new test case) Did you update documentation/Wiki relevant to your implementation? Link to the wiki page? -->
1 parent 0ecd469 commit 99da2fc

12 files changed

Lines changed: 1075 additions & 1036 deletions

ansible/library/announce_routes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1170,7 +1170,7 @@ def main():
11701170
module.fail_json(msg='Unable to load topology "{}"'.format(topo_name))
11711171
if dut_interfaces:
11721172
topo['topology']['VMs'] = MultiServersUtils.get_vms_by_dut_interfaces(topo['topology']['VMs'], dut_interfaces)
1173-
for vm_name in topo['configuration'].keys():
1173+
for vm_name in list(topo['configuration'].keys()):
11741174
if vm_name not in topo['topology']['VMs']:
11751175
topo['configuration'].pop(vm_name)
11761176

ansible/library/test_facts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def _read_testbed_topo_from_yaml():
180180
{dut: i for i, dut in enumerate(tb["duts"])}
181181
if 'servers' in tb:
182182
tb['multi_servers_tacacs_ip'], _ = \
183-
_cidr_to_ip_mask(tb['servers'].values()[0]["ptf_ip"])
183+
_cidr_to_ip_mask(list(tb['servers'].values())[0]["ptf_ip"])
184184
self.testbed_topo[tb["conf-name"]] = tb
185185

186186
if self.testbed_filename.endswith(".csv"):

ansible/library/vlan_config.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@ def main():
5151
vlan_configs.update({vlan: {}})
5252
vlan_configs[vlan]['id'] = vlan_param['id']
5353
vlan_configs[vlan]['tag'] = vlan_param['tag']
54-
vlan_configs[vlan]['prefix'] = vlan_param['prefix']
55-
vlan_configs[vlan]['prefix_v6'] = vlan_param['prefix_v6']
54+
if 'prefix' in vlan_param:
55+
vlan_configs[vlan]['prefix'] = vlan_param['prefix']
56+
if 'prefix_v6' in vlan_param:
57+
vlan_configs[vlan]['prefix_v6'] = vlan_param['prefix_v6']
5658
vlan_configs[vlan]['intfs'] = [port_alias[i]
5759
for i in vlan_param['intfs']]
5860
vlan_configs[vlan]['portchannels'] = vlan_param.get(

ansible/plugins/filter/filters.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import ipaddress
22
import math
33
import os.path
4+
from collections import OrderedDict
45

56
from ansible import errors
67

@@ -159,7 +160,10 @@ def extract_hostname(values, topology, vm_base, inventory_hostname, dut_interfac
159160
if vm_base not in values:
160161
raise errors.AnsibleFilterError('Current vm_base: %s is not found in vm_list' % vm_base)
161162

162-
vms = MultiServersUtils.get_vms_by_dut_interfaces(topology, dut_interfaces) if dut_interfaces else topology
163+
sorted_topo = OrderedDict()
164+
for kv_tuple in sorted(topology.items(), key=lambda item: item[1]['vm_offset']):
165+
sorted_topo[kv_tuple[0]] = kv_tuple[1]
166+
vms = MultiServersUtils.get_vms_by_dut_interfaces(sorted_topo, dut_interfaces) if dut_interfaces else topology
163167
base = values.index(vm_base)
164168
for hostname, attr in vms.items():
165169
if base + attr['vm_offset'] >= len(values):
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
t1-spine.j2
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
t1-tor.j2
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
t1-spine.j2
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
t1-tor.j2

ansible/roles/vm_set/tasks/announce_routes.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
exabgp:
8383
name: "{{ vm_item.key }}-v6"
8484
state: "configure"
85-
router_id: "{{ ptf_local_ipv4 }}"
85+
router_id: "{{ configuration_properties.common.nhipv4|default('10.10.246.254') }}"
8686
local_ip: "{{ ptf_local_ipv6 }}"
8787
peer_ip: "{{ configuration[vm_item.key].bp_interface.ipv6.split('/')[0] }}"
8888
local_asn: "{{ configuration[vm_item.key].bgp.asn }}"
@@ -114,7 +114,7 @@
114114
- name: Verify that exabgp processes for IPv6 are started
115115
wait_for:
116116
host: "{{ ptf_host_ip }}"
117-
port: "{{ 6000 + topology.VMs[vm_item.key].vm_offset|int }}"
117+
port: "{{ 6000 + vm_item.value.vm_offset|int }}"
118118
state: "started"
119119
timeout: 180
120120
loop: "{{ topo_vms|dict2items }}"

ansible/templates/minigraph_dpg.j2

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,9 @@
169169
{% endif %}
170170
<VlanID>{{ vlan_param['id'] }}</VlanID>
171171
<Tag>{{ vlan_param['tag'] }}</Tag>
172+
{% if 'prefix' in vlan_param %}
172173
<Subnets>{{ vlan_param['prefix'] | ipaddr('network') }}/{{ vlan_param['prefix'] | ipaddr('prefix') }}</Subnets>
174+
{% endif %}
173175
{% if 'secondary_subnet' in vlan_param %}
174176
<SecondarySubnets>{{ vlan_param['secondary_subnet'] | ipaddr('network') }}/{{ vlan_param['secondary_subnet'] | ipaddr('secondary_subnet') }}<SecondarySubnets>
175177
{% endif %}
@@ -185,6 +187,7 @@
185187
{% for index in range(vms_number) %}
186188
{% if vm_topo_config['vm'][vms[index]]['ip_intf'][dut_index|int] is not none %}
187189
{% for intf_index in range(vm_topo_config['vm'][vms[index]]['ip_intf'][dut_index|int]|length) %}
190+
{% if vm_topo_config['vm'][vms[index]]['bgp_ipv4'][dut_index|int] %}
188191
<IPInterface>
189192
<Name i:nil="true"/>
190193
{% if 'port-channel' in vm_topo_config['vm'][vms[index]]['ip_intf'][dut_index|int][intf_index]|lower %}
@@ -194,6 +197,8 @@
194197
{% endif %}
195198
<Prefix>{{ vm_topo_config['vm'][vms[index]]['bgp_ipv4'][dut_index|int][intf_index] }}/{{ vm_topo_config['vm'][vms[index]]['ipv4mask'][dut_index|int][intf_index] }}</Prefix>
196199
</IPInterface>
200+
{% endif %}
201+
{% if vm_topo_config['vm'][vms[index]]['bgp_ipv6'][dut_index|int] %}
197202
<IPInterface>
198203
<Name i:Name="true"/>
199204
{% if 'port-channel' in vm_topo_config['vm'][vms[index]]['ip_intf'][dut_index|int][intf_index]|lower %}
@@ -203,16 +208,19 @@
203208
{% endif %}
204209
<Prefix>{{ vm_topo_config['vm'][vms[index]]['bgp_ipv6'][dut_index|int][intf_index] }}/{{ vm_topo_config['vm'][vms[index]]['ipv6mask'][dut_index|int][intf_index] }}</Prefix>
205210
</IPInterface>
211+
{% endif %}
206212
{% endfor %}
207213
{% endif %}
208214
{% endfor %}
209215
{% if 'tor' in vm_topo_config['dut_type'] | lower %}
210216
{% for vlan, vlan_param in vlan_configs.items() %}
217+
{% if 'prefix' in vlan_param %}
211218
<IPInterface>
212219
<Name i:nil="true"/>
213220
<AttachTo>{{ vlan }}</AttachTo>
214221
<Prefix>{{ vlan_param['prefix'] }}</Prefix>
215222
</IPInterface>
223+
{% endif %}
216224
{%if 'secondary_subnet' in vlan_param %}
217225
<IPInterface>
218226
<Name i:nil="true"/>

0 commit comments

Comments
 (0)