Merge "Use charmhelpers OPENSTACK_RELEASES instead of internal KNOWN_RELEASES"

This commit is contained in:
Jenkins 2017-05-12 15:34:44 +00:00 committed by Gerrit Code Review
commit e67bce05d4
5 changed files with 33 additions and 46 deletions

View File

@ -29,7 +29,6 @@ import charmhelpers.contrib.openstack.utils as ch_utils
import charmhelpers.core.hookenv as hookenv
import charmhelpers.core.host as ch_host
import charms_openstack.ip as os_ip
import charms_openstack.os_release_data as os_release_data
ADDRESS_TYPES = os_ip.ADDRESS_MAP.keys()
@ -807,10 +806,10 @@ class APIConfigurationAdapter(ConfigurationAdapter):
def use_memcache(self):
release = ch_utils.get_os_codename_install_source(
self.openstack_origin)
if release not in os_release_data.KNOWN_RELEASES:
if release not in ch_utils.OPENSTACK_RELEASES:
return ValueError("Unkown release {}".format(release))
return (os_release_data.KNOWN_RELEASES.index(release) >=
os_release_data.KNOWN_RELEASES.index('mitaka'))
return (ch_utils.OPENSTACK_RELEASES.index(release) >=
ch_utils.OPENSTACK_RELEASES.index('mitaka'))
@property
def memcache_server(self):

View File

@ -44,7 +44,6 @@ import charms.reactive as reactive
import charms_openstack.adapters as os_adapters
import charms_openstack.ip as os_ip
import charms_openstack.os_release_data as os_release_data
# _releases{} is a dictionary of release -> class that is instantiated
@ -362,12 +361,12 @@ def get_charm_instance(release=None, *args, **kwargs):
cls = _releases[known_releases[-1]]
else:
# check that the release is a valid release
if release not in os_release_data.KNOWN_RELEASES:
if release not in os_utils.OPENSTACK_RELEASES:
raise RuntimeError(
"Release {} is not a known OpenStack release?".format(release))
release_index = os_release_data.KNOWN_RELEASES.index(release)
release_index = os_utils.OPENSTACK_RELEASES.index(release)
if (release_index <
os_release_data.KNOWN_RELEASES.index(known_releases[0])):
os_utils.OPENSTACK_RELEASES.index(known_releases[0])):
raise RuntimeError(
"Release {} is not supported by this charm. Earliest support "
"is {} release".format(release, known_releases[0]))
@ -375,7 +374,7 @@ def get_charm_instance(release=None, *args, **kwargs):
# try to find the release that is supported.
for known_release in reversed(known_releases):
if (release_index >=
os_release_data.KNOWN_RELEASES.index(known_release)):
os_utils.OPENSTACK_RELEASES.index(known_release)):
cls = _releases[known_release]
break
if cls is None:
@ -445,7 +444,7 @@ class OpenStackCharmMeta(type):
return
if 'release' in members.keys():
release = members['release']
if release not in os_release_data.KNOWN_RELEASES:
if release not in os_utils.OPENSTACK_RELEASES:
raise RuntimeError(
"Release {} is not a known OpenStack release"
.format(release))
@ -1260,10 +1259,10 @@ class OpenStackAPICharm(OpenStackCharm):
if not release:
release = os_utils.get_os_codename_install_source(
self.config['openstack-origin'])
if release not in os_release_data.KNOWN_RELEASES:
if release not in os_utils.OPENSTACK_RELEASES:
return ValueError("Unkown release {}".format(release))
return (os_release_data.KNOWN_RELEASES.index(release) >=
os_release_data.KNOWN_RELEASES.index('mitaka'))
return (os_utils.OPENSTACK_RELEASES.index(release) >=
os_utils.OPENSTACK_RELEASES.index('mitaka'))
def token_cache_pkgs(self, release=None):
"""Determine additional packages needed for token caching

View File

@ -1,33 +0,0 @@
# Copyright 2016 Canonical Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# OpenStackCharm() - base class for build OpenStack charms from for the
# reactive framework.
# need/want absolute imports for the package imports to work properly
KNOWN_RELEASES = [
'diablo',
'essex',
'folsom',
'grizzly',
'havana',
'icehouse',
'juno',
'kilo',
'liberty',
'mitaka',
'newton',
'ocata',
]

View File

@ -13,6 +13,9 @@ commands = ostestr {posargs}
[testenv:py27]
basepython = python2.7
deps = -r{toxinidir}/test-requirements.txt
# Py27 needs to be disabled as upstream charms.reactive is not Py3.5+ only
# However, we can't yet remove the actually py27 test from the gate.
commands = python -c "print('Py27 testing disabled.')" && /bin/true
[testenv:py34]
basepython = python3.4

View File

@ -41,6 +41,25 @@ sys.modules['charmhelpers.contrib.hahelpers'] = charmhelpers.contrib.hahelpers
sys.modules['charmhelpers.contrib.hahelpers.cluster'] = (
charmhelpers.contrib.hahelpers.cluster)
# mock in the openstack releases so that the tests can run
# Note that these don't need to be maintained UNLESS new functionality is for
# later OpenStack releases.
charmhelpers.contrib.openstack.utils.OPENSTACK_RELEASES = (
'diablo',
'essex',
'folsom',
'grizzly',
'havana',
'icehouse',
'juno',
'kilo',
'liberty',
'mitaka',
'newton',
'ocata',
'pike',
)
def _fake_retry(num_retries, base_delay=0, exc_type=Exception):
def _retry_on_exception_inner_1(f):