mirror of https://github.com/docker/docs.git
Move rename functionality into Container
Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
This commit is contained in:
parent
bee063c07d
commit
30a84f1be6
|
@ -192,6 +192,15 @@ class Container(object):
|
||||||
def remove(self, **options):
|
def remove(self, **options):
|
||||||
return self.client.remove_container(self.id, **options)
|
return self.client.remove_container(self.id, **options)
|
||||||
|
|
||||||
|
def rename_to_tmp_name(self):
|
||||||
|
"""Rename the container to a hopefully unique temporary container name
|
||||||
|
by prepending the short id.
|
||||||
|
"""
|
||||||
|
self.client.rename(
|
||||||
|
self.id,
|
||||||
|
'%s_%s' % (self.short_id, self.name)
|
||||||
|
)
|
||||||
|
|
||||||
def inspect_if_not_inspected(self):
|
def inspect_if_not_inspected(self):
|
||||||
if not self.has_been_inspected:
|
if not self.has_been_inspected:
|
||||||
self.inspect()
|
self.inspect()
|
||||||
|
|
|
@ -446,13 +446,6 @@ class Service(object):
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def _recreate_rename_container(self, container):
|
|
||||||
# Use a hopefully unique container name by prepending the short id
|
|
||||||
self.client.rename(
|
|
||||||
container.id,
|
|
||||||
'%s_%s' % (container.short_id, container.name)
|
|
||||||
)
|
|
||||||
|
|
||||||
def recreate_container(self,
|
def recreate_container(self,
|
||||||
container,
|
container,
|
||||||
timeout=DEFAULT_TIMEOUT,
|
timeout=DEFAULT_TIMEOUT,
|
||||||
|
@ -466,7 +459,7 @@ class Service(object):
|
||||||
log.info("Recreating %s" % container.name)
|
log.info("Recreating %s" % container.name)
|
||||||
|
|
||||||
self._recreate_stop_container(container, timeout)
|
self._recreate_stop_container(container, timeout)
|
||||||
self._recreate_rename_container(container)
|
container.rename_to_tmp_name()
|
||||||
new_container = self.create_container(
|
new_container = self.create_container(
|
||||||
do_build=False,
|
do_build=False,
|
||||||
previous_container=container,
|
previous_container=container,
|
||||||
|
|
Loading…
Reference in New Issue