summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorsshedi <53473811+sshedi@users.noreply.github.com>2021-07-23 21:10:41 +0530
committerGitHub <noreply@github.com>2021-07-23 10:40:41 -0500
commit6e7066ea2b06940c4931f0258c7982b09966582f (patch)
tree6b960749538b4544b88a83c33253c5703efc430f /cloudinit
parent4257e30ac4b8730af35c078f2df0a2234dd19ffa (diff)
downloadvyos-cloud-init-6e7066ea2b06940c4931f0258c7982b09966582f.tar.gz
vyos-cloud-init-6e7066ea2b06940c4931f0258c7982b09966582f.zip
Add ability to manage fallback network config on PhotonOS (#941)
Currently cloud-init generates fallback network config on various scenarios. For example: 1. When no DS found 2. There is no 'network' info given in DS metadata. 3. If a DS gives a network config once and upon reboot if DS doesn't give any network info, previously set network data will be overridden. A newly introduced key in cloud.cfg.tmpl can be used to control this behavior on PhotonOS. Also, if OS comes with a set of default network files(configs), like in PhotonOS, cloud-init should not overwrite them by default. This change also includes some nitpicking changes of reorganizing few config variables. Signed-off-by: Shreenidhi Shedi <sshedi@vmware.com>
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/distros/photon.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/cloudinit/distros/photon.py b/cloudinit/distros/photon.py
index 3ef5dd40..61e270c0 100644
--- a/cloudinit/distros/photon.py
+++ b/cloudinit/distros/photon.py
@@ -5,6 +5,7 @@
#
# This file is part of cloud-init. See LICENSE file for license information.
+from cloudinit import net
from cloudinit import util
from cloudinit import subp
from cloudinit import distros
@@ -54,6 +55,20 @@ class Distro(distros.Distro):
util.logexc(LOG, 'Command %s failed', cmd)
return False, None, None
+ def generate_fallback_config(self):
+ key = 'disable_fallback_netcfg'
+ disable_fallback_netcfg = self._cfg.get(key, True)
+ LOG.debug('%s value is: %s', key, disable_fallback_netcfg)
+
+ if not disable_fallback_netcfg:
+ return net.generate_fallback_config()
+
+ LOG.info(
+ 'Skipping generate_fallback_config. Rely on PhotonOS default '
+ 'network config'
+ )
+ return None
+
def apply_locale(self, locale, out_fn=None):
# This has a dependancy on glibc-i18n, user need to manually install it
# and enable the option in cloud.cfg