diff options
author | Teodor Garzdin <teodorgarzedin@gmail.com> | 2022-08-24 23:57:33 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-24 15:57:33 -0500 |
commit | 08edff81c6a5602f9867cc8a0378ee64271caaaa (patch) | |
tree | 7c94e2ee7aaba91f3de286e92311f7876f9ea78b /cloudinit/net | |
parent | 6d208e8e8031e7c23847320a5f0c50112770dfeb (diff) | |
download | cloud-init-git-08edff81c6a5602f9867cc8a0378ee64271caaaa.tar.gz |
Networkd multi-address support/fix (#1685)
Fix that given a cloud-init network config with multiple addresses for
an interface the networkd backend outputs an invalid networkd service
config. According to the `man` page of `systemd-networkd` only one
`Address=` field per `[Address]` section is allowed.
Diffstat (limited to 'cloudinit/net')
-rw-r--r-- | cloudinit/net/networkd.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/cloudinit/net/networkd.py b/cloudinit/net/networkd.py index 4a52d5dd..abfc1037 100644 --- a/cloudinit/net/networkd.py +++ b/cloudinit/net/networkd.py @@ -46,10 +46,16 @@ class CfgParser: for k, v in sorted(self.conf_dict.items()): if not v: continue - contents += "[" + k + "]\n" - for e in sorted(v): - contents += e + "\n" - contents += "\n" + if k == "Address": + for e in sorted(v): + contents += "[" + k + "]\n" + contents += e + "\n" + contents += "\n" + else: + contents += "[" + k + "]\n" + for e in sorted(v): + contents += e + "\n" + contents += "\n" return contents |