Merge "Add support for image_size_cap in charm config"
This commit is contained in:
commit
f39ada5abf
11
config.yaml
11
config.yaml
|
@ -156,6 +156,17 @@ options:
|
|||
default: ami,ari,aki,vhd,vmdk,raw,qcow2,vdi,iso,root-tar
|
||||
description: |
|
||||
Comma separated list of disk formats that Glance will support.
|
||||
image-size-cap:
|
||||
type: string
|
||||
default: 1TB
|
||||
description: |
|
||||
Maximum size of image a user can upload. Defaults to 1TB
|
||||
(1099511627776 bytes). Example values: 500M, 500MB, 5G, 5TB.
|
||||
Valid units: K, KB, M, MB, G, GB, T, TB, P, PB. If no units provided,
|
||||
bytes are assumed.
|
||||
.
|
||||
WARNING: this value should only be increased after careful consideration
|
||||
and must be set to a value under 8EB (9223372036854775808 bytes).
|
||||
# HA configuration settings
|
||||
dns-ha:
|
||||
type: boolean
|
||||
|
|
|
@ -12,13 +12,19 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from charmhelpers.core.strutils import (
|
||||
bytes_from_string
|
||||
)
|
||||
|
||||
from charmhelpers.core.hookenv import (
|
||||
is_relation_made,
|
||||
relation_ids,
|
||||
relation_get,
|
||||
related_units,
|
||||
service_name,
|
||||
config
|
||||
config,
|
||||
log as juju_log,
|
||||
ERROR
|
||||
)
|
||||
|
||||
from charmhelpers.contrib.openstack.context import (
|
||||
|
@ -46,6 +52,18 @@ class GlanceContext(OSContextGenerator):
|
|||
}
|
||||
if config('container-formats'):
|
||||
ctxt['container_formats'] = config('container-formats')
|
||||
|
||||
image_size_cap = config('image-size-cap')
|
||||
if image_size_cap:
|
||||
try:
|
||||
ctxt['image_size_cap'] = bytes_from_string(
|
||||
image_size_cap.replace(' ', '').upper())
|
||||
except (ValueError, KeyError):
|
||||
juju_log('Unable to parse value for image-size-cap ({}), '
|
||||
'see config.yaml for information about valid '
|
||||
'formatting'.format(config('image-size-cap')),
|
||||
level=ERROR)
|
||||
raise
|
||||
return ctxt
|
||||
|
||||
|
||||
|
|
|
@ -40,6 +40,10 @@ registry_client_protocol = http
|
|||
{% endfor -%}
|
||||
{% endif -%}
|
||||
|
||||
{% if image_size_cap -%}
|
||||
image_size_cap = {{ image_size_cap }}
|
||||
{% endif -%}
|
||||
|
||||
{% include "parts/rabbitmq" %}
|
||||
|
||||
{% if rabbitmq_host or rabbitmq_hosts -%}
|
||||
|
|
|
@ -43,6 +43,10 @@ registry_client_protocol = http
|
|||
{% endfor -%}
|
||||
{% endif -%}
|
||||
|
||||
{% if image_size_cap -%}
|
||||
image_size_cap = {{ image_size_cap }}
|
||||
{% endif -%}
|
||||
|
||||
{% include "parts/rabbitmq" %}
|
||||
|
||||
{% if rabbitmq_host or rabbitmq_hosts -%}
|
||||
|
|
|
@ -45,6 +45,10 @@ scrubber_datadir = /var/lib/glance/scrubber
|
|||
image_cache_dir = /var/lib/glance/image-cache/
|
||||
db_enforce_mysql_charset = False
|
||||
|
||||
{% if image_size_cap -%}
|
||||
image_size_cap = {{ image_size_cap }}
|
||||
{% endif -%}
|
||||
|
||||
[glance_store]
|
||||
filesystem_store_datadir = /var/lib/glance/images/
|
||||
stores = {{ known_stores }}
|
||||
|
|
|
@ -37,6 +37,10 @@ scrubber_datadir = /var/lib/glance/scrubber
|
|||
image_cache_dir = /var/lib/glance/image-cache/
|
||||
db_enforce_mysql_charset = False
|
||||
|
||||
{% if image_size_cap -%}
|
||||
image_size_cap = {{ image_size_cap }}
|
||||
{% endif -%}
|
||||
|
||||
[glance_store]
|
||||
{%- if use_internal_endpoints %}
|
||||
catalog_info = {{ volume_catalog_info }}
|
||||
|
|
|
@ -41,19 +41,32 @@ class TestGlanceContexts(CharmTestCase):
|
|||
def test_glance_context(self):
|
||||
config = {
|
||||
'disk-formats': 'dfmt1',
|
||||
'container-formats': ''}
|
||||
'container-formats': '',
|
||||
'image-size-cap': ''}
|
||||
self.config.side_effect = lambda x: config[x]
|
||||
self.assertEqual(contexts.GlanceContext()(), {'disk_formats': 'dfmt1'})
|
||||
|
||||
def test_glance_context_container_fmt(self):
|
||||
config = {
|
||||
'disk-formats': 'dfmt1',
|
||||
'container-formats': 'cmft1'}
|
||||
'container-formats': 'cmft1',
|
||||
'image-size-cap': ''}
|
||||
self.config.side_effect = lambda x: config[x]
|
||||
self.assertEqual(contexts.GlanceContext()(),
|
||||
{'disk_formats': 'dfmt1',
|
||||
'container_formats': 'cmft1'})
|
||||
|
||||
def test_glance_context_image_size_cap(self):
|
||||
config = {
|
||||
'disk-formats': 'dfmt1',
|
||||
'container-formats': 'cmft1',
|
||||
'image-size-cap': '1TB'}
|
||||
self.config.side_effect = lambda x: config[x]
|
||||
self.assertEqual(contexts.GlanceContext()(),
|
||||
{'disk_formats': 'dfmt1',
|
||||
'container_formats': 'cmft1',
|
||||
'image_size_cap': 1099511627776})
|
||||
|
||||
def test_swift_not_related(self):
|
||||
self.relation_ids.return_value = []
|
||||
self.assertEqual(contexts.ObjectStoreContext()(), {})
|
||||
|
|
Loading…
Reference in New Issue