First set of changes toward shared base images.

This commit is contained in:
jakedt 2014-02-14 16:06:30 -05:00
parent 8794547593
commit 5742e6ea4e
3 changed files with 54 additions and 35 deletions

View file

@ -13,6 +13,7 @@ class Storage(object):
# the code which uses Storage
repositories = 'repositories'
images = 'images'
shared_images = 'sharedimages'
# Set the IO buffer to 64kB
buffer_size = 64 * 1024
@ -28,46 +29,45 @@ class Storage(object):
return tmpf, fn
#FIXME(samalba): Move all path resolver in each module (out of the base)
def images_list_path(self, namespace, repository):
return '{0}/{1}/{2}/_images_list'.format(self.repositories,
namespace,
repository)
def image_path(self, namespace, repository, image_id, storage_uuid):
if storage_uuid:
return '{0}/{1}/'.format(self.shared_images, storage_uuid)
else:
return '{0}/{1}/{2}/{3}/'.format(self.images, namespace, repository,
image_id)
def image_path(self, namespace, repository, image_id):
return '{0}/{1}/{2}/{3}/'.format(self.images, namespace, repository,
image_id)
def image_json_path(self, namespace, repository, image_id, storage_uuid):
base_path = self.image_path(namespace, repository, image_id, storage_uuid)
return '{0}/json'.format(base_path)
def image_json_path(self, namespace, repository, image_id):
return '{0}/{1}/{2}/{3}/json'.format(self.images, namespace,
repository, image_id)
def image_mark_path(self, namespace, repository, image_id, storage_uuid):
base_path = self.image_path(namespace, repository, image_id, storage_uuid)
return '{0}/_inprogress'.format(base_path)
def image_mark_path(self, namespace, repository, image_id):
return '{0}/{1}/{2}/{3}/_inprogress'.format(self.images, namespace,
repository, image_id)
def image_checksum_path(self, namespace, repository, image_id, storage_uuid):
base_path = self.image_path(namespace, repository, image_id, storage_uuid)
return '{0}/_checksum'.format(base_path)
def image_checksum_path(self, namespace, repository, image_id):
return '{0}/{1}/{2}/{3}/_checksum'.format(self.images, namespace,
repository, image_id)
def image_layer_path(self, namespace, repository, image_id, storage_uuid):
base_path = self.image_path(namespace, repository, image_id, storage_uuid)
return '{0}/layer'.format(base_path)
def image_layer_path(self, namespace, repository, image_id):
return '{0}/{1}/{2}/{3}/layer'.format(self.images, namespace,
repository, image_id)
def image_ancestry_path(self, namespace, repository, image_id):
return '{0}/{1}/{2}/{3}/ancestry'.format(self.images, namespace,
repository, image_id)
def image_ancestry_path(self, namespace, repository, image_id, storage_uuid):
base_path = self.image_path(namespace, repository, image_id, storage_uuid)
return '{0}/ancestry'.format(base_path)
def repository_namespace_path(self, namespace, repository):
return '{0}/{1}/{2}/'.format(self.images, namespace, repository)
def image_file_trie_path(self, namespace, repository, image_id):
return '{0}/{1}/{2}/{3}/files.trie'.format(self.images, namespace,
repository, image_id)
def image_file_trie_path(self, namespace, repository, image_id,
storage_uuid):
base_path = self.image_path(namespace, repository, image_id, storage_uuid)
return '{0}/files.trie'.format(base_path)
def image_file_diffs_path(self, namespace, repository, image_id):
return '{0}/{1}/{2}/{3}/diffs.json'.format(self.images, namespace,
repository, image_id)
def image_file_diffs_path(self, namespace, repository, image_id,
storage_uuid):
base_path = self.image_path(namespace, repository, image_id, storage_uuid)
return '{0}/diffs.json'.format(base_path)
def get_direct_download_url(self, path, expires_in=60):
return None