Browse Source

[ozone] adding ozone_service_id in path and making corrections accordingly

ayush.goyal 2 years ago
parent
commit
310695b485

+ 7 - 7
apps/filebrowser/src/filebrowser/templates/listdir.mako

@@ -61,12 +61,12 @@ ${ fb_components.menubar() }
         <div class="btn-toolbar" style="display: inline; vertical-align: middle">
         <div class="btn-toolbar" style="display: inline; vertical-align: middle">
           <div id="ch-dropdown" class="btn-group" style="vertical-align: middle">
           <div id="ch-dropdown" class="btn-group" style="vertical-align: middle">
             <button class="btn dropdown-toggle" title="${_('Actions')}" data-toggle="dropdown"
             <button class="btn dropdown-toggle" title="${_('Actions')}" data-toggle="dropdown"
-            data-bind="visible: !inTrash(), enable: selectedFiles().length > 0 && ((!isS3() && !isABFS()) || (isS3() && !isS3Root()) || (isABFS() && !isABFSRoot()))">
+            data-bind="visible: !inTrash(), enable: selectedFiles().length > 0 && ((!isS3() && !isABFS() && !isOFS()) || (isS3() && !isS3Root()) || (isABFS() && !isABFSRoot()) || (isOFS() && !isOFSRoot()))">
               <i class="fa fa-cog"></i> ${_('Actions')}
               <i class="fa fa-cog"></i> ${_('Actions')}
               <span class="caret" style="line-height: 15px"></span>
               <span class="caret" style="line-height: 15px"></span>
             </button>
             </button>
             <ul class="dropdown-menu" style="top: auto">
             <ul class="dropdown-menu" style="top: auto">
-              <li><a data-hue-analytics="filebrowser:actions-menu/rename-click" href="javascript: void(0)" title="${_('Rename')}" data-bind="visible: !inTrash() && selectedFiles().length == 1 && !isOFSRoot() && !isOFSVol(), click: renameFile,
+              <li><a data-hue-analytics="filebrowser:actions-menu/rename-click" href="javascript: void(0)" title="${_('Rename')}" data-bind="visible: !inTrash() && selectedFiles().length == 1 && !isOFSServiceID() && !isOFSVol(), click: renameFile,
               enable: selectedFiles().length == 1 && isCurrentDirSelected().length == 0"><i class="fa fa-fw fa-font"></i>
               enable: selectedFiles().length == 1 && isCurrentDirSelected().length == 0"><i class="fa fa-fw fa-font"></i>
               ${_('Rename')}</a></li>
               ${_('Rename')}</a></li>
               <li><a data-hue-analytics="filebrowser:actions-menu/move-click" href="javascript: void(0)" title="${_('Move')}" data-bind="click: move, enable: selectedFiles().length > 0 &&
               <li><a data-hue-analytics="filebrowser:actions-menu/move-click" href="javascript: void(0)" title="${_('Move')}" data-bind="click: move, enable: selectedFiles().length > 0 &&
@@ -171,25 +171,25 @@ ${ fb_components.menubar() }
           <!-- /ko -->
           <!-- /ko -->
           <!-- ko ifnot: isS3() || isABFS() -->
           <!-- ko ifnot: isS3() || isABFS() -->
           <div id="upload-dropdown" class="btn-group" style="vertical-align: middle">
           <div id="upload-dropdown" class="btn-group" style="vertical-align: middle">
-            <a data-hue-analytics="filebrowser:upload-btn-click" href="javascript: void(0)" class="btn upload-link dropdown-toggle" title="${_('Upload')}" data-bind="click: uploadFile, visible: !inTrash(), css: {'disabled': isS3() && isS3Root() || isABFS() && isABFSRoot() || (isOFS() && (isOFSRoot() || isOFSVol()))}">
+            <a data-hue-analytics="filebrowser:upload-btn-click" href="javascript: void(0)" class="btn upload-link dropdown-toggle" title="${_('Upload')}" data-bind="click: uploadFile, visible: !inTrash(), css: {'disabled': isS3() && isS3Root() || isABFS() && isABFSRoot() || (isOFS() && (isOFSRoot() || isOFSServiceID() || isOFSVol()))}">
               <i class="fa fa-arrow-circle-o-up"></i> ${_('Upload')}
               <i class="fa fa-arrow-circle-o-up"></i> ${_('Upload')}
             </a>
             </a>
           </div>
           </div>
           <!-- /ko -->
           <!-- /ko -->
           % endif
           % endif
           <div class="btn-group" style="vertical-align: middle">
           <div class="btn-group" style="vertical-align: middle">
-            <a href="javascript: void(0)" data-toggle="dropdown" class="btn dropdown-toggle" data-bind="visible: !inTrash()">
+            <a href="javascript: void(0)" data-toggle="dropdown" class="btn dropdown-toggle" data-bind="visible: !inTrash(), css: {'disabled': isOFSRoot()}">
               <i class="fa fa-plus-circle"></i> ${_('New')}
               <i class="fa fa-plus-circle"></i> ${_('New')}
               <span class="caret"></span>
               <span class="caret"></span>
             </a>
             </a>
             <ul class="dropdown-menu pull-right" style="top: auto">
             <ul class="dropdown-menu pull-right" style="top: auto">
-              <li data-bind="visible: !isS3() && !isABFS() && !isOFS() || isS3() && !isS3Root() || isABFS() && !isABFSRoot() || isOFS() && !isOFSRoot() && !isOFSVol()"><a data-hue-analytics="filebrowser:new-file-btn-click" href="javascript: void(0)" class="create-file-link" title="${_('File')}"><i class="fa fa-file-o"></i> ${_('File')}</a></li>
+              <li data-bind="visible: !isS3() && !isABFS() && !isOFS() || isS3() && !isS3Root() || isABFS() && !isABFSRoot() || isOFS() && !isOFSServiceID() && !isOFSVol()"><a data-hue-analytics="filebrowser:new-file-btn-click" href="javascript: void(0)" class="create-file-link" title="${_('File')}"><i class="fa fa-file-o"></i> ${_('File')}</a></li>
               <li><a href="javascript: void(0)" class="create-directory-link" title="${_('Directory')}">
               <li><a href="javascript: void(0)" class="create-directory-link" title="${_('Directory')}">
                 <i class="fa fa-folder"></i>
                 <i class="fa fa-folder"></i>
-                <span data-bind="visible: !isS3() && !isABFS() && !isOFS() || isS3() && !isS3Root() || isABFS() && !isABFSRoot() || isOFS() && !isOFSRoot() && !isOFSVol()">${_('Directory')}</span>
+                <span data-bind="visible: !isS3() && !isABFS() && !isOFS() || isS3() && !isS3Root() || isABFS() && !isABFSRoot() || isOFS() && !isOFSServiceID() && !isOFSVol()">${_('Directory')}</span>
                 <span data-bind="visible: (isS3() && isS3Root()) || (isOFS() && isOFSVol())">${_('Bucket')}</span>
                 <span data-bind="visible: (isS3() && isS3Root()) || (isOFS() && isOFSVol())">${_('Bucket')}</span>
                 <span data-bind="visible: isABFS() && isABFSRoot()">${_('File System')}</span>
                 <span data-bind="visible: isABFS() && isABFSRoot()">${_('File System')}</span>
-                <span data-bind="visible: isOFS() && isOFSRoot()">${_('Volume')}</span>
+                <span data-bind="visible: isOFS() && isOFSServiceID()">${_('Volume')}</span>
               </a></li>
               </a></li>
             </ul>
             </ul>
           </div>
           </div>

+ 13 - 9
apps/filebrowser/src/filebrowser/templates/listdir_components.mako

@@ -461,7 +461,7 @@ else:
     <div id="createDirectoryModal" class="modal hide fade">
     <div id="createDirectoryModal" class="modal hide fade">
       <div class="modal-header">
       <div class="modal-header">
         <button type="button" class="close" data-dismiss="modal" aria-label="${ _('Close') }"><span aria-hidden="true">&times;</span></button>
         <button type="button" class="close" data-dismiss="modal" aria-label="${ _('Close') }"><span aria-hidden="true">&times;</span></button>
-        <!-- ko if: (!isS3() && !isABFS() && !isOFS()) || (isS3() && !isS3Root()) || (isABFS() && !isABFSRoot()) || (isOFS() && !isOFSRoot() && !isOFSVol())  -->
+        <!-- ko if: (!isS3() && !isABFS() && !isOFS()) || (isS3() && !isS3Root()) || (isABFS() && !isABFSRoot()) || (isOFS() && !isOFSServiceID() && !isOFSVol())  -->
         <h2 class="modal-title">${_('Create Directory')}</h2>
         <h2 class="modal-title">${_('Create Directory')}</h2>
         <!-- /ko -->
         <!-- /ko -->
         <!-- ko if: (isS3() && isS3Root()) || (isOFS() && isOFSVol()) -->
         <!-- ko if: (isS3() && isS3Root()) || (isOFS() && isOFSVol()) -->
@@ -470,13 +470,13 @@ else:
         <!-- ko if: isABFS() && isABFSRoot() -->
         <!-- ko if: isABFS() && isABFSRoot() -->
         <h2 class="modal-title">${_('Create File System')}</h2>
         <h2 class="modal-title">${_('Create File System')}</h2>
         <!-- /ko -->
         <!-- /ko -->
-        <!-- ko if: isOFS() && isOFSRoot() -->
+        <!-- ko if: isOFS() && isOFSServiceID() -->
         <h2 class="modal-title">${_('Create Volume')}</h2>
         <h2 class="modal-title">${_('Create Volume')}</h2>
         <!-- /ko -->
         <!-- /ko -->
       </div>
       </div>
       <div class="modal-body">
       <div class="modal-body">
         <label>
         <label>
-          <!-- ko if: (!isS3() && !isABFS() && !isOFS()) || (isS3() && !isS3Root()) || (isABFS() && !isABFSRoot()) || (isOFS() && !isOFSRoot() && !isOFSVol()) -->
+          <!-- ko if: (!isS3() && !isABFS() && !isOFS()) || (isS3() && !isS3Root()) || (isABFS() && !isABFSRoot()) || (isOFS() && !isOFSServiceID() && !isOFSVol()) -->
           ${_('Directory Name')}
           ${_('Directory Name')}
           <!-- /ko -->
           <!-- /ko -->
           <!-- ko if: (isS3() && isS3Root()) || (isOFS() && isOFSVol()) -->
           <!-- ko if: (isS3() && isS3Root()) || (isOFS() && isOFSVol()) -->
@@ -485,7 +485,7 @@ else:
           <!-- ko if: isABFS() && isABFSRoot() -->
           <!-- ko if: isABFS() && isABFSRoot() -->
           ${_('File System Name')}
           ${_('File System Name')}
           <!-- /ko -->
           <!-- /ko -->
-          <!-- ko if: isOFS() && isOFSRoot() -->
+          <!-- ko if: isOFS() && isOFSServiceID() -->
           ${_('Volume Name')}
           ${_('Volume Name')}
           <!-- /ko -->
           <!-- /ko -->
           <input id="newDirectoryNameInput" name="name" value="" type="text" class="input-xlarge"/></label>
           <input id="newDirectoryNameInput" name="name" value="" type="text" class="input-xlarge"/></label>
@@ -587,12 +587,12 @@ else:
   <!-- actions context menu -->
   <!-- actions context menu -->
   <ul class="context-menu dropdown-menu">
   <ul class="context-menu dropdown-menu">
   <!-- ko ifnot: $root.inTrash -->
   <!-- ko ifnot: $root.inTrash -->
-    <li data-bind="visible: (!isS3() && !isABFS() && !isOFS()) || (isS3() && !isS3Root()) || (isABFS() && !isABFSRoot()) || (isOFS() && !isOFSRoot() && !isOFSVol()), css: {'disabled': $root.selectedFiles().length != 1 || isCurrentDirSelected().length > 0}">
+    <li data-bind="visible: (!isS3() && !isABFS() && !isOFS()) || (isS3() && !isS3Root()) || (isABFS() && !isABFSRoot()) || (isOFS() && !isOFSServiceID() && !isOFSVol()), css: {'disabled': $root.selectedFiles().length != 1 || isCurrentDirSelected().length > 0}">
     <a href="javascript: void(0)" title="${_('Rename')}" data-bind="click: ($root.selectedFiles().length == 1 && isCurrentDirSelected().length == 0) ? $root.renameFile: void(0)"><i class="fa fa-fw fa-font"></i>
     <a href="javascript: void(0)" title="${_('Rename')}" data-bind="click: ($root.selectedFiles().length == 1 && isCurrentDirSelected().length == 0) ? $root.renameFile: void(0)"><i class="fa fa-fw fa-font"></i>
     ${_('Rename')}</a></li>
     ${_('Rename')}</a></li>
-    <li data-bind="visible: (!isS3() && !isABFS() && !isOFS()) || (isS3() && !isS3Root()) || (isABFS() && !isABFSRoot()) || (isOFS() && !isOFSRoot() && !isOFSVol()), css: {'disabled': $root.selectedFiles().length == 0 || isCurrentDirSelected().length > 0}">
+    <li data-bind="visible: (!isS3() && !isABFS() && !isOFS()) || (isS3() && !isS3Root()) || (isABFS() && !isABFSRoot()) || (isOFS() && !isOFSServiceID() && !isOFSVol()), css: {'disabled': $root.selectedFiles().length == 0 || isCurrentDirSelected().length > 0}">
     <a href="javascript: void(0)" title="${_('Move')}" data-bind="click: ( $root.selectedFiles().length > 0 && isCurrentDirSelected().length == 0) ? $root.move: void(0)"><i class="fa fa-fw fa-random"></i> ${_('Move')}</a></li>
     <a href="javascript: void(0)" title="${_('Move')}" data-bind="click: ( $root.selectedFiles().length > 0 && isCurrentDirSelected().length == 0) ? $root.move: void(0)"><i class="fa fa-fw fa-random"></i> ${_('Move')}</a></li>
-    <li data-bind="visible: (!isS3() && !isABFS() && !isOFS()) || (isS3() && !isS3Root()) || (isABFS() && !isABFSRoot()) || (isOFS() && !isOFSRoot() && !isOFSVol()), css: {'disabled': $root.selectedFiles().length == 0 || isCurrentDirSelected().length > 0}">
+    <li data-bind="visible: (!isS3() && !isABFS() && !isOFS()) || (isS3() && !isS3Root()) || (isABFS() && !isABFSRoot()) || (isOFS() && !isOFSServiceID() && !isOFSVol()), css: {'disabled': $root.selectedFiles().length == 0 || isCurrentDirSelected().length > 0}">
     <a href="javascript: void(0)" title="${_('Copy')}" data-bind="click: ($root.selectedFiles().length > 0 && isCurrentDirSelected().length == 0) ? $root.copy: void(0)"><i class="fa fa-fw fa-files-o"></i> ${_('Copy')}</a></li>
     <a href="javascript: void(0)" title="${_('Copy')}" data-bind="click: ($root.selectedFiles().length > 0 && isCurrentDirSelected().length == 0) ? $root.copy: void(0)"><i class="fa fa-fw fa-files-o"></i> ${_('Copy')}</a></li>
     % if show_download_button:
     % if show_download_button:
     <li data-bind="css: {'disabled': $root.inTrash() || $root.selectedFiles().length != 1 || selectedFile().type != 'file'}">
     <li data-bind="css: {'disabled': $root.inTrash() || $root.selectedFiles().length != 1 || selectedFile().type != 'file'}">
@@ -1156,10 +1156,14 @@ else:
         return self.isOFS() && self.currentPath().toLowerCase() === 'ofs://';
         return self.isOFS() && self.currentPath().toLowerCase() === 'ofs://';
       });
       });
 
 
-      self.isOFSVol = ko.pureComputed(function () {
+      self.isOFSServiceID = ko.pureComputed(function () {
         return self.isOFS() && self.currentPath().split("/").length === 3 && self.currentPath().split("/")[2] !== '';
         return self.isOFS() && self.currentPath().split("/").length === 3 && self.currentPath().split("/")[2] !== '';
       });
       });
 
 
+      self.isOFSVol = ko.pureComputed(function () {
+        return self.isOFS() && self.currentPath().split("/").length === 4 && self.currentPath().split("/")[3] !== '';
+      });
+
       self.inTrash = ko.computed(function() {
       self.inTrash = ko.computed(function() {
         return self.currentPath().match(/^\/user\/.+?\/\.Trash/);
         return self.currentPath().match(/^\/user\/.+?\/\.Trash/);
       });
       });
@@ -1860,7 +1864,7 @@ else:
           resetPrimaryButtonsStatus(); //globally available
           resetPrimaryButtonsStatus(); //globally available
           return false;
           return false;
         }
         }
-        if (self.isOFSRoot() || self.isOFSVol()) {
+        if (self.isOFSServiceID() || self.isOFSVol()) {
           if ($("#newDirectoryNameInput").val().length < 3 || $("#newDirectoryNameInput").val().length > 63) {
           if ($("#newDirectoryNameInput").val().length < 3 || $("#newDirectoryNameInput").val().length > 63) {
             $("#volumeBucketNameAlert").show();
             $("#volumeBucketNameAlert").show();
             $("#newDirectoryNameInput").addClass("fieldError");
             $("#newDirectoryNameInput").addClass("fieldError");

+ 0 - 12
desktop/libs/indexer/src/indexer/indexers/sql.py

@@ -33,7 +33,6 @@ from notebook.connectors.base import get_interpreter
 from notebook.models import make_notebook
 from notebook.models import make_notebook
 from useradmin.models import User
 from useradmin.models import User
 
 
-from desktop.conf import OZONE
 from desktop.lib import django_mako
 from desktop.lib import django_mako
 from desktop.lib.exceptions_renderable import PopupException
 from desktop.lib.exceptions_renderable import PopupException
 from desktop.settings import BASE_DIR
 from desktop.settings import BASE_DIR
@@ -183,18 +182,7 @@ class SQLIndexer(object):
 
 
     if external_path.lower().startswith("abfs"): #this is to check if its using an ABFS path
     if external_path.lower().startswith("abfs"): #this is to check if its using an ABFS path
       external_path = abfspath(external_path)
       external_path = abfspath(external_path)
-    elif external_path.lower().startswith("ofs") or source_path.lower().startswith("ofs"):  # This is to check if its using an OFS path
-      if OZONE['default'].FS_DEFAULTFS.get():
-        fs_defaultfs_schemeless = OZONE['default'].FS_DEFAULTFS.get()[6:]
 
 
-        # Add fs_defaultfs netloc in the OFS path for Hive/Impala.
-        # fs_defaultfs can be Ozone service ID if Ozone is in HA or Ozone Manager URI in non-HA mode.
-        # E.g: ofs:// + fs_defaultfs_schemeless + /vol1/buk1/key
-
-        external_path = external_path[:6] + fs_defaultfs_schemeless + external_path[5:]
-        source_path = source_path[:6] + fs_defaultfs_schemeless + source_path[5:]
-      else:
-        raise PopupException('Ozone fs_defaultFS is not configured.')
 
 
     tbl_properties = OrderedDict()
     tbl_properties = OrderedDict()
     if skip_header:
     if skip_header: