2023-12-15 20:27:47 +03:00
|
|
|
package configmigrate
|
2023-09-04 20:45:50 +03:00
|
|
|
|
|
|
|
// migrateTo7 performs the following changes:
|
|
|
|
//
|
|
|
|
// # BEFORE:
|
|
|
|
// 'schema_version': 6
|
|
|
|
// 'dhcp':
|
|
|
|
// 'enabled': false
|
|
|
|
// 'interface_name': vboxnet0
|
|
|
|
// 'gateway_ip': '192.168.56.1'
|
|
|
|
// 'subnet_mask': '255.255.255.0'
|
|
|
|
// 'range_start': '192.168.56.10'
|
|
|
|
// 'range_end': '192.168.56.240'
|
|
|
|
// 'lease_duration': 86400
|
|
|
|
// 'icmp_timeout_msec': 1000
|
|
|
|
// # …
|
|
|
|
//
|
|
|
|
// # AFTER:
|
|
|
|
// 'schema_version': 7
|
|
|
|
// 'dhcp':
|
|
|
|
// 'enabled': false
|
|
|
|
// 'interface_name': vboxnet0
|
|
|
|
// 'dhcpv4':
|
|
|
|
// 'gateway_ip': '192.168.56.1'
|
|
|
|
// 'subnet_mask': '255.255.255.0'
|
|
|
|
// 'range_start': '192.168.56.10'
|
|
|
|
// 'range_end': '192.168.56.240'
|
|
|
|
// 'lease_duration': 86400
|
|
|
|
// 'icmp_timeout_msec': 1000
|
|
|
|
// # …
|
2023-09-06 13:43:29 +03:00
|
|
|
func migrateTo7(diskConf yobj) (err error) {
|
2023-09-04 20:45:50 +03:00
|
|
|
diskConf["schema_version"] = 7
|
|
|
|
|
2023-09-06 13:43:29 +03:00
|
|
|
dhcp, ok, _ := fieldVal[yobj](diskConf, "dhcp")
|
|
|
|
if !ok {
|
2023-09-04 20:45:50 +03:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
dhcpv4 := yobj{}
|
|
|
|
err = coalesceError(
|
|
|
|
moveSameVal[string](dhcp, dhcpv4, "gateway_ip"),
|
|
|
|
moveSameVal[string](dhcp, dhcpv4, "subnet_mask"),
|
|
|
|
moveSameVal[string](dhcp, dhcpv4, "range_start"),
|
|
|
|
moveSameVal[string](dhcp, dhcpv4, "range_end"),
|
|
|
|
moveSameVal[int](dhcp, dhcpv4, "lease_duration"),
|
|
|
|
moveSameVal[int](dhcp, dhcpv4, "icmp_timeout_msec"),
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
dhcp["dhcpv4"] = dhcpv4
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|