Browse code

cloud-init: Delete the contents of network folder before network customization

After cloud-init customization, the 99-dhcp-en.network file is retained
along with the new network file (10-eth0.network) even though
99-disable-networking-config.cfg file is deleted before doing customization.
Fix to delete the network directory contents (/etc/systemd/network) before
creating the custom network files in cloud-init customization.

Change-Id: Ib9940f24ee9865cc80893bc188f25d1ecce166de
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/7315
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Anish Swaminathan <anishs@vmware.com>
(cherry picked from commit 8b0fe8db2fe31606e55e344d2082b015fc64d6ee)
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/7437
Reviewed-by: Srivatsa S. Bhat <srivatsab@vmware.com>

Keerthana K authored on 2019/05/28 20:05:10
Showing 2 changed files
... ...
@@ -2,7 +2,7 @@
2 2
 
3 3
 Name:           cloud-init
4 4
 Version:        18.3
5
-Release:        2%{?dist}
5
+Release:        3%{?dist}
6 6
 Summary:        Cloud instance init scripts
7 7
 Group:          System Environment/Base
8 8
 License:        GPLv3
... ...
@@ -147,6 +147,8 @@ rm -rf $RPM_BUILD_ROOT
147 147
 
148 148
 
149 149
 %changelog
150
+*   Tue May 28 2019 Keerthana K <keerthanak@vmware.com> 18.3-3
151
+-   Delete the contents of network directory before adding the custom network files.
150 152
 *   Tue Dec 04 2018 Ajay Kaher <akaher@vmware.com> 18.3-2
151 153
 -   Fix auto startup at boot time
152 154
 *   Wed Oct 24 2018 Ajay Kaher <akaher@vmware.com> 18.3-1
... ...
@@ -1,7 +1,7 @@
1 1
 diff -rupN cloud-init-0.7.9/cloudinit/distros/photon.py cloud-init-0.7.9-new/cloudinit/distros/photon.py
2 2
 --- cloud-init-0.7.9/cloudinit/distros/photon.py	1969-12-31 16:00:00.000000000 -0800
3 3
 +++ cloud-init-0.7.9-new/cloudinit/distros/photon.py	2017-05-15 05:13:49.156848344 -0700
4
-@@ -0,0 +1,319 @@
4
+@@ -0,0 +1,320 @@
5 5
 +# vi: ts=4 expandtab
6 6
 +#
7 7
 +# Copyright (C) 2017 VMware Inc.
... ...
@@ -103,6 +103,7 @@ diff -rupN cloud-init-0.7.9/cloudinit/distros/photon.py cloud-init-0.7.9-new/clo
103 103
 +                    route_index += 1
104 104
 +
105 105
 +            if info.get('auto'):
106
++                util.delete_dir_contents(self.network_conf_dir)
106 107
 +                self._write_interface_file(net_fn, net_cfg, route_entry)
107 108
 +            if 'dns-nameservers' in info:
108 109
 +                nameservers.extend(info['dns-nameservers'])