diff options
author | Wesley Wiedenmeier <wesley.wiedenmeier@gmail.com> | 2016-03-22 01:24:01 -0500 |
---|---|---|
committer | Wesley Wiedenmeier <wesley.wiedenmeier@gmail.com> | 2016-03-22 01:24:01 -0500 |
commit | 88bfbe22a2f1128f358501bc10f5a2cbd1f7facf (patch) | |
tree | 9ad8c61c67c9f260f1deffce027d86df27f082a5 /cloudinit | |
parent | 7e399773a95e21e4c825dab61847d6abcd2aa511 (diff) | |
download | vyos-cloud-init-88bfbe22a2f1128f358501bc10f5a2cbd1f7facf.tar.gz vyos-cloud-init-88bfbe22a2f1128f358501bc10f5a2cbd1f7facf.zip |
Basic code added to kick off network configuration and cause fallback network
configuration to be run if there is no network configuration provided by the
datasource.
NOTE: the code added here will not behave correctly if a net datasource has
network configuration. this code is temporary and should be reverted once
support for network configuration for net datasources after retrieving
config is in place.
based on: http://paste.ubuntu.com/15443576/
With this in place cloud-init properly chooses a fallback interface, configures
it and brings it online
Diffstat (limited to 'cloudinit')
-rw-r--r-- | cloudinit/sources/__init__.py | 4 | ||||
-rw-r--r-- | cloudinit/stages.py | 11 |
2 files changed, 15 insertions, 0 deletions
diff --git a/cloudinit/sources/__init__.py b/cloudinit/sources/__init__.py index d3cfa560..08058762 100644 --- a/cloudinit/sources/__init__.py +++ b/cloudinit/sources/__init__.py @@ -217,6 +217,10 @@ class DataSource(object): def get_package_mirror_info(self): return self.distro.get_package_mirror_info(data_source=self) + @property + def network_config(self): + return self.metadata.network_config + def normalize_pubkey_data(pubkey_data): keys = [] diff --git a/cloudinit/stages.py b/cloudinit/stages.py index dbcf3d55..d508897b 100644 --- a/cloudinit/stages.py +++ b/cloudinit/stages.py @@ -587,6 +587,17 @@ class Init(object): # Run the handlers self._do_handlers(user_data_msg, c_handlers_list, frequency) + def apply_networking(self): + """Attempt to apply network configuration, either using network + configuration from datasource or fallback configuration if that is + not available""" + if self.datasource and self.datasource.network_config: + ds_net_conf = self.datasource.network_config + res = self.distro.apply_network_config(ds_net_conf, bring_up=True) + else: + res = self.distro.apply_fallback_network(bring_up=True) + return res + class Modules(object): def __init__(self, init, cfg_files=None, reporter=None): |