Browse Source

[api] Add is_yarn_enabled in /get_config API (#2798)

* [api] Add is_yarn_enabled in /get_config API

* [tests] Update /get_config UTs
Harsh Gupta 3 years ago
parent
commit
e95d043e3a
2 changed files with 5 additions and 0 deletions
  1. 3 0
      desktop/core/src/desktop/api2.py
  2. 2 0
      desktop/core/src/desktop/api2_tests.py

+ 3 - 0
desktop/core/src/desktop/api2.py

@@ -56,6 +56,8 @@ from desktop.models import Document2, Document, Directory, FilesystemException,
   UserPreferences, get_user_preferences, set_user_preferences, get_cluster_config, __paginate, _get_gist_document
 from desktop.views import serve_403_error
 
+from hadoop.cluster import is_yarn
+
 if sys.version_info[0] > 2:
   from io import StringIO as string_io
   from django.utils.translation import gettext as _
@@ -87,6 +89,7 @@ def api_error_handler(func):
 def get_config(request):
   config = get_cluster_config(request.user)
   config['hue_config']['is_admin'] = is_admin(request.user)
+  config['hue_config']['is_yarn_enabled'] = is_yarn()
   config['clusters'] = list(get_clusters(request.user).values())
   config['documents'] = {
     'types': list(Document2.objects.documents(user=request.user).order_by().values_list('type', flat=True).distinct())

+ 2 - 0
desktop/core/src/desktop/api2_tests.py

@@ -122,6 +122,8 @@ class TestApi2(object):
     config = json.loads(response.content)
 
     assert_true('types' in config['documents'])
+    assert_true('is_admin' in config['hue_config'])
+    assert_true('is_yarn_enabled' in config['hue_config'])
     assert_false('query-TestApi2.test_get_config' in config['documents']['types'], config)
 
     doc = Document2.objects.create(