|
|
|
@ -69,10 +69,15 @@ def parse_opts(argv):
|
|
|
|
|
action='store_true',
|
|
|
|
|
help="""Start docker container interactively (-ti).""",
|
|
|
|
|
default=False)
|
|
|
|
|
parser.add_argument('-d', '--detach',
|
|
|
|
|
action='store_true',
|
|
|
|
|
help="""Start container detached.""",
|
|
|
|
|
default=False)
|
|
|
|
|
opts = parser.parse_args(argv[1:])
|
|
|
|
|
|
|
|
|
|
return opts
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def docker_arg_map(key, value):
|
|
|
|
|
value = str(value).encode('ascii', 'ignore')
|
|
|
|
|
if len(value) == 0:
|
|
|
|
@ -84,12 +89,12 @@ def docker_arg_map(key, value):
|
|
|
|
|
'net': "--net=%s" % value,
|
|
|
|
|
'pid': "--pid=%s" % value,
|
|
|
|
|
'privileged': "--privileged=%s" % value.lower(),
|
|
|
|
|
#'restart': "--restart=%s" % "false",
|
|
|
|
|
'user': "--user=%s" % value,
|
|
|
|
|
'volumes': "--volume=%s" % value,
|
|
|
|
|
'volumes_from': "--volumes-from=%s" % value,
|
|
|
|
|
}.get(key, None)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def run_docker_container(opts, container_name):
|
|
|
|
|
container_found = False
|
|
|
|
|
|
|
|
|
@ -142,13 +147,15 @@ def run_docker_container(opts, container_name):
|
|
|
|
|
if opts.user:
|
|
|
|
|
continue
|
|
|
|
|
arg = docker_arg_map(container_data,
|
|
|
|
|
json_data[step][container][container_data])
|
|
|
|
|
json_data[step][container][container_data])
|
|
|
|
|
if arg:
|
|
|
|
|
cmd.append(arg)
|
|
|
|
|
|
|
|
|
|
if opts.user:
|
|
|
|
|
cmd.append('--user')
|
|
|
|
|
cmd.append(opts.user)
|
|
|
|
|
if opts.detach:
|
|
|
|
|
cmd.append('--detach')
|
|
|
|
|
if opts.interactive:
|
|
|
|
|
cmd.append('-ti')
|
|
|
|
|
# May as well remove it when we're done too
|
|
|
|
@ -167,19 +174,17 @@ def run_docker_container(opts, container_name):
|
|
|
|
|
if not container_found:
|
|
|
|
|
print("Container '%s' not found!" % container_name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def list_docker_containers(opts):
|
|
|
|
|
print opts
|
|
|
|
|
with open(opts.config) as f:
|
|
|
|
|
json_data = json.load(f)
|
|
|
|
|
|
|
|
|
|
for step in (json_data or []):
|
|
|
|
|
if step is None:
|
|
|
|
|
continue
|
|
|
|
|
print step
|
|
|
|
|
for container in (json_data[step] or []):
|
|
|
|
|
print('\tcontainer: %s' % container)
|
|
|
|
|
for container_data in (json_data[step][container] or []):
|
|
|
|
|
#print('\t\tcontainer_data: %s' % container_data)
|
|
|
|
|
if container_data == "start_order":
|
|
|
|
|
print('\t\tstart_order: %s' % json_data[step][container][container_data])
|
|
|
|
|
|
|
|
|
@ -189,4 +194,3 @@ if opts.container:
|
|
|
|
|
run_docker_container(opts, opts.container)
|
|
|
|
|
else:
|
|
|
|
|
list_docker_containers(opts)
|
|
|
|
|
|
|
|
|
|