Remove unused intermediate_container from return value.

Signed-off-by: Daniel Nephin <dnephin@gmail.com>
This commit is contained in:
Daniel Nephin 2014-12-06 14:20:29 -05:00 committed by Daniel Nephin
commit 26f45efea2
3 changed files with 27 additions and 36 deletions

View file

@ -176,18 +176,14 @@ class Project(object):
do_build=True):
running_containers = []
for service in self.get_services(service_names, include_links=start_links):
if recreate:
for (_, container) in service.recreate_containers(
insecure_registry=insecure_registry,
create_func = (service.recreate_containers if recreate
else service.start_or_create_containers)
for container in create_func(
insecure_registry=insecure_registry,
detach=detach,
do_build=do_build):
running_containers.append(container)
else:
for container in service.start_or_create_containers(
insecure_registry=insecure_registry,
detach=detach,
do_build=do_build):
running_containers.append(container)
running_containers.append(container)
return running_containers

View file

@ -242,8 +242,9 @@ class Service(object):
def recreate_containers(self, insecure_registry=False, do_build=True, **override_options):
"""
If a container for this service doesn't exist, create and start one. If there are
any, stop them, create+start new ones, and remove the old containers.
If a container for this service doesn't exist, create and start one. If
there are any, stop them, create+start new ones, and remove the old
containers.
"""
containers = self.containers(stopped=True)
if not containers:
@ -253,21 +254,22 @@ class Service(object):
do_build=do_build,
**override_options)
self.start_container(container)
return [(None, container)]
return [container]
else:
tuples = []
for c in containers:
log.info("Recreating %s..." % c.name)
tuples.append(self.recreate_container(c, insecure_registry=insecure_registry, **override_options))
return tuples
return [
self.recreate_container(
container,
insecure_registry=insecure_registry,
**override_options)
for container in containers
]
def recreate_container(self, container, **override_options):
"""Recreate a container. An intermediate container is created so that
the new container has the same name, while still supporting
`volumes-from` the original container.
"""
log.info("Recreating %s..." % container.name)
try:
container.stop()
except APIError as e:
@ -295,7 +297,7 @@ class Service(object):
intermediate_container.remove()
return (intermediate_container, new_container)
return new_container
def start_container_if_stopped(self, container, **options):
if container.is_running: