Adds transitional deprecation code for old dashboard names.

This code allows users who upgrade from Folsom to Grizzly to
continue using their old settings file until H.

The code is in the settings file because it must be run prior
to the modules listed in INSTALLED_APPS being loaded into the
python path.

Fixes bug 1071444.

Change-Id: I7ac30b731be3cdc7513e3d6bc34d624963bbea9b
This commit is contained in:
Gabriel Hurley 2012-11-20 20:33:09 -08:00
parent 699469827b
commit 86427b83d6

View File

@ -21,9 +21,13 @@
import logging
import os
import sys
import warnings
from openstack_dashboard import exceptions
warnings.formatwarning = lambda message, category, *args, **kwargs: \
'%s: %s' % (category.__name__, message)
ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
BIN_DIR = os.path.abspath(os.path.join(ROOT_PATH, '..', 'bin'))
@ -163,10 +167,38 @@ OPENSTACK_KEYSTONE_DEFAULT_ROLE = 'Member'
DEFAULT_EXCEPTION_REPORTER_FILTER = 'horizon.exceptions.HorizonReporterFilter'
if DEBUG:
logging.basicConfig(level=logging.DEBUG)
try:
from local.local_settings import *
except ImportError:
logging.warning("No local_settings file found.")
if DEBUG:
logging.basicConfig(level=logging.DEBUG)
# Deprecation for Essex/Folsom dashboard names; remove this code in H.
_renames = (
('horizon.dashboards.nova', 'openstack_dashboard.dashboards.project'),
('horizon.dashboards.syspanel', 'openstack_dashboard.dashboards.admin'),
('horizon.dashboards.settings', 'openstack_dashboard.dashboards.settings')
)
INSTALLED_APPS = list(INSTALLED_APPS)
_dashboards = list(HORIZON_CONFIG['dashboards'])
for old, new in _renames:
if old in INSTALLED_APPS:
warnings.warn('The "%s" package is deprecated. Please update your '
'INSTALLED_APPS setting to use the new "%s" package.\n'
% (old, new), Warning)
INSTALLED_APPS[INSTALLED_APPS.index(old)] = new
_old_name = old.split(".")[-1]
if _old_name in HORIZON_CONFIG['dashboards'] and _old_name != "settings":
_new_name = new.split(".")[-1]
warnings.warn('The "%s" dashboard name is deprecated. Please update '
'your HORIZON_CONFIG["dashboards"] setting to use the '
'new "%s" dashboard name.\n' % (_old_name, _new_name),
Warning)
_dashboards[_dashboards.index(_old_name)] = _new_name
HORIZON_CONFIG['dashboards'] = _dashboards