Hi Pedro, Thanks for filing the bug and making cloud-init better.
I can confirm locally with the following:
cat > LP1978543.yaml <<EOF
version: 2
ethernets:
enp0s3:
dhcp4: false
addresses: [10.0.4.10/24]
nameservers:
addresses: [10.0.4.1]
routes:
- to: default
via: 10.0.4.1
metric: 100
EOF
PYTHONPATH=. python3 -m cloudinit.cmd.main devel net-convert -m enp0s3,AA -O netplan --k yaml -p LP1978543.yaml -D ubuntu -d out
Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/csmith/src/cloud-init/cloudinit/cmd/main.py", line 1073, in <module>
return_value = main(sys.argv)
File "/home/csmith/src/cloud-init/cloudinit/cmd/main.py", line 1059, in main
retval = util.log_time(
File "/home/csmith/src/cloud-init/cloudinit/util.py", line 2621, in log_time
ret = func(*args, **kwargs)
File "/home/csmith/src/cloud-init/cloudinit/cmd/devel/net_convert.py", line 136, in handle_args
ns = network_state.parse_net_config_data(pre_ns)
File "/home/csmith/src/cloud-init/cloudinit/net/network_state.py", line 1056, in parse_net_config_data
nsi.parse_config(skip_broken=skip_broken)
File "/home/csmith/src/cloud-init/cloudinit/net/network_state.py", line 279, in parse_config
self.parse_config_v2(skip_broken=skip_broken)
File "/home/csmith/src/cloud-init/cloudinit/net/network_state.py", line 328, in parse_config_v2
handler(self, command)
File "/home/csmith/src/cloud-init/cloudinit/net/network_state.py", line 721, in handle_ethernets
subnets = self._v2_to_v1_ipcfg(cfg)
File "/home/csmith/src/cloud-init/cloudinit/net/network_state.py", line 880, in _v2_to_v1_ipcfg
_normalize_route(
File "/home/csmith/src/cloud-init/cloudinit/net/network_state.py", line 1019, in _normalize_route
_normalize_net_keys(
File "/home/csmith/src/cloud-init/cloudinit/net/network_state.py", line 953, in _normalize_net_keys
raise ValueError(f"Address {addr} is not a valid ip address")
ValueError: Address default is not a valid ip address
When I change `to: default` to the alternative `to: 0.0.0.0/0` we render correctly without error
csmith@uptown:~/src/cloud-init$ PYTHONPATH=. python3 -m cloudinit.cmd.main devel net-convert -m enp0s3,AA -O netplan --k yaml -p LP1978543.yaml -D ubuntu -d out
Read input format 'yaml' from 'LP1978543.yaml'.
Wrote output format 'netplan' to 'out/'
csmith@uptown:~/src/cloud-init$ cat out/etc/netplan/50-cloud-init.yaml
# This file is generated from information provided by the datasource. Changes
# to it will not persist across an instance reboot. To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
ethernets:
enp0s3: addresses:
- 10.0.4.10/24
dhcp4: false nameservers: addresses:
- 10.0.4.1
routes:
- metric: 100
to: 0.0.0.0/0 via: 10.0.4.1
version: 2
Hi Pedro, Thanks for filing the bug and making cloud-init better.
I can confirm locally with the following:
cat > LP1978543.yaml <<EOF
version: 2
ethernets:
enp0s3:
dhcp4: false
addresses: [10.0.4.10/24]
nameservers:
addresses: [10.0.4.1]
routes:
- to: default
via: 10.0.4.1
metric: 100
EOF
PYTHONPATH=. python3 -m cloudinit.cmd.main devel net-convert -m enp0s3,AA -O netplan --k yaml -p LP1978543.yaml -D ubuntu -d out python3. 8/runpy. py", line 194, in _run_module_as_main python3. 8/runpy. py", line 87, in _run_code csmith/ src/cloud- init/cloudinit/ cmd/main. py", line 1073, in <module> csmith/ src/cloud- init/cloudinit/ cmd/main. py", line 1059, in main csmith/ src/cloud- init/cloudinit/ util.py" , line 2621, in log_time csmith/ src/cloud- init/cloudinit/ cmd/devel/ net_convert. py", line 136, in handle_args state.parse_ net_config_ data(pre_ ns) csmith/ src/cloud- init/cloudinit/ net/network_ state.py" , line 1056, in parse_net_ config_ data parse_config( skip_broken= skip_broken) csmith/ src/cloud- init/cloudinit/ net/network_ state.py" , line 279, in parse_config parse_config_ v2(skip_ broken= skip_broken) csmith/ src/cloud- init/cloudinit/ net/network_ state.py" , line 328, in parse_config_v2 csmith/ src/cloud- init/cloudinit/ net/network_ state.py" , line 721, in handle_ethernets to_v1_ipcfg( cfg) csmith/ src/cloud- init/cloudinit/ net/network_ state.py" , line 880, in _v2_to_v1_ipcfg route( csmith/ src/cloud- init/cloudinit/ net/network_ state.py" , line 1019, in _normalize_route net_keys( csmith/ src/cloud- init/cloudinit/ net/network_ state.py" , line 953, in _normalize_net_keys f"Address {addr} is not a valid ip address")
Traceback (most recent call last):
File "/usr/lib/
return _run_code(code, main_globals, None,
File "/usr/lib/
exec(code, run_globals)
File "/home/
return_value = main(sys.argv)
File "/home/
retval = util.log_time(
File "/home/
ret = func(*args, **kwargs)
File "/home/
ns = network_
File "/home/
nsi.
File "/home/
self.
File "/home/
handler(self, command)
File "/home/
subnets = self._v2_
File "/home/
_normalize_
File "/home/
_normalize_
File "/home/
raise ValueError(
ValueError: Address default is not a valid ip address
When I change `to: default` to the alternative `to: 0.0.0.0/0` we render correctly without error uptown: ~/src/cloud- init$ PYTHONPATH=. python3 -m cloudinit.cmd.main devel net-convert -m enp0s3,AA -O netplan --k yaml -p LP1978543.yaml -D ubuntu -d out
csmith@
Read input format 'yaml' from 'LP1978543.yaml'.
Wrote output format 'netplan' to 'out/'
csmith@ uptown: ~/src/cloud- init$ cat out/etc/ netplan/ 50-cloud- init.yaml cloud.cfg. d/99-disable- network- config. cfg with the following:
addresses:
nameserver s:
addresses:
via: 10.0.4.1
# This file is generated from information provided by the datasource. Changes
# to it will not persist across an instance reboot. To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/
# network: {config: disabled}
network:
ethernets:
enp0s3:
- 10.0.4.10/24
dhcp4: false
- 10.0.4.1
routes:
- metric: 100
to: 0.0.0.0/0
version: 2