Explorar o código

[libzookeeper] Enable Kerberos automatically based on HDFS security

We don't need another property that way and Kerberos is a all or nothing
setup.
Even if HDFS is not used in Hue, the default hue.ini has security set
to false.
Romain Rigaux %!s(int64=10) %!d(string=hai) anos
pai
achega
4de03c5
Modificáronse 1 ficheiros con 15 adicións e 2 borrados
  1. 15 2
      desktop/libs/libzookeeper/src/libzookeeper/models.py

+ 15 - 2
desktop/libs/libzookeeper/src/libzookeeper/models.py

@@ -16,11 +16,24 @@
 # limitations under the License.
 
 from kazoo.client import KazooClient
+
+from hadoop import cluster
+from desktop.lib.exceptions_renderable import PopupException
+
 from libzookeeper.conf import PRINCIPAL_NAME
 
 
 def get_children_data(ensemble, namespace, read_only=True):
-  zk = KazooClient(hosts=ensemble, read_only=read_only, sasl_server_principal=PRINCIPAL_NAME.get())
+  hdfs = cluster.get_hdfs()
+  if hdfs is None:
+    raise PopupException(_('No [hdfs] configured in hue.ini.'))
+
+  if hdfs.security_enabled:
+    sasl_server_principal = PRINCIPAL_NAME.get()
+  else:
+    sasl_server_principal = None
+
+  zk = KazooClient(hosts=ensemble, read_only=read_only, sasl_server_principal=sasl_server_principal)
 
   zk.start()
 
@@ -33,5 +46,5 @@ def get_children_data(ensemble, namespace, read_only=True):
     children_data.append(data)
 
   zk.stop()
-  
+
   return children_data