Add parameters to cinder backend configuration
Add configuration parameters cinder_store_user_name, cinder_store_password, cinder_store_project_name and cinder_store_auth_address to cinder volume type backend configuration. This avoids a glance_store bug that prevents glance-api from starting. Closes-Bug: #2052726 Change-Id: I4b6ca32ed426f77a326711c2457046dbda594e77
This commit is contained in:
parent
d9e52f7869
commit
da1636dedc
|
@ -33,6 +33,7 @@ from charmhelpers.contrib.openstack.context import (
|
||||||
ApacheSSLContext as SSLContext,
|
ApacheSSLContext as SSLContext,
|
||||||
BindHostContext,
|
BindHostContext,
|
||||||
VolumeAPIContext,
|
VolumeAPIContext,
|
||||||
|
IdentityServiceContext,
|
||||||
)
|
)
|
||||||
|
|
||||||
from charmhelpers.contrib.hahelpers.cluster import (
|
from charmhelpers.contrib.hahelpers.cluster import (
|
||||||
|
@ -318,6 +319,13 @@ class MultiBackendContext(OSContextGenerator):
|
||||||
|
|
||||||
return cinder_ctx
|
return cinder_ctx
|
||||||
|
|
||||||
|
def _get_keystone_config(self):
|
||||||
|
keystone_ctx = IdentityServiceContext()()
|
||||||
|
if not keystone_ctx:
|
||||||
|
return
|
||||||
|
|
||||||
|
return keystone_ctx
|
||||||
|
|
||||||
def __call__(self):
|
def __call__(self):
|
||||||
ctxt = {
|
ctxt = {
|
||||||
"enabled_backend_configs": {},
|
"enabled_backend_configs": {},
|
||||||
|
@ -367,6 +375,7 @@ class MultiBackendContext(OSContextGenerator):
|
||||||
# backend cinder_volume_type should be left blank so that glance
|
# backend cinder_volume_type should be left blank so that glance
|
||||||
# creates volume in cinder without specifying any volume type.
|
# creates volume in cinder without specifying any volume type.
|
||||||
if cinder_volume_types:
|
if cinder_volume_types:
|
||||||
|
keystone_ctx = self._get_keystone_config()
|
||||||
for volume_type in volume_types:
|
for volume_type in volume_types:
|
||||||
ctxt['enabled_backend_configs'][volume_type] = {
|
ctxt['enabled_backend_configs'][volume_type] = {
|
||||||
'cinder_volume_type': volume_type,
|
'cinder_volume_type': volume_type,
|
||||||
|
@ -374,6 +383,17 @@ class MultiBackendContext(OSContextGenerator):
|
||||||
'cinder_state_transition_timeout': config(
|
'cinder_state_transition_timeout': config(
|
||||||
'cinder-state-transition-timeout'),
|
'cinder-state-transition-timeout'),
|
||||||
}
|
}
|
||||||
|
if keystone_ctx:
|
||||||
|
ctxt['enabled_backend_configs'][volume_type].update({
|
||||||
|
'cinder_store_user_name': keystone_ctx.get(
|
||||||
|
'admin_user'),
|
||||||
|
'cinder_store_password': keystone_ctx.get(
|
||||||
|
'admin_password'),
|
||||||
|
'cinder_store_project_name': keystone_ctx.get(
|
||||||
|
'admin_tenant_name'),
|
||||||
|
'cinder_store_auth_address': keystone_ctx.get(
|
||||||
|
'keystone_authtoken').get('auth_url'),
|
||||||
|
})
|
||||||
else:
|
else:
|
||||||
# default cinder volume type cinder
|
# default cinder volume type cinder
|
||||||
ctxt['enabled_backend_configs']['cinder'] = {
|
ctxt['enabled_backend_configs']['cinder'] = {
|
||||||
|
|
|
@ -389,7 +389,9 @@ class TestGlanceContexts(CharmTestCase):
|
||||||
'default_store_backend': 'cinder',
|
'default_store_backend': 'cinder',
|
||||||
})
|
})
|
||||||
|
|
||||||
def test_multi_backend_with_cinder_volume_types_defined(self):
|
@patch('charmhelpers.contrib.openstack.context.IdentityServiceContext\
|
||||||
|
.__call__')
|
||||||
|
def test_multi_backend_with_cinder_volume_types_defined(self, keystone):
|
||||||
# return relation_ids only for cinder but not for swift
|
# return relation_ids only for cinder but not for swift
|
||||||
def _relation_ids(*args, **kwargs):
|
def _relation_ids(*args, **kwargs):
|
||||||
if args[0] == 'cinder-volume-service':
|
if args[0] == 'cinder-volume-service':
|
||||||
|
@ -399,6 +401,12 @@ class TestGlanceContexts(CharmTestCase):
|
||||||
|
|
||||||
self.maxDiff = None
|
self.maxDiff = None
|
||||||
self.relation_ids.side_effect = _relation_ids
|
self.relation_ids.side_effect = _relation_ids
|
||||||
|
keystone.return_value = {
|
||||||
|
'admin_user': 'user',
|
||||||
|
'admin_password': 'password',
|
||||||
|
'admin_tenant_name': 'services',
|
||||||
|
'keystone_authtoken': {'auth_url': 'http://10.0.0.1:35357/v3'},
|
||||||
|
}
|
||||||
self.is_relation_made.return_value = False
|
self.is_relation_made.return_value = False
|
||||||
data_dir = '/some/data/dir'
|
data_dir = '/some/data/dir'
|
||||||
conf_dict = {
|
conf_dict = {
|
||||||
|
@ -420,6 +428,11 @@ class TestGlanceContexts(CharmTestCase):
|
||||||
'cinder_volume_type': 'volume-type-test',
|
'cinder_volume_type': 'volume-type-test',
|
||||||
'cinder_http_retries': 3,
|
'cinder_http_retries': 3,
|
||||||
'cinder_state_transition_timeout': 30,
|
'cinder_state_transition_timeout': 30,
|
||||||
|
'cinder_store_user_name': 'user',
|
||||||
|
'cinder_store_password': 'password',
|
||||||
|
'cinder_store_project_name': 'services',
|
||||||
|
'cinder_store_auth_address':
|
||||||
|
'http://10.0.0.1:35357/v3',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'enabled_backends': 'local:file, volume-type-test:cinder',
|
'enabled_backends': 'local:file, volume-type-test:cinder',
|
||||||
|
|
Loading…
Reference in New Issue