Don't recreate pre-existing volumes.

During the initialize_volumes phase, if a volume using the
non-namespaced name already exists, don't create the namespaced
equivalent.

Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
Joffrey F 2016-01-04 15:10:32 -08:00
commit 05935b5e54
4 changed files with 51 additions and 2 deletions

View file

@ -1,6 +1,8 @@
from __future__ import absolute_import
from __future__ import unicode_literals
from docker.errors import NotFound
class Volume(object):
def __init__(self, client, project, name, driver=None, driver_opts=None):
@ -21,6 +23,15 @@ class Volume(object):
def inspect(self):
return self.client.inspect_volume(self.full_name)
@property
def is_user_created(self):
try:
self.client.inspect_volume(self.name)
except NotFound:
return False
return True
@property
def full_name(self):
return '{0}_{1}'.format(self.project, self.name)