2020-08-18 12:37:07 +00:00
|
|
|
# local
|
2020-08-19 14:10:56 +00:00
|
|
|
from ._subcommand import ServiceCommand
|
2020-08-19 15:15:00 +00:00
|
|
|
|
|
|
|
# parent
|
|
|
|
from ..misc import are_you_sure
|
2020-08-18 12:37:07 +00:00
|
|
|
|
|
|
|
|
2020-08-19 14:10:56 +00:00
|
|
|
class UpdateCommand(ServiceCommand):
|
2020-08-18 12:37:07 +00:00
|
|
|
"""kiwi update"""
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
super().__init__(
|
2020-08-19 14:10:56 +00:00
|
|
|
'update', num_projects='?', num_services='*',
|
|
|
|
action="Updating",
|
2020-08-18 12:37:07 +00:00
|
|
|
description="Update the whole instance, a project or service(s) inside a project"
|
|
|
|
)
|
|
|
|
|
2020-08-19 14:10:56 +00:00
|
|
|
def _run_instance(self, runner, args):
|
2020-08-18 13:05:19 +00:00
|
|
|
if are_you_sure([
|
|
|
|
"This will update the entire instance at once.",
|
|
|
|
"",
|
|
|
|
"This is probably not what you intended, because:",
|
|
|
|
" - Updates may take a long time",
|
|
|
|
" - Updates may break beloved functionality",
|
|
|
|
]):
|
2020-08-19 14:10:56 +00:00
|
|
|
return super()._run_instance(runner, args)
|
2020-08-18 13:05:19 +00:00
|
|
|
|
|
|
|
return False
|
|
|
|
|
2020-08-19 14:10:56 +00:00
|
|
|
def _run_services(self, runner, args, project, services):
|
|
|
|
result = True
|
|
|
|
|
|
|
|
result &= runner.run('build')
|
2020-08-18 12:37:07 +00:00
|
|
|
result &= runner.run('pull')
|
|
|
|
result &= runner.run('conf-copy')
|
|
|
|
result &= runner.run('down')
|
|
|
|
result &= runner.run('up')
|
|
|
|
|
|
|
|
return result
|