Selaa lähdekoodia

HUE-876 [oozie] Add a warning if oozie share lib is not installed

Checking for Oozie deployment dir and Share Lib existence on HDFS.
Adding a test too.
Romain Rigaux 13 vuotta sitten
vanhempi
commit
bd3782c081

+ 6 - 6
desktop/core/src/desktop/lib/conf.py

@@ -613,9 +613,9 @@ def coerce_bool(value):
   raise Exception("Could not coerce %r to boolean value" % (value,))
 
 
-def validate_path(confvar, is_dir=None):
+def validate_path(confvar, is_dir=None, fs=os.path, message='Path does not exist on the filesystem.'):
   """
-  Validate that the value of confvar is an existent local path.
+  Validate that the value of confvar is an existent path.
 
   @param confvar  The configuration variable.
   @param is_dir  True/False would verify that the path is/isn't a directory.
@@ -623,13 +623,13 @@ def validate_path(confvar, is_dir=None):
   @return [(confvar, error_msg)] or []
   """
   path = confvar.get()
-  if path is None or not os.path.exists(path):
-    return [(confvar, 'Path does not exist on local filesystem.')]
+  if path is None or not fs.exists(path):
+    return [(confvar, message)]
   if is_dir is not None:
     if is_dir:
-      if not os.path.isdir(path):
+      if not fs.isdir(path):
         return [(confvar, 'Not a directory.')]
-    elif not os.path.isfile(path):
+    elif not fs.isfile(path):
       return [(confvar, 'Not a file.')]
   return [ ]
 

+ 11 - 1
desktop/core/src/desktop/tests.py

@@ -17,13 +17,14 @@
 # limitations under the License.
 from desktop.lib import django_mako
 
-from nose.tools import assert_true, assert_equal
+from nose.tools import assert_true, assert_equal, assert_not_equal
 from desktop.lib.django_test_util import make_logged_in_client
 from django.conf.urls.defaults import patterns, url
 from django.core.urlresolvers import reverse
 from django.http import HttpResponse
 from django.db.models import query, CharField, SmallIntegerField
 from desktop.lib.paginator import Paginator
+from desktop.lib.conf import validate_path
 import desktop
 import desktop.urls
 import desktop.conf
@@ -34,6 +35,7 @@ from desktop.lib.exceptions import PopupException
 import desktop.views as views
 import proxy.conf
 
+
 def setup_test_environment():
   """
   Sets up mako to signal template rendering.
@@ -323,6 +325,14 @@ def test_log_event():
 
   root.removeHandler(handler)
 
+def test_validate_path():
+  reset = desktop.conf.SSL_PRIVATE_KEY.set_for_testing('/')
+  assert_equal([], validate_path(desktop.conf.SSL_PRIVATE_KEY, is_dir=True))
+  reset()
+
+  reset = desktop.conf.SSL_PRIVATE_KEY.set_for_testing('/tmm/does_not_exist')
+  assert_not_equal([], validate_path(desktop.conf.SSL_PRIVATE_KEY, is_dir=True))
+  reset()
 
 def test_config_check():
   reset = (

+ 31 - 5
desktop/libs/liboozie/src/liboozie/conf.py

@@ -15,24 +15,50 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+from django.utils.translation import ugettext as _, ugettext_lazy as _t
 
-from desktop.lib.conf import Config, coerce_bool
-from django.utils.translation import ugettext_lazy as _
+from desktop.lib.conf import Config, coerce_bool, validate_path
 
 
 OOZIE_URL = Config(
   key='oozie_url',
-  help=_('URL to Oozie server. This is required for job submission.'),
+  help=_t('URL to Oozie server. This is required for job submission.'),
   default='http://localhost:11000/oozie',
   type=str)
 
 SECURITY_ENABLED = Config(
   key="security_enabled",
-  help=_("Whether Oozie requires client to do perform Kerberos authentication"),
+  help=_t("Whether Oozie requires client to perform Kerberos authentication"),
   default=False,
   type=coerce_bool)
 
 REMOTE_DEPLOYMENT_DIR = Config(
   key="remote_deployement_dir",
   default="/user/hue/oozie/deployments",
-  help=_("Location on HDFS where the workflows/coordinator are deployed when submitted by a non owner."))
+  help=_t("Location on HDFS where the workflows/coordinator are deployed when submitted by a non owner."))
+
+
+
+def config_validator():
+  """
+  config_validator() -> [ (config_variable, error_message) ]
+
+  Called by core check_config() view.
+  """
+  from hadoop.cluster import get_all_hdfs
+
+  res = []
+
+  class ConfigMock:
+    def __init__(self, value): self.value = value
+    def get(self): return self.value
+    def get_fully_qualifying_key(self): return self.value
+
+  for cluster in get_all_hdfs().values():
+    res.extend(validate_path(REMOTE_DEPLOYMENT_DIR, is_dir=True, fs=cluster,
+                             message=_('The deployment directory of Oozie workflows does not exist. '
+                                       'Please run "Setup App" on the Oozie workflow page.')))
+    res.extend(validate_path(ConfigMock('/user/oozie/share/lib'), is_dir=True, fs=cluster,
+                             message=_('Oozie Share Lib not installed in default location.')))
+
+  return res