summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzsdc <taras@vyos.io>2023-02-16 18:29:53 +0200
committerzsdc <taras@vyos.io>2023-02-16 18:29:53 +0200
commit67c90165b39b31da6b066a80513b22e8259156f7 (patch)
tree46893e3296969b375a52c19e76fb70dde9e6e659
parent8cf8051edd8bf903954f788217210ed977ec1e09 (diff)
downloadvyos-cloud-init-67c90165b39b31da6b066a80513b22e8259156f7.tar.gz
vyos-cloud-init-67c90165b39b31da6b066a80513b22e8259156f7.zip
network: T5012: Added a new option for network-config control
A new option for Cloud-Init was added: ``` vyos_config_options: network_config: <disabled/enabled> ``` Possible values: * by default - equal to the `network['config']` from the active Cloud-Init configuration * `enabled` - configure networking, even if global `network['config']` is set to `disabled` * `disabled` - do not configure networking, regardless of global `network['config']` value
-rw-r--r--cloudinit/config/cc_vyos.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/cloudinit/config/cc_vyos.py b/cloudinit/config/cc_vyos.py
index dd95a245..0d445506 100644
--- a/cloudinit/config/cc_vyos.py
+++ b/cloudinit/config/cc_vyos.py
@@ -31,7 +31,7 @@ from cloudinit.distros import ug_util
from cloudinit.settings import PER_INSTANCE
from cloudinit.sources import INSTANCE_JSON_FILE
from cloudinit.stages import Init
-from cloudinit.util import load_file, load_json, get_hostname_fqdn
+from cloudinit.util import load_file, load_json, get_hostname_fqdn, get_cfg_by_path
from cloudinit.sources.DataSourceOVF import get_properties as ovf_get_properties
try:
from vyos.configtree import ConfigTree
@@ -594,8 +594,16 @@ def handle(name, cfg, cloud, log, _args):
hostname = None
network_configured = True
+ # get network-config control options
+ network_config_global: str = get_cfg_by_path(cfg, 'network/config', '')
+ network_config_vyos: str = get_cfg_by_path(
+ cfg, 'vyos_config_options/network_config', network_config_global)
+ if network_config_vyos == 'disabled':
+ logger.debug("Network-config is disabled (global/vyos): {}/{}".format(
+ network_config_global, network_config_vyos))
+
# process networking configuration data
- if netcfg and network_configured is False:
+ if netcfg and network_configured is False and network_config_vyos != 'disabled':
# check which one version of config we have
# version 1
if netcfg['version'] == 1: