Merge "Add OpenStack Queens support"
This commit is contained in:
commit
30f637bc55
|
@ -146,10 +146,11 @@ options:
|
|||
description: Enable PKI token signing.
|
||||
preferred-api-version:
|
||||
type: int
|
||||
default: 2
|
||||
default:
|
||||
description: |
|
||||
Use this keystone api version for keystone endpoints and advertise this
|
||||
version to identity client charms.
|
||||
version to identity client charms. For OpenStack releases < Queens this
|
||||
option defaults to 2; for Queens or later it defaults to 3.
|
||||
haproxy-server-timeout:
|
||||
type: int
|
||||
default:
|
||||
|
|
|
@ -291,11 +291,11 @@ class KeystoneContext(context.OSContextGenerator):
|
|||
from keystone_utils import (
|
||||
api_port, set_admin_token, endpoint_url, resolve_address,
|
||||
PUBLIC, ADMIN, PKI_CERTS_DIR, ensure_pki_cert_paths, ADMIN_DOMAIN,
|
||||
snap_install_requested,
|
||||
snap_install_requested, get_api_version,
|
||||
)
|
||||
ctxt = {}
|
||||
ctxt['token'] = set_admin_token(config('admin-token'))
|
||||
ctxt['api_version'] = int(config('preferred-api-version'))
|
||||
ctxt['api_version'] = get_api_version()
|
||||
ctxt['admin_role'] = config('admin-role')
|
||||
if ctxt['api_version'] > 2:
|
||||
ctxt['service_tenant_id'] = \
|
||||
|
|
|
@ -1148,7 +1148,18 @@ def set_admin_passwd(passwd, user=None):
|
|||
|
||||
def get_api_version():
|
||||
api_version = config('preferred-api-version')
|
||||
if api_version not in [2, 3]:
|
||||
cmp_release = CompareOpenStackReleases(
|
||||
get_os_codename_install_source(config('openstack-origin'))
|
||||
)
|
||||
if not api_version:
|
||||
# NOTE(jamespage): Queens dropped support for v2, so default
|
||||
# to v3.
|
||||
if cmp_release >= 'queens':
|
||||
api_version = 3
|
||||
else:
|
||||
api_version = 2
|
||||
if ((cmp_release < 'queens' and api_version not in [2, 3]) or
|
||||
(cmp_release >= 'queens' and api_version != 3)):
|
||||
raise ValueError('Bad preferred-api-version')
|
||||
return api_version
|
||||
|
||||
|
|
|
@ -107,6 +107,7 @@ class TestKeystoneUtils(CharmTestCase):
|
|||
'contexts': [self.ctxt],
|
||||
}
|
||||
}
|
||||
self.get_os_codename_install_source.return_value = 'icehouse'
|
||||
|
||||
@patch('charmhelpers.contrib.openstack.templating.OSConfigRenderer')
|
||||
@patch('os.path.exists')
|
||||
|
@ -1357,3 +1358,21 @@ class TestKeystoneUtils(CharmTestCase):
|
|||
def test_run_in_apache_set_release(self):
|
||||
self.os_release.return_value = 'kilo'
|
||||
self.assertTrue(utils.run_in_apache(release='liberty'))
|
||||
|
||||
def test_get_api_version_icehouse(self):
|
||||
self.assertEqual(utils.get_api_version(), 2)
|
||||
|
||||
def test_get_api_version_queens(self):
|
||||
self.get_os_codename_install_source.return_value = 'queens'
|
||||
self.assertEqual(utils.get_api_version(), 3)
|
||||
|
||||
def test_get_api_version_invalid_option_value(self):
|
||||
self.test_config.set('preferred-api-version', 4)
|
||||
with self.assertRaises(ValueError):
|
||||
utils.get_api_version()
|
||||
|
||||
def test_get_api_version_queens_invalid_option_value(self):
|
||||
self.test_config.set('preferred-api-version', 2)
|
||||
self.get_os_codename_install_source.return_value = 'queens'
|
||||
with self.assertRaises(ValueError):
|
||||
utils.get_api_version()
|
||||
|
|
Loading…
Reference in New Issue