Simplify the "deploy" command
Consolidate the feature flags so when a user selects the "--reboot" option it will update grub as well at the same time. Story: 2010867 Task: 48556 Change-Id: Ic53945718590438c53e366ca66359cc711e53616 Signed-off-by: Charles Short <charles.short@windriver.com>
This commit is contained in:
parent
b564e73a4e
commit
d4fd1f4f9f
@ -18,21 +18,15 @@ from apt_ostree.deploy import Deploy
|
||||
@click.command(help="Deploy a specific commit.")
|
||||
@pass_state_context
|
||||
@branch_argument
|
||||
@click.option(
|
||||
"--update",
|
||||
help="Update grub configuration.",
|
||||
is_flag=True,
|
||||
default=False
|
||||
)
|
||||
@click.option(
|
||||
"-r", "--reboot",
|
||||
help="Initiate a reboot after operation is complete.",
|
||||
is_flag=True,
|
||||
default=False
|
||||
)
|
||||
def deploy(state, branch, update, reboot):
|
||||
def deploy(state, branch, reboot):
|
||||
try:
|
||||
Deploy(state).deploy(update, reboot)
|
||||
Deploy(state).deploy(reboot)
|
||||
except KeyboardInterrupt:
|
||||
click.secho("\n" + ("Exiting at your request."))
|
||||
sys.exit(130)
|
||||
|
@ -253,3 +253,21 @@ def url_option(f):
|
||||
required=True,
|
||||
callback=callback
|
||||
)(f)
|
||||
|
||||
|
||||
"""deploy"""
|
||||
|
||||
|
||||
def reboot_option(f):
|
||||
"""Reboot host."""
|
||||
def callback(ctxt, param, value):
|
||||
state = ctxt.ensure_object(State)
|
||||
state.reboot = value
|
||||
return value
|
||||
return click.option(
|
||||
"--reboot", "-r",
|
||||
help="Reboot host",
|
||||
is_flag=True,
|
||||
default=False,
|
||||
callback=callback
|
||||
)(f)
|
||||
|
@ -102,7 +102,7 @@ class Deploy:
|
||||
self.ostree.ostree_checkout(branch, self.rootfs)
|
||||
return self.rootfs
|
||||
|
||||
def deploy(self, update, reboot):
|
||||
def deploy(self, reboot):
|
||||
"""Run ostree admin deploy."""
|
||||
ref = self.ostree.ostree_ref(self.state.branch)
|
||||
if not ref:
|
||||
@ -117,7 +117,7 @@ class Deploy:
|
||||
self.logging.error("Failed to deploy.")
|
||||
sys.exit(1)
|
||||
|
||||
if update:
|
||||
if reboot:
|
||||
self.logging.info("Updating grub.")
|
||||
r = utils.run_command(
|
||||
["update-grub"]
|
||||
@ -126,7 +126,6 @@ class Deploy:
|
||||
self.logging.error("Failed to update grub.")
|
||||
sys.exit(1)
|
||||
|
||||
if reboot:
|
||||
self.logging.info("Rebooting now.")
|
||||
r = utils.run_command(
|
||||
["shutdown", "-r", "now"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user