summaryrefslogtreecommitdiff
path: root/cloudinit/cmd/main.py
diff options
context:
space:
mode:
authorWesley Wiedenmeier <wesley.wiedenmeier@gmail.com>2017-02-17 02:16:20 -0600
committerScott Moser <smoser@brickies.net>2017-03-10 13:39:39 -0500
commit9044a05469d1b138d4ee34c55c7f5bdb6f97164d (patch)
tree52927263680539265102559c0707ba531131c6b8 /cloudinit/cmd/main.py
parentdf88d29ddf66057dd6912816cd8be2dc1c7fa443 (diff)
downloadvyos-cloud-init-9044a05469d1b138d4ee34c55c7f5bdb6f97164d.tar.gz
vyos-cloud-init-9044a05469d1b138d4ee34c55c7f5bdb6f97164d.zip
Add feature flags to cloudinit.version.
This exposes a mechanism for users of cloud-init to determine if a version has a specific feature, and adds documentation to that affect. We list an existing feature NETWORK_CONFIG_V1 as an example. Also add a 'features' subcommand for listing these to stdout.
Diffstat (limited to 'cloudinit/cmd/main.py')
-rw-r--r--cloudinit/cmd/main.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/cloudinit/cmd/main.py b/cloudinit/cmd/main.py
index 6ff4e1c0..fd221323 100644
--- a/cloudinit/cmd/main.py
+++ b/cloudinit/cmd/main.py
@@ -680,6 +680,10 @@ def status_wrapper(name, args, data_d=None, link_d=None):
return len(v1[mode]['errors'])
+def main_features(name, args):
+ sys.stdout.write('\n'.join(sorted(version.FEATURES)) + '\n')
+
+
def main(sysv_args=None):
if sysv_args is not None:
parser = argparse.ArgumentParser(prog=sysv_args[0])
@@ -770,6 +774,10 @@ def main(sysv_args=None):
' upon'))
parser_dhclient.set_defaults(action=('dhclient_hook', dhclient_hook))
+ parser_features = subparsers.add_parser('features',
+ help=('list defined features'))
+ parser_features.set_defaults(action=('features', main_features))
+
args = parser.parse_args(args=sysv_args)
try:
@@ -788,6 +796,7 @@ def main(sysv_args=None):
if name in ("modules", "init"):
functor = status_wrapper
+ rname = None
report_on = True
if name == "init":
if args.local:
@@ -802,10 +811,10 @@ def main(sysv_args=None):
rname, rdesc = ("single/%s" % args.name,
"running single module %s" % args.name)
report_on = args.report
-
- elif name == 'dhclient_hook':
- rname, rdesc = ("dhclient-hook",
- "running dhclient-hook module")
+ else:
+ rname = name
+ rdesc = "running 'cloud-init %s'" % name
+ report_on = False
args.reporter = events.ReportEventStack(
rname, rdesc, reporting_enabled=report_on)