Move keep_old check up into Project
Signed-off-by: Chris Corbyn <chris@w3style.co.uk>
This commit is contained in:
parent
a04143e2a7
commit
ab1fbc96c3
4 changed files with 48 additions and 54 deletions
|
|
@ -154,7 +154,7 @@ class Service(object):
|
|||
return Container.create(self.client, **container_options)
|
||||
raise
|
||||
|
||||
def recreate_containers(self, keep_old=False, **override_options):
|
||||
def recreate_containers(self, **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.
|
||||
|
|
@ -166,8 +166,6 @@ class Service(object):
|
|||
container = self.create_container(**override_options)
|
||||
self.start_container(container)
|
||||
return [(None, container)]
|
||||
elif keep_old:
|
||||
return [(None, self.start_container_if_stopped(c)) for c in containers]
|
||||
else:
|
||||
tuples = []
|
||||
|
||||
|
|
@ -249,6 +247,16 @@ class Service(object):
|
|||
)
|
||||
return container
|
||||
|
||||
def start_or_create_containers(self):
|
||||
containers = self.containers(stopped=True)
|
||||
|
||||
if len(containers) == 0:
|
||||
log.info("Creating %s..." % self.next_container_name())
|
||||
new_container = self.create_container()
|
||||
return [self.start_container(new_container)]
|
||||
else:
|
||||
return [self.start_container_if_stopped(c) for c in containers]
|
||||
|
||||
def get_linked_names(self):
|
||||
return [s.name for (s, _) in self.links]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue