Skip to content

Commit

Permalink
Adds transitional deprecation code for old dashboard names.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gabrielhurley committed Nov 21, 2012
1 parent 6994698 commit 86427b8
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions openstack_dashboard/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'))

Expand Down Expand Up @@ -163,10 +167,38 @@

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

0 comments on commit 86427b8

Please sign in to comment.