cloud-init icon indicating copy to clipboard operation
cloud-init copied to clipboard

net: Passthough v2 netconfigs in netplan systems

Open aciba90 opened this issue 3 years ago • 0 comments

Proposed Commit Message

net: Passthough v2 raw net_conf in netplan systems

Adhere to Netplan Passthrough documented behavior,
not limiting v2 netplan configs to the subset of
props that cloud-init supports.

LP: #1978543

Additional Context

SC-1120 https://bugs.launchpad.net/cloud-init/+bug/1978543 Netplan Passthrough

Test Steps

cat > /tmp/lp1978543.yaml <<EOF
network:
  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

lxc init ubuntu-daily:jammy lp1978543
lxc file push /tmp/lp1978543.yaml lp1978543/etc/cloud/cloud.cfg.d/custom-networking.cfg
lxc file push /tmp/lp1978543.yaml lp1978543/root/
lxc start lp1978543
lxc exec lp1978543 -- cloud-init status --wait

lxc exec lp1978543 -- grep -in valueerror /var/log/cloud-init.log
# No errors found
$ lxc exec lp1978543 -- cat /etc/netplan/50-cloud-init.yaml
...
network:
    ethernets:
        enp0s3:
            addresses:
            - 10.0.4.10/24
            dhcp4: false
            nameservers:
                addresses:
                - 10.0.4.1
            routes:
            -   metric: 100
                to: default
                via: 10.0.4.1
    version: 2

lxc exec lp1978543 -- python3 -m cloudinit.cmd.main devel net-convert -m enp0s3,AA -O netplan --k yaml -p lp1978543.yaml -D ubuntu -d out
# No errors found

$ lxc exec lp1978543 -- cat out/etc/netplan/50-cloud-init.yaml
...
network:
    ethernets:
        enp0s3:
            addresses:
            - 10.0.4.10/24
            dhcp4: false
            nameservers:
                addresses:
                - 10.0.4.1
            routes:
            -   metric: 100
                to: default
                via: 10.0.4.1
    version: 2

Checklist:

  • [x] My code follows the process laid out in the documentation
  • [x] I have updated or added any unit tests accordingly
  • [ ] I have updated or added any documentation accordingly

aciba90 avatar Aug 12 '22 09:08 aciba90