Skip to content

Commit 449f3d4

Browse files
authored
Merge pull request #4817 from c-po/dhcpv6-migrator-fix
dhcpv6: T7967: fix migration script for automatic SLAAC selection
2 parents 4fbb3c6 + c5ef4f4 commit 449f3d4

File tree

3 files changed

+25
-15
lines changed

3 files changed

+25
-15
lines changed

smoketest/config-tests/basic-ipv6

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ set interfaces ethernet eth0 vif-s 10 vif-c 20 address 'dhcpv6'
66
set interfaces ethernet eth0 vif-s 10 vif-c 20 ipv6 address autoconf
77
set interfaces ethernet eth1 duplex 'auto'
88
set interfaces ethernet eth1 speed 'auto'
9-
set interfaces ethernet eth1 vif 50
10-
set interfaces ethernet eth1 vif-s 60 vif-c 70
9+
set interfaces ethernet eth1 vif 50 address '1.2.3.4/31'
10+
set interfaces ethernet eth1 vif-s 60 vif-c 70 address '2.3.4.5/31'
11+
set interfaces ethernet eth2 address 'dhcpv6'
1112
set interfaces ethernet eth2 duplex 'auto'
13+
set interfaces ethernet eth2 ipv6 address autoconf
1214
set interfaces ethernet eth2 speed 'auto'
1315
set interfaces loopback lo
1416
set interfaces pppoe pppoe0 authentication password 'vyos'

smoketest/configs/basic-ipv6

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,16 @@ interfaces {
2222
duplex auto
2323
speed auto
2424
vif 50 {
25+
address 1.2.3.4/31
2526
}
2627
vif-s 60 {
2728
vif-c 70 {
29+
address 2.3.4.5/31
2830
}
2931
}
3032
}
3133
ethernet eth2 {
34+
address dhcpv6
3235
duplex auto
3336
speed auto
3437
}

src/migration-scripts/interfaces/32-to-33

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,31 +23,36 @@ def migrate(config: ConfigTree) -> None:
2323
for type in config.list_nodes(['interfaces']):
2424
for interface in config.list_nodes(['interfaces', type]):
2525
iface_base_path = ['interfaces', type, interface]
26-
dhcpv6_addr_path = iface_base_path + ['address', 'dhcpv6']
27-
autoconf_path = iface_base_path + ['ipv6', 'address', 'autoconf']
28-
if config.exists(dhcpv6_addr_path) and not config.exists(autoconf_path):
29-
config.set(autoconf_path)
26+
dhcpv6_addr_path = iface_base_path + ['address']
27+
28+
if config.exists(dhcpv6_addr_path) and 'dhcpv6' in config.return_values(dhcpv6_addr_path):
29+
autoconf_path = iface_base_path + ['ipv6', 'address', 'autoconf']
30+
if not config.exists(autoconf_path):
31+
config.set(autoconf_path)
3032

3133
vif_path = iface_base_path + ['vif']
3234
if config.exists(vif_path):
3335
for vif in config.list_nodes(vif_path):
3436
vif_dhcpv6_addr_path = vif_path + [vif, 'address']
35-
vif_autoconf_path = vif_path + [vif, 'ipv6', 'address', 'autoconf']
36-
if config.exists(vif_dhcpv6_addr_path) and not config.exists(vif_autoconf_path):
37-
config.set(vif_autoconf_path)
37+
if config.exists(vif_dhcpv6_addr_path) and 'dhcpv6' in config.return_values(vif_dhcpv6_addr_path):
38+
vif_autoconf_path = vif_path + [vif, 'ipv6', 'address', 'autoconf']
39+
if not config.exists(vif_autoconf_path):
40+
config.set(vif_autoconf_path)
3841

3942
vif_s_path = iface_base_path + ['vif-s']
4043
if config.exists(vif_s_path):
4144
for vif_s in config.list_nodes(vif_s_path):
4245
vif_s_dhcpv6_addr_path = vif_s_path + [vif_s, 'address']
43-
vif_s_autoconf_path = vif_s_path + [vif_s, 'ipv6', 'address', 'autoconf']
44-
if config.exists(vif_s_dhcpv6_addr_path) and not config.exists(vif_s_autoconf_path):
45-
config.set(vif_s_autoconf_path)
46+
if config.exists(vif_s_dhcpv6_addr_path) and 'dhcpv6' in config.return_values(vif_s_dhcpv6_addr_path):
47+
vif_s_autoconf_path = vif_s_path + [vif_s, 'ipv6', 'address', 'autoconf']
48+
if not config.exists(vif_s_autoconf_path):
49+
config.set(vif_s_autoconf_path)
4650

4751
vif_c_path = iface_base_path + ['vif-s', vif_s, 'vif-c']
4852
if config.exists(vif_c_path):
4953
for vif_c in config.list_nodes(vif_c_path):
5054
vif_c_dhcpv6_addr_path = vif_c_path + [vif_c, 'address']
51-
vif_c_autoconf_path = vif_c_path + [vif_c, 'ipv6', 'address', 'autoconf']
52-
if config.exists(vif_c_dhcpv6_addr_path) and not config.exists(vif_c_autoconf_path):
53-
config.set(vif_c_autoconf_path)
55+
if config.exists(vif_c_dhcpv6_addr_path) and 'dhcpv6' in config.return_values(vif_c_dhcpv6_addr_path):
56+
vif_c_autoconf_path = vif_c_path + [vif_c, 'ipv6', 'address', 'autoconf']
57+
if not config.exists(vif_c_autoconf_path):
58+
config.set(vif_c_autoconf_path)

0 commit comments

Comments
 (0)