You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ol...@apache.org on 2018/06/17 15:59:06 UTC

[ambari] 01/02: AMBARI-23945. Infra Solr migration - Add disable-solr-authorization command

This is an automated email from the ASF dual-hosted git repository.

oleewere pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git

commit 331d7d9c096e1357395a30a10a584f177218498a
Author: Oliver Szabo <ol...@gmail.com>
AuthorDate: Sun Jun 17 02:49:16 2018 +0200

    AMBARI-23945. Infra Solr migration - Add disable-solr-authorization command
---
 ambari-infra/ambari-infra-solr-client/build.xml        |  2 +-
 .../src/main/python/migrationHelper.py                 | 18 ++++++++++++++++++
 .../src/main/resources/data/.keep                      | 15 ---------------
 .../main/resources/data/security-without-authr.json    |  6 ++++++
 4 files changed, 25 insertions(+), 16 deletions(-)

diff --git a/ambari-infra/ambari-infra-solr-client/build.xml b/ambari-infra/ambari-infra-solr-client/build.xml
index 71c59e7..822eadc 100644
--- a/ambari-infra/ambari-infra-solr-client/build.xml
+++ b/ambari-infra/ambari-infra-solr-client/build.xml
@@ -46,7 +46,7 @@
       <fileset file="src/main/resources/managed-schema"/>
     </copy>
     <copy todir="target/package/migrate/data" includeEmptyDirs="no">
-      <fileset file="src/main/resources/data/.keep"/>
+      <fileset file="src/main/resources/data/security-without-authr.json"/>
     </copy>
     <copy todir="target/package" includeEmptyDirs="no">
       <fileset file="src/main/resources/solrCloudCli.sh"/>
diff --git a/ambari-infra/ambari-infra-solr-client/src/main/python/migrationHelper.py b/ambari-infra/ambari-infra-solr-client/src/main/python/migrationHelper.py
index 87a64ae..ed8d34c 100755
--- a/ambari-infra/ambari-infra-solr-client/src/main/python/migrationHelper.py
+++ b/ambari-infra/ambari-infra-solr-client/src/main/python/migrationHelper.py
@@ -1291,6 +1291,22 @@ def update_state_jsons(options, accessor, parser, config, service_filter):
     else:
       print "Collection ('{0}') does not exist or filtered out. Skipping update collection state operation.".format(backup_fulltext_index_name)
 
+
+def disable_solr_authorization(options, accessor, parser, config):
+  solr_znode='/infra-solr'
+  if config.has_section('infra_solr') and config.has_option('infra_solr', 'znode'):
+    solr_znode=config.get('infra_solr', 'znode')
+  kerberos_enabled='false'
+  if config.has_section('cluster') and config.has_option('cluster', 'kerberos_enabled'):
+    kerberos_enabled=config.get('cluster', 'kerberos_enabled')
+  if kerberos_enabled == 'true':
+    print "Disable Solr authorization by uploading a new security.json ..."
+    copy_znode(options, config, COLLECTIONS_DATA_JSON_LOCATION.format("security-without-authr.json"),
+             "{0}/security.json".format(solr_znode), copy_from_local=True)
+  else:
+    print "Security is not enabled. Skipping disable Solr authorization operation."
+
+
 if __name__=="__main__":
   parser = optparse.OptionParser("usage: %prog [options]")
 
@@ -1388,6 +1404,8 @@ if __name__=="__main__":
         service_components_command(options, accessor, parser, config, LOGSEARCH_SERVICE_NAME, LOGSEARCH_LOGFEEDER_COMPONENT_NAME, "RESTART", "Restart")
       elif options.action.lower() == 'rolling-restart-solr':
         rolling_restart_solr(options, accessor, parser, config)
+      elif options.action.lower() == 'disable-solr-authorization':
+        disable_solr_authorization(options, accessor, parser, config)
       else:
         parser.print_help()
         print 'action option is invalid (available actions: delete-collections | backup | cleanup-znodes | backup-and-cleanup | migrate | restore | rolling-restart-solr)'
diff --git a/ambari-infra/ambari-infra-solr-client/src/main/resources/data/.keep b/ambari-infra/ambari-infra-solr-client/src/main/resources/data/.keep
deleted file mode 100644
index 5c8bc35..0000000
--- a/ambari-infra/ambari-infra-solr-client/src/main/resources/data/.keep
+++ /dev/null
@@ -1,15 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF 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.
-echo "Keep this empty file"
\ No newline at end of file
diff --git a/ambari-infra/ambari-infra-solr-client/src/main/resources/data/security-without-authr.json b/ambari-infra/ambari-infra-solr-client/src/main/resources/data/security-without-authr.json
new file mode 100644
index 0000000..7c36905
--- /dev/null
+++ b/ambari-infra/ambari-infra-solr-client/src/main/resources/data/security-without-authr.json
@@ -0,0 +1,6 @@
+{
+  "authentication":
+  {
+    "class": "org.apache.solr.security.KerberosPlugin"
+  }
+}
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
oleewere@apache.org.