summaryrefslogtreecommitdiff
path: root/cloudinit/cmd/main.py
diff options
context:
space:
mode:
authorChad Smith <chad.smith@canonical.com>2017-12-05 16:25:11 -0700
committerChad Smith <chad.smith@canonical.com>2017-12-05 16:25:11 -0700
commit30b4d15764a1a9644379cf95770e8b2480856882 (patch)
tree102b18e80e5ff8bf383a7fe35e56f88328cd924a /cloudinit/cmd/main.py
parent47016791ca5e97d80e45d3f100bc4e5d0b88627d (diff)
downloadvyos-cloud-init-30b4d15764a1a9644379cf95770e8b2480856882.tar.gz
vyos-cloud-init-30b4d15764a1a9644379cf95770e8b2480856882.zip
cli: Add clean and status subcommands
The 'cloud-init clean' command allows a user or script to clear cloud-init artifacts from the system so that cloud-init sees the system as unconfigured upon reboot. Optional parameters can be provided to remove cloud-init logs and reboot after clean. The 'cloud-init status' command allows the user or script to check whether cloud-init has finished all configuration stages and whether errors occurred. An optional --wait argument will poll on a 0.25 second interval until cloud-init configuration is complete. The benefit here is scripts can block on cloud-init completion before performing post-config tasks.
Diffstat (limited to 'cloudinit/cmd/main.py')
-rw-r--r--cloudinit/cmd/main.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/cloudinit/cmd/main.py b/cloudinit/cmd/main.py
index 6fb9d9e7..aa56225d 100644
--- a/cloudinit/cmd/main.py
+++ b/cloudinit/cmd/main.py
@@ -767,6 +767,12 @@ def main(sysv_args=None):
parser_collect_logs = subparsers.add_parser(
'collect-logs', help='Collect and tar all cloud-init debug info')
+ parser_clean = subparsers.add_parser(
+ 'clean', help='Remove logs and artifacts so cloud-init can re-run.')
+
+ parser_status = subparsers.add_parser(
+ 'status', help='Report cloud-init status or wait on completion.')
+
if sysv_args:
# Only load subparsers if subcommand is specified to avoid load cost
if sysv_args[0] == 'analyze':
@@ -783,6 +789,18 @@ def main(sysv_args=None):
logs_parser(parser_collect_logs)
parser_collect_logs.set_defaults(
action=('collect-logs', handle_collect_logs_args))
+ elif sysv_args[0] == 'clean':
+ from cloudinit.cmd.clean import (
+ get_parser as clean_parser, handle_clean_args)
+ clean_parser(parser_clean)
+ parser_clean.set_defaults(
+ action=('clean', handle_clean_args))
+ elif sysv_args[0] == 'status':
+ from cloudinit.cmd.status import (
+ get_parser as status_parser, handle_status_args)
+ status_parser(parser_status)
+ parser_status.set_defaults(
+ action=('status', handle_status_args))
args = parser.parse_args(args=sysv_args)