Merge "Fix keystone v3 support with swift backend"

This commit is contained in:
Zuul 2018-03-09 09:19:18 +00:00 committed by Gerrit Code Review
commit 9445cf8155
7 changed files with 61 additions and 18 deletions

View File

@ -384,6 +384,7 @@ class IdentityServiceContext(OSContextGenerator):
# so a missing value just indicates keystone needs
# upgrading
ctxt['admin_tenant_id'] = rdata.get('service_tenant_id')
ctxt['admin_domain_id'] = rdata.get('service_domain_id')
return ctxt
return {}

View File

@ -317,8 +317,7 @@ def keystone_changed():
juju_log('identity-service relation incomplete. Peer not ready?')
return
CONFIGS.write(GLANCE_API_CONF)
CONFIGS.write(GLANCE_REGISTRY_CONF)
CONFIGS.write_all()
# Configure any object-store / swift relations now that we have an
# identity-service

View File

@ -99,6 +99,7 @@ CHARM = "glance"
GLANCE_CONF_DIR = "/etc/glance"
GLANCE_REGISTRY_CONF = "%s/glance-registry.conf" % GLANCE_CONF_DIR
GLANCE_API_CONF = "%s/glance-api.conf" % GLANCE_CONF_DIR
GLANCE_SWIFT_CONF = "%s/glance-swift.conf" % GLANCE_CONF_DIR
GLANCE_REGISTRY_PASTE = os.path.join(GLANCE_CONF_DIR,
'glance-registry-paste.ini')
GLANCE_API_PASTE = os.path.join(GLANCE_CONF_DIR,
@ -170,6 +171,13 @@ CONFIG_FILES = OrderedDict([
context.MemcacheContext()],
'services': ['glance-api']
}),
(GLANCE_SWIFT_CONF, {
'hook_contexts': [glance_contexts.ObjectStoreContext(),
context.IdentityServiceContext(
service='glance',
service_user='glance')],
'services': ['glance-api']
}),
(ceph_config_file(), {
'hook_contexts': [context.CephContext()],
'services': ['glance-api', 'glance-registry']
@ -195,6 +203,7 @@ def register_configs():
# Regstration of some configs may not be required depending on
# existing of certain relations.
release = os_release('glance-common')
cmp_release = CompareOpenStackReleases(release)
configs = templating.OSConfigRenderer(templates_dir=TEMPLATES,
openstack_release=release)
@ -228,6 +237,10 @@ def register_configs():
if enable_memcache(release=release):
configs.register(MEMCACHED_CONF, [context.MemcacheContext()])
if cmp_release >= 'mitaka':
configs.register(GLANCE_SWIFT_CONF,
CONFIG_FILES[GLANCE_SWIFT_CONF]['hook_contexts'])
return configs

View File

@ -54,15 +54,9 @@ default_store = file
{% endif -%}
{% if swift_store -%}
swift_store_auth_version = 2
swift_store_auth_address = {{ service_protocol }}://{{ service_host }}:{{ service_port }}/v2.0/
swift_store_user = {{ admin_tenant_name }}:{{ admin_user }}
swift_store_key = {{ admin_password }}
swift_store_create_container_on_put = True
swift_store_container = glance
swift_store_large_object_size = 5120
swift_store_large_object_chunk_size = 200
swift_enable_snet = False
default_swift_reference = swift
swift_store_config_file = /etc/glance/glance-swift.conf
swift_store_create_container_on_put = true
{% endif -%}
{% if rbd_pool -%}

View File

@ -0,0 +1,21 @@
{% if swift_store -%}
[swift]
{% if api_version == "3" -%}
auth_version = 3
auth_address = {{ service_protocol }}://{{ service_host }}:{{ service_port }}/v3
{% else -%}
auth_version = 2
auth_address = {{ service_protocol }}://{{ service_host }}:{{ service_port }}/v2.0
{% endif -%}
user = {{ admin_tenant_name }}:{{ admin_user }}
key = {{ admin_password }}
{% if api_version == "3" -%}
project_domain_name = {{ admin_domain_name }}
project_domain_id = {{ admin_domain_id }}
user_domain_name = {{ admin_domain_name }}
user_domain_id = {{ admin_domain_id }}
{% endif -%}
container = glance
large_object_size = 5120
large_object_chunk_size = 200
{% endif -%}

View File

@ -459,9 +459,7 @@ class GlanceRelationTests(CharmTestCase):
configs.write = MagicMock()
self.relation_ids.return_value = []
relations.keystone_changed()
self.assertEqual([call('/etc/glance/glance-api.conf'),
call('/etc/glance/glance-registry.conf')],
configs.write.call_args_list)
configs.write_all.assert_called_once()
self.assertTrue(configure_https.called)
@patch.object(relations, 'image_service_joined')
@ -481,9 +479,7 @@ class GlanceRelationTests(CharmTestCase):
['image-service:0'],
]
relations.keystone_changed()
self.assertEqual([call('/etc/glance/glance-api.conf'),
call('/etc/glance/glance-registry.conf')],
configs.write.call_args_list)
configs.write_all.assert_called_once()
object_store_joined.assert_called_with()
self.assertTrue(configure_https.called)
image_service_joined.assert_called_with('image-service:0')

View File

@ -119,6 +119,24 @@ class TestGlanceUtils(CharmTestCase):
configs.register.assert_has_calls(calls, any_order=True)
self.mkdir.assert_called_with('/etc/ceph')
@patch('os.path.exists')
def test_register_configs_mitaka(self, exists):
exists.return_value = True
self.os_release.return_value = 'mitaka'
self.relation_ids.return_value = False
configs = utils.register_configs()
calls = []
for conf in [utils.GLANCE_REGISTRY_CONF,
utils.GLANCE_API_CONF,
utils.GLANCE_SWIFT_CONF,
utils.HAPROXY_CONF,
utils.HTTPS_APACHE_24_CONF]:
calls.append(
call(conf,
utils.CONFIG_FILES[conf]['hook_contexts'])
)
configs.register.assert_has_calls(calls, any_order=True)
def test_restart_map(self):
self.enable_memcache.return_value = True
self.config.side_effect = None
@ -127,12 +145,13 @@ class TestGlanceUtils(CharmTestCase):
ex_map = OrderedDict([
(utils.GLANCE_REGISTRY_CONF, ['glance-registry']),
(utils.GLANCE_API_CONF, ['glance-api']),
(utils.GLANCE_SWIFT_CONF, ['glance-api']),
(utils.ceph_config_file(), ['glance-api', 'glance-registry']),
(utils.HAPROXY_CONF, ['haproxy']),
(utils.HTTPS_APACHE_CONF, ['apache2']),
(utils.HTTPS_APACHE_24_CONF, ['apache2']),
(utils.MEMCACHED_CONF, ['memcached']),
(utils.GLANCE_POLICY_FILE, ['glance-api', 'glance-registry'])
(utils.GLANCE_POLICY_FILE, ['glance-api', 'glance-registry']),
])
self.assertEqual(ex_map, utils.restart_map())
self.enable_memcache.return_value = False