Quieter log output when recreating

Moved log stuff to Service, which I think makes more sense anyway.
Maybe.
This commit is contained in:
Aanand Prasad 2014-01-15 18:06:49 +00:00
parent ea4753c49a
commit 8c583d1bb2
2 changed files with 6 additions and 7 deletions

View File

@ -1,8 +1,5 @@
from __future__ import unicode_literals
from __future__ import absolute_import
import logging
log = logging.getLogger(__name__)
class Container(object):
"""
@ -91,19 +88,15 @@ class Container(object):
return self.dictionary['State']['Running']
def start(self, **options):
log.info("Starting %s..." % self.name)
return self.client.start(self.id, **options)
def stop(self, **options):
log.info("Stopping %s..." % self.name)
return self.client.stop(self.id, **options)
def kill(self):
log.info("Killing %s..." % self.name)
return self.client.kill(self.id)
def remove(self):
log.info("Removing %s..." % self.name)
return self.client.remove_container(self.id)
def inspect_if_not_inspected(self):

View File

@ -43,19 +43,23 @@ class Service(object):
def start(self, **options):
for c in self.containers(stopped=True):
if not c.is_running:
log.info("Starting %s..." % c.name)
self.start_container(c, **options)
def stop(self, **options):
for c in self.containers():
log.info("Stopping %s..." % c.name)
c.stop(**options)
def kill(self, **options):
for c in self.containers():
log.info("Killing %s..." % c.name)
c.kill(**options)
def remove_stopped(self, **options):
for c in self.containers(stopped=True):
if not c.is_running:
log.info("Removing %s..." % c.name)
c.remove(**options)
def create_container(self, one_off=False, **override_options):
@ -81,12 +85,14 @@ class Service(object):
containers = self.containers(stopped=True)
if len(containers) == 0:
log.info("Creating %s..." % self.next_container_name())
return ([], [self.create_container(**override_options)])
else:
old_containers = []
new_containers = []
for c in containers:
log.info("Recreating %s..." % c.name)
(old_container, new_container) = self.recreate_container(c, **override_options)
old_containers.append(old_container)
new_containers.append(new_container)