diff options
author | Scott Moser <smoser@ubuntu.com> | 2016-03-10 21:43:46 -0500 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2016-03-10 21:43:46 -0500 |
commit | 781ded8127deefb49a8806e49bdb7bb6e4d4b245 (patch) | |
tree | ff9a951f01a94ba796d8d849a14372aad2d80dff /cloudinit/distros | |
parent | 098d05b2f1253ba0808772851a1a8e85cb0108a9 (diff) | |
download | vyos-cloud-init-781ded8127deefb49a8806e49bdb7bb6e4d4b245.tar.gz vyos-cloud-init-781ded8127deefb49a8806e49bdb7bb6e4d4b245.zip |
commit planned implementation of datasourcenocloud
this adds the consumption of 'network-config' to the datasourcenocloud.
There is an implementation of the network rendering taht is untested
in distros/debian.
Diffstat (limited to 'cloudinit/distros')
-rw-r--r-- | cloudinit/distros/__init__.py | 11 | ||||
-rw-r--r-- | cloudinit/distros/debian.py | 10 |
2 files changed, 21 insertions, 0 deletions
diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py index a73acae5..461253a7 100644 --- a/cloudinit/distros/__init__.py +++ b/cloudinit/distros/__init__.py @@ -75,6 +75,9 @@ class Distro(object): # to write this blob out in a distro format raise NotImplementedError() + def _write_network_config(self, settings): + raise NotImplementedError() + def _find_tz_file(self, tz): tz_file = os.path.join(self.tz_zone_dir, str(tz)) if not os.path.isfile(tz_file): @@ -132,6 +135,14 @@ class Distro(object): return self._bring_up_interfaces(dev_names) return False + def apply_network_config(self, netconfig, bring_up=True): + # Write it out + dev_names = self._write_network_config(netconfig) + # Now try to bring them up + if bring_up: + return self._bring_up_interfaces(dev_names) + return False + @abc.abstractmethod def apply_locale(self, locale, out_fn=None): raise NotImplementedError() diff --git a/cloudinit/distros/debian.py b/cloudinit/distros/debian.py index db5890b1..89d8d28e 100644 --- a/cloudinit/distros/debian.py +++ b/cloudinit/distros/debian.py @@ -26,6 +26,8 @@ from cloudinit import distros from cloudinit import helpers from cloudinit import log as logging from cloudinit import util +from cloudinit import net +from cloudinit.net import network_state from cloudinit.distros.parsers.hostname import HostnameConf @@ -76,6 +78,14 @@ class Distro(distros.Distro): util.write_file(self.network_conf_fn, settings) return ['all'] + def _write_network_config(self, netconfig): + # TODO: THIS IS NOT TESTED + state = network_state.NetworkState() + state.load(netconfig) + state.parse_config() + net.render_network_state("/", state) + return ['all'] + def _bring_up_interfaces(self, device_names): use_all = False for d in device_names: |