Эх сурвалжийг харах

[pig] Adding config check explicting that Oozie is required

Same for Oozie
Romain Rigaux 12 жил өмнө
parent
commit
ec65862

+ 21 - 7
apps/oozie/src/oozie/conf.py

@@ -17,44 +17,58 @@
 
 import os.path
 
-from django.utils.translation import ugettext_lazy as _
+from django.utils.translation import ugettext as _, ugettext_lazy as _t
 
 from desktop.lib.conf import Config, coerce_bool
 from desktop.lib import paths
+from liboozie.conf import get_oozie_status
+
+from oozie.settings import NICE_NAME
 
 
 DEFINITION_XSLT_DIR = Config(
   key="definition_xslt_dir",
   default=os.path.join(os.path.dirname(__file__), "xslt"),
-  help=_("Location on local FS where the xslt files are stored for workflow import."),
+  help=_t("Location on local FS where the xslt files are stored for workflow import."),
   private=True)
 
 LOCAL_SAMPLE_DIR = Config(
   key="local_data_dir",
   default=os.path.join(os.path.dirname(__file__), "..", "..", "examples"),
-  help=_("Location on local filesystem where the examples are stored."),
+  help=_t("Location on local filesystem where the examples are stored."),
   private=True)
 
 LOCAL_SAMPLE_DATA_DIR = Config(
   key="sample_data_dir",
   default=paths.get_thirdparty_root("sample_data"),
-  help=_("Location on local filesystem where the data for the examples is stored."),
+  help=_t("Location on local filesystem where the data for the examples is stored."),
   private=True)
 
 REMOTE_SAMPLE_DIR = Config(
   key="remote_data_dir",
   default="/user/hue/oozie/workspaces",
-  help=_("Location on HDFS where the Oozie workflows are stored."))
+  help=_t("Location on HDFS where the Oozie workflows are stored."))
 
 SHARE_JOBS = Config(
   key='share_jobs',
   default=True,
   type=coerce_bool,
-  help=_('Share workflows and coordinators information with all users. If set to false, '
+  help=_t('Share workflows and coordinators information with all users. If set to false, '
          'they will be visible only to the owner and administrators.'))
 
 OOZIE_JOBS_COUNT = Config(
   key='oozie_jobs_count',
   default=100,
   type=int,
-  help=_('Maximum number of Oozie workflows or coodinators to retrieve in one API call.'))
+  help=_t('Maximum number of Oozie workflows or coodinators to retrieve in one API call.'))
+
+
+def config_validator():
+  res = []
+
+  status = get_oozie_status()
+
+  if 'NORMAL' not in status:
+    res.append((NICE_NAME, _("The app won't work without a running Oozie server")))
+
+  return res

+ 17 - 3
apps/pig/src/pig/conf.py

@@ -17,18 +17,32 @@
 
 import os
 
-from django.utils.translation import ugettext_lazy as _
+from django.utils.translation import ugettext as _, ugettext_lazy as _t
 
 from desktop.lib.conf import Config
+from liboozie.conf import get_oozie_status
+
+from pig.settings import NICE_NAME
 
 
 LOCAL_SAMPLE_DIR = Config(
   key="local_data_dir",
   default=os.path.join(os.path.dirname(__file__), "..", "..", "examples"),
-  help=_("Location on local filesystem where the examples are stored."),
+  help=_t("Location on local filesystem where the examples are stored."),
   private=True)
 
 REMOTE_SAMPLE_DIR = Config(
   key="remote_data_dir",
   default="/user/hue/pig/examples",
-  help=_("Location on HDFS where the Pig examples are stored."))
+  help=_t("Location on HDFS where the Pig examples are stored."))
+
+
+def config_validator():
+  res = []
+
+  status = get_oozie_status()
+
+  if 'NORMAL' not in status:
+    res.append((NICE_NAME, _("The app won't work without a running Oozie server")))
+
+  return res

+ 12 - 6
desktop/libs/liboozie/src/liboozie/conf.py

@@ -38,6 +38,17 @@ REMOTE_DEPLOYMENT_DIR = Config(
   help=_t("Location on HDFS where the workflows/coordinators are deployed when submitted by a non-owner."))
 
 
+def get_oozie_status():
+  from liboozie.oozie_api import get_oozie
+
+  status = 'down'
+
+  try:
+    status = str(get_oozie().get_oozie_status())
+  except:
+    pass
+
+  return status
 
 def config_validator():
   """
@@ -46,15 +57,10 @@ def config_validator():
   Called by core check_config() view.
   """
   from hadoop.cluster import get_all_hdfs
-  from liboozie.oozie_api import get_oozie
 
   res = []
 
-  status = 'down'
-  try:
-    status = str(get_oozie().get_oozie_status())
-  except:
-    pass
+  status = get_oozie_status()
   if 'NORMAL' not in status:
     res.append((status, _('The Oozie server is not available')))