diff options
author | Andrew Kutz <101085+akutz@users.noreply.github.com> | 2021-11-09 13:41:03 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-09 12:41:03 -0700 |
commit | fff6de4a18fa4eca709870e995de99c543a4ac1c (patch) | |
tree | 9ba77646969bb8df6a49a7ba012c7bdc73280339 /cloudinit/net/networkd.py | |
parent | 3d150688617e2b8a16d715c7fb819c759f91915a (diff) | |
download | vyos-cloud-init-fff6de4a18fa4eca709870e995de99c543a4ac1c.tar.gz vyos-cloud-init-fff6de4a18fa4eca709870e995de99c543a4ac1c.zip |
Fix for set-name bug in networkd renderer (#1100)
This patch address an issue where the use of the "set-name"
directive caused the networkd renderer to fail.
LP: #1949407
Diffstat (limited to 'cloudinit/net/networkd.py')
-rw-r--r-- | cloudinit/net/networkd.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/cloudinit/net/networkd.py b/cloudinit/net/networkd.py index ee6fd2ad..c97c18f6 100644 --- a/cloudinit/net/networkd.py +++ b/cloudinit/net/networkd.py @@ -41,11 +41,11 @@ class CfgParser: def get_final_conf(self): contents = '' - for k, v in self.conf_dict.items(): + for k, v in sorted(self.conf_dict.items()): if not v: continue contents += '['+k+']\n' - for e in v: + for e in sorted(v): contents += e + '\n' contents += '\n' @@ -242,6 +242,19 @@ class Renderer(renderer.Renderer): name = iface['name'] # network state doesn't give dhcp domain info # using ns.config as a workaround here + + # Check to see if this interface matches against an interface + # from the network state that specified a set-name directive. + # If there is a device with a set-name directive and it has + # set-name value that matches the current name, then update the + # current name to the device's name. That will be the value in + # the ns.config['ethernets'] dict below. + for dev_name, dev_cfg in ns.config['ethernets'].items(): + if 'set-name' in dev_cfg: + if dev_cfg.get('set-name') == name: + name = dev_name + break + self.dhcp_domain(ns.config['ethernets'][name], cfg) ret_dict.update({link: cfg.get_final_conf()}) |