Преглед на файлове

[security] Adding HDFS ACL API

Romain Rigaux преди 11 години
родител
ревизия
4c50f80f26

+ 77 - 0
apps/security/src/security/templates/hdfs.mako

@@ -0,0 +1,77 @@
+## Licensed to Cloudera, Inc. under one
+## or more contributor license agreements.  See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership.  Cloudera, Inc. licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License.  You may obtain a copy of the License at
+##
+##     http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+
+<%!
+from desktop.views import commonheader, commonfooter
+from django.utils.translation import ugettext as _
+%>
+
+
+<%namespace name="layout" file="layout.mako" />
+
+${ commonheader(_('Hadoop Security'), "security", user) | n,unicode }
+${ layout.menubar(section='hdfs') }
+
+
+<div class="container-fluid">
+  <div class="row-fluid">
+    <div class="span2">
+      <div class="sidebar-nav">
+        <ul class="nav nav-list">
+          <li class="nav-header">${ _('Properties') }</li>
+          <li class="active"><a href="#properties"><i class="fa fa-eye"></i> ${ _('View') }</a></li>
+          <li><a href="#listDataset"><i class="fa fa-cubes"></i> ${ _('ACLs') }</a></li>
+        </ul>
+      </div>
+    </div>
+    <div class="span10">
+      <div class="card card-small">
+        <h1 class="card-heading simple">${ _('View') }</h1>
+        <div class="card-body">
+          Assist: 
+          ${ assist }        
+        <div>
+        <div class="card-body">     
+          Hadoop Groups: 
+          ${ hadoop_groups }
+        <div>
+        <div class="form-actions" id="bottom-nav">
+          <a id="backBtn" class="btn disabled">${ _('Back') }</a>
+          <a id="nextBtn" class="btn btn-primary disable-feedback">${ _('Next') }</a>
+        </div>
+
+        </div>
+
+        <div id="listDataset" class="section hide">
+          <div class="alert alert-info"><h3>${ _('Existing datasets') }</h3></div>
+        </div>
+
+        <div id="listHistory" class="section hide">
+          <div class="alert alert-info"><h3>${ _('History') }</h3></div>          
+        </div>
+
+      </form>
+
+    </div>
+    </div>
+
+  </div>
+
+</div>
+
+
+
+${ commonfooter(messages) | n,unicode }

+ 0 - 0
apps/security/src/security/templates/index.mako → apps/security/src/security/templates/hive.mako


+ 3 - 1
apps/security/src/security/urls.py

@@ -19,5 +19,7 @@ from django.conf.urls.defaults import patterns, url
 
 
 urlpatterns = patterns('security.views',
-  url(r'^$', 'index', name='index'),
+  url(r'^$', 'hive', name='index'),
+  url(r'^hive$', 'hive', name='hive'),
+  url(r'^hdfs$', 'hdfs', name='hdfs'),
 )

+ 21 - 4
apps/security/src/security/views.py

@@ -15,19 +15,36 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+from beeswax.api import autocomplete
 from desktop.lib.django_util import render
+from filebrowser.views import view
 
 from libsentry.api import get_api
-from beeswax.api import autocomplete
 
 
-def index(request):
+def get_hadoop_groups(): # Mock for now, maybe pull from LDAP
+  return ['romain', 'sambashare', 'cdrom', 'lpadmin', 'admin', 'adm', 'lp', 'dialout', 'plugdev']
+
+  
+def hive(request):
   assist = autocomplete(request, database=None, table=None)
-  hadoop_groups = ['romain', 'sambashare', 'cdrom', 'lpadmin', 'admin', 'adm', 'lp', 'dialout', 'plugdev']
+  hadoop_groups = get_hadoop_groups()
   roles = get_api(request.user).list_sentry_roles_by_group()
   
-  return render("index.mako", request, {      
+  return render("hive.mako", request, {      
       'assist': assist,
       'hadoop_groups': hadoop_groups,
       'roles': roles
   })
+
+
+def hdfs(request):
+  request.ajax = True # Hack for now
+  hadoop_groups = get_hadoop_groups()
+  assist = view(request, '/')    
+  del request.ajax
+  
+  return render("hdfs.mako", request, {      
+      'assist': assist,
+      'hadoop_groups': hadoop_groups,
+  })

+ 46 - 0
desktop/libs/hadoop/src/hadoop/fs/webhdfs.py

@@ -474,6 +474,52 @@ class WebHdfs(Hdfs):
     self._invoke_with_redirect('POST', path, params, data)
 
 
+  # e.g. ACLSPEC = user:joe:rwx,user::rw-
+  def modify_acl_entries(self, path, aclspec):
+    path = Hdfs.normpath(path)
+    params = self._getparams()
+    params['op'] = 'MODIFYACLENTRIES'
+    params['aclspec'] = aclspec
+    self._invoke_with_redirect('PUT', path, params)
+
+
+  def remove_acl_entries(self, path, aclspec):
+      path = Hdfs.normpath(path)
+      params = self._getparams()
+      params['op'] = 'REMOVEACLENTRIES'
+      params['aclspec'] = aclspec
+      self._invoke_with_redirect('PUT', path, params)
+
+
+  def remove_default_acl(self, path):
+      path = Hdfs.normpath(path)
+      params = self._getparams()
+      params['op'] = 'REMOVEDEFAULTACL'
+      self._invoke_with_redirect('PUT', path, params)
+
+
+  def remove_acl(self, path):
+      path = Hdfs.normpath(path)
+      params = self._getparams()
+      params['op'] = 'REMOVEACL'
+      self._invoke_with_redirect('PUT', path, params)
+
+
+  def set_acl(self, path, aclspec):
+      path = Hdfs.normpath(path)
+      params = self._getparams()
+      params['op'] = 'REMOVEACL'
+      params['aclspec'] = aclspec
+      self._invoke_with_redirect('PUT', path, params)
+
+
+  def get_acl_status(self, path):
+      path = Hdfs.normpath(path)
+      params = self._getparams()
+      params['op'] = 'GETACLSTATUS'
+      self._invoke_with_redirect('PUT', path, params)
+
+
   def copyfile(self, src, dst, skip_header=False):
     sb = self._stats(src)
     if sb is None: