Permalink
Browse files

Merge "Adds transitional deprecation code for old dashboard names."

  • Loading branch information...
2 parents 76ef256 + 86427b8 commit e6d3c23943a11357ffc755f8052894e15d8dfc1a Jenkins committed with openstack-gerrit Nov 21, 2012
Showing with 34 additions and 2 deletions.
  1. +34 −2 openstack_dashboard/settings.py
@@ -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 @@
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 e6d3c23

Please sign in to comment.