summaryrefslogtreecommitdiff
path: root/cloudinit/cmd
diff options
context:
space:
mode:
authorRyan Harper <ryan.harper@canonical.com>2018-09-05 14:17:16 +0000
committerServer Team CI Bot <josh.powers+server-team-bot@canonical.com>2018-09-05 14:17:16 +0000
commitdb50bc0d999e3a90136864a774f85e4e15b144e8 (patch)
treec0233ddee1fdec72c19500217ae001fa41d9a051 /cloudinit/cmd
parent3f6d0972d83c8bfd6a5e666d73cb84a8cfe9c8b6 (diff)
downloadvyos-cloud-init-db50bc0d999e3a90136864a774f85e4e15b144e8.tar.gz
vyos-cloud-init-db50bc0d999e3a90136864a774f85e4e15b144e8.zip
sysconfig: refactor sysconfig to accept distro specific templates paths
Multiple distros use sysconfig format but have different content and paths to certain files. Update distros to specify these template paths in their renderer_configs dictionary.
Diffstat (limited to 'cloudinit/cmd')
-rwxr-xr-xcloudinit/cmd/devel/net_convert.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/cloudinit/cmd/devel/net_convert.py b/cloudinit/cmd/devel/net_convert.py
index 271dc5ed..a0f58a0a 100755
--- a/cloudinit/cmd/devel/net_convert.py
+++ b/cloudinit/cmd/devel/net_convert.py
@@ -10,6 +10,7 @@ import yaml
from cloudinit.sources.helpers import openstack
from cloudinit.sources import DataSourceAzure as azure
+from cloudinit import distros
from cloudinit.net import eni, netplan, network_state, sysconfig
from cloudinit import log
@@ -36,6 +37,11 @@ def get_parser(parser=None):
metavar="PATH",
help="directory to place output in",
required=True)
+ parser.add_argument("-D", "--distro",
+ choices=[item for sublist in
+ distros.OSFAMILIES.values()
+ for item in sublist],
+ required=True)
parser.add_argument("-m", "--mac",
metavar="name,mac",
action='append',
@@ -96,14 +102,20 @@ def handle_args(name, args):
sys.stderr.write('\n'.join([
"", "Internal State",
yaml.dump(ns, default_flow_style=False, indent=4), ""]))
+ distro_cls = distros.fetch(args.distro)
+ distro = distro_cls(args.distro, {}, None)
+ config = {}
if args.output_kind == "eni":
r_cls = eni.Renderer
+ config = distro.renderer_configs.get('eni')
elif args.output_kind == "netplan":
r_cls = netplan.Renderer
+ config = distro.renderer_configs.get('netplan')
else:
r_cls = sysconfig.Renderer
+ config = distro.renderer_configs.get('sysconfig')
- r = r_cls()
+ r = r_cls(config=config)
sys.stderr.write(''.join([
"Read input format '%s' from '%s'.\n" % (
args.kind, args.network_data.name),