瀏覽代碼

[core] Manage apps to load from hue.ini

Now load the desktop config first in order to support a black list of
apps from the [desktop] section of hue.ini
The blacklisted app won't even be loaded for now.
Romain Rigaux 11 年之前
父節點
當前提交
310eef4

+ 4 - 4
apps/spark/src/spark/conf.py

@@ -50,9 +50,9 @@ def get_spark_status(user):
 def config_validator(user):
   res = []
 
-#  status = get_spark_status(user)
-#
-#  if status != 'OK':
-#    res.append((NICE_NAME, _("The app won't work without a running Job Server")))
+  status = get_spark_status(user)
+
+  if status != 'OK':
+    res.append((NICE_NAME, _("The app won't work without a running Job Server")))
 
   return res

+ 8 - 4
desktop/conf.dist/hue.ini

@@ -70,10 +70,14 @@
   # See https://docs.djangoproject.com/en/1.4/ref/middleware/ for more details on middlewares in Django.
   ## middleware=desktop.auth.backend.LdapSynchronizationBackend
 
-  ## Comma-separated list of regular expressions, which match the redirect URL.
-  ## For example, to restrict to your local domain and FQDN, the following value can be used:
-  ##   ^\/.*$,^http:\/\/www.mydomain.com\/.*$
-  # redirect_whitelist=
+  # Comma-separated list of regular expressions, which match the redirect URL.
+  # For example, to restrict to your local domain and FQDN, the following value can be used:
+  # ^\/.*$,^http:\/\/www.mydomain.com\/.*$
+  ## redirect_whitelist=
+
+  # Comma separated list of apps to not load at server startup.
+  # e.g.: pig,zookeeper
+  ## app_blacklist=
 
   # Administrators
   # ----------------

+ 9 - 5
desktop/conf/pseudo-distributed.ini.tmpl

@@ -79,10 +79,14 @@
   # See https://docs.djangoproject.com/en/1.4/ref/middleware/ for more details on middlewares in Django.
   ## middleware=desktop.auth.backend.LdapSynchronizationBackend
 
-  ## Comma-separated list of regular expressions, which match the redirect URL.
-  ## For example, to restrict to your local domain and FQDN, the following value can be used:
-  ##   ^\/.*$,^http:\/\/www.mydomain.com\/.*$
-  # redirect_whitelist=
+  # Comma-separated list of regular expressions, which match the redirect URL.
+  # For example, to restrict to your local domain and FQDN, the following value can be used:
+  # ^\/.*$,^http:\/\/www.mydomain.com\/.*$
+  ## redirect_whitelist=
+
+  # Comma separated list of apps to not load at server startup.
+  # e.g.: pig,zookeeper
+  ## app_blacklist=
 
   # Administrators
   # ----------------
@@ -328,7 +332,7 @@
 ###########################################################################
 
 [libopenid]
-  # (Required) OpenId SSO endpoint url. 
+  # (Required) OpenId SSO endpoint url.
   ## server_endpoint_url=https://www.google.com/accounts/o8/id
 
   # OpenId 1.1 identity url prefix to be used instead of SSO endpoint url

+ 5 - 4
desktop/core/src/desktop/appmanager.py

@@ -227,7 +227,7 @@ def load_libs():
   DESKTOP_MODULES.append(DesktopModuleInfo(desktop))
 
 
-def load_apps():
+def load_apps(app_blacklist):
   """Loads the applications from the directories in APP_DIRS.
   Sets DESKTOP_MODULES and DJANGO_APPS globals in this module.
 
@@ -241,9 +241,10 @@ def load_apps():
   DESKTOP_APPS = []
 
   for sdk_app in pkg_resources.iter_entry_points("desktop.sdk.application"):
-    m = sdk_app.load()
-    dmi = DesktopModuleInfo(m)
-    DESKTOP_APPS.append(dmi)
+    if sdk_app.name not in app_blacklist:
+      m = sdk_app.load()
+      dmi = DesktopModuleInfo(m)
+      DESKTOP_APPS.append(dmi)
 
   LOG.debug("Loaded Desktop Applications: " + ", ".join(a.name for a in DESKTOP_APPS))
   DESKTOP_MODULES += DESKTOP_APPS

+ 7 - 0
desktop/core/src/desktop/conf.py

@@ -134,6 +134,13 @@ REDIRECT_WHITELIST = Config(
   type=list_of_compiled_res(skip_empty=True),
   default='')
 
+APP_BLACKLIST = Config(
+  key='app_blacklist',
+  default='',
+  type=coerce_csv,
+  help=_('Comma separated list of apps to not load at server startup.')
+)
+
 def is_https_enabled():
   return bool(SSL_CERTIFICATE.get() and SSL_PRIVATE_KEY.get())
 

+ 5 - 2
desktop/core/src/desktop/settings.py

@@ -208,9 +208,13 @@ appmanager.load_libs()
 _lib_conf_modules = [dict(module=app.conf, config_key=None) for app in appmanager.DESKTOP_LIBS if app.conf is not None]
 LOCALE_PATHS.extend([app.locale_path for app in appmanager.DESKTOP_LIBS])
 
+# Load desktop config
+_desktop_conf_modules = [dict(module=desktop.conf, config_key=None)]
+conf.initialize(_desktop_conf_modules, _config_dir)
+
 # Activate l10n
 # Install apps
-appmanager.load_apps()
+appmanager.load_apps(desktop.conf.APP_BLACKLIST.get())
 for app in appmanager.DESKTOP_APPS:
   INSTALLED_APPS.extend(app.django_apps)
   LOCALE_PATHS.append(app.locale_path)
@@ -220,7 +224,6 @@ logging.debug("Installed Django modules: %s" % ",".join(map(str, appmanager.DESK
 
 # Load app configuration
 _app_conf_modules = [dict(module=app.conf, config_key=app.config_key) for app in appmanager.DESKTOP_APPS if app.conf is not None]
-_app_conf_modules.append(dict(module=desktop.conf, config_key=None))
 
 conf.initialize(_lib_conf_modules, _config_dir)
 conf.initialize(_app_conf_modules, _config_dir)