Implement new option: filesystem-store-datadir

This change implements a new option in config.yaml that can be used
to change the location of the images store on the filesystem.

Change-Id: I0d8e7409b8eb4e5e403455db03d73020f741afc4
Closes-Bug: #1657165
This commit is contained in:
Andre Ruiz 2019-02-19 15:36:22 -03:00
parent 211ac1ec6e
commit 6e6b492485
7 changed files with 32 additions and 5 deletions

View File

@ -337,3 +337,14 @@ options:
description: |
A comma-separated list of nagios service groups.
If left empty, the nagios_context will be used as the servicegroup
filesystem-store-datadir:
type: string
default: "/var/lib/glance/images/"
description: |
Directory to which the filesystem backend store writes images.
Upon start up, Glance creates the directory if it doesnt already exist
and verifies write access to the user under which glance-api runs. If
the write access isnt available, a BadStoreConfiguration exception is
raised and the filesystem store may not be available for adding new
images. NOTE: This directory is used only when filesystem store is used
as a storage backend.

View File

@ -53,6 +53,10 @@ class GlanceContext(OSContextGenerator):
if config('container-formats'):
ctxt['container_formats'] = config('container-formats')
if config('filesystem-store-datadir'):
ctxt['filesystem_store_datadir'] = (
config('filesystem-store-datadir'))
image_size_cap = config('image-size-cap')
if image_size_cap:
try:

View File

@ -50,7 +50,7 @@ image_size_cap = {{ image_size_cap }}
notification_driver = rabbit
{% endif -%}
filesystem_store_datadir = /var/lib/glance/images/
filesystem_store_datadir = {{ filesystem_store_datadir }}
{% if swift_store -%}
swift_store_auth_version = 2

View File

@ -53,7 +53,7 @@ image_size_cap = {{ image_size_cap }}
notification_driver = rabbit
{% endif -%}
filesystem_store_datadir = /var/lib/glance/images/
filesystem_store_datadir = {{ filesystem_store_datadir }}
{% if swift_store -%}
swift_store_auth_version = 2

View File

@ -50,7 +50,8 @@ image_size_cap = {{ image_size_cap }}
{% endif -%}
[glance_store]
filesystem_store_datadir = /var/lib/glance/images/
filesystem_store_datadir = {{ filesystem_store_datadir }}
stores = {{ known_stores }}
{% if rbd_pool -%}
default_store = rbd

View File

@ -45,7 +45,9 @@ image_size_cap = {{ image_size_cap }}
{%- if use_internal_endpoints %}
catalog_info = {{ volume_catalog_info }}
{%- endif %}
filesystem_store_datadir = /var/lib/glance/images/
filesystem_store_datadir = {{ filesystem_store_datadir }}
stores = {{ known_stores }}
{% if rbd_pool -%}
default_store = rbd

View File

@ -42,29 +42,38 @@ class TestGlanceContexts(CharmTestCase):
config = {
'disk-formats': 'dfmt1',
'container-formats': '',
'filesystem-store-datadir': "/var/lib/glance/images/",
'image-size-cap': ''}
self.config.side_effect = lambda x: config[x]
self.assertEqual(contexts.GlanceContext()(), {'disk_formats': 'dfmt1'})
self.assertEqual(contexts.GlanceContext()(), {
'disk_formats': 'dfmt1',
'filesystem_store_datadir': "/var/lib/glance/images/"})
def test_glance_context_container_fmt(self):
config = {
'disk-formats': 'dfmt1',
'container-formats': 'cmft1',
'filesystem-store-datadir': "/var/lib/glance/images/",
'image-size-cap': ''}
self.config.side_effect = lambda x: config[x]
self.assertEqual(contexts.GlanceContext()(),
{'disk_formats': 'dfmt1',
'filesystem_store_datadir':
"/var/lib/glance/images/",
'container_formats': 'cmft1'})
def test_glance_context_image_size_cap(self):
config = {
'disk-formats': 'dfmt1',
'container-formats': 'cmft1',
'filesystem-store-datadir': "/var/lib/glance/images/",
'image-size-cap': '1TB'}
self.config.side_effect = lambda x: config[x]
self.assertEqual(contexts.GlanceContext()(),
{'disk_formats': 'dfmt1',
'container_formats': 'cmft1',
'filesystem_store_datadir':
"/var/lib/glance/images/",
'image_size_cap': 1099511627776})
def test_swift_not_related(self):