#!/usr/bin/python
# 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.
import xml.etree.ElementTree as ET
import os,errno,sys
from os import listdir
from os.path import isfile, join, dirname
try:
from urllib.parse import urlparse
except ImportError:
from urlparse import urlparse
debugLevel = 1
SUPPORTED_COMPONENTS = [ "hdfs", "hive", "hbase", "knox", "storm" ]
#
# xmlTemplateDirectory: directory where all of the xml templates are kept here
#
xmlTemplateDirectory = './install/conf.templates/enable'
def showUsage():
print("This script must be run with a <componentName> as parameter")
print("USAGE: upgrade-plugin.py <componentName>")
print(" <componentName> could be any one of the following: %s" % (SUPPORTED_COMPONENTS))
if (len(sys.argv) == 1):
showUsage()
sys.exit(1)
componentName = sys.argv[1]
if (componentName not in SUPPORTED_COMPONENTS):
print("Invalid componentName passed as parameter: %s" % (componentName))
showUsage()
sys.exit(1)
#
# For hdfs, the componentName is hadoop (for path calculation)
#
if (componentName == 'hdfs'):
configPath = 'hadoop'
else:
configPath = componentName
#
# configDirectory: where OLD (champlain) configuration exists and NEW (dal) configuration is written to
#
configDirectory = '/etc/' + configPath + '/conf'
def getXMLConfigKeys(xmlFileName):
ret = []
tree = ET.parse(xmlFileName)
root = tree.getroot()
for config in root.iter('property'):
name = config.find('name').text
ret.append(name)
return ret
def getXMLConfigMap(xmlFileName):
ret = {}
tree = ET.parse(xmlFileName)
root = tree.getroot()
for config in root.iter('property'):
name = config.find('name').text
val = config.find('value').text
ret[name] = val
return ret
def writeXMLUsingProperties(xmlTemplateFileName,prop,xmlOutputFileName):
tree = ET.parse(xmlTemplateFileName)
root = tree.getroot()
for config in root.iter('property'):
name = config.find('name').text
if (name in prop):
config.find('value').text = prop[name]
tree.write(xmlOutputFileName)
def rewriteConfig(props,newProps):
if (debugLevel > 0):
for k,v in props.items():
print("old config[%s] = [%s]" % (k,v))
#
# Derived fields
#
pmUrl = props['xasecure.' + componentName + '.policymgr.url']
url = urlparse(pmUrl)
restUrl = url[0] + "://" + url[1]
serviceName = url[2].split("/")[-1]
props['ranger.plugin.' + componentName + '.policy.rest.url'] = restUrl
props['ranger.plugin.' + componentName + '.service.name'] = serviceName
props['ranger.plugin.' + componentName + '.policy.pollIntervalMs'] = props['xasecure.' + componentName + '.policymgr.url.reloadIntervalInMillis']
#props['ranger.plugin.' + componentName + '.policy.rest.ssl.config.file'] = props['y']
fileLoc = props['xasecure.' + componentName + '.policymgr.url.laststoredfile']
props['ranger.plugin.' + componentName + '.policy.cache.dir'] = dirname(fileLoc)
if ( 'xasecure.policymgr.sslconfig.filename' in props ):
props['ranger.plugin.' + componentName + '.policy.rest.ssl.config.file'] = props['xasecure.policymgr.sslconfig.filename']
else:
sslConfigFileName = join(configDirectory,'ranger-policymgr-ssl.xml')
props['ranger.plugin.' + componentName + '.policy.rest.ssl.config.file'] = sslConfigFileName
#
# Fix for KNOX ssl (missing) configuration
#
if ('xasecure.policymgr.clientssl.keystore.credential.file' not in props):
props['xasecure.policymgr.clientssl.keystore.credential.file'] = 'jceks://file/tmp/keystore-' + serviceName + '-ssl.jceks'
if ( 'xasecure.policymgr.clientssl.truststore.credential.file' not in props):
props['xasecure.policymgr.clientssl.truststore.credential.file'] = 'jceks://file/tmp/keystore-' + serviceName + '-ssl.jceks'
for fn in listdir(xmlTemplateDirectory):
file = join(xmlTemplateDirectory,fn)
if isfile(file) and fn.startswith("ranger-") and fn.endswith(".xml") :
newConfigFile = join(configDirectory, fn)
writeXMLUsingProperties(file, props, newConfigFile)
def main():
props = {}
newProps = {}
foundFiles = []
for fn in listdir(configDirectory):
file = join(configDirectory,fn)
if isfile(file) and fn.startswith("xasecure-") and fn.endswith(".xml") :
foundFiles.append(file)
r = getXMLConfigMap(file)
props.update(r)
if (len(foundFiles) == 0):
print("INFO: Previous version of ranger is not enabled/configured for component [%s]" % (componentName))
sys.exit(0)
if (len(foundFiles) != 3):
print("ERROR: Expected to find three files matching xasecure-*.xml files under the folder (%s) - found %s" % (configDirectory,foundFiles))
sys.exit(1)
for fn in listdir(xmlTemplateDirectory):
file = join(xmlTemplateDirectory,fn)
if isfile(file) and fn.startswith("ranger-") and fn.endswith(".xml") :
r = getXMLConfigMap(file)
newProps.update(r)
newConfigFile = join(configDirectory,fn)
if isfile(newConfigFile):
print("ERROR: new config file [%s] already exists. Upgrade script can not overwrite an existing config file." % (newConfigFile))
sys.exit(1)
rewriteConfig(props,newProps)
main()
没有合适的资源?快使用搜索试试~ 我知道了~
ranger-2.3.0-hdfs-plugin.tar.gz
需积分: 0 1 下载量 95 浏览量
2023-12-20
13:57:47
上传
评论
收藏 33.89MB GZ 举报
温馨提示
ranger-2.3.0-hdfs-plugin.tar.gz, source from https://github.com/zer0beat/apache-ranger-compiled/releases
资源推荐
资源详情
资源评论
收起资源包目录
ranger-2.3.0-hdfs-plugin.tar.gz (58个子文件)
ranger-2.3.0-hdfs-plugin
lib
ranger-hdfs-plugin-shim-2.3.0.jar 15KB
ranger-hdfs-plugin-impl
elasticsearch-core-7.6.0.jar 44KB
gethostname4j-0.0.2.jar 4KB
elasticsearch-7.6.0.jar 11.27MB
ranger-plugins-audit-2.3.0.jar 239KB
httpasyncclient-4.1.3.jar 175KB
ranger-plugins-common-2.3.0.jar 982KB
elasticsearch-rest-high-level-client-7.6.0.jar 1.4MB
elasticsearch-rest-client-7.6.0.jar 62KB
httpcore-4.4.6.jar 316KB
joda-time-2.10.6.jar 629KB
ranger-hdfs-plugin-2.3.0.jar 58KB
jetty-client-9.4.31.v20200723.jar 320KB
solr-solrj-8.6.3.jar 2.2MB
httpmime-4.5.6.jar 41KB
httpcore-nio-4.4.6.jar 348KB
commons-lang-2.6.jar 278KB
elasticsearch-x-content-7.6.0.jar 129KB
jna-platform-5.2.0.jar 2.41MB
rank-eval-client-7.6.0.jar 75KB
httpclient-4.5.6.jar 749KB
jna-5.2.0.jar 1.42MB
lucene-core-8.4.0.jar 3.15MB
hppc-0.8.0.jar 1.14MB
lang-mustache-client-7.6.0.jar 61KB
ranger-plugins-cred-2.3.0.jar 20KB
ranger-plugin-classloader-2.3.0.jar 16KB
install
lib
slf4j-api-1.7.32.jar 41KB
woodstox-core-5.0.3.jar 501KB
commons-io-2.5.jar 204KB
hadoop-auth-3.3.0.jar 102KB
commons-collections-3.2.2.jar 575KB
commons-cli-1.2.jar 40KB
stax2-api-3.1.4.jar 158KB
htrace-core4-4.1.0-incubating.jar 1.43MB
commons-compress-1.8.1.jar 357KB
commons-configuration2-2.1.1.jar 602KB
commons-lang-2.6.jar 278KB
credentialbuilder-2.3.0.jar 19KB
guava-27.0-jre.jar 2.62MB
commons-logging-1.2.jar 60KB
ranger-plugins-installer-2.3.0.jar 16KB
commons-lang3-3.3.2.jar 403KB
hadoop-common-3.3.0.jar 4.09MB
conf.templates
enable
ranger-hdfs-audit-changes.cfg 8KB
ranger-hdfs-security.xml 4KB
hdfs-site-changes.cfg 1KB
ranger-policymgr-ssl.xml 2KB
ranger-hdfs-audit.xml 6KB
ranger-policymgr-ssl-changes.cfg 1KB
ranger-hdfs-security-changes.cfg 2KB
disable
hdfs-site-changes.cfg 1KB
enable-hdfs-plugin.sh 26KB
ranger_credential_helper.py 3KB
upgrade-hdfs-plugin.sh 1KB
disable-hdfs-plugin.sh 26KB
install.properties 6KB
upgrade-plugin.py 6KB
共 58 条
- 1
资源评论
z_______.____
- 粉丝: 3
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功