Browse Source

HUE-4360 [meta] Protect when the configuration files are missing

Romain Rigaux 9 years ago
parent
commit
366689400b

+ 2 - 13
desktop/libs/metadata/src/metadata/metadata_sites.py

@@ -46,7 +46,7 @@ def get_conf(name='navigator'):
 
 
 
 
 def get_navigator_server_url():
 def get_navigator_server_url():
-  return get_conf().get(_CONF_NAVIGATOR_SERVER_URL, 'http://localhost:7187/api')
+  return get_conf().get(_CONF_NAVIGATOR_SERVER_URL, 'http://localhost:7187')
 
 
 def get_navigator_audit_log_dir():
 def get_navigator_audit_log_dir():
   return get_conf().get(_CONF_NAVIGATOR_AUDIT_LOG_DIR)
   return get_conf().get(_CONF_NAVIGATOR_AUDIT_LOG_DIR)
@@ -73,15 +73,4 @@ def _parse_property(file_path):
   except IOError, err:
   except IOError, err:
     if err.errno != errno.ENOENT:
     if err.errno != errno.ENOENT:
       LOG.error('Cannot read from "%s": %s' % (file_path, err))
       LOG.error('Cannot read from "%s": %s' % (file_path, err))
-    return ""
-
-def _parse_site(site_path):
-  try:
-    data = file(site_path, 'r').read()
-  except IOError, err:
-    if err.errno != errno.ENOENT:
-      LOG.error('Cannot read from "%s": %s' % (site_path, err))
-      return
-    data = ""
-
-  return confparse.ConfParse(data)
+    return {}

+ 18 - 0
desktop/libs/metadata/src/metadata/metadata_sites_tests.py

@@ -55,3 +55,21 @@ navigator.audit_log_max_file_size=100
       for reset in resets:
       for reset in resets:
         reset()
         reset()
       shutil.rmtree(tmpdir)
       shutil.rmtree(tmpdir)
+
+
+  def test_missing_navigator_site(self):
+    tmpdir = tempfile.mkdtemp()
+    shutil.rmtree(tmpdir)
+
+    resets = [
+        NAVIGATOR.CONF_DIR.set_for_testing(tmpdir)
+    ]
+
+    try:
+      metadata_sites.reset()
+
+      assert_equal(get_navigator_server_url(), 'http://localhost:7187')
+    finally:
+      metadata_sites.reset()
+      for reset in resets:
+        reset()