2020-08-17 12:12:33 +00:00
|
|
|
# system
|
|
|
|
import logging
|
|
|
|
|
|
|
|
# local
|
|
|
|
from ._subcommand import ServiceCommand
|
|
|
|
from .utils.dockercommand import DockerCommand
|
2020-08-17 12:51:43 +00:00
|
|
|
from .utils.project import get_project_name, list_projects
|
2020-08-17 12:12:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
class UpCommand(ServiceCommand):
|
|
|
|
"""kiwi up"""
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
super().__init__(
|
|
|
|
'up', num_projects='?', num_services='*',
|
2020-08-17 12:51:43 +00:00
|
|
|
description="Bring up the whole instance, a project or service(s) inside a project"
|
2020-08-17 12:12:33 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
def run(self, runner, config, args):
|
2020-08-17 12:51:43 +00:00
|
|
|
if 'projects' not in args or args.projects is None:
|
2020-08-17 12:12:33 +00:00
|
|
|
# "up" for all projects
|
|
|
|
for project_name in list_projects(config):
|
|
|
|
args.projects = project_name
|
|
|
|
runner.run('up')
|
|
|
|
|
|
|
|
return
|
|
|
|
|
2020-08-17 12:51:43 +00:00
|
|
|
if 'services' in args and args.services:
|
|
|
|
logging.info(f"Bringing up services {args.services} in project '{get_project_name(args)}'")
|
|
|
|
else:
|
|
|
|
logging.info(f"Bringing up project '{get_project_name(args)}'")
|
|
|
|
|
2020-08-17 13:00:05 +00:00
|
|
|
if runner.run('net-up'):
|
|
|
|
DockerCommand('docker-compose').run(
|
|
|
|
config, args, ['up', '-d', *args.services]
|
|
|
|
)
|
|
|
|
return True
|
|
|
|
|
|
|
|
return False
|